Beispiel #1
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);
    }
  }
Beispiel #2
0
 @Override
 protected void onCast(
     GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
   List<Entity> entities =
       context.resolveTarget(player, source, EntityReference.OTHER_FRIENDLY_MINIONS);
   SpellDesc destroySpell = DestroySpell.create(target.getReference());
   SpellUtils.castChildSpell(context, player, destroySpell, source, target);
   String cardId = desc.getString(SpellArg.CARD);
   for (Entity entity : entities) {
     Minion minion = (Minion) entity;
     if (minion.getSourceCard().getCardId().equalsIgnoreCase(cardId)) {
       destroySpell = DestroySpell.create(minion.getReference());
       SpellUtils.castChildSpell(context, player, destroySpell, source, target);
       SpellUtils.castChildSpell(context, player, ForceDeathPhaseSpell.create(), source, target);
       return;
     }
   }
 }