Ejemplo n.º 1
0
 @Override
 protected void onCast(
     GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
   if (target == null) {
     return;
   }
   int iterations = desc.getInt(SpellArg.HOW_MANY, 0);
   SpellDesc spell = (SpellDesc) desc.get(SpellArg.SPELL_1);
   Condition condition = (Condition) desc.get(SpellArg.CONDITION);
   for (int i = 0; i < iterations; i++) {
     List<Entity> targets = context.resolveTarget(player, null, desc.getTarget());
     if (targets.isEmpty()) {
       return;
     }
     Entity randomTarget = SpellUtils.getRandomTarget(targets);
     SpellUtils.castChildSpell(context, player, spell, source, randomTarget);
     if (condition.isFulfilled(context, player, randomTarget)) {
       return;
     }
   }
 }
Ejemplo n.º 2
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);
    }
  }
Ejemplo n.º 3
0
 @Override
 protected void onCast(
     GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
   Secret secret = (Secret) desc.get(SpellArg.SECRET);
   context.getLogic().playSecret(player, secret);
 }