public void MSTest_check_dead_monsters_all_dead() { Player P = new Player(); Node n = new Node(); Pack pack = new Pack("pack", 2); P.location = n; pack.location = n; pack.members[0].HP = 1; pack.members[1].HP = 1; Monster M1 = pack.members[0]; Monster M2 = pack.members[1]; P.accelerated = true; P.Attack(pack.members[0]); Assert.IsTrue(pack.CurrentHP() == 0 && !n.packs.Contains(pack)); }
/* Execute a fight between the player and the packs in this node. * Such a fight can take multiple rounds as describe in the Project Document. * A fight terminates when either the node has no more monster-pack, or when * the player's HP is reduced to 0. */ public void fight(Player player, int seed, bool withSeed) //now runs a single enemy turn { if (withSeed) { RandomGenerator.initializeWithSeed(seed); } rnd = RandomGenerator.rnd; /*Possibly to do: * - Attack after failed flee attempt? (currently present)*/ //throw new NotImplementedException(); //still missing node contest check Pack attackPack = packs[rnd.Next(packs.Count - 1)]; double fleeCheck = rnd.NextDouble(); double packHP = attackPack.CurrentHP(); double fleeTreshold = (1 - (packHP / attackPack.startingHP)) / 2; if (fleeCheck <= fleeTreshold) { Logger.log("A pack tries to flee"); foreach (Node n in attackPack.location.neighbors) { attackPack.move(n); if (n.packs.Contains(attackPack)) { Logger.log("A pack flees!"); packs.Remove(attackPack); if (contested(player)) { attackPack = packs[rnd.Next(packs.Count - 1)]; } break; } } } if (contested(player)) { attackPack.Attack(player); } }
public void MStest_currenthp() { Pack p = new Pack("pid", 3); Assert.IsTrue(p.startingHP == p.CurrentHP()); }