public static void nextTurn() { try { // System.gc();//Maybe good or maybe very bad idea...-_-||| AITakeTurn(turn); // if(age >= 2) // JOptionPane.showMessageDialog(null,hands,"Hand Card List",JOptionPane.INFORMATION_MESSAGE); Manager.getKernel().doEndOfTurn(turn); updateBoard(); // handCard.unload(); if (turn < 6) { if (age == 2) { handCard.nextHand(hands[(2 * numOfPlayers - turn + observeIndex) % numOfPlayers], false); Manager.debug("Player is taking hands[" + (2 * numOfPlayers - turn) % numOfPlayers + "]"); } else { handCard.nextHand(hands[(turn + observeIndex) % numOfPlayers], false); Manager.debug("Player is taking hands[" + (turn) % numOfPlayers + "]"); } turn++; } else { changeCardGivenUp(CardsGivenup + numOfPlayers); Manager.getKernel().doEndOfAge(age); for (int i = 0; i < numOfPlayers; i++) { int[][] mvps = boards[i].getMilitaryVPS(); // if(i == 0 ) // JOptionPane.showMessageDialog(null, // "Left:"+mvps[KernelManager.LEFT][age] + " Right:" + // mvps[KernelManager.RIGHT][age]); if (mvps[KernelManager.LEFT][age] > 0) wonder[i].addBattleSign(age, true); else if (mvps[KernelManager.LEFT][age] < 0) wonder[i].addBattleSign(0, true); if (mvps[KernelManager.RIGHT][age] > 0) wonder[i].addBattleSign(age, false); else if (mvps[KernelManager.RIGHT][age] < 0) wonder[i].addBattleSign(0, false); // JOptionPane.showMessageDialog(null, // mvps[KernelManager.LEFT][age] + "\t" + // mvps[KernelManager.RIGHT][age]); } if (age < 3) { age++; turn = 1; Manager.getKernel().startAge(age); bigCircle.getChildren().clear(); bigCircle .getChildren() .add( MovingStroke.set( new Circle(29, Color.web("white", 0)), Color.web("white", 0.7), 6, 5, 10, 0.3 * (age != 2 ? -1 : 1))); hands = Manager.getKernel().getHands(); handCard.nextHand(hands[0], true); if (age == 2) { updateAge(2); dicCounterClockwise(); } else { updateAge(3); dicClockwise(); } } else { // Game finished if (Manager.getKernel().isReplayMode()) replayControl.stop(); handCard.nextHand(null, true); Manager.getKernel().doEndOfGame(); ScoreBoard sb = new ScoreBoard(boards); sb.setLayoutX((screenX - sb.getBoundsInLocal().getWidth()) / 2); sb.setLayoutY(-300); mbg.root.getChildren().add(sb); Manager.getKernel().saveRec(true); Timeline tl = new Timeline( new KeyFrame( Duration.ZERO, new KeyValue(sb.opacityProperty(), 0), new KeyValue(sb.layoutYProperty(), -300)), new KeyFrame( Duration.seconds(0.5), new KeyValue(sb.opacityProperty(), 1), new KeyValue( sb.layoutYProperty(), (screenY - sb.getBoundsInLocal().getHeight()) / 2))); tl.play(); // quit();//Only for test } } } catch (Throwable e) { StringWriter str = new StringWriter(); PrintWriter writer = new PrintWriter(str); e.printStackTrace(writer); Manager.error(e); } }
public static void addCardGivenUp(int i) { changeCardGivenUp(getCardsGivenup() + i); }