Exemplo n.º 1
0
 public static SpellDesc create(EntityReference target, int manaModifier, boolean randomTarget) {
   Map<SpellArg, Object> arguments = SpellDesc.build(ReturnMinionToHandSpell.class);
   arguments.put(SpellArg.MANA_MODIFIER, manaModifier);
   arguments.put(SpellArg.TARGET, target);
   arguments.put(SpellArg.RANDOM_TARGET, randomTarget);
   return new SpellDesc(arguments);
 }
Exemplo n.º 2
0
  public static SpellDesc create(EntityReference target, int hpAdjustment) {
    Map<SpellArg, Object> arguments = SpellDesc.build(ReviveMinionSpell.class);
    arguments.put(SpellArg.HP_BONUS, hpAdjustment);
    arguments.put(SpellArg.TARGET, target);

    return new SpellDesc(arguments);
  }
Exemplo n.º 3
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);
   }
 }
Exemplo n.º 4
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;
     }
   }
 }
Exemplo n.º 5
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);
    }
  }
Exemplo n.º 6
0
 @Override
 protected void onCast(
     GameContext context, Player player, SpellDesc desc, Entity source, Entity target) {
   int hpAdjustment = desc.getValue(SpellArg.HP_BONUS, context, player, target, source, 0);
   Actor targetActor = (Actor) target;
   int boardPosition = SpellUtils.getBoardPosition(context, player, desc, source);
   MinionCard minionCard = (MinionCard) targetActor.getSourceCard();
   Minion minion = minionCard.summon();
   if (hpAdjustment != 0) {
     minion.setHp(hpAdjustment);
   }
   context.getLogic().summon(player.getId(), minion, null, boardPosition, false);
 }
Exemplo n.º 7
0
 @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);
   }
 }
Exemplo n.º 8
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;
     }
   }
 }
Exemplo n.º 9
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);
 }
Exemplo n.º 10
0
 public static SpellDesc create(Secret secret) {
   Map<SpellArg, Object> arguments = SpellDesc.build(AddSecretSpell.class);
   arguments.put(SpellArg.SECRET, secret);
   arguments.put(SpellArg.TARGET, EntityReference.FRIENDLY_HERO);
   return new SpellDesc(arguments);
 }
Exemplo n.º 11
0
 public static SpellDesc create() {
   Map<SpellArg, Object> arguments = SpellDesc.build(MergeSpell.class);
   return new SpellDesc(arguments);
 }