Esempio n. 1
0
  @Override
  protected void drawOnContainer(Graphics g) {
    // draw target arrows immediately above stack for active item only
    if (activeItem != null) {
      Vector2 arrowOrigin =
          new Vector2(
              activeItem.getLeft()
                  + VStack.CARD_WIDTH * FCardPanel.TARGET_ORIGIN_FACTOR_X
                  + VStack.PADDING
                  + VStack.BORDER_THICKNESS,
              activeItem.getTop()
                  + VStack.CARD_HEIGHT * FCardPanel.TARGET_ORIGIN_FACTOR_Y
                  + VStack.PADDING
                  + VStack.BORDER_THICKNESS);

      PlayerView activator = activeStackInstance.getActivatingPlayer();
      arrowOrigin = arrowOrigin.add(screenPos.x, screenPos.y);

      StackItemView instance = activeStackInstance;
      while (instance != null) {
        for (CardView c : instance.getTargetCards()) {
          TargetingOverlay.drawArrow(g, arrowOrigin, c, activator.isOpponentOf(c.getController()));
        }
        for (PlayerView p : instance.getTargetPlayers()) {
          TargetingOverlay.drawArrow(g, arrowOrigin, p, activator.isOpponentOf(p));
        }
        instance = instance.getSubInstance();
      }
    }
  }
Esempio n. 2
0
    private StackInstanceDisplay(StackItemView stackInstance0, float width) {
      stackInstance = stackInstance0;
      CardView card = stackInstance.getSourceCard();

      text = stackInstance.getText();
      if (stackInstance.isOptionalTrigger()
          && stackInstance0
              .getActivatingPlayer()
              .equals(MatchController.instance.getCurrentPlayer())) {
        text = "(OPTIONAL) " + text;
      }

      // TODO: A hacky workaround is currently used to make the game not leak the color information
      // for Morph cards.
      final CardStateView curState = card.getCurrentState();
      final boolean isFaceDown = curState.getState() == CardStateName.FaceDown;
      final DetailColors color =
          isFaceDown
              ? CardDetailUtil.DetailColors.FACE_DOWN
              : CardDetailUtil.getBorderColor(
                  card.getCurrentState(),
                  true); // otherwise doesn't work correctly for face down Morphs
      backColor = FSkinColor.fromRGB(color.r, color.g, color.b);
      foreColor = FSkinColor.getHighContrastColor(backColor);

      width -= CARD_WIDTH; // account for card picture
      width -=
          3 * PADDING
              + 2
                  * BORDER_THICKNESS; // account for left and right insets and gap between picture
                                      // and text
      float height = Math.max(CARD_HEIGHT, textRenderer.getWrappedBounds(text, FONT, width).height);
      height += 2 * (PADDING + BORDER_THICKNESS);
      preferredHeight = Math.round(height);
    }
Esempio n. 3
0
 public boolean hasSameCounters(CardView otherCard) {
   Map<CounterType, Integer> counters = getCounters();
   if (counters == null) {
     return otherCard.getCounters() == null;
   }
   return counters.equals(otherCard.getCounters());
 }
Esempio n. 4
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;
  }
Esempio n. 5
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);
    }
  }
Esempio n. 6
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;
 }
Esempio n. 7
0
  // temporarily reveal zones targeted by active stack instance
  private void revealTargetZones() {
    if (activeStackInstance == null) {
      return;
    }

    final Set<ZoneType> zones = new HashSet<ZoneType>();
    playersWithValidTargets = new HashMap<PlayerView, Object>();
    for (final CardView c : activeStackInstance.getTargetCards()) {
      if (c.getZone() != null) {
        zones.add(c.getZone());
        playersWithValidTargets.put(c.getController(), c);
      }
    }
    if (zones.isEmpty() || playersWithValidTargets.isEmpty()) {
      return;
    }
    MatchController.instance.openZones(zones, playersWithValidTargets);
  }
 @Override
 public void valueChanged(final ListSelectionEvent e) {
   final int row = BoxedProductCardListViewer.this.jList.getSelectedIndex();
   // (String) jList.getSelectedValue();
   if ((row >= 0) && (row < BoxedProductCardListViewer.this.list.size())) {
     final PaperCard cp = BoxedProductCardListViewer.this.list.get(row);
     BoxedProductCardListViewer.this.detail.setCard(CardView.getCardForUi(cp));
     BoxedProductCardListViewer.this.picture.setCard(cp);
   }
 }
Esempio n. 9
0
 void updateTargetCards(SpellAbilityStackInstance si) {
   set(
       TrackableProperty.TargetCards,
       CardView.getCollection(si.getTargetChoices().getTargetCards()));
 }
Esempio n. 10
0
 void updateSourceCard(SpellAbilityStackInstance si) {
   set(TrackableProperty.SourceCard, CardView.get(si.getSourceCard()));
 }
Esempio n. 11
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;
 }