Ejemplo n.º 1
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);
    }
  }
Ejemplo n.º 2
0
 public static CardStateView getState(Card c, CardStateName state) {
   if (c == null) {
     return null;
   }
   CardState s = c.getState(state);
   return s == null ? null : s.getView();
 }