Esempio n. 1
0
  private List<GameAction> getPlayCardActions(GameContext context, Player player) {
    List<GameAction> playCardActions = new ArrayList<GameAction>();
    playCardActions.addAll(getHeroPowerActions(context, player));

    for (Card card : player.getHand()) {
      CardReference cardReference =
          new CardReference(player.getId(), CardLocation.HAND, card.getId(), card.getName());
      if (!context.getLogic().canPlayCard(player.getId(), cardReference)) {
        continue;
      }

      if (card.hasAttribute(Attribute.CHOOSE_ONE)) {
        IChooseOneCard chooseOneCard = (IChooseOneCard) card;
        if (context.getLogic().hasAttribute(player, Attribute.BOTH_CHOOSE_ONE_OPTIONS)) {
          GameAction chooseOneAction = chooseOneCard.playBothOptions();
          rollout(chooseOneAction, context, player, playCardActions);
        } else {
          for (GameAction chooseOneAction : chooseOneCard.playOptions()) {
            rollout(chooseOneAction, context, player, playCardActions);
          }
        }
      } else {
        rollout(card.play(), context, player, playCardActions);
      }
    }
    return playCardActions;
  }
Esempio n. 2
0
 @Override
 protected void onCast(
     GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
   int value = desc.getValue();
   for (Card card : player.getHand()) {
     card.modifyAttribute(Attribute.MANA_COST_MODIFIER, value);
   }
 }
 @Override
 protected void onCast(
     GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
   int manaCostModifier = desc.getInt(SpellArg.MANA_MODIFIER, 0);
   Minion minion = (Minion) target;
   Player owner = context.getPlayer(minion.getOwner());
   if (owner.getHand().getCount() >= GameLogic.MAX_HAND_CARDS) {
     logger.debug("{} is destroyed because {}'s hand is full", minion, owner.getName());
     context.getLogic().markAsDestroyed((Actor) target);
   } else {
     logger.debug("{} is returned to {}'s hand", minion, owner.getName());
     context.getLogic().removeMinion(minion);
     Card sourceCard = minion.getSourceCard().getCopy();
     context.getLogic().receiveCard(minion.getOwner(), sourceCard);
     sourceCard.setAttribute(Attribute.MANA_COST_MODIFIER, manaCostModifier);
   }
 }
Esempio n. 4
0
  @Override
  protected void onCast(
      GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
    if (target != null) {
      Card targetCard = null;
      if (target.getEntityType() == EntityType.CARD) {
        targetCard = (Card) target;
      } else if (target.getEntityType() == EntityType.MINION) {
        Minion minion = (Minion) target;
        targetCard = minion.getSourceCard();
      }
      context.getLogic().receiveCard(player.getId(), targetCard.getCopy());
      return;
    }

    CardLocation cardLocation = (CardLocation) desc.get(SpellArg.CARD_LOCATION);
    int numberOfCardsToCopy = desc.getInt(SpellArg.VALUE, 1);

    Player opponent = context.getOpponent(player);
    CardCollection sourceCollection = null;
    switch (cardLocation) {
      case DECK:
        sourceCollection = opponent.getDeck();
        break;
      case HAND:
        sourceCollection = opponent.getHand();
        break;
      default:
        logger.error("Trying to copy cards from invalid cardLocation {}", cardLocation);
        break;
    }

    for (int i = 0; i < numberOfCardsToCopy; i++) {
      if (sourceCollection.isEmpty()) {
        return;
      }
      Card clone = sourceCollection.getRandom().getCopy();
      context.getLogic().receiveCard(player.getId(), clone);
    }
  }
Esempio n. 5
0
 private static boolean isHardRemoval(Card card) {
   return hardRemoval.contains(card.getCardId());
 }