Ejemplo n.º 1
0
  @Override
  public boolean attempt(Game game, Event event, java.util.Map<Parameter, Set> parameters) {
    int successes = 0;
    Set cause = parameters.get(Parameter.CAUSE);
    int required = 1;
    if (parameters.containsKey(Parameter.NUMBER))
      required = Sum.get(parameters.get(Parameter.NUMBER));

    for (Player player : parameters.get(Parameter.PLAYER).getAll(Player.class)) {
      java.util.Set<Card> cards = null;
      if (parameters.containsKey(Parameter.CHOICE))
        cards = parameters.get(Parameter.CHOICE).getAll(Card.class);
      else cards = new Set(player.getHand(game.actualState).objects).getAll(Card.class);

      successes = 0;
      for (Card thisCard : cards) {
        java.util.Map<Parameter, Set> newParameters = new java.util.HashMap<Parameter, Set>();
        newParameters.put(Parameter.CAUSE, cause);
        newParameters.put(Parameter.CARD, new Set(thisCard));
        if (createEvent(
                game,
                thisCard.getOwner(game.actualState) + " discards " + thisCard + ".",
                DISCARD_ONE_CARD,
                newParameters)
            .attempt(event)) successes++;

        if (successes == required) break;
      }
      if (successes != required) return false;
    }
    return true;
  }
Ejemplo n.º 2
0
  public void updateMainContent(Card cc) {
    TextView cash = (TextView) findViewById(R.id.menu_text);
    if (game.getAddedCash() > 0)
      cash.setText("Cash: $" + game.getCash() + "  (+$" + game.getAddedCash() + ")");
    else if (game.getAddedCash() < 0)
      cash.setText("Cash: $" + game.getCash() + "  ($" + game.getAddedCash() + ")");
    else cash.setText("Cash: $" + game.getCash());

    LinearLayout ll = (LinearLayout) findViewById(R.id.linearLayout3);
    new Color();
    ll.setBackgroundColor(
        Color.rgb(
            game.getCurrentCard().getColor()[0],
            game.getCurrentCard().getColor()[1],
            game.getCurrentCard().getColor()[2]));

    TextView h1 = (TextView) findViewById(R.id.textView1);
    h1.setText(cc.getStreet().toUpperCase());

    TextView h2 = (TextView) findViewById(R.id.textView2);
    h2.setText(cc.getArea());

    TextView own = (TextView) findViewById(R.id.textView3);
    own.setText("" + cc.getOwner());

    TextView val = (TextView) findViewById(R.id.textView4);
    val.setText("$" + Integer.toString(cc.getValue()));

    TextView tax = (TextView) findViewById(R.id.textView5);
    tax.setText("$" + Integer.toString(cc.getTax()));

    TextView hou = (TextView) findViewById(R.id.textView6);
    String pri = new String();
    if (cc.getHousePrise() <= 0) pri = " --";
    else pri = Integer.toString(cc.getHousePrise());
    hou.setText("$" + pri);

    // The buttons
    buyStreet.setEnabled(
        game.getCash() >= game.getCurrentCard().getValue()
            && game.getCurrentCard().getStreet() != GameMechanics.DEFAULT_STREET
            && game.getPlayer().getUserId() != game.getCurrentCard().getOwnerId());

    buyHouse.setEnabled(
        game.getCash() >= game.getCurrentCard().getHousePrise()
            && game.getCurrentCard().getHouses() < 5
            && game.getCurrentCard().getStreet() != GameMechanics.DEFAULT_STREET
            && game.getPlayer().getUserId() == game.getCurrentCard().getOwnerId());

    // Do the houses
    for (int i = 1; i <= 5; i++) {
      ImageView houses = new ImageView(this);
      houses = (ImageView) findViewById(ivid[i]);
      if (cc.getHouses() >= i) houses.setImageResource(hoid[i]);
      else houses.setImageResource(hoid[0]);
      houses.invalidate();
    }

    return;
  }
Ejemplo n.º 3
0
 void updateOwner(Card c) {
   set(TrackableProperty.Owner, PlayerView.get(c.getOwner()));
 }