Skip to content

Implement Cards

darkfriend77 edited this page Jan 19, 2017 · 18 revisions

Choose the approprate set of cards, where the card you want to implement is listed. All current sets are pregenerated under CardSets. Let's start with an example, "Greater Arcane Missiles".

Pregenerated Code

// ------------------------------------------- SPELL - MAGE
// [CFM_623] Greater Arcane Missiles - COST:7 
// - Set: gangs, Rarity: epic
// --------------------------------------------------------
// Text: Shoot three missiles at random enemies that deal $3 damage each. *spelldmg
// --------------------------------------------------------
cards.Add("CFM_623", new List<Enchantment> {
	// TODO [CFM_623] Greater Arcane Missiles && Test: Greater Arcane Missiles_CFM_623
	new Enchantment
	{
		Activation = EnchantmentActivation.SPELL,
		SingleTask = null,
	},
});

Implementing new Task

For this spell we will only add a single task, which will enqueue 3 random missiles.

SingleTask = 
   new EnqueueTask(
     // times we enqueue the task
     3, 
     // 3dmg, targetslist, how many of them
     ComplexTask.DamageRandomTargets(3, EntityType.ENEMIES, 1), 
     // if spell damage will increase enqueueing .... like arcane missiles
     true) 

Implementing new Test

And for the last part we create a test for it, which also is pregenerated in this location CardSets.

[TestMethod]
public void GreaterArcaneMissiles_CFM_623()
{
	var game = new Game(new GameConfig
	{
		StartPlayer = 1,
		Player1HeroClass = CardClass.MAGE,
		Player2HeroClass = CardClass.MAGE,
		FillDecks = true
	});
	game.StartGame();
	game.Player1.BaseMana = 10;
	game.Player2.BaseMana = 10;
  var minion1 = Generic.DrawCard(game.CurrentPlayer, Cards.FromName("Ironfur Grizzly"));
  game.Process(PlayCardTask.Any(game.CurrentPlayer, (ICharacter)minion1));
  var minion2 = Generic.DrawCard(game.CurrentPlayer, Cards.FromName("Ironfur Grizzly"));
  game.Process(PlayCardTask.Any(game.CurrentPlayer, (ICharacter)minion2));
  game.Process(EndTurnTask.Any(game.CurrentPlayer));
  var totHealth = game.CurrentOpponent.Hero.Health;
  totHealth += ((ICharacter)minion1).Health;
  totHealth += ((ICharacter)minion2).Health;
  Assert.AreEqual(36, totHealth);
  var spell1 = Generic.DrawCard(game.CurrentPlayer, Cards.FromName("Greater Arcane Missiles"));
  game.Process(PlayCardTask.Spell(game.CurrentPlayer, spell1));
  totHealth = game.CurrentOpponent.Hero.Health;
  totHealth += ((ICharacter)minion1).IsDead ? 0 : ((ICharacter)minion1).Health;
  totHealth += ((ICharacter)minion2).IsDead ? 0 : ((ICharacter)minion2).Health;
  Assert.AreEqual(27, totHealth);
  var minion3 = Generic.DrawCard(game.CurrentPlayer, Cards.FromName("Dalaran Mage"));
  game.Process(PlayCardTask.Minion(game.CurrentPlayer, (ICharacter)minion3));
  game.Process(EndTurnTask.Any(game.CurrentPlayer));
  game.Process(EndTurnTask.Any(game.CurrentPlayer));
  var spell2 = Generic.DrawCard(game.CurrentPlayer, Cards.FromName("Greater Arcane Missiles"));
  game.Process(PlayCardTask.Spell(game.CurrentPlayer, spell2));
  totHealth = game.CurrentOpponent.Hero.Health;
  totHealth += ((ICharacter)minion1).IsDead ? 0 : ((ICharacter)minion1).Health;
  totHealth += ((ICharacter)minion2).IsDead ? 0 : ((ICharacter)minion2).Health;
  // Spellpower check
  Assert.AreEqual(1, game.CurrentPlayer.Hero.SpellPower);
  Assert.AreEqual(15, totHealth);
}