public void TestTournamentParticipation() { QuestMatch game = ScenarioCreator.GameNoDeal(2); game.AttachLogger(new Quest.Core.Logger("TestTournamentParticipation")); Player aiPlayer = game.Players[0]; aiPlayer.Behaviour = new Strategy1(); Player otherPlayer = game.Players[1]; TournamentAtCamelot tournament = new TournamentAtCamelot(game); //no player can rank up by winning tournament - don't participate otherPlayer.Rank.AddShields(1); aiPlayer.Rank.AddShields(1); Assert.IsFalse(aiPlayer.Behaviour.ParticipateInTournament(tournament)); //other player has 11 shields, can rank up - participate otherPlayer.Rank.AddShields(10); Assert.IsTrue(aiPlayer.Behaviour.ParticipateInTournament(tournament)); //make ai player a knight - 10 base BP aiPlayer.Rank.AddShields(10); //cards Amour amour = new Amour(game); Dagger dagger = new Dagger(game); Dagger dagger2 = new Dagger(game); SirGalahad sirGalahad = new SirGalahad(game); Sword sword = new Sword(game); Sword sword2 = new Sword(game); //other player can win - play strongest possible hand aiPlayer.Hand.Add(amour); //10 aiPlayer.Hand.Add(dagger); //5 aiPlayer.Hand.Add(dagger2); //5 aiPlayer.Hand.Add(sirGalahad); //15 aiPlayer.Hand.Add(sword); //10 aiPlayer.Hand.Add(sword2); //10 //expected: amour, dagger, SirGalahad, sword List <BattleCard> played1 = aiPlayer.Behaviour.PlayCardsInTournament(tournament, aiPlayer); Assert.AreEqual(4, played1.Count); aiPlayer.Play(played1); //40 BP from cards, 10 base BP from rank Assert.AreEqual(50, aiPlayer.BattlePointsInPlay()); }
public void TestTournamentParticipation2() { QuestMatch game = ScenarioCreator.GameNoDeal(2); game.AttachLogger(new Quest.Core.Logger("TestTournamentParticipation2")); Player aiPlayer = game.Players[0]; aiPlayer.Behaviour = new Strategy1(); Player otherPlayer = game.Players[1]; TournamentAtCamelot tournament = new TournamentAtCamelot(game); //ai player has 11 shields, can rank up - participate aiPlayer.Rank.AddShields(11); Assert.IsTrue(aiPlayer.Behaviour.ParticipateInTournament(tournament)); //make other player a squire - 5 base BP, can't rank up otherPlayer.Rank.AddShields(1); //cards Amour amour = new Amour(game); Dagger dagger = new Dagger(game); Dagger dagger2 = new Dagger(game); SirGalahad sirGalahad = new SirGalahad(game); Sword sword = new Sword(game); Sword sword2 = new Sword(game); //other player can win - play strongest possible hand aiPlayer.Hand.Add(amour); //10 aiPlayer.Hand.Add(dagger); //5 aiPlayer.Hand.Add(dagger2); //5 aiPlayer.Hand.Add(sirGalahad); //15 aiPlayer.Hand.Add(sword); //10 aiPlayer.Hand.Add(sword2); //10 //expected: dagger, sword List <BattleCard> played2 = aiPlayer.Behaviour.PlayCardsInTournament(tournament, aiPlayer); Assert.IsTrue((played2.Contains(dagger2)) || (played2.Contains(dagger))); Assert.IsTrue((played2.Contains(sword2)) || (played2.Contains(sword))); Assert.AreEqual(2, played2.Count); aiPlayer.Play(played2); //5 from a dagger, 10 from a sword, 10 from base BP Assert.AreEqual(25, aiPlayer.BattlePointsInPlay()); }
public void TestPlayCardsInQuest() { QuestMatch game = ScenarioCreator.GameNoDeal(2); game.AttachLogger(new Quest.Core.Logger("TestPlayCardsInTest")); Player aiPlayer = game.Players[0]; Player sponsorPlayer = game.Players[1]; aiPlayer.Behaviour = new Strategy2(); // Setup quest RescueTheFairMaiden quest = new RescueTheFairMaiden(game); // 3 stages. game.CurrentStory = quest; quest.Sponsor = sponsorPlayer; //quest.AddParticipant(aiPlayer); FIXME Thieves questThieves = new Thieves(game); Saxons questSaxons = new Saxons(game); RobberKnight questRobberKnight = new RobberKnight(game); sponsorPlayer.Hand.Add(new List <Card>() { questThieves, questSaxons, questRobberKnight }); quest.AddFoeStage(questThieves); quest.AddFoeStage(questSaxons); quest.AddFoeStage(questRobberKnight); // Make player knight, 10 BP. aiPlayer.Rank.AddShields(5); // Test cards. Amour amour1 = new Amour(game); // 10 BP. Amour amour2 = new Amour(game); // Hopefully only one is played. SirGawain gawain = new SirGawain(game); // 10 BP. SirTristan tristan = new SirTristan(game); // 10 BP. SirGalahad galahad = new SirGalahad(game); // 15 BP. BattleAx axe = new BattleAx(game); // +5 BP aiPlayer.Hand.Add(amour1); aiPlayer.Hand.Add(amour2); aiPlayer.Hand.Add(gawain); aiPlayer.Hand.Add(tristan); aiPlayer.Hand.Add(galahad); aiPlayer.Hand.Add(axe); // Test first stage. Amour should be played first. List <BattleCard> played = aiPlayer.Behaviour.PlayCardsInQuest(quest, aiPlayer.Hand); Assert.AreEqual(1, played.Count); Assert.IsTrue((played.Contains(amour1) || played.Contains(amour2))); aiPlayer.Play(played); //quest.ResolveStage(); // FIXME // Does allies get played second? played = aiPlayer.Behaviour.PlayCardsInQuest(quest, aiPlayer.Hand); Assert.AreEqual(2, played.Count); Assert.IsTrue(played.Contains(gawain)); Assert.IsTrue(played.Contains(tristan)); aiPlayer.Play(played); //quest.ResolveStage(); FIXME // Does weapon (and galahad) get played last? played = aiPlayer.Behaviour.PlayCardsInQuest(quest, aiPlayer.Hand); Assert.AreEqual(2, played.Count); Assert.IsTrue(played.Contains(galahad)); Assert.IsTrue(played.Contains(axe)); }
public void TestPlayCardsInQuest() { //not testing bids for now QuestMatch game = ScenarioCreator.GameNoDeal(2); game.AttachLogger(new Quest.Core.Logger("TestPlayCardsInTest")); Player aiPlayer = game.Players[0]; Player sponsorPlayer = game.Players[1]; aiPlayer.Behaviour = new Strategy1(); // Setup quest RescueTheFairMaiden quest = new RescueTheFairMaiden(game); // 3 stages. game.CurrentStory = quest; quest.Sponsor = sponsorPlayer; //quest.AddParticipant(aiPlayer); // FIXME Thieves questThieves = new Thieves(game); Saxons questSaxons = new Saxons(game); RobberKnight questRobberKnight = new RobberKnight(game); sponsorPlayer.Hand.Add(new List <Card>() { questThieves, questSaxons, questRobberKnight }); quest.AddFoeStage(questThieves); //5 quest.AddFoeStage(questSaxons); //10 quest.AddFoeStage(questRobberKnight); //15 // Make player knight, 10 BP. aiPlayer.Rank.AddShields(5); //cards, no foes Lance lance = new Lance(game); //20 Lance lance2 = new Lance(game); //20 BattleAx battleAx = new BattleAx(game); //15 SirGalahad sirGalahad = new SirGalahad(game); //15 Amour amour = new Amour(game); //10 Sword sword = new Sword(game); //10 KingPellinore kingPellinore = new KingPellinore(game); //10 aiPlayer.Hand.Add(lance); aiPlayer.Hand.Add(lance2); aiPlayer.Hand.Add(battleAx); aiPlayer.Hand.Add(sirGalahad); //play stage 2 aiPlayer.Hand.Add(amour); //play stage 1 aiPlayer.Hand.Add(sword); aiPlayer.Hand.Add(kingPellinore); //first stage: amour List <BattleCard> played = aiPlayer.Behaviour.PlayCardsInQuest(quest, aiPlayer.Hand); Assert.AreEqual(1, played.Count); Assert.IsTrue(played.Contains(amour)); aiPlayer.Play(played); //quest.ResolveStage(); FIXME //2nd stage: galahad played = aiPlayer.Behaviour.PlayCardsInQuest(quest, aiPlayer.Hand); Assert.AreEqual(1, played.Count); Assert.IsTrue(played.Contains(sirGalahad)); aiPlayer.Play(played); //quest.ResolveStage(); FIXME //3rd stage: a lance, battleAx, sword, kingPellinore //is the quest not advancing stage?not sure played = aiPlayer.Behaviour.PlayCardsInQuest(quest, aiPlayer.Hand); Assert.AreEqual(4, played.Count); Assert.IsTrue((played.Contains(lance) || played.Contains(lance2))); Assert.IsTrue(played.Contains(battleAx)); Assert.IsTrue(played.Contains(sword)); Assert.IsTrue(played.Contains(kingPellinore)); }
public void init() { excalibur = new Weapon("excalibur", 30, getCardImage("excalibur")); lance = new Weapon("lance", 20, getCardImage("lance")); battleax = new Weapon("battleax", 15, getCardImage("battleax")); sword = new Weapon("sword", 10, getCardImage("sword")); horse = new Weapon("horse", 10, getCardImage("horse")); dagger = new Weapon("dagger", 5, getCardImage("dagger")); //Foes dragon = new Foe("dragon", 50, 70, getCardImage("dragon")); giant = new Foe("giant", 40, 0, getCardImage("giant")); mordred = new Foe("mordred", 30, 0, getCardImage("mordred")); greenknight = new Foe("greenknight", 25, 40, getCardImage("greenknight")); blackknight = new Foe("blackknight", 25, 35, getCardImage("blackknight")); evilknight = new Foe("evilknight", 20, 30, getCardImage("evilknight")); saxonknight = new Foe("saxonknight", 15, 25, getCardImage("saxonknight")); robberknight = new Foe("robberknight", 15, 0, getCardImage("robberknight")); saxons = new Foe("saxons", 10, 20, getCardImage("saxons")); boar = new Foe("boar", 5, 15, getCardImage("boar")); thieves = new Foe("thieves", 5, 0, getCardImage("thieves")); //Tests tovalor = new Test("tovalor", 0, 0, getCardImage("tovalor")); toquestingbeast = new Test("toquestingbeast", 0, 4, getCardImage("toquestingbeast")); totemptation = new Test("totemptation", 0, 0, getCardImage("totemptation")); tomorganlefey = new Test("tomorganlefey", 0, 3, getCardImage("tomorganlefey")); //Allies galahad = new Ally("galahad", 15, 0, 0, getCardImage("galahad")); arthur = new Ally("arthur", 10, 0, 2, getCardImage("arthur")); pellinore = new Ally("pellinore", 10, 0, 4, getCardImage("pellinore")); guinevere = new Ally("guinevere", 0, 0, 3, getCardImage("guinevere")); iseult = new Ally("iseult", 0, 0, 2, getCardImage("iseult")); gawain = new Ally("gawain", 10, 20, 0, getCardImage("gawain")); lancelot = new Ally("lancelot", 15, 0, 0, getCardImage("lancelot")); percival = new Ally("percival", 5, 20, 0, getCardImage("percival")); tristan = new Ally("tristan", 10, 0, 0, getCardImage("tristan")); //Amour amour amour amour amour amour = new Amour("amour", 10, 2, getCardImage("amour")); //Quests holygrail = new QuestCard("holygrail", "quest", 5, new Foe[] { dragon, giant, mordred, greenknight, blackknight, evilknight, saxonknight, robberknight, saxons, boar, thieves }, getCardImage("holygrail")); enchantedforest = new QuestCard("enchantedforest", "quest", 3, new Foe[] { evilknight }, getCardImage("enchantedforest")); arthursenemies = new QuestCard("arthursenemies", "quest", 3, new Foe[0], getCardImage("arthursenemies")); saxonraiders = new QuestCard("saxonraiders", "quest", 2, new Foe[] { saxons, saxonknight }, getCardImage("saxonraiders")); boarhunt = new QuestCard("boarhunt", "quest", 2, new Foe[] { boar }, getCardImage("boarhunt")); questingbeast = new QuestCard("questingbeast", "quest", 4, new Foe[0], getCardImage("questingbeast")); queenshonor = new QuestCard("queenshonor", "quest", 4, new Foe[] { dragon, giant, mordred, greenknight, blackknight, evilknight, saxonknight, robberknight, saxons, boar, thieves }, getCardImage("queenshonor")); slaydragon = new QuestCard("slaydragon", "quest", 3, new Foe[] { dragon }, getCardImage("slaydragon")); rescuemaiden = new QuestCard("rescuemaiden", "quest", 3, new Foe[] { blackknight }, getCardImage("rescuemaiden")); greenknighttest = new QuestCard("greenknighttest", "quest", 4, new Foe[] { greenknight }, getCardImage("greenknighttest")); //Tourneys camelot = new TourneyCard("camelot", "tourney", 3, getCardImage("camelot")); orkney = new TourneyCard("orkney", "tourney", 2, getCardImage("orkney")); tintagel = new TourneyCard("tintagel", "tourney", 1, getCardImage("tintagel")); york = new TourneyCard("york", "tourney", 0, getCardImage("york")); //Events chivdeed = new EventCard("chivdeed", "event", getCardImage("chivdeed")); prosperity = new EventCard("prosperity", "event", getCardImage("prosperity")); courtcalled = new EventCard("courtcalled", "event", getCardImage("courtcalled")); kingscall = new EventCard("kingscall", "event", getCardImage("kingscall")); recognition = new EventCard("recognition", "event", getCardImage("recognition")); plague = new EventCard("plague", "event", getCardImage("plague")); pox = new EventCard("pox", "event", getCardImage("pox")); queensfavor = new EventCard("queensfavor", "event", getCardImage("queensfavor")); }
// assuming battleCards is sorted, starting from weakest private List <BattleCard>[] bestCardsToPlayInQuest(QuestCard questCard, Hand hand) { List <BattleCard>[] stages = new List <BattleCard> [questCard.StageCount]; List <Amour> amours = new List <Amour>(hand.GetDistinctCards <Amour>()); List <AllyCard> allies = new List <AllyCard>(hand.GetCards <AllyCard>()); List <WeaponCard> weapons = new List <WeaponCard>(hand.GetCards <WeaponCard>()); allies.Sort((x, y) => x.BattlePoints.CompareTo(y.BattlePoints)); weapons.Sort((x, y) => x.BattlePoints.CompareTo(y.BattlePoints)); for (int i = 0; i < questCard.StageCount; i++) { stages[i] = new List <BattleCard>(); } BattleArea lastCards = new BattleArea(); BattleArea currCards; for (int i = 0; i < questCard.StageCount; i++) { currCards = new BattleArea(); BattleArea weaponArea = new BattleArea(); weapons.ForEach(x => weaponArea.Add(x)); List <WeaponCard> playableWeapons = weaponArea.GetDistinctCards <WeaponCard>(); while (currCards.BattlePoints() < lastCards.BattlePoints() + 10 && amours.Count + allies.Count + playableWeapons.Count > 0) { if (i == 0 && amours.Count > 0) { Amour nextAmour = amours[0]; stages[i].Add(nextAmour); currCards.Add(nextAmour); amours.Remove(nextAmour); continue; } // Add ally. else if (allies.Count > 0) { AllyCard nextAlly = allies[0]; stages[i].Add(nextAlly); currCards.Add(nextAlly); allies.Remove(nextAlly); continue; } // Add wepon else if (playableWeapons.Count > 0) { WeaponCard nextWeapon = playableWeapons[0]; stages[i].Add(nextWeapon); currCards.Add(nextWeapon); playableWeapons.Remove(nextWeapon); weapons.Remove(nextWeapon); continue; } } lastCards = currCards; } return(stages); }