diff --git a/src/main/java/views/MainPanel.java b/src/main/java/views/MainPanel.java index c780527..f5be9a9 100644 --- a/src/main/java/views/MainPanel.java +++ b/src/main/java/views/MainPanel.java @@ -59,31 +59,11 @@ add(myHandButtonsPanel, BorderLayout.SOUTH); add(opponentButtonsPanel, BorderLayout.NORTH); - setStep(Step.SelectOpponentHands); + opponentHandButtons.stream().filter(x -> x.getText().equals(CLOSED_SYMBOL)).forEach(x -> { + x.setEnabled(true); + }); repaint(); } - - void setStep(Step step) { - currentStep = step; - switch (step) { - case SelectMyHands: - break; - case SelectOpponentHands: - opponentHandButtons.stream().filter(x -> x.getText().equals(CLOSED_SYMBOL)).forEach(x -> { - x.setEnabled(true); - }); - break; - - case Declare: - opponentHandButtons.stream().filter(x -> x.getText().equals(CLOSED_SYMBOL)).forEach(x -> { - x.setEnabled(false); - }); - break; - case Confirm: - - break; - } - } void botBehave(IAttack iAttack){ iAttack.shiftTurn(); var bot = new BotIntelligence(); @@ -175,7 +155,6 @@ myHandButtons.add(cardButton); myHandButtonsPanel.add(cardButton, BorderLayout.WEST); - final var a=indexForMyHands;//actionPerformedの中に書くと、クリックされて初めて、回しきったindexForMyHandsを参照してしまうため、ここで一時変数に格納する cardButton.addActionListener(new ActionListener() { @Override @@ -223,7 +202,9 @@ if (option == JOptionPane.YES_OPTION) { target = opponentHands.size()-index;//画面上,相手の手札も自分の手札と同じように左から右へ並べられているため,それを補正するために反転させている var t = index; - setStep(Step.Declare); + opponentHandButtons.stream().filter(x -> x.getText().equals(CLOSED_SYMBOL)).forEach(x -> { + x.setEnabled(false); + }); String[] optionsToChoose = new String[DECK_COUNT]; for (var i = 0; i < optionsToChoose.length; i++) optionsToChoose[i] = String.valueOf(i); var getDeclaredNumber = (String) JOptionPane.showInputDialog( @@ -238,7 +219,6 @@ guess = Integer.parseInt(getDeclaredNumber); var g= Integer.parseInt(getDeclaredNumber); iAttack.Attack(g, attacker, t); - setStep(Step.Confirm); boolean isSucceed=iAttack.isSucceedLatestAttack(); @@ -246,7 +226,9 @@ resultMessage+=isSucceed?"成功しました。":"失敗しました。"; JOptionPane.showMessageDialog(null,resultMessage); }else{ - setStep(Step.SelectOpponentHands); + opponentHandButtons.stream().filter(x -> x.getText().equals(CLOSED_SYMBOL)).forEach(x -> { + x.setEnabled(true); + }); return; }