Exemplo n.º 1
0
 public boolean hasSameCounters(CardView otherCard) {
   Map<CounterType, Integer> counters = getCounters();
   if (counters == null) {
     return otherCard.getCounters() == null;
   }
   return counters.equals(otherCard.getCounters());
 }
Exemplo n.º 2
0
  public static boolean mayViewAny(Iterable<CardView> cards, Iterable<PlayerView> viewers) {
    if (cards == null) {
      return false;
    }

    for (CardView cv : cards) {
      if (cv.canBeShownToAny(viewers)) {
        return true;
      }
    }
    return false;
  }
Exemplo n.º 3
0
  void updateState(Card c) {
    updateName(c);

    boolean isSplitCard = c.isSplitCard();
    set(TrackableProperty.Cloned, c.isCloned());
    set(TrackableProperty.SplitCard, isSplitCard);
    set(TrackableProperty.FlipCard, c.isFlipCard());

    CardStateView cloner = CardView.getState(c, CardStateName.Cloner);
    set(
        TrackableProperty.Cloner,
        cloner == null ? null : cloner.getName() + " (" + cloner.getId() + ")");

    CardState currentState = c.getCurrentState();
    if (isSplitCard) {
      if (c.getCurrentStateName() != CardStateName.LeftSplit
          && c.getCurrentStateName() != CardStateName.RightSplit) {
        currentState = c.getState(CardStateName.LeftSplit);
      }
    }

    CardStateView currentStateView = currentState.getView();
    if (getCurrentState() != currentStateView) {
      set(TrackableProperty.CurrentState, currentStateView);
      currentStateView.updatePower(
          c); // ensure power, toughness, and loyalty updated when current state changes
      currentStateView.updateToughness(c);
      currentStateView.updateLoyalty(c);

      // update the color only while in Game
      if (c.getGame() != null) {
        currentStateView.updateColors(currentState);
      }
    }
    currentState
        .getView()
        .updateKeywords(c, currentState); // update keywords even if state doesn't change

    CardState alternateState =
        isSplitCard ? c.getState(CardStateName.RightSplit) : c.getAlternateState();
    if (alternateState == null) {
      set(TrackableProperty.AlternateState, null);
    } else {
      CardStateView alternateStateView = alternateState.getView();
      if (getAlternateState() != alternateStateView) {
        set(TrackableProperty.AlternateState, alternateStateView);
        alternateStateView.updatePower(
            c); // ensure power, toughness, and loyalty updated when current state changes
        alternateStateView.updateToughness(c);
        alternateStateView.updateLoyalty(c);

        // update the color only while in Game
        if (c.getGame() != null) {
          alternateStateView.updateColors(alternateState);
        }
      }
      alternateState.getView().updateKeywords(c, alternateState);
    }
  }
Exemplo n.º 4
0
 CardCollection setCards(CardCollection oldCards, CardCollection newCards, TrackableProperty key) {
   if (newCards == null || newCards.isEmpty()) { // avoid storing empty collections
     set(key, null);
     return null;
   }
   set(key, CardView.getCollection(newCards)); // TODO prevent overwriting list if not necessary
   return newCards;
 }
Exemplo n.º 5
0
 // special methods for updating card and player properties as needed and returning the new
 // collection
 Card setCard(Card oldCard, Card newCard, TrackableProperty key) {
   if (newCard != oldCard) {
     set(key, CardView.get(newCard));
   }
   return newCard;
 }