
This is how you gain life.
PlayerLife p = AllZone.GameAction.getPlayerLife(Constant.Player.Computer);
p.addLife(2);
Usually I wouldn’t hardcode the player (human or computer) so the code would look like this.
PlayerLife p = AllZone.GameAction.getPlayerLife(card.getController());
p.addLife(2);
Subtracting life is similar.
PlayerLife p = AllZone.GameAction.getPlayerLife(Constant.Player.Computer);
p.subtractLife(4);
Drawing a card looks like this. If you wanted to draw multiple cards, you would use a for loop. AllZone.GameAction.drawCard(Constant.Player.Human);
Whenever a card is put into a graveyard, AllZone.GameAction.destroy(Card) is used.
AllZone.GameAction.destroy(Card);
Cards like Strangling Soot will have a SpellAbility.resolve that looks like this.
AllZone.GameAction.destroy(spell.getTargetCard());
Terror is similar but says that the card cannot be regenerated. AllZone.GameAction.destroyNoRegeneration(Card);
This discards a card at random from a player.
AllZone.GameAction.discardRandom(Constant.Player.Computer);
Regular discard is done this way. This assumes that the chosen card is already picked and this method just moves the card from a player’s hand to the graveyard.
AllZone.GameAction.discard(Card);
Sacrificing a card is similar to discarding, the chosen card is already picked. This would be called from the Input class, since it handles all the user input from the mouse. The Input class lets the user choose a card and then the code below is executed.
AllZone.GameAction.sacrifice(Card);
Shuffling your library is a common occurrence.
AllZone.GameAction.shuffle(card.getController());
Cards like Shock just add damage to a card. GameAction.checkStateEffects moves the card to the graveyard if it is needed.
Card c = spell.getTargetCard();
c.addDamage(2);
No comments:
Post a Comment