diff --git a/src/main/java/controls/StepScheduler.java b/src/main/java/controls/StepScheduler.java index ff50f63..aae2156 100644 --- a/src/main/java/controls/StepScheduler.java +++ b/src/main/java/controls/StepScheduler.java @@ -9,6 +9,7 @@ public class StepScheduler implements IAttack { Algo algo; + Constants.Step step; int turnCount=0; boolean isATurn; public StepScheduler(){ @@ -17,7 +18,7 @@ } public Constants.Step getStep(){ - return null; + return step; } @Override diff --git a/src/main/java/interfaces/IAttack.java b/src/main/java/interfaces/IAttack.java index 6a4c620..5aa2275 100644 --- a/src/main/java/interfaces/IAttack.java +++ b/src/main/java/interfaces/IAttack.java @@ -1,5 +1,7 @@ package interfaces; +import views.Constants; + import java.util.List; import java.util.Map; @@ -13,6 +15,6 @@ Map.Entry getTopCard(); boolean isDeckLess(); - + Constants.Step getStep(); boolean isSucceedLatestAttack(); } diff --git a/src/main/java/views/CardButton.java b/src/main/java/views/CardButton.java index bb64898..939a5f3 100644 --- a/src/main/java/views/CardButton.java +++ b/src/main/java/views/CardButton.java @@ -9,6 +9,7 @@ import static views.Constants.CARD_HEIGHT; public class CardButton extends JButton { + private Status status; final int UNSELECTED_THICKNESS=1; final int SELECTED_THICKNESS=4; public CardButton(String text) { @@ -25,4 +26,36 @@ this.setBorder(new LineBorder(UNSELECTED_COLOR, UNSELECTED_THICKNESS, true)); } } + public void setStatus(Status status){ + switch (status){ + case OPEN -> { + this.setBackground(OPEN_COLOR); + } + case CLOSED -> { + this.setBackground(CLOSED_COLOR); + } + case MY_CLOSED -> { + this.setContentAreaFilled(false); + this.setFocusPainted(false); // used for demonstration + } + } + } + @Override + protected void paintComponent(Graphics g) { + final Graphics2D g2 = (Graphics2D) g.create(); + g2.setPaint(new GradientPaint( + new Point(0, 0), + OPEN_COLOR, + new Point(0, getHeight()), + CLOSED_COLOR)); + g2.fillRect(0, 0, getWidth(), getHeight()); + g2.dispose(); + + super.paintComponent(g); + } + public enum Status{ + OPEN, //開示されている + CLOSED, //開示されていない + MY_CLOSED //開示されていない(ただし自分専用) + } } diff --git a/src/main/java/views/Constants.java b/src/main/java/views/Constants.java index 9d5afab..b720729 100644 --- a/src/main/java/views/Constants.java +++ b/src/main/java/views/Constants.java @@ -11,13 +11,18 @@ SelectMyHands, SelectOpponentHands, Declare, - Confirm + Confirm, + OpponentSelect, + OpponentDeclare, + OpponentJudge, + OpponentConfirm } public static String CLOSED_SYMBOL="?"; public static int DECK_COUNT=11; public static Color SELECTED_COLOR=Color.CYAN; public static Color UNSELECTED_COLOR=Color.BLACK; public static Color OPEN_COLOR=Color.WHITE; + public static Color CLOSED_COLOR=Color.BLACK; public static JButton cardPaint=new JButton(){ @Override protected void paintComponent(Graphics g) { diff --git a/src/main/java/views/MainPanel.java b/src/main/java/views/MainPanel.java index 99ef2e4..83926f5 100644 --- a/src/main/java/views/MainPanel.java +++ b/src/main/java/views/MainPanel.java @@ -16,9 +16,9 @@ import static views.Constants.*; public class MainPanel extends JPanel { - private List myHandButtons; + private List myHandButtons; - private List opponentHandButtons; + private List opponentHandButtons; private List selectableMyHandKeys; private List selectableOpponentHandKeys; @@ -60,6 +60,7 @@ map(x -> x.getKey()).toList();//カードのリストからキーのリストへ変換 for (var i : myHands) { var cardButton = new CardButton(i.getKey().toString()); + cardButton.setStatus(i.getValue()? CardButton.Status.OPEN: CardButton.Status.MY_CLOSED); if (!selectableMyHandKeys.contains(i.getKey())) cardButton.setEnabled(false); myHandButtons.add(cardButton); myHandButtonsPanel.add(cardButton, BorderLayout.WEST); @@ -69,14 +70,16 @@ indexForOpponent=0; for (var i : opponentHands) { var cardButton = new CardButton(i.getValue() ? i.getKey().toString() :CLOSED_SYMBOL); + cardButton.setStatus(i.getValue()? CardButton.Status.OPEN: CardButton.Status.CLOSED); cardButton.setEnabled(false); cardButton.addActionListener(new ActionListener() { final int index=indexForOpponent; public void actionPerformed(ActionEvent e) { + var baseColor= cardButton.getBackground(); // cardButton.setBackground(SELECTED_COLOR); - - cardButton.setBorder(new LineBorder(SELECTED_COLOR, 4, true)); + cardButton.setEnabledSelection(true); + // cardButton.setBorder(new LineBorder(SELECTED_COLOR, 4, true)); //相手のカードを選択したときに確認用ダイアログを出す var option = JOptionPane.showConfirmDialog(null, "Select This Card?", "confirmation", 2); if (option == JOptionPane.YES_OPTION) { @@ -157,8 +160,10 @@ //remove(opponentButtonsPanel); for(int i=0,n=opponentHandButtons.size();i{ //