// Constructor
  public PlayerDisplay(HumanPlayer hp) {
    myCards = new JLabel("My Cards");
    pd = new JPanel();
    rd = new JPanel();
    wd = new JPanel();
    String personCard = null;
    String roomCard = null;
    String weaponCard = null;

    for (Card c : hp.getMyCards()) {
      if (c.getCardType() == CardType.PERSON) {
        personCard = c.getName();
      } else if (c.getCardType() == CardType.ROOM) {
        roomCard = c.getName();
      } else {
        weaponCard = c.getName();
      }
    }

    pd = createDisplay("Person", personCard);
    rd = createDisplay("Room", roomCard);
    wd = createDisplay("Weapon", weaponCard);

    setLayout(new GridLayout(8, 1));
    add(myCards);
    add(pd);
    add(rd);
    add(wd);
  }
Beispiel #2
0
  public DetectiveNotes(ArrayList<Card> cards) {
    // Sets the standard window information
    this.setLayout(new GridLayout(0, 2));
    setTitle("Detective Notes");
    setSize(600, 700);

    // Initialize the lists
    playerList = new ArrayList<String>();
    weaponList = new ArrayList<String>();
    roomList = new ArrayList<String>();

    // Adds an "unsure" option to each list
    playerList.add("Unsure");
    weaponList.add("Unsure");
    roomList.add("Unsure");

    // Reads the card names out of the file, storing it in the appropriate list
    for (Card card : cards) {
      if (card.getCardType() == CardType.PERSON) playerList.add(card.getName());
      else if (card.getCardType() == CardType.WEAPON) weaponList.add(card.getName());
      else if (card.getCardType() == CardType.ROOM) roomList.add(card.getName());
    }

    // Sets up the selection boxes for the people, weapons, and rooms
    JPanel people = new JPanel();
    people.setBorder(new TitledBorder(new EtchedBorder(), "People"));
    JComboBox PeopleCombo = new JComboBox(playerList.toArray());
    PeopleCombo.setBorder(new TitledBorder(new EtchedBorder(), "People Guess"));

    JPanel weapons = new JPanel();
    weapons.setBorder(new TitledBorder(new EtchedBorder(), "Weapons"));
    JComboBox WeaponsCombo = new JComboBox(weaponList.toArray());
    WeaponsCombo.setBorder(new TitledBorder(new EtchedBorder(), "Weapons Guess"));

    JPanel rooms = new JPanel();
    rooms.setBorder(new TitledBorder(new EtchedBorder(), "Rooms"));
    JComboBox RoomsCombo = new JComboBox(roomList.toArray());
    RoomsCombo.setBorder(new TitledBorder(new EtchedBorder(), "Rooms Guess"));

    // Adds the player information to the JFrame
    addPlayerCheckboxes(people);
    add(people);
    add(PeopleCombo);

    // Adds the weapon information to the JFrame
    addWeaponCheckboxes(weapons);
    add(weapons);
    add(WeaponsCombo);

    // Adds the room information to the JFrame
    addRoomCheckboxes(rooms);
    add(rooms);
    add(RoomsCombo);
  }
Beispiel #3
0
 void updateRemembered(Card c) {
   if (c.getRemembered() == null) {
     set(TrackableProperty.Remembered, null);
     return;
   }
   StringBuilder sb = new StringBuilder();
   sb.append("\r\nRemembered: \r\n");
   for (final Object o : c.getRemembered()) {
     if (o instanceof Card) {
       final Card card = (Card) o;
       if (card.isFaceDown()) {
         sb.append("Face Down");
         // face-down cards don't show unique number to avoid cheating
       } else {
         sb.append(card.getName());
         sb.append(" (");
         sb.append(card.getId());
         sb.append(")");
       }
     } else if (o != null) {
       sb.append(o.toString());
     }
     sb.append("\r\n");
   }
   set(TrackableProperty.Remembered, sb.toString());
 }
  /**
   * getBasics.
   *
   * @param cards a {@link java.util.ArrayList} object.
   * @param color a {@link java.lang.String} object.
   * @return a {@link java.util.ArrayList} object.
   */
  public static ArrayList<Card> getBasics(ArrayList<Card> cards, String color) {
    ArrayList<Card> ret = new ArrayList<Card>();

    for (Card c : cards) {
      String name = c.getName();

      if (c.isEnchanted()) ; // do nothing
      else if (name.equals("Swamp") || name.equals("Bog")) {
        if (color == Constant.Color.Black) {
          ret.add(c);
        }
      } else if (name.equals("Forest") || name.equals("Grass")) {
        if (color == Constant.Color.Green) {
          ret.add(c);
        }

      } else if (name.equals("Plains") || name.equals("White Sand")) {
        if (color == Constant.Color.White) {
          ret.add(c);
        }

      } else if (name.equals("Mountain") || name.equals("Rock")) {
        if (color == Constant.Color.Red) {
          ret.add(c);
        }

      } else if (name.equals("Island") || name.equals("Underwater")) {
        if (color == Constant.Color.Blue) {
          ret.add(c);
        }
      }
    }

    return ret;
  }
 /**
  * getCard.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @param name a {@link java.lang.String} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getCard(ArrayList<Card> cards, String name) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     if (c.getName().equals(name)) ret.add(c);
   }
   return ret;
 }
  /**
   * getNonBasicLand.
   *
   * @param cards a {@link java.util.ArrayList} object.
   * @param landName a {@link java.lang.String} object.
   * @return a {@link java.util.ArrayList} object.
   */
  public static ArrayList<Card> getNonBasicLand(ArrayList<Card> cards, String landName) {
    ArrayList<Card> ret = new ArrayList<Card>();

    for (Card c : cards) if (c.getName().equals(landName)) ret.add(c);

    return ret;
  }
Beispiel #7
0
 @Override
 public boolean equals(Object c) {
   if (c instanceof Card) {
     Card cardC = (Card) c;
     return (name.equals(cardC.getName()) && cardType == cardC.getCardType());
   }
   return false;
 }
 /**
  * getMoxen.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @param moxName a {@link java.lang.String} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getMoxen(ArrayList<Card> cards, String moxName) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     String name = c.getName();
     if (name.equals(moxName) && !c.isCreature()) ret.add(c);
   }
   return ret;
 }
 /**
  * getTokenCreatures.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @param tokenName a {@link java.lang.String} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getTokenCreatures(ArrayList<Card> cards, String tokenName) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     String name = c.getName();
     if (c.isCreature() && c.isToken() && name.equals(tokenName)) ret.add(c);
   }
   return ret;
 }
Beispiel #10
0
 @Test
 public void createCards() {
   name = "Grapeshot Catapult";
   set = "Old";
   rarity = "Common";
   foil = "false";
   Card card = new Card(name, set, rarity, foil, conditions);
   assertEquals(card.getName(), "Grapeshot Catapult");
   assertEquals(card.getConditions(), conditions);
   assertEquals(card.getFoil(), "false");
   assertEquals(card.getSet(), "Old");
   assertEquals(card.getRarity(), "Common");
   assertEquals(card.getTotal(), "9");
   Card newCard = new Card("Cool", "New", rarity, foil, conditions);
   assertEquals(newCard.getName(), "Cool");
   assertNotEquals(card.getSet(), "New");
   assertEquals(newCard.getSet(), "New");
 }
  /**
   * getNonBasics.
   *
   * @param cards a {@link java.util.ArrayList} object.
   * @return a {@link java.util.ArrayList} object.
   */
  public static ArrayList<Card> getNonBasics(ArrayList<Card> cards) {
    ArrayList<Card> ret = new ArrayList<Card>();

    for (Card c : cards) {
      if (!c.isLand() && !c.getName().startsWith("Mox") && !(c instanceof ManaPool)) {
        ret.add(c);
      } else {
        String name = c.getName();
        if (c.isEnchanted()
            || name.equals("Swamp")
            || name.equals("Bog")
            || name.equals("Forest")
            || name.equals("Grass")
            || name.equals("Plains")
            || name.equals("White Sand")
            || name.equals("Mountain")
            || name.equals("Rock")
            || name.equals("Island")
            || name.equals("Underwater")
            || name.equals("Badlands")
            || name.equals("Bayou")
            || name.equals("Plateau")
            || name.equals("Scrubland")
            || name.equals("Savannah")
            || name.equals("Taiga")
            || name.equals("Tropical Island")
            || name.equals("Tundra")
            || name.equals("Underground Sea")
            || name.equals("Volcanic Island")
            || name.startsWith("Mox")
            || c instanceof ManaPool) {
          // do nothing.
        } else {
          ret.add(c);
        }
      }
    }

    return ret;
  }
Beispiel #12
0
  public PlayerPanel(HumanPlayer player) {
    myCards = new JLabel("My Cards");
    peopleField = new JTextArea();
    roomField = new JTextArea();
    weaponField = new JTextArea();

    // Displaying the players cards to the screen
    ArrayList<Card> humanPlayerCards = new ArrayList<Card>();
    humanPlayerCards = player.getCards();
    // String variables to keep track of more than one type of card
    String roomTxt = "";
    String personTxt = "";
    String weaponTxt = "";

    for (Card c : humanPlayerCards) {
      // Add name to the text if there is already text
      if (c.getCardType() == CardType.PERSON) {
        if (!(personTxt.equals(""))) {
          personTxt = personTxt + "\n" + (c.getName());
        } else {
          personTxt = c.getName();
        }
      } else if (c.getCardType() == CardType.ROOM) {
        if (!(roomTxt.equals(""))) {
          roomTxt = roomTxt + "\n" + (c.getName());
        } else {
          roomTxt = c.getName();
        }
      } else {
        if (!(weaponTxt.equals(""))) {
          weaponTxt = weaponTxt + "\n" + (c.getName());
        } else {
          weaponTxt = c.getName();
        }
      }
    }
    roomField.setText(roomTxt);
    roomField.setEditable(false);
    peopleField.setText(personTxt);
    peopleField.setEditable(false);
    weaponField.setText(weaponTxt);
    weaponField.setEditable(false);

    pPanel = new JPanel();
    rPanel = new JPanel();
    wPanel = new JPanel();

    pPanel.add(peopleField);
    rPanel.add(roomField);
    wPanel.add(weaponField);
    pPanel.setBorder(new TitledBorder(new EtchedBorder(), "People"));
    rPanel.setBorder(new TitledBorder(new EtchedBorder(), "Room"));
    wPanel.setBorder(new TitledBorder(new EtchedBorder(), "Weapon"));

    setLayout(new GridLayout(4, 1));
    add(myCards);
    add(pPanel);
    add(rPanel);
    add(wPanel);
  }
  /**
   * isStackable.
   *
   * @param c a {@link forge.Card} object.
   * @return a boolean.
   */
  public static boolean isStackable(Card c) {

    /*String name = c.getName();
    if( name.equals("Swamp") || name.equals("Bog") ||
        name.equals("Forest") || name.equals("Grass") ||
        name.equals("Plains") || name.equals("White Sand") ||
        name.equals("Mountain") || name.equals("Rock") ||
        name.equals("Island") || name.equals("Underwater")) {
      return true;
    }
    */
    if (c.isLand()
        || (c.getName().startsWith("Mox") && !c.getName().equals("Mox Diamond"))
        || (c.isLand() && c.isEnchanted())
        || (c.isAura() && c.isEnchanting())
        || (c.isToken() && CardFactoryUtil.multipleControlled(c))
        || (c.isCreature() && (c.isEquipped() || c.isEnchanted()))
        || (c.isEquipment() && c.isEquipping())
        || (c.isEnchantment())
        || (c instanceof ManaPool && c.isSnow())) return true;

    return false;
  }
  @Override
  public void onResume() {
    super.onResume();

    readTrunk();

    linearLayout = (LinearLayout) getView().findViewById(R.id.mTLinear);
    linearLayout.removeAllViews();
    int size = trunk.getSize();
    int index = 0;
    while (index < size) {
      Card c = trunk.getDeck().get(index);
      ImageView imageView = new ImageView(getActivity());
      imageView.setImageDrawable(
          getResources()
              .getDrawable(
                  getResources()
                      .getIdentifier("com.tetramaster:drawable/" + c.getName(), null, null)));
      imageView.setTag(c.getName());
      imageView.setOnClickListener(this);
      linearLayout.addView(imageView);
      index++;
    }
  }
 /**
  * getNonCreatureArtifacts.
  *
  * @param cards a {@link java.util.ArrayList} object.
  * @return a {@link java.util.ArrayList} object.
  */
 public static ArrayList<Card> getNonCreatureArtifacts(ArrayList<Card> cards) {
   ArrayList<Card> ret = new ArrayList<Card>();
   for (Card c : cards) {
     String name = c.getName();
     if (c.isArtifact()
         && !c.isCreature()
         && !c.isLand()
         && !c.isGlobalEnchantment()
         && !(c.isEquipment() && c.isEquipping())
         && !name.equals("Mox Emerald")
         && !name.equals("Mox Jet")
         && !name.equals("Mox Pearl")
         && !name.equals("Mox Ruby")
         && !name.equals("Mox Sapphire")) ret.add(c);
   }
   return ret;
 }
Beispiel #16
0
 public void handleRocketCourier(Card consToBuy) {
   int handleRocketCourierChoice =
       optionPane.showConfirmDialog(
           game,
           String.format(game.descriptions.getString("WouldAllThings"), consToBuy.getName()),
           "",
           JOptionPane.YES_NO_OPTION,
           JOptionPane.QUESTION_MESSAGE);
   if (handleRocketCourierChoice == JOptionPane.YES_OPTION) {
     this.player.playerDeck.hand.add(new Card(consToBuy));
     this.RocketCourierState--;
   } else {
     HeroTopOfDeckState =
         this.player.playerDeck.addNewCardToDiscard(new Card(consToBuy), HeroTopOfDeckState);
   }
   this.player.playerDeck.resetHandLocation();
 }
  /** ゲームを開始する 最初の2枚を配った後プレーヤーの動きを呼び出す */
  private static void startGame() {
    String startStr = "プレーヤーのカード : ";

    // カードを配る(ディーラー用とプレーヤー用が必要)
    for (int i = 1; i <= 2; i++) {
      Card playerCard = deck.dealCard();
      player.addCardAndCalc(playerCard);
      deck.deleteCard(playerCard);

      Card dealerCard = deck.dealCard();
      dealer.addCardAndCalc(dealerCard);
      deck.deleteCard(dealerCard);

      startStr += playerCard.getMark() + "の" + playerCard.getName() + " ";
    }

    System.out.println(startStr);

    // プレーヤーから行動
    playerGame(true);
  }
  /**
   * プレーヤーの挙動
   *
   * <p>ブラックジャックまたはバーストの場合を除き、 hitOrStand()結果をもとにplayerのヒットフラグをセットし、繰り返す
   */
  private static void playerGame(boolean isFirst) {

    // プレーヤーのヒットフラグがtrueの時カードを引く(初回は通らない)
    if (player.isHit()) {
      Card card = deck.dealCard();
      player.addCardAndCalc(card);
      deck.deleteCard(card);
      System.out.println("引いたカード : " + card.getMark() + "の" + card.getName());
    }

    /*
     * 結果が21以上・・・バーストで終了
     * 結果が21・・・・・目標達成なので終了、初期状態だった場合はブラックジャックフラグをセット
     * それ以外・・・・・入力値によってヒットフラグをセットする
     */
    if (player.getCalcResult() > 21) {
      player.setHit(false);
    } else if (player.getCalcResult() == 21) {
      if (player.getCardList().size() == 2) {
        player.setBlackJack(true);
      }
      player.setHit(false);
    } else {
      player.setHit(hitOrStand());
    }

    /*
     * 初回は必ずディーラーの動きを呼び出す
     * ディーラーのヒットフラグがtrueならdealerGame()
     * プレーヤーのヒットフラグがtrueならplayerGame()
     * ヒットフラグが両方falseになるまで再帰呼び出し
     */
    if (isFirst) {
      dealerGame();
    } else if (dealer.isHit()) {
      dealerGame();
    } else if (player.isHit()) {
      playerGame(false);
    }
  }
Beispiel #19
0
  public boolean attemptCardPurchaseWithinCardList(ArrayList<Card> s, Point p) {
    for (Card c : s) {
      if (c.getLocation().contains(p)) {

        if (c.getType() == Card.Type.Monster) {
          if (this.turnState == TurnState.FreeCard) {
            executeCard(c);
            this.game.gameDeck.hand.remove(c);
            if (!c.getName().equals("Cultist")) {
              this.game.gameDeck.discard.add(c);
              this.game.gameDeck.drawCard();
              if (this.VoidthirsterState) {
                this.player.incrementHonor(1);
                this.game.decrementHonor(1);
                this.VoidthirsterState = false;
              }
            }
          } else if (this.monsterPower > 0 && c.getCost() <= this.power + this.monsterPower) {
            for (int i = 0; i < c.getCost(); i++) {
              if (this.monsterPower > 0) {
                this.monsterPower--;
              } else {
                this.power--;
              }
            }
          } else if (c.getCost() <= this.power) {
            this.power -= c.getCost();
            executeCard(c);
            this.game.gameDeck.hand.remove(c);
            if (!c.getName().equals("Cultist")) {
              this.game.gameDeck.discard.add(c);
              this.game.gameDeck.drawCard();
              if (this.VoidthirsterState) {
                this.player.incrementHonor(1);
                this.game.decrementHonor(1);
                this.VoidthirsterState = false;
              }
            }
            if (this.VoidMesmerState) {
              this.turnState = TurnState.VoidMesmerState;
              this.turnStateMagnitude = c.getCost();
            }
          }
        } else {
          if (this.turnState == TurnState.FreeCard) {
            this.game.gameDeck.hand.remove(c);
            if (this.testForMechana(c)
                && c.getType() == Card.Type.Construct
                && this.RocketCourierState > 0) {
              this.handleRocketCourier(c);
            } else {
              HeroTopOfDeckState =
                  this.player.playerDeck.addNewCardToDiscard(c, HeroTopOfDeckState);
            }
            this.game.gameDeck.drawCard();
          } else if (c.getType() == Card.Type.Construct
              && this.testForMechana(c)
              && c.getCost() <= (this.rune + this.constructRune + this.mechanaConstructRune)) {
            for (int i = 0; i < c.getCost(); i++) {
              if (this.mechanaConstructRune > 0) {
                this.mechanaConstructRune--;
              } else if (this.constructRune > 0) {
                this.constructRune--;
              } else {
                this.rune--;
              }
            }
            if (this.RocketCourierState > 0) {
              this.handleRocketCourier(c);
            } else {
              HeroTopOfDeckState =
                  this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState);
            }
            if (this.game.gameDeck.hand.contains(c)) {
              this.game.gameDeck.hand.remove(c);
              this.game.gameDeck.drawCard();
            }
          } else if (c.getType() == Card.Type.Construct
              && c.getCost() <= (this.rune + this.constructRune)) {
            for (int i = 0; i < c.getCost(); i++) {
              if (this.constructRune > 0) {
                this.constructRune--;
              } else {
                this.rune--;
              }
            }
            if (this.testForMechana(c) && this.RocketCourierState > 0) {
              this.handleRocketCourier(c);
            } else {
              HeroTopOfDeckState =
                  this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState);
            }
            if (this.game.gameDeck.hand.contains(c)) {
              this.game.gameDeck.hand.remove(c);
              this.game.gameDeck.drawCard();
            }
          } else if (this.AiyanaState
              && c.getType() == Card.Type.Hero
              && c.getHonorWorth() <= this.rune) {
            this.rune -= c.getHonorWorth();
            HeroTopOfDeckState =
                this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState);
            if (this.game.gameDeck.hand.contains(c)) {
              this.game.gameDeck.hand.remove(c);
              this.game.gameDeck.drawCard();
            }
          } else if (this.heroRune > 0
              && c.getType() == Card.Type.Hero
              && c.getCost() < this.rune + this.heroRune) {
            for (int i = 0; i < c.getCost(); i++) {
              if (this.heroRune > 0) {
                this.heroRune--;
              } else {
                this.rune--;
              }
            }
            HeroTopOfDeckState =
                this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState);
            if (this.game.gameDeck.hand.contains(c)) {
              this.game.gameDeck.hand.remove(c);
              this.game.gameDeck.drawCard();
            }
          } else if (c.getCost() <= this.rune) {
            this.rune -= c.getCost();
            if (this.testForMechana(c)
                && c.getType() == Card.Type.Construct
                && this.RocketCourierState > 0) {
              this.handleRocketCourier(c);
            } else {
              HeroTopOfDeckState =
                  this.player.playerDeck.addNewCardToDiscard(new Card(c), HeroTopOfDeckState);
            }
            if (this.game.gameDeck.hand.contains(c)) {
              this.game.gameDeck.hand.remove(c);
              this.game.gameDeck.drawCard();
            }
          }
        }
        return true;
      }
    }
    return false;
  }
  /**
   * setupPanel.
   *
   * @param p a {@link javax.swing.JPanel} object.
   * @param list a {@link java.util.ArrayList} object.
   * @param stack a boolean.
   */
  private static void setupPanel(JPanel p, ArrayList<Card> list, boolean stack) {

    int maxY = 0;
    int maxX = 0;
    // remove all local enchantments

    Card c;
    /*
    for(int i = 0; i < list.size(); i++)
    {
      c = (Card)list.get(i);
      if(c.isLocalEnchantment())
        list.remove(i);
    }

    //add local enchantments to the permanents
    //put local enchantments "next to" the permanent they are enchanting
    //the inner for loop is backward so permanents with more than one local enchantments are in the right order
    Card ca[];
    for(int i = 0; i < list.size(); i++)
    {
      c = (Card)list.get(i);
      if(c.hasAttachedCards())
      {
        ca = c.getAttachedCards();
        for(int inner = ca.length - 1; 0 <= inner; inner--)
          list.add(i + 1, ca[inner]);
      }
    }
    */

    if (stack) {
      // add all Cards in list to the GUI, add arrows to Local Enchantments

      ArrayList<Card> manaPools = getManaPools(list);
      ArrayList<Card> enchantedLands = getEnchantedLands(list);
      ArrayList<Card> basicBlues = getBasics(list, Constant.Color.Blue);
      ArrayList<Card> basicReds = getBasics(list, Constant.Color.Red);
      ArrayList<Card> basicBlacks = getBasics(list, Constant.Color.Black);
      ArrayList<Card> basicGreens = getBasics(list, Constant.Color.Green);
      ArrayList<Card> basicWhites = getBasics(list, Constant.Color.White);
      ArrayList<Card> badlands = getNonBasicLand(list, "Badlands");
      ArrayList<Card> bayou = getNonBasicLand(list, "Bayou");
      ArrayList<Card> plateau = getNonBasicLand(list, "Plateau");
      ArrayList<Card> scrubland = getNonBasicLand(list, "Scrubland");
      ArrayList<Card> savannah = getNonBasicLand(list, "Savannah");
      ArrayList<Card> taiga = getNonBasicLand(list, "Taiga");
      ArrayList<Card> tropicalIsland = getNonBasicLand(list, "Tropical Island");
      ArrayList<Card> tundra = getNonBasicLand(list, "Tundra");
      ArrayList<Card> undergroundSea = getNonBasicLand(list, "Underground Sea");
      ArrayList<Card> volcanicIsland = getNonBasicLand(list, "Volcanic Island");

      ArrayList<Card> nonBasics = getNonBasics(list);

      ArrayList<Card> moxEmerald = getMoxen(list, "Mox Emerald");
      ArrayList<Card> moxJet = getMoxen(list, "Mox Jet");
      ArrayList<Card> moxPearl = getMoxen(list, "Mox Pearl");
      ArrayList<Card> moxRuby = getMoxen(list, "Mox Ruby");
      ArrayList<Card> moxSapphire = getMoxen(list, "Mox Sapphire");
      // ArrayList<Card> moxDiamond = getMoxen(list, "Mox Diamond");

      list = new ArrayList<Card>();
      list.addAll(manaPools);
      list.addAll(enchantedLands);
      list.addAll(basicBlues);
      list.addAll(basicReds);
      list.addAll(basicBlacks);
      list.addAll(basicGreens);
      list.addAll(basicWhites);
      list.addAll(badlands);
      list.addAll(bayou);
      list.addAll(plateau);
      list.addAll(scrubland);
      list.addAll(savannah);
      list.addAll(taiga);
      list.addAll(tropicalIsland);
      list.addAll(tundra);
      list.addAll(undergroundSea);
      list.addAll(volcanicIsland);

      list.addAll(nonBasics);

      list.addAll(moxEmerald);
      list.addAll(moxJet);
      list.addAll(moxPearl);
      list.addAll(moxRuby);
      list.addAll(moxSapphire);
      // list.addAll(moxDiamond);

      int atInStack = 0;

      int marginX = 5;
      int marginY = 5;

      int x = marginX;

      int cardOffset = Constant.Runtime.stackOffset[0];

      String color = "";
      ArrayList<JPanel> cards = new ArrayList<JPanel>();

      ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>();

      boolean nextEnchanted = false;
      Card prevCard = null;
      int nextXIfNotStacked = 0;
      for (int i = 0; i < list.size(); i++) {
        JPanel addPanel;
        c = list.get(i);

        addPanel = new CardPanel(c);

        boolean startANewStack = false;

        if (!isStackable(c)) {
          startANewStack = true;
        } else {
          String newColor = c.getName(); // CardUtil.getColor(c);

          if (!newColor.equals(color)) {
            startANewStack = true;
            color = newColor;
          }
        }

        if (i == 0) {
          startANewStack = false;
        }

        if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) {
          startANewStack = true;
        }

        if (c.isAura() && c.isEnchanting() && !nextEnchanted) startANewStack = false;
        else if (c.isAura() && c.isEnchanting()) {
          startANewStack = true;
          nextEnchanted = false;
        }

        if (c.isLand() && c.isEnchanted()) {
          startANewStack = false;
          nextEnchanted = true;
        }

        // very hacky, but this is to ensure enchantment stacking occurs correctly when a land is
        // enchanted, and there are more lands of that same name

        else if ((prevCard != null
            && c.isLand()
            && prevCard.isLand()
            && prevCard.isEnchanted()
            && prevCard.getName().equals(c.getName()))) startANewStack = true;
        else if (prevCard != null
            && c.isLand()
            && prevCard.isLand()
            && !prevCard.getName().equals(c.getName())) startANewStack = true;

        /*
        if (c.getName().equals("Squirrel Nest")) {
            startANewStack = true;
            System.out.println("startANewStack: " + startANewStack);
        }
        */
        if (c.isAura() && c.isEnchanting() && prevCard != null && prevCard instanceof ManaPool)
          startANewStack = true;
        if (c instanceof ManaPool && prevCard instanceof ManaPool && prevCard.isSnow())
          startANewStack = false;

        if (startANewStack) {
          setupConnectedCards(connectedCards);
          connectedCards.clear();

          // Fixed distance if last was a stack, looks a bit nicer
          if (atInStack > 1) {
            x +=
                Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height)
                    + marginX;
          } else {
            x = nextXIfNotStacked;
          }

          atInStack = 0;
        } else {
          if (i != 0) {
            x += cardOffset;
          }
        }

        nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width;

        int xLoc = x;

        int yLoc = marginY;
        yLoc += atInStack * cardOffset;

        addPanel.setLocation(new Point(xLoc, yLoc));
        addPanel.setSize(addPanel.getPreferredSize());

        cards.add(addPanel);

        connectedCards.add((CardPanel) addPanel);

        atInStack++;
        prevCard = c;
      }

      setupConnectedCards(connectedCards);
      connectedCards.clear();

      for (int i = cards.size() - 1; i >= 0; i--) {
        JPanel card = cards.get(i);
        // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX);
        maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY);
        p.add(card);
      }

      maxX = nextXIfNotStacked;

      // System.out.println("x:" + maxX + ", y:" + maxY);
      if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) {
        //        p.setSize(new Dimension(maxX, maxY));
        p.setPreferredSize(new Dimension(maxX, maxY));
      }

    } else {
      // add all Cards in list to the GUI, add arrows to Local Enchantments
      JPanel addPanel;
      for (int i = 0; i < list.size(); i++) {
        c = list.get(i);
        /*if(c.isLocalEnchantment())
          addPanel = getCardPanel(c, "<< " +c.getName());
        else
          addPanel = getCardPanel(c);
          */
        addPanel = new CardPanel(c);

        p.add(addPanel);
      }
    }
  } // setupPanel()
Beispiel #21
0
  public synchronized boolean executeAction(Action a) {
    if (a.onUnite && !this.united) {
      this.actionOnUnite = a;
      this.united = true;
    }
    switch (a.action) {
      case HonorBoost:
        this.player.incrementHonor(a.magnitude);
        this.game.decrementHonor(a.magnitude);
        return true;
      case PowerBoost:
        this.power += a.magnitude;
        return true;
      case RuneBoost:
        this.rune += a.magnitude;
        return true;
      case DrawCard:
        player.playerDeck.drawNCards(a.magnitude);
        return true;
      case Discard:
        optionPane.showMessageDialog(
            game,
            String.format(game.descriptions.getString("SelectDeckDiscard"), a.magnitude),
            "",
            JOptionPane.PLAIN_MESSAGE);
        this.turnState = TurnState.Discard;
        this.turnStateMagnitude = a.magnitude;
        chill();
        return true;
      case OptionalDiscard:
        int za =
            optionPane.showConfirmDialog(
                game,
                String.format(game.descriptions.getString("OptionalHandDiscard"), a.magnitude),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (za == JOptionPane.YES_OPTION) {
          this.turnState = TurnState.Discard;
          this.turnStateMagnitude = a.magnitude;
          chill();
          return true;
        }
        return false;
      case ForcedDeckBanish:
        optionPane.showMessageDialog(
            game,
            String.format(game.descriptions.getString("ForcedBanish"), a.magnitude),
            "",
            JOptionPane.PLAIN_MESSAGE);
        this.turnState = TurnState.DeckBanish;
        this.turnStateMagnitude = a.magnitude;
        chill();
        return true;
      case CenterBanish:
        int m =
            optionPane.showConfirmDialog(
                game,
                String.format(game.descriptions.getString("OptionalCenterBanish"), a.magnitude),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (m == JOptionPane.YES_OPTION) {
          this.turnState = TurnState.CenterBanish;
          this.turnStateMagnitude = a.magnitude;
          chill();
          return true;
        }
        return false;
      case HandBanish:
        int z =
            optionPane.showConfirmDialog(
                game,
                String.format(game.descriptions.getString("OptionalHandBanish"), a.magnitude),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (z == JOptionPane.YES_OPTION) {
          this.turnState = TurnState.HandBanish;
          this.turnStateMagnitude = a.magnitude;
          chill();
          return true;
        }
        return false;
      case OptionalDeckBanish:
        if (player.playerDeck.hand.size() == 0) return false;
        int n =
            optionPane.showConfirmDialog(
                game,
                String.format(game.descriptions.getString("OptionalDeckBanish"), a.magnitude),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (n == JOptionPane.YES_OPTION) {
          this.turnState = TurnState.DeckBanish;
          this.turnStateMagnitude = a.magnitude;
          chill();
          return true;
        }
        return false;
      case HonorAndRuneBoost:
        this.rune += a.magnitude;
        this.player.incrementHonor(a.magnitude);
        this.game.decrementHonor(a.magnitude);
        return true;
      case ConstructRuneBoost:
        this.constructRune += a.magnitude;
        return true;
      case MechanaConstructRuneBoost:
        this.mechanaConstructRune += a.magnitude;
        return true;
      case EnterAiyanaState:
        this.AiyanaState = true;
        return true;
      case HeroRuneBoost:
        this.heroRune += a.magnitude;
        return true;
      case MonsterPowerBoost:
        this.monsterPower += a.magnitude;
        return true;
      case DefeatMonster:
        if (!this.game.gameDeck.canAMonsterBeDefeated(a.magnitude)) {
          this.player.incrementHonor(1);
          this.game.decrementHonor(1);
        } else {
          this.turnState = TurnState.DefeatMonster;
          this.turnStateMagnitude = a.magnitude;
        }
        return true;
      case EnterVoidMesmer:
        this.VoidMesmerState = true;
        return true;
      case FreeCard:
        optionPane.showMessageDialog(
            game, game.descriptions.getString("FreeCard"), "", JOptionPane.PLAIN_MESSAGE);
        this.turnState = TurnState.FreeCard;
        this.turnStateMagnitude = a.magnitude;
      case HeavyOrMystic:
        Object objects[] = {"Mystic", "Heavy Infantry"};
        int heavyOrMysticChoice =
            optionPane.showOptionDialog(
                game,
                game.descriptions.getString("HeavyOrMystic"),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                objects);
        if (heavyOrMysticChoice == JOptionPane.YES_OPTION) {
          this.player.playerDeck.hand.add(new Card(Main.getMystic()));
          this.player.playerDeck.deckRend.resetHandLocation();
        } else {
          this.player.playerDeck.hand.add(new Card(Main.getHeavyInfantry()));
          this.player.playerDeck.deckRend.resetHandLocation();
        }
        return true;
      case LunarStag:
        Object objects2[] = {
          game.descriptions.getString("2Rune"), game.descriptions.getString("2Honor")
        };
        int lunarStagChoice =
            optionPane.showOptionDialog(
                game,
                game.descriptions.getString("LunarStag"),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                objects2);
        if (lunarStagChoice == JOptionPane.YES_OPTION) {
          this.rune += 2;
        } else {
          this.player.incrementHonor(2);
          this.game.decrementHonor(2);
        }
        return true;
      case AskaraOfFate:
        this.player.playerDeck.drawCard();
        for (Player p : this.game.players) {
          p.playerDeck.drawCard();
        }
        return true;
      case AskaraCenterBanish:
        int num1 =
            optionPane.showConfirmDialog(
                game,
                String.format(game.descriptions.getString("OptionalCenterBanish"), 1),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (num1 == JOptionPane.YES_OPTION) {
          this.turnState = TurnState.AskaraCenterBanish;
          this.turnStateMagnitude = 1;
          chill();
          return true;
        }
        return false;
      case NookHound:
        this.player.playerDeck.drawCard();
        Card nookHoundCard =
            this.player.playerDeck.hand.get(this.player.playerDeck.hand.size() - 1);
        int nookHoundNumber =
            optionPane.showConfirmDialog(
                game,
                String.format(
                    game.descriptions.getString("OptionalDiscardDeShiz"), nookHoundCard.getName()),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (nookHoundNumber == JOptionPane.YES_OPTION) {
          this.player.playerDeck.hand.remove(this.player.playerDeck.hand.size() - 1);
          this.player.playerDeck.discard.add(nookHoundCard);
          this.player.playerDeck.drawCard();
        }
        return true;
      case AskaraDiscard:
        optionPane.showMessageDialog(
            game, game.descriptions.getString("DiscardDerpDeDerp"), "", JOptionPane.PLAIN_MESSAGE);
        this.turnState = TurnState.AskaraDiscard;
        this.turnStateMagnitude = 2;
        chill();
        return true;

      case TwofoldAskaraPlayed:
        if (this.player.playerDeck.checkForHeroInPlayedforTwoFold()) {
          optionPane.showMessageDialog(
              game, game.descriptions.getString("PickAndShit"), "", JOptionPane.PLAIN_MESSAGE);
          this.turnState = TurnState.TwofoldAskara;
          chill();

        } else {
          optionPane.showMessageDialog(
              game, game.descriptions.getString("NoHero"), "", JOptionPane.PLAIN_MESSAGE);
        }

        return true;
      case RajAction:
        optionPane.showMessageDialog(
            game, game.descriptions.getString("FryRy"), "", JOptionPane.PLAIN_MESSAGE);
        this.turnState = TurnState.RajTurnState;
        this.turnStateMagnitude = 1;
        chill();

        return true;
      case SeaTyrantAction:
        this.player.incrementHonor(5);
        this.game.decrementHonor(5);
        for (Player p : this.game.players) {
          if (!(p.equals(this.player))) {
            p.flipTyrantConstructsBool();
          }
        }
        return true;
      case CetraAction:
        if (this.game.gameDeck.checkForHeroInCenter()) {
          optionPane.showMessageDialog(
              game, game.descriptions.getString("CenterRowsShiz"), "", JOptionPane.PLAIN_MESSAGE);
          this.turnState = TurnState.FreeCardHero;
          chill();
        } else {
          optionPane.showMessageDialog(
              game, game.descriptions.getString("NoHeroToBuy"), "", JOptionPane.PLAIN_MESSAGE);
        }
        return true;

      case CorrosiveWidowAction:
        this.player.incrementHonor(3);
        this.game.decrementHonor(3);
        for (Player p : this.game.players) {
          if (!p.equals(this.player)) {
            p.flipWidowConstructsBool();
          }
        }
        return true;

      case TabletOfTimesDawn:
        int tabletOptionChoice =
            optionPane.showConfirmDialog(
                game,
                game.descriptions.getString("ZaBannishtheThings"),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE);
        if (tabletOptionChoice == JOptionPane.YES_OPTION) {
          this.game.extraTurn = true;
          for (int i = 0; i < this.player.playerDeck.constructs.size(); i++) {
            if (this.player.playerDeck.constructs.get(i).getName().equals("Tablet_of_Times_Dawn")) {
              this.player.playerDeck.constructs.remove(i);
            }
          }
          return true;
        }
        return false;

      case YggdrasilStaff:
        this.power += 1;
        if (this.rune >= 4) {
          int yggdrasilStaffChoice =
              optionPane.showConfirmDialog(
                  game,
                  game.descriptions.getString("WouldZaThings"),
                  "",
                  JOptionPane.YES_NO_OPTION,
                  JOptionPane.QUESTION_MESSAGE);
          if (yggdrasilStaffChoice == JOptionPane.YES_OPTION) {
            this.rune -= 4;
            this.player.incrementHonor(3);
            this.game.decrementHonor(3);
            return true;
          }
        }
        return true;

      case AvatarGolem:
        this.power += 2;
        boolean mechanaConstructHonor = false;
        boolean lifeboundConstructHonor = false;
        boolean voidConstructHonor = false;
        boolean enlightenedConstructHonor = false;
        for (Card c : this.player.playerDeck.constructs) {
          if (this.testForMechana(c) && !mechanaConstructHonor) {
            this.player.incrementHonor(1);
            this.game.decrementHonor(1);
            mechanaConstructHonor = true;
          } else if (c.getFaction() == Card.Faction.Lifebound && !lifeboundConstructHonor) {
            this.player.incrementHonor(1);
            this.game.decrementHonor(1);
            lifeboundConstructHonor = true;
          } else if (c.getFaction() == Card.Faction.Void && !voidConstructHonor) {
            this.player.incrementHonor(1);
            this.game.decrementHonor(1);
            voidConstructHonor = true;
          } else if (c.getFaction() == Card.Faction.Enlightened && !enlightenedConstructHonor) {
            this.player.incrementHonor(1);
            this.game.decrementHonor(1);
            enlightenedConstructHonor = true;
          }
        }
        return true;

      case KorAction:
        this.power += 2;
        if (this.player.playerDeck.constructs.size() >= 2) {
          player.playerDeck.drawNCards(1);
        }
        return true;

      case MechanaInitiate:
        Object mechanaInitiateOptions[] = {"1 Rune", "1 Power"};
        int mechanaInitiateChoice =
            optionPane.showOptionDialog(
                game,
                game.descriptions.getString("GainAllTheThings"),
                "",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                mechanaInitiateOptions);
        if (mechanaInitiateChoice == JOptionPane.YES_OPTION) {
          this.rune += 1;
        } else {
          this.power += 1;
        }
        return true;

      case HedronCannon:
        for (Card c : this.player.playerDeck.constructs) {
          if (this.testForMechana(c)) {
            this.power += 1;
          }
        }
        return true;

      case Voidthirster:
        this.power += 1;
        this.VoidthirsterState = true;
        return true;

      case XeronAction:
        this.player.incrementHonor(3);
        this.game.decrementHonor(3);
        for (int i = 0; i < this.game.players.size(); i++) {
          if (!this.game.players.get(i).equals(this.player)) {
            Card xeronTemp = this.game.players.get(i).playerDeck.stealCard();
            if (xeronTemp != null) {
              this.player.playerDeck.hand.add(xeronTemp);
              this.player.playerDeck.resetHandLocation();
            }
          }
        }
        return true;

      case RocketCourier:
        this.RocketCourierState++;
        return true;

      case HedronLinkDevice:
        this.HedronLinkDeviceState = true;
        return true;
      case HeroTopOfDeck:
        this.HeroTopOfDeckState = true;
        return true;
    }
    return false;
  }
  /**
   * setupNoLandPermPanel.
   *
   * @param p a {@link javax.swing.JPanel} object.
   * @param list a {@link java.util.ArrayList} object.
   * @param stack a boolean.
   */
  private static void setupNoLandPermPanel(JPanel p, ArrayList<Card> list, boolean stack) {

    int maxY = 0;
    int maxX = 0;

    Card c;

    if (stack) {
      // add all Cards in list to the GUI, add arrows to Local Enchantments

      ArrayList<Card> planeswalkers = getPlaneswalkers(list);
      ArrayList<Card> equippedEnchantedCreatures =
          getEquippedEnchantedCreatures(
              list); // this will also fetch the equipment and/or enchantment
      ArrayList<Card> nonTokenCreatures = getNonTokenCreatures(list);
      ArrayList<Card> tokenCreatures = getTokenCreatures(list);

      // sort tokenCreatures by name (TODO: fix the warning message somehow)
      Collections.sort(
          tokenCreatures,
          new Comparator<Card>() {
            public int compare(Card c1, Card c2) {
              return c1.getName().compareTo(c2.getName());
            }
          });

      ArrayList<Card> artifacts = getNonCreatureArtifacts(list);
      ArrayList<Card> enchantments = getGlobalEnchantments(list);
      // ArrayList<Card> nonBasics = getNonBasics(list);

      list = new ArrayList<Card>();
      list.addAll(planeswalkers);
      list.addAll(equippedEnchantedCreatures);
      list.addAll(nonTokenCreatures);
      list.addAll(tokenCreatures);
      list.addAll(artifacts);
      list.addAll(enchantments);

      int atInStack = 0;

      int marginX = 5;
      int marginY = 5;

      int x = marginX;

      int cardOffset = Constant.Runtime.stackOffset[0];

      String color = "";
      ArrayList<JPanel> cards = new ArrayList<JPanel>();

      ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>();

      boolean nextEquippedEnchanted = false;
      int nextXIfNotStacked = 0;
      Card prevCard = null;
      for (int i = 0; i < list.size(); i++) {
        JPanel addPanel;
        c = list.get(i);
        addPanel = new CardPanel(c);

        boolean startANewStack = false;

        if (!isStackable(c)) {
          startANewStack = true;
        } else {
          String newColor = c.getName(); // CardUtil.getColor(c);

          if (!newColor.equals(color)) {
            startANewStack = true;
            color = newColor;
          }
        }

        if (i == 0) {
          startANewStack = false;
        }

        if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) {
          startANewStack = true;
        }

        if ((c.isEquipment() || c.isAura())
            && (c.isEquipping() || c.isEnchanting())
            && !nextEquippedEnchanted) startANewStack = false;
        else if ((c.isEquipment() || c.isAura()) && (c.isEquipping() || c.isEnchanting())) {
          startANewStack = true;
          nextEquippedEnchanted = false;
        }

        if (c.isCreature() && (c.isEquipped() || c.isEnchanted())) {
          startANewStack = false;
          nextEquippedEnchanted = true;
        }
        // very hacky, but this is to ensure equipment stacking occurs correctly when a token is
        // equipped/enchanted, and there are more tokens of that same name
        else if ((prevCard != null
            && c.isCreature()
            && prevCard.isCreature()
            && (prevCard.isEquipped() || prevCard.isEnchanted())
            && prevCard.getName().equals(c.getName()))) startANewStack = true;
        else if (prevCard != null
            && c.isCreature()
            && prevCard.isCreature()
            && !prevCard.getName().equals(c.getName())) startANewStack = true;

        if (((c.isAura() && c.isEnchanting()) || (c.isEquipment() && c.isEquipping()))
            && prevCard != null
            && prevCard.isPlaneswalker()) startANewStack = true;

        if (startANewStack) {
          setupConnectedCards(connectedCards);
          connectedCards.clear();

          // Fixed distance if last was a stack, looks a bit nicer
          if (atInStack > 1) {
            x +=
                Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height)
                    + marginX;
          } else {
            x = nextXIfNotStacked;
          }

          atInStack = 0;
        } else {
          if (i != 0) {
            x += cardOffset;
          }
        }

        nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width;

        int xLoc = x;

        int yLoc = marginY;
        yLoc += atInStack * cardOffset;

        addPanel.setLocation(new Point(xLoc, yLoc));
        addPanel.setSize(addPanel.getPreferredSize());

        cards.add(addPanel);

        connectedCards.add((CardPanel) addPanel);

        atInStack++;
        prevCard = c;
      }

      setupConnectedCards(connectedCards);
      connectedCards.clear();

      for (int i = cards.size() - 1; i >= 0; i--) {
        JPanel card = cards.get(i);
        // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX);
        maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY);
        p.add(card);
      }

      maxX = nextXIfNotStacked;

      if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) {
        p.setPreferredSize(new Dimension(maxX, maxY));
      }

    } else {
      JPanel addPanel;
      for (int i = 0; i < list.size(); i++) {
        c = list.get(i);
        addPanel = new CardPanel(c);

        p.add(addPanel);
      }
    }
  } // setupPanel()
Beispiel #23
0
 @Override
 public void draw(Graphics2D g2d) {
   // After updating we will draw all the objects to the screen
   g2d.setColor(Color.WHITE);
   g2d.fillRect(0, 0, windowWidth, windowHeight);
   g2d.setColor(Color.BLACK);
   Font font = new Font("Arial", Font.BOLD, 30);
   g2d.setFont(font);
   int textWidth =
       (int)
           (font.getStringBounds("You Are Now In Battle State", g2d.getFontRenderContext())
               .getWidth());
   g2d.drawString(
       "You Are Now In Battle State", windowWidth / 2 - textWidth / 2, windowHeight / 2);
   // Draw the battle images of the enemy and MainCharacter
   g2d.drawImage(
       mainCharacterImage,
       60,
       3 * windowHeight / 4 - 2 * 60,
       mainCharacterImage.getWidth() * 2,
       mainCharacterImage.getHeight() * 2,
       null);
   g2d.drawImage(
       enemyImage,
       windowWidth - 60 - enemyImage.getWidth(),
       60,
       enemyImage.getWidth(),
       enemyImage.getHeight(),
       null);
   // Draw an action box at the bottom where we decide our actions on each turn
   g2d.setColor(Color.CYAN);
   g2d.fillRect(0, 3 * windowHeight / 4, windowWidth, windowHeight / 4 + 2);
   // Draw the hp and mp bars of the MainCharacter and the Enemy
   g2d.setColor(Color.BLACK);
   g2d.drawRect(0, 3 * windowHeight / 4, windowWidth, windowHeight / 4 + 2);
   Font hpFont = new Font("Arial", Font.BOLD, 15);
   g2d.setFont(hpFont);
   String text =
       "Health: "
           + String.valueOf(StartGameState.character.health)
           + "/"
           + String.valueOf(StartGameState.character.maxHealth);
   textWidth = (int) (hpFont.getStringBounds(text, g2d.getFontRenderContext()).getWidth());
   g2d.drawString(
       text, 60 + mainCharacterImage.getWidth() * 2 + 45, 3 * windowHeight / 4 - 30 - 15 - 20);
   text =
       "Mana:  "
           + String.valueOf(StartGameState.character.mana)
           + "/"
           + String.valueOf(StartGameState.character.maxMana);
   g2d.drawString(text, 60 + mainCharacterImage.getWidth() * 2 + 45, 3 * windowHeight / 4 - 30);
   text = MainCharacter.characterName;
   g2d.drawString(
       text,
       60 + mainCharacterImage.getWidth() * 2 + 45,
       3 * windowHeight / 4 - 30 - 2 * 15 - 2 * 20);
   g2d.setColor(Color.GRAY);
   g2d.fillRoundRect(
       60 + mainCharacterImage.getWidth() * 2 + 45 + textWidth + 20,
       3 * windowHeight / 4 - 45 - 15 - 20,
       100,
       15,
       3,
       3);
   g2d.fillRoundRect(
       60 + mainCharacterImage.getWidth() * 2 + 45 + textWidth + 20,
       3 * windowHeight / 4 - 45,
       100,
       15,
       3,
       3);
   g2d.setColor(Color.GREEN);
   g2d.fillRoundRect(
       60 + mainCharacterImage.getWidth() * 2 + 45 + textWidth + 20,
       3 * windowHeight / 4 - 45 - 15 - 20,
       (int)
           (((float) StartGameState.character.health / (float) StartGameState.character.maxHealth)
               * 100),
       15,
       3,
       3);
   g2d.setColor(Color.BLUE);
   g2d.fillRoundRect(
       60 + mainCharacterImage.getWidth() * 2 + 45 + textWidth + 20,
       3 * windowHeight / 4 - 45,
       (int)
           (((float) StartGameState.character.mana / (float) StartGameState.character.maxMana)
               * 100),
       15,
       3,
       3);
   g2d.setColor(Color.BLACK);
   g2d.drawRoundRect(
       60 + mainCharacterImage.getWidth() * 2 + 45 + textWidth + 20,
       3 * windowHeight / 4 - 45 - 15 - 20,
       100,
       15,
       3,
       3);
   g2d.drawRoundRect(
       60 + mainCharacterImage.getWidth() * 2 + 45 + textWidth + 20,
       3 * windowHeight / 4 - 45,
       100,
       15,
       3,
       3);
   // Enemy health and mana bars
   text = "Health: " + String.valueOf(enemy.health) + "/" + String.valueOf(enemy.maxHealth);
   textWidth = (int) (hpFont.getStringBounds(text, g2d.getFontRenderContext()).getWidth());
   g2d.drawString(
       text, windowWidth - 60 - enemyImage.getWidth() - 45 - 100 - 20 - textWidth, 60 + 15);
   text = "Mana:  " + String.valueOf(enemy.mana) + "/" + String.valueOf(enemy.maxMana);
   g2d.drawString(
       text,
       windowWidth - 60 - enemyImage.getWidth() - 45 - 100 - 20 - textWidth,
       60 + 2 * 15 + 20);
   text = enemy.getName();
   g2d.drawString(
       text, windowWidth - 60 - enemyImage.getWidth() - 45 - 100 - 20 - textWidth, 60 - 20);
   g2d.setColor(Color.GRAY);
   g2d.fillRoundRect(windowWidth - 60 - enemyImage.getWidth() - 45 - 100, 60, 100, 15, 3, 3);
   g2d.fillRoundRect(
       windowWidth - 60 - enemyImage.getWidth() - 45 - 100, 60 + 15 + 20, 100, 15, 3, 3);
   g2d.setColor(Color.GREEN);
   g2d.fillRoundRect(
       windowWidth - 60 - enemyImage.getWidth() - 45 - 100,
       60,
       (int) (((float) enemy.health / (float) enemy.maxHealth) * 100),
       15,
       3,
       3);
   g2d.setColor(Color.BLUE);
   g2d.fillRoundRect(
       windowWidth - 60 - enemyImage.getWidth() - 45 - 100,
       60 + 15 + 20,
       (int) (((float) enemy.mana / (float) enemy.maxMana) * 100),
       15,
       3,
       3);
   g2d.setColor(Color.BLACK);
   g2d.drawRoundRect(windowWidth - 60 - enemyImage.getWidth() - 45 - 100, 60, 100, 15, 3, 3);
   g2d.drawRoundRect(
       windowWidth - 60 - enemyImage.getWidth() - 45 - 100, 60 + 15 + 20, 100, 15, 3, 3);
   // Draw the player's hand and the current card
   int x = drawButton.getX() + drawButton.getWidth() + 40;
   int y = drawButton.getY() + 10;
   int i = 0;
   if (deckCount < MainCharacter.deck.size()) {
     g2d.drawImage(cardBack, 3 * windowWidth / 4 - 15 - cardBack.getWidth(), y, null);
   }
   if (hand.size() > 0) {
     int cardSpacing = cardWidth / hand.size();
     for (Card card : hand.values()) {
       if (i != cardScroller.getCountX() - 1) {
         card.draw(g2d, x + i * (cardSpacing), y, 0, 0);
       }
       i++;
     }
     Card current = hand.getIndexed(cardScroller.getCountX() - 1);
     current.draw(g2d, x + (cardScroller.getCountX() - 1) * (cardSpacing), y - 20, 0, 0);
     // If it is MainCharacter turn then we draw the actions in the action box
     g2d.setFont(new Font("Arial", Font.BOLD, 20));
     g2d.setColor(Color.BLACK);
     int explanationWidth = windowWidth / 4 - 25;
     g2d.drawString(current.getName(), 3 * windowWidth / 4 + 15, cardButton.getY());
     Font explanationFont = new Font("Arial", Font.BOLD, 10);
     g2d.setFont(explanationFont);
     ArrayList<String> lines = new ArrayList<>();
     // Determines width and height of only the text
     String dialog = current.getExplanation();
     int width =
         (int) (explanationFont.getStringBounds(dialog, g2d.getFontRenderContext()).getWidth());
     if (width > explanationWidth) {
       String[] split = dialog.split("\\s+");
       int tempWidth = 0;
       int maxWidth = 0;
       String line = "";
       for (i = 0; i < split.length; i++) {
         tempWidth +=
             (int)
                 (explanationFont
                     .getStringBounds(split[i] + "_", g2d.getFontRenderContext())
                     .getWidth());
         if (tempWidth > explanationWidth) {
           tempWidth =
               (int)
                   (explanationFont
                       .getStringBounds(split[i] + "_", g2d.getFontRenderContext())
                       .getWidth());
           lines.add(line);
           line = split[i] + " ";
         } else {
           line = line + split[i] + " ";
         }
         if (tempWidth > maxWidth) {
           maxWidth = tempWidth;
         }
       }
       lines.add(line);
     } else {
       lines.add(dialog);
     }
     for (i = 0; i < lines.size(); i++) {
       g2d.drawString(
           lines.get(i), 3 * windowWidth / 4 + 15, cardButton.getY() + (i + 1) * (10 + 4));
     }
     g2d.setFont(hpFont);
     String[] effects = current.getEffectStrings();
     for (i = 0; i < effects.length; i++) {
       g2d.drawString(
           effects[i],
           3 * windowWidth / 4 + 15,
           cardButton.getY() + (lines.size()) * (10 + 4) + (i + 1) * (5 + 15));
     }
     g2d.drawString(
         "Mana Cost: " + String.valueOf(current.getManaCost()),
         3 * windowWidth / 4 + 15,
         cardButton.getY() + (lines.size()) * (10 + 4) + (i + 1) * (15 + 5));
   }
   if (drawNoMana) {
     g2d.setFont(new Font("Arial", Font.BOLD, 15));
     g2d.drawString("You don't have", cardButton.getX(), cardButton.getY() + 15);
     g2d.drawString("enough mana!", cardButton.getX(), cardButton.getY() + 2 * 15 + 10);
   } else if (drawNoCards) {
     g2d.setFont(new Font("Arial", Font.BOLD, 15));
     g2d.drawString("You are out of", cardButton.getX(), cardButton.getY() + 15);
     g2d.drawString("cards to draw!", cardButton.getX(), cardButton.getY() + 2 * 15 + 10);
   } else if (drawItemUsed) {
     g2d.setFont(new Font("Arial", Font.BOLD, 15));
     g2d.drawString("You have used", cardButton.getX(), cardButton.getY() + 15);
     g2d.drawString(
         itemMenu.getLastItem().name + "!", cardButton.getX(), cardButton.getY() + 2 * 15 + 10);
   } else if (turn == 0 && drawParalyzed) {
     g2d.setFont(new Font("Arial", Font.BOLD, 15));
     g2d.drawString("You cannot move,", cardButton.getX(), cardButton.getY() + 15);
     g2d.drawString("you're paralyzed!", cardButton.getX(), cardButton.getY() + 2 * 15 + 10);
   } else if (turn == 1 && drawParalyzed) {
     Font messageFont = new Font("Arial", Font.BOLD, 15);
     g2d.setFont(messageFont);
     text = enemy.getName() + " cannot move, they're paralyzed!";
     ArrayList<String> lines = new ArrayList<>();
     int width = (int) (messageFont.getStringBounds(text, g2d.getFontRenderContext()).getWidth());
     if (width > cardButton.getWidth() * 2 + 40) {
       String[] split = text.split("\\s+");
       int tempWidth = 0;
       int maxWidth = 0;
       String line = "";
       for (i = 0; i < split.length; i++) {
         tempWidth +=
             (int)
                 (messageFont
                     .getStringBounds(split[i] + "_", g2d.getFontRenderContext())
                     .getWidth());
         if (tempWidth > cardButton.getWidth() * 2 + 40) {
           tempWidth =
               (int)
                   (messageFont
                       .getStringBounds(split[i] + "_", g2d.getFontRenderContext())
                       .getWidth());
           lines.add(line);
           line = split[i] + " ";
         } else {
           line = line + split[i] + " ";
         }
         if (tempWidth > maxWidth) {
           maxWidth = tempWidth;
         }
       }
       lines.add(line);
     } else {
       lines.add(text);
     }
     for (i = 0; i < lines.size(); i++) {
       g2d.drawString(lines.get(i), cardButton.getX(), cardButton.getY() + 15 + 30 * i);
     }
   } else if (turn == 0 && turnState == 4) {
     g2d.setFont(new Font("Arial", Font.BOLD, 15));
     g2d.drawString("You try to", cardButton.getX(), cardButton.getY() + 15);
     g2d.drawString("run away...", cardButton.getX(), cardButton.getY() + 2 * 15 + 10);
   } else if (turn == 0 && turnState == 5) {
     Font messageFont = new Font("Arial", Font.BOLD, 15);
     g2d.setFont(messageFont);
     if (drawMoveApplication) {
       text = effectMessage;
     } else {
       text = "You have used " + playedCard.getName() + " on " + enemy.getName() + "!";
     }
     ArrayList<String> lines = new ArrayList<>();
     int width = (int) (messageFont.getStringBounds(text, g2d.getFontRenderContext()).getWidth());
     if (width > cardButton.getWidth() * 2 + 40) {
       String[] split = text.split("\\s+");
       int tempWidth = 0;
       int maxWidth = 0;
       String line = "";
       for (i = 0; i < split.length; i++) {
         tempWidth +=
             (int)
                 (messageFont
                     .getStringBounds(split[i] + "_", g2d.getFontRenderContext())
                     .getWidth());
         if (tempWidth > cardButton.getWidth() * 2 + 40) {
           tempWidth =
               (int)
                   (messageFont
                       .getStringBounds(split[i] + "_", g2d.getFontRenderContext())
                       .getWidth());
           lines.add(line);
           line = split[i] + " ";
         } else {
           line = line + split[i] + " ";
         }
         if (tempWidth > maxWidth) {
           maxWidth = tempWidth;
         }
       }
       lines.add(line);
     } else {
       lines.add(text);
     }
     for (i = 0; i < lines.size(); i++) {
       g2d.drawString(lines.get(i), cardButton.getX(), cardButton.getY() + 15 + 30 * i);
     }
   } else if (turn == 0) {
     drawActionBox(g2d);
   } else if (turn == 1) {
     drawEnemyMessage(g2d);
   } else if (turn == 2) {
     drawVictoryMessage(g2d);
   } else if (turn == 3) {
     drawLossMessage(g2d);
   }
 }