Package cero.games

Examples of cero.games.Zone


        collection = game.getPlayers().get(Integer.valueOf(split[1]))
            .getZones();
      }
    } else if (split[0].equals("c")) {
      if (split.length == 2) {
        Zone zone = game.getZones().get(split[1]);
        if (zone != null)
          collection = zone.getSortedList();
        else
          System.out.println("no such zone");
      }
      if (split.length == 3) {
        collection = game.getPlayers().get(Integer.valueOf(split[1]))
View Full Code Here


    Collection<Card> cardSet = new ArrayList<Card>();
    for (Card card : card52Set)
      cardSet.add(card);
   
    //dealsource creation
    Zone dealzone = new ZoneHand("Deal Source", cardSet);
    bataille.getZones().add(dealzone);
   
    //Players and zones creation
    for (int i = 0; i < bataille.getPlayers().size(); i++) {
      cero.games.Player player = bataille.getPlayers().get(i);
View Full Code Here

  public void roundStart(RoundEvent e) {
  }

  public void roundEnd(RoundEvent e) {
    Zone z;
    Player winner = null;
    Card52 winnersCard = null;
    boolean equality = false;
    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

  public void roundStart(RoundEvent e) {
    Game game = e.getGame();
    ZonesGroup zones = game.getZones();

    Zone dealsource = zones.get("Deal Source");

    for (Zone zone : zones)
      zone.moveCards(dealsource);
   
    for (cero.games.Player p : game.getPlayers())
      for (Zone z : p.getZones())
        z.moveCards(dealsource);

    // shuffling
    dealsource.setSorter(new ShuffleSorter());
    dealsource.sort();

    // dealing
    int playernum = 0;
    for (Card card : dealsource.getSortedList()) {
      playernum = (playernum) % (game.getPlayers().size());
      dealsource.moveCard(card, game.getPlayers().get(playernum)
          .getZones().get("stock"));
      playernum++;
    }

  }
View Full Code Here

    Collection<Card> cardSet = new ArrayList<Card>();
    for (Card card : card52Set)
      cardSet.add(card);

    // dealsource creation
    Zone talonZone = new ZonePile("Talon");
    Zone stockZone = new ZoneStock("Stock", cardSet, (ZonePile) talonZone);
    uno.getZones().add(talonZone);
    uno.getZones().add(stockZone);

    // Players and zones creation
    for (int i = 0; i < uno.getPlayers().size(); i++) {
View Full Code Here

            .getZones();
      }
      print(collection);
    } else if (split[0].equals("z")) {
      if (split.length == 2) {
        Zone zone = CommandLineLauncher.getGame().getZones().get(
            split[1]);
        if (zone == null) {
          System.out.println("zone inconnue");
          return false;
        }
        else {
          ActionLookAtZone action = new ActionLookAtZone();
          try {
            action.playerActed(new ActionEvent(CommandLineLauncher
                .getGame(), CommandLineLauncher.getCurrentPlayer(),
                zone, null, null));
          } catch (ActionException e) {
            e.printStackTrace();
          }
          CommandLineLauncher.getGame().registerAction(action);
          currentAction = action;
        }
      }
      else if (split.length == 3) {
        Zone zone = CommandLineLauncher.getGame().getPlayers().get(
            Integer.valueOf(split[1])).getZones().get(split[2]);
        if (zone == null) {
          System.out.println("zone inconnue");
          return false;
        }
View Full Code Here

  @Override
  public boolean executer(String parametres) {
    String[] arg = parametres.split(":");
    Game game = CommandLineLauncher.getGame();
    Zone from;
    Zone to;
    List<Card> cards = new ArrayList<Card>();
    if (arg.length == 3) {
      String[] split = arg[0].split("-");
      if (split.length == 1)
        from = game.getZones().get(split[0]);
View Full Code Here

  }

  boolean drawACard(UnoGame g) {
    ActionPick act = new ActionPick();
    try {
      Zone stock = g.getStock();
      Zone hand = getHand();
      act.playerActed(new ActionEvent(g, this, stock, hand, null));
      g.registerAction(act);
      return true;
    } catch (ActionException e) {
      e.printStackTrace();
View Full Code Here

  @Override
  public boolean executer(String parametres) {
    Game game = CommandLineLauncher.getGame();
    Player player = CommandLineLauncher.getCurrentPlayer();
    Zone from = player.getZones().get("Hand");
    Zone to = game.getZones().get("Talon");
    int cardid;
    try {
      cardid = Integer.valueOf(parametres);
    } catch (Exception e) {
      System.out.println("incorrect card id");
View Full Code Here

  @Override
  public boolean executer(String parametres) {
    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);
View Full Code Here

TOP

Related Classes of cero.games.Zone

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.