Пример #1
0
        @Override
        public void actionPerformed(ActionEvent e) {

          if (e.getSource() == cancelButton) {
            getController().cancelPlayCard();
          } else if (e.getSource() == useButton) {
            if (devCards.getSelectedDevCard() == DevCardType.MONOPOLY) {
              closeModal();
              getController().playMonopolyCard(resCard1.getSelectedResourceCard());
            } else if (devCards.getSelectedDevCard() == DevCardType.YEAR_OF_PLENTY) {
              closeModal();
              getController()
                  .playYearOfPlentyCard(
                      resCard1.getSelectedResourceCard(), resCard2.getSelectedResourceCard());
            }
          }
        }
Пример #2
0
 @Override
 public void reset() {
   useButton.setText(DEFAULT_USE_BUTTON_LABEL);
   useButton.setEnabled(false);
   resCard1.setEnabled(false);
   resCard2.setEnabled(false);
   devCards.clearSelection();
   resCard1.clearSelection();
   resCard2.clearSelection();
 }
Пример #3
0
        @Override
        public void selectedButtonChanged(ButtonGroupPanel source) {

          DevCardType selectedDevCard = devCards.getSelectedDevCard();

          if (selectedDevCard == null) {
            useButton.setText(DEFAULT_USE_BUTTON_LABEL);
            useButton.setEnabled(false);
            resCard1.setEnabled(false);
            resCard2.setEnabled(false);
          } else if (selectedDevCard == DevCardType.MONUMENT) {
            useButton.setText(DEFAULT_USE_BUTTON_LABEL);
            useButton.setEnabled(false);
            resCard1.setEnabled(false);
            resCard2.setEnabled(false);

            closeModal();
            getController().playMonumentCard();
          } else if (selectedDevCard == DevCardType.ROAD_BUILD) {
            useButton.setText(DEFAULT_USE_BUTTON_LABEL);
            useButton.setEnabled(false);
            resCard1.setEnabled(false);
            resCard2.setEnabled(false);

            closeModal();
            getController().playRoadBuildCard();
          } else if (selectedDevCard == DevCardType.SOLDIER) {
            useButton.setText(DEFAULT_USE_BUTTON_LABEL);
            useButton.setEnabled(false);
            resCard1.setEnabled(false);
            resCard2.setEnabled(false);

            closeModal();
            getController().playSoldierCard();
          } else if (selectedDevCard == DevCardType.MONOPOLY) {
            useButton.setText("use monopoly");
            useButton.setEnabled(resCard1.getSelectedResourceCard() != null);
            resCard1.setEnabled(true);
            resCard2.setEnabled(false);
          } else if (selectedDevCard == DevCardType.YEAR_OF_PLENTY) {
            useButton.setText("use year of plenty");
            useButton.setEnabled(
                resCard1.getSelectedResourceCard() != null
                    && resCard2.getSelectedResourceCard() != null);
            resCard1.setEnabled(true);
            resCard2.setEnabled(true);
          }
        }
Пример #4
0
  public PlayDevCardView() {
    this.setOpaque(true);
    this.setBorder(BorderFactory.createLineBorder(Color.black, BORDER_WIDTH));

    this.setLayout(new BorderLayout());

    // Title Panel (immutable)
    JPanel titlePanel = new JPanel(new BorderLayout());
    title = new JLabel("Development Cards");
    FontUtils.setFont(title, LABEL_TEXT_SIZE);
    titlePanel.add(title, BorderLayout.WEST);
    this.add(titlePanel, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

    // Separator
    mainPanel.add(new JSeparator());

    // Blank space
    mainPanel.add(Box.createRigidArea(new Dimension(0, 10)));

    // Development Card Chooser
    devCards = new DevelopmentCardChooser();
    devCards.setListener(btnGrpPnlListener);
    mainPanel.add(devCards);

    // Blank space
    mainPanel.add(Box.createRigidArea(new Dimension(0, 10)));

    JPanel resPanel = new JPanel();
    resPanel.setLayout(new BoxLayout(resPanel, BoxLayout.Y_AXIS));

    // Resource Card 1
    resCard1 = new ResourceCardChooser();
    resCard1.setEnabled(false);
    resCard1.setListener(btnGrpPnlListener);
    mainPanel.add(resCard1);

    // Blank space
    mainPanel.add(Box.createRigidArea(new Dimension(0, 5)));

    // Resource Card 2
    resCard2 = new ResourceCardChooser();
    resCard2.setEnabled(false);
    resCard2.setListener(btnGrpPnlListener);
    resPanel.add(resCard2);

    mainPanel.add(resPanel);

    // Blank space
    mainPanel.add(Box.createRigidArea(new Dimension(0, 10)));

    // Use Dev Card Button
    JPanel usePanel = new JPanel();
    useButton = new JButton(DEFAULT_USE_BUTTON_LABEL);
    useButton.setEnabled(false);
    FontUtils.setFont(useButton, BUTTON_TEXT_SIZE);
    useButton.addActionListener(actionListener);
    usePanel.add(useButton);
    mainPanel.add(usePanel);

    // Blank space
    mainPanel.add(Box.createRigidArea(new Dimension(0, 10)));

    // Cancel Button
    JPanel cancelPanel = new JPanel();
    cancelButton = new JButton("Cancel");
    FontUtils.setFont(cancelButton, BUTTON_TEXT_SIZE);
    cancelButton.addActionListener(actionListener);
    cancelPanel.add(cancelButton);
    mainPanel.add(cancelPanel);

    this.add(mainPanel, BorderLayout.CENTER);
  }
Пример #5
0
 @Override
 public void setCardAmount(DevCardType cardType, int amount) {
   devCards.setCardAmount(cardType, amount);
 }
Пример #6
0
 @Override
 public void setCardEnabled(DevCardType cardType, boolean enabled) {
   devCards.setCardEnabled(cardType, enabled);
 }