Package cero.games

Examples of cero.games.Card


   *            the index of the first card to swap
   * @param j
   *            the index of the second card to swap
   */
  private void swap(List<Card> list, int i, int j) {
    Card t = list.get(i);
    list.set(i, list.get(j));
    list.set(j, t);
  }
View Full Code Here


    Collection<Card> cardcol = new ArrayList<Card>();

    for (Player p : e.getGame().getPlayers()) {
      z = p.getZones().get("current");
      if (z.getCardCount() > 0) {
        Card c = z.getSortedList().get(z.getSortedList().size() - 1);
        if (c instanceof Card52) {
          if (winnersCard == null) {
            winnersCard = ((Card52) c);
            winner = p;
          } else {
            if (((Card52) c).getValue() > winnersCard.getValue()) {
              winnersCard = ((Card52) c);
              winner = p;
              equality = false;
            } else if (((Card52) c).getValue() == winnersCard
                .getValue()) {
              equality = true;
            }
          }
        }
      }
    }

    if (winner == null)
      throw new RuntimeException("There is no player ?!");

    if (!equality) {
      for (Player p : e.getGame().getPlayers()) {
        z = p.getZones().get("current");
        if (z.getCardCount() > 0) {
          for (Card c : z.getSortedList()) {
            cardcol.add(c);
            z.deleteCard(c);
          }
        }
      }
      Zone dest = winner.getZones().get("won");
      for (Card c : cardcol)
        dest.addCard(c);
    } else {
      Zone from, to;
      for (Player p : e.getGame().getPlayers()) {
        from = p.getZones().get("stock");
        to = p.getZones().get("current");
        if (from.getCardCount() > 1) {
          Card c = from.getSortedList().get(
              from.getSortedList().size() - 1);
          from.deleteCard(c);
          to.addCard(c.getHiddenCard());
        } else if (from.getCardCount() == 1) {
          Card c = from.getSortedList().get(
              from.getSortedList().size() - 1);
          from.deleteCard(c);
          to.addCard(c);
        }
      }
View Full Code Here

  }

  @Override
  public void executeAction() {
    super.executeAction();
    Card c = getCards().iterator().next();
    if (c instanceof CardUno) {
      CardUno cu = (CardUno) c;
      if (cu.getValue() == CardUno.INVERSION)
        getGame().getPlayers().sort(new InvertSorter());
      if (cu.getValue() == CardUno.PLUS2) {
View Full Code Here

      cardid = Integer.valueOf(parametres);
    } catch (Exception e) {
      System.out.println("incorrect card id");
      return false;
    }
    Card playedcard = null;
    for (Card card : from.getSortedList()) {
      if (card.getCardId() == cardid) {
        playedcard = card;
        break;
      }
View Full Code Here

    Game game = CommandLineLauncher.getGame();
    Player player = CommandLineLauncher.getCurrentPlayer();
    Zone from = game.getZones().get("Stock");
    Zone to = player.getZones().get("Hand");
    //FIXME : use top card instead !
    Card playedcard = from.getSortedList().get(0);
    ArrayList<Card> colcards = new ArrayList<Card>();
    colcards.add(playedcard);

    ActionPick action = new ActionPick();
    try {
View Full Code Here

     * Action made when we play a card.
     */
    private void playCard() {
      Zone from = player.getZones().get("Hand");
      Zone to = game.getZones().get("Talon");
      Card playedcard = getGCard().getCard();
      // FIXME we shouldn't have to check for such things...
      boolean cardfound = false;
      for (Card c : from) {
        if (c == playedcard) {
          cardfound = true;
View Full Code Here

TOP

Related Classes of cero.games.Card

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.