public int AIStagePower(List <Card> currStage) { Card currCard = null; int power = 0; for (int i = 0; i < currStage.Count; i++) { currCard = currStage[i]; if (currCard.GetType() == typeof(WeaponCard)) { WeaponCard currWeapon = (WeaponCard)currCard; power += currWeapon.power; } else if (currCard.GetType() == typeof(FoeCard)) { FoeCard currFoe = (FoeCard)currCard; if (_questCard.featuredFoe == currFoe.type) { power += currFoe.hiPower; } else if (_questCard.featuredFoe == "*") { power += currFoe.hiPower; } else { power += currFoe.loPower; } } } return(power); }
public List <Card> playBid(List <Card> hand, int round) { strategyUtil strat = new strategyUtil(); // this CPU bids with any test cards, foe cards of less than 30bp and duplicate weapons (1 of each) List <Card> bid = playBid(hand, round); if (round > 1) { return(bid); } for (int i = 0; i < hand.Count; i++) { if (hand[i].type == "Test Card") { bid.Add(hand[i]); } if (hand[i].type == "Foe Card") { FoeCard foe = (FoeCard)hand[i]; if (foe.minBP < 30) { bid.Add(hand[i]); } } if (hand[i].type == "Weapon Card" && strat.hasMultiple(hand, hand[i].name) && strat.checkDuplicate(hand[i], bid, hand[i].type)) { bid.Add(hand[i]); } } return(bid); }
public int SetNthStage(int total, int stageindex, QuestController Qc, bool EquipmentAllowed) { int nthTotal = 0; int ID = this.playerID; List <int> Indexes = new List <int>(); int index = StrongestFoe(Qc); FoeCard FC = (FoeCard)Qc.hands[playerID].cards[index]; nthTotal += FC.BattlePoints; PlayCard(index, Qc, true, stageindex); Indexes.Add(index); if (EquipmentAllowed == true) { for (int i = 0; i < Qc.hands[ID].cards.Count; i++) { if (Qc.hands[ID].cards[i].Type == "Equipment") { EquipmentCard EC = (EquipmentCard)Qc.hands[ID].cards[i]; if (EC.BattlePoints + nthTotal < total) { index = i; nthTotal += EC.BattlePoints; PlayCard(i, Qc, true, stageindex); Indexes.Add(index); break; } } } } RemoveCards(Indexes, Qc); return(nthTotal); }
// if the foe passed in is the quest foe, or the quest foe is all, or it is a saxon quest and the foe is a saxon return max public int getContextBP(FoeCard foe, string questFoe) { if (questFoe == foe.name || questFoe == "All" || saxonBonus(foe, questFoe)) { return(foe.maxBP); } return(foe.minBP); }
// sets up the final stage of a quest for this CPU player, in this strategy: // we need to get 40BP in as few cards as possible public List <Card> setUpFinalFoe(List <Card> hand, string questFoe) { strategyUtil strat = new strategyUtil(); // instantiate a List of foes and weapons from the user's hand List <Card> foes = new List <Card>(); List <Card> weapons = new List <Card>(); // seperate the foes and weapons into their own lists from the hand for (var i = 0; i < hand.Count; i++) { if (hand[i].type == "Foe Card") { foes.Add(hand[i]); } // make sure that we sort out weapons that are already in the weapons if (hand[i].type == "Weapon Card" && strat.checkDuplicate(hand[i], weapons, "Weapon Card")) { weapons.Add(hand[i]); } } foes = strat.sortFoesByDescendingOrder(foes, questFoe); weapons = strat.sortWeaponsByDescendingOrder(weapons); // instantiate the foeEncounter list List <Card> foeEncounter = new List <Card>(); // subtract the foe with the MOST BP in the user's hand from 40, the AI threshold FoeCard strongFoe = (FoeCard)foes[0]; int bpNeeded = (40 - strongFoe.minBP); // Add this foe to the foeEncounter as the foe to be played foeEncounter.Add(foes[0]); hand.Remove(foes[0]); // initialize index as 0 to loop through the weapons int index = 0; // while we still need BP toreach our 40 threshold while (bpNeeded > 0 && index < weapons.Count) { // if we still have weapons to loop through // subtract the BP of the next most powerful weapon from the threshold WeaponCard nextWeapon = (WeaponCard)weapons[index]; bpNeeded -= nextWeapon.battlePoints; // add this weapon to the encounter foeEncounter.Add(weapons[index]); hand.Remove(weapons[index]); // increment index index++; } // return the most powerful foe we have with the set of weapons that most quickly gets us to 40 BP. return(foeEncounter); }
public void Test_FoeCard() { FoeCard foeCard = new FoeCard("FoeCard", "Foe", 0, 10, false, "/GG.png"); Assert.AreEqual(foeCard.name, "FoeCard"); Assert.AreEqual(foeCard.type, "Foe"); Assert.AreEqual(foeCard.loPower, 0); Assert.AreEqual(foeCard.hiPower, 10); Assert.AreEqual(foeCard.special, false); Assert.AreEqual(foeCard.asset, "/GG.png"); }
// returns True if the quest is a Saxon quest and the foe is a saxon public bool saxonBonus(FoeCard foe, string questFoe) { if (questFoe == "All Saxons") { if (foe.name == "Saxons" || foe.name == "Saxon Knight") { return(true); } } return(false); }
public void FoeCard_CreatedWithGiven_WillHaveTheVariables() { var foe = new FoeCard("Foe Card", "Robber Knight", " ", 15, 20); foe.display(); Assert.AreEqual("Foe Card", foe.type); Assert.AreEqual("Robber Knight", foe.name); Assert.AreEqual(" ", foe.texturePath); Assert.AreEqual(15, foe.minBP); Assert.AreEqual(20, foe.maxBP); // Use the Assert class to test conditions. }
protected List <FoeCard> extractFoes(List <Card> hand) { List <FoeCard> foeCards = new List <FoeCard>(); for (int i = 0; i < hand.Count; i++) { if (hand [i] is FoeCard) { FoeCard currFoe = (FoeCard)hand [i]; foeCards.Add(currFoe); } } return(foeCards); }
// checks that the player has at LEAST 2 foes with less than 25 BP that they can discard if need be public bool canIDiscard(List <Card> hand) { int count = 0; for (int i = 0; i < hand.Count; i++) { if (hand[i].type == "Foe Card") { // && hand[i].battlePoints < 25){ FoeCard foe = (FoeCard)hand[i]; if (foe.minBP < 25) { count += 1; } } } return(count >= 2); }
// Discard 2 lowest BP foes for the King's Call Event public List <Card> discardFoesForKing(List <Card> hand) { List <Card> foes = new List <Card>(); List <Card> discard = new List <Card>(); // Get Foes from hand for (int i = 0; i < hand.Count; i++) { if (hand[i].type == "Foe Card") { foes.Add(hand[i]); } } // if there is only one foe return that if (foes.Count == 1) { discard.Add(foes[0]); return(discard); } // else return the 2 lowest by bubble sorting else { // bubble sort into ascending order by min bp for (int x = 0; x < foes.Count; x++) { for (int i = 0; i < (foes.Count - 1); i++) { FoeCard foe1 = (FoeCard)foes[i]; FoeCard foe2 = (FoeCard)foes[i + 1]; if (foe1.minBP > foe2.minBP) { var temp = foes[i + 1]; foes[i + 1] = foes[i]; foes[i] = temp; } } } discard.Add(foes[0]); discard.Add(foes[1]); return(discard); } }
// Sorts the weapon in ASCENDING order public List <Card> sortFoesByAscendingOrder(List <Card> foes, string questFoe) { for (int x = 0; x < foes.Count; x++) { for (int i = 0; i < (foes.Count - 1); i++) { FoeCard foe1 = (FoeCard)foes[i]; FoeCard foe2 = (FoeCard)foes[i + 1]; int foe1Bp = getContextBP(foe1, questFoe); int foe2Bp = getContextBP(foe2, questFoe); if (foe1Bp > foe2Bp) { var temp = foes[i + 1]; foes[i + 1] = foes[i]; foes[i] = temp; } } } return(foes); }
public List <Card> playBid(List <Card> hand, int round) { List <Card> bid = new List <Card>(); if (round > 1) { return(bid); } for (int i = 0; i < hand.Count; i++) { if (hand[i].type == "Foe Card") { // && hand[i].battlePoints < 20){ FoeCard foe = (FoeCard)hand[i]; if (foe.minBP < 20) { bid.Add(hand[i]); } } } return(bid); }
public void kingsCall_PlayerHasMultipleFoes() { var player = new Player("Ahmed", new List <Card>(), new iStrategyCPU1()); player.hand.Add(new FoeCard("Foe Card", "Robber Knight1", "Textures/foe/robberKnight", 15, 15)); player.hand.Add(new FoeCard("Foe Card", "Robber Knight2", "Textures/foe/robberKnight", 20, 20)); player.hand.Add(new FoeCard("Foe Card", "Robber Knight3", "Textures/foe/robberKnight", 25, 25)); List <Card> discard = player.kingsCall(); Assert.AreEqual(2, discard.Count); Assert.AreEqual(1, player.hand.Count); FoeCard someFoe = (FoeCard)player.hand[0]; Assert.AreEqual(25, someFoe.minBP); FoeCard foe1 = (FoeCard)discard[0]; FoeCard foe2 = (FoeCard)discard[1]; Assert.AreEqual(15, foe1.minBP); Assert.AreEqual(20, foe2.minBP); }
//NEEDS CHANGESSSSSSSSSSSS!!!!!!!!!!!!!! public void CalculateTotalBP() { int total = 0; strategyUtil util = new strategyUtil(); for (int i = 0; i < selectedCards.Count; i++) { if (selectedCards[i].type == "Foe Card") { FoeCard foe = (FoeCard)selectedCards[i]; if (QuestState.currentQuest != null) { total += util.getContextBP(foe, QuestState.currentQuest.foe); } else { total += foe.minBP; } } else if (selectedCards[i].type == "Weapon Card") { WeaponCard weapon = (WeaponCard)selectedCards[i]; total += weapon.battlePoints; } else if (selectedCards[i].type == "Ally Card") { AllyCard ally = (AllyCard)selectedCards[i]; total += ally.battlePoints; } else if (selectedCards[i].type == "Amour Card") { AmourCard amour = (AmourCard)selectedCards[i]; total += amour.battlePoints; } } totalBP.text = "BP: " + total.ToString(); }
//Does AI Particatpe in the quest public bool doIParticipateInQuest(QuestCard quest) { bool participate = false; int power = 0; //Total Powers of Weapon int numFoe = 0; //Valid Foes For Discard for (int i = 0; i < _hand.Count; i++) { if (_hand[i].GetType() == typeof(WeaponCard)) { WeaponCard currWeapon = (WeaponCard)_hand[i]; power = currWeapon.power + power; } if (_hand[i].GetType() == typeof(FoeCard)) { FoeCard currFoe = (FoeCard)_hand[i]; if (currFoe.loPower < 25) { numFoe++; } } } if (power / quest.stages > 10 && numFoe >= 2) { participate = true; } if (participate) { //currBehaviour = ParticipateInQuest(_hand); } else { //currBehaviour = Backout(); } return(participate); }
// generates the list that is the actual bid to be played by the user, given the round they are bidding in public List <Card> playBid(List <Card> hand, int round) { strategyUtil strat = new strategyUtil(); // instantiate a list that represents the bid we're willing to play List <Card> bid = new List <Card>(); // In Round 1 this AI will bid foes with less than 25 BP, no duplicates if (round == 1) { for (int i = 0; i < hand.Count; i++) { if ((hand[i].type == "Foe Card" && strat.checkDuplicate(hand[i], bid, "Foe Card"))) { // hand[i].minBP < 25) FoeCard foe = (FoeCard)hand[i]; if (foe.minBP < 25) { bid.Add(hand[i]); } } } } // in Round 2, this AI will bid the same way as round 1, except it will allow duplicates if (round == 2) { for (int i = 0; i < hand.Count; i++) { if (hand[i].type == "Foe Card") { // && hand[i].minBP < 25){ FoeCard foe = (FoeCard)hand[i]; if (foe.minBP < 25) { bid.Add(hand[i]); } } } } // return our bid as a list of cards return(bid); }
public void Test_Player() { Player player1 = new Player(1); Player player2 = new Player(2); Deck deck = new Deck("Adventure"); //Test Uniqueness of player Assert.AreEqual(player1.playerId, 1); Assert.AreEqual(player2.playerId, 2); Assert.AreNotEqual(player1.playerId, player2.playerId); for (int i = 0; i < 12; i++) { player1.addCard(deck.Draw()); player2.addCard(deck.Draw()); } //Check hands add Assert.AreEqual(player1.hand.Count, 12); Assert.AreEqual(player2.hand.Count, 12); //Test Rankup procedure player1.AddShields(10); Assert.AreEqual(player1.shieldCounter, 10); //Receiving Card Test player1.addPlayCard(deck.Draw()); Assert.AreEqual(player1.inPlay.Count, 1); Player player3 = new Player(3); FoeCard foeCard = new FoeCard("FoeCard", "Foe", 0, 10, false, "/GG.png"); player3.addCard(foeCard); Assert.AreEqual(player3.hand[0].name, "FoeCard"); }
public bool nextBid() { bool participate = false; int handValue = 0; for (int i = 0; i < _hand.Count; i++) { if (_hand[i].GetType() == typeof(FoeCard)) { FoeCard currFoe = (FoeCard)_hand[i]; if (currFoe.loPower < 25) { handValue = handValue + currFoe.loPower; } } } if (handValue > 25) { participate = true; } return(participate); }
public QuestArea(FoeCard foe) { this.mainCard = foe; }
// Load the cards up. public void loadCards(List <Card> cards, GameObject area) { Card currCard; // Create Card GameObject's. for (int i = 0; i < cards.Count; i++) { currCard = cards[i]; area.GetComponent <CardArea>().addCard(currCard); GameObject CardUI = null; // TODO: Clean this up. if (currCard.GetType() == typeof(WeaponCard)) { WeaponCard currWeapon = (WeaponCard)currCard; CardUI = Instantiate(WeaponCard, new Vector3(), Quaternion.identity); //CardUI = Instantiate(WeaponCard ,area.transform); CardUI.GetComponent <WeaponCard>().name = currWeapon.name; CardUI.GetComponent <WeaponCard>().asset = currWeapon.asset; CardUI.GetComponent <WeaponCard>().power = currWeapon.power; } else if (currCard.GetType() == typeof(FoeCard)) { FoeCard currFoe = (FoeCard)currCard; CardUI = Instantiate(FoeCard, new Vector3(), Quaternion.identity); //CardUI = Instantiate(FoeCard,area.transform); CardUI.GetComponent <FoeCard>().name = currFoe.name; CardUI.GetComponent <FoeCard>().type = currFoe.type; CardUI.GetComponent <FoeCard>().loPower = currFoe.loPower; CardUI.GetComponent <FoeCard>().hiPower = currFoe.hiPower; CardUI.GetComponent <FoeCard>().special = currFoe.special; CardUI.GetComponent <FoeCard>().asset = currFoe.asset; } else if (currCard.GetType() == typeof(AllyCard)) { AllyCard currAlly = (AllyCard)currCard; CardUI = Instantiate(AllyCard, new Vector3(), Quaternion.identity); //CardUI = Instantiate(AllyCard,area.transform); CardUI.GetComponent <AllyCard>().name = currAlly.name; CardUI.GetComponent <AllyCard>().asset = currAlly.asset; CardUI.GetComponent <AllyCard>().special = currAlly.special; CardUI.GetComponent <AllyCard>().power = currAlly.power; CardUI.GetComponent <AllyCard>().bid = currAlly.bid; CardUI.GetComponent <AllyCard>().bonusPower = currAlly.bonusPower; CardUI.GetComponent <AllyCard>().bonusBid = currAlly.bonusBid; CardUI.GetComponent <AllyCard>().questCondition = currAlly.questCondition; CardUI.GetComponent <AllyCard>().allyCondition = currAlly.allyCondition; } else if (currCard.GetType() == typeof(AmourCard)) { AmourCard currAmour = (AmourCard)currCard; CardUI = Instantiate(AmourCard, new Vector3(), Quaternion.identity); CardUI = Instantiate(AmourCard, area.transform); CardUI.GetComponent <AmourCard>().name = currAmour.name; CardUI.GetComponent <AmourCard>().asset = currAmour.asset; CardUI.GetComponent <AmourCard>().power = currAmour.power; CardUI.GetComponent <AmourCard>().bid = currAmour.bid; } else if (currCard.GetType() == typeof(TestCard)) { TestCard currTest = (TestCard)currCard; CardUI = Instantiate(TestCard, new Vector3(), Quaternion.identity); //CardUI = Instantiate(TestCard,area.transform); CardUI.GetComponent <TestCard>().name = currTest.name; CardUI.GetComponent <TestCard>().asset = currTest.asset; CardUI.GetComponent <TestCard>().minBids = currTest.minBids; } // Load the card sprite. Sprite card = Resources.Load <Sprite>(currCard.asset); CardUI.gameObject.GetComponent <Image>().sprite = card; currCard.obj = CardUI; currCard.obj.transform.parent = area.transform; } }
public void Test_AI() { AIPlayer ai = new AIPlayer(0, 1); List <Player> players = new List <Player> (); FoeCard thieves = new FoeCard("Thieves", "Thieves", 5, 5, false, "card_image/foe/foeCard4"); FoeCard thieves2 = new FoeCard("Thieves", "Thieves", 5, 5, false, "card_image/foe/foeCard4"); FoeCard boar = new FoeCard("Boar", "Boar", 5, 15, false, "card_image/foe/foeCard3"); WeaponCard excalibur = new WeaponCard("Excalibur", 30, "card_image/weapons/weaponCard3"); WeaponCard excalibur2 = new WeaponCard("Excalibur", 30, "card_image/weapons/weaponCard3"); AllyCard sirtristan = new AllyCard("Sir Tristan", 10, 0, 20, 0, null, "Queen Iseult", false, "card_image/special/specialCard4"); WeaponCard lance = new WeaponCard("Lance", 20, "card_image/weapons/weaponCard4"); WeaponCard lance2 = new WeaponCard("Lance", 20, "card_image/weapons/weaponCard4"); WeaponCard dagger = new WeaponCard("Dagger", 5, "card_image/weapons/weaponCard2"); players.Add(ai); players.Add(new Player(1)); players.Add(new Player(2)); //SPONSOR QUEST QuestCard quest = new QuestCard("Boar Hunt", 2, "Boar", "card_image/quest/questCard4"); ai.addCard(thieves); Assert.IsNull(ai.sponsorQuest(quest, players)); ai.addCard(thieves2); Assert.IsNull(ai.sponsorQuest(quest, players)); ai.addCard(boar); List <List <Card> > stages = ai.sponsorQuest(quest, players); Assert.IsTrue(stages [0].Contains(thieves)); Assert.IsTrue(stages [1].Contains(boar)); ai.addCard(excalibur); ai.addCard(excalibur2); ai.addCard(lance); stages = ai.sponsorQuest(quest, players); Assert.IsTrue(stages [0].Contains(thieves)); Assert.IsTrue(stages [0].Contains(excalibur2)); Assert.AreEqual(stages [0].Count, 2); Assert.IsTrue(stages [1].Contains(boar)); Assert.IsTrue(stages [1].Contains(excalibur)); Assert.IsTrue(stages [1].Contains(lance)); Assert.AreEqual(stages [1].Count, 3); players [1].AddShields(3); //2 shield to evolve Assert.IsNull(ai.sponsorQuest(quest, players)); //reset player 1 players [1] = new Player(1); //JOIN AND PLAY QUEST ai = new AIPlayer(0, 1); players[0] = ai; Assert.IsFalse(ai.joinQuest(quest, players)); ai.addCard(thieves); ai.addCard(boar); ai.addCard(lance); ai.addCard(lance2); ai.addCard(excalibur); Assert.IsFalse(ai.joinQuest(quest, players)); ai.addCard(excalibur2); //2 foe cards from the quest sponsor Assert.IsTrue(ai.joinQuest(quest, players)); ai = new AIPlayer(0, 1); players [0] = ai; ai.addCard(thieves); ai.addCard(boar); ai.addCard(excalibur); ai.addCard(sirtristan); Assert.IsFalse(ai.joinQuest(quest, players)); ai.addCard(lance); Assert.IsTrue(ai.joinQuest(quest, players)); //will play lance and excalibur and sir tristan ai.addCard(dagger); List <Card> played = ai.playQuest(players, -1, true, false); Assert.IsTrue(played.Contains(sirtristan)); Assert.IsTrue(played.Contains(excalibur)); Assert.IsTrue(played.Contains(lance)); Assert.IsTrue(played.Contains(dagger)); Assert.AreEqual(played.Count, 4); ai = new AIPlayer(0, 1); players [0] = ai; ai.addCard(excalibur); ai.addCard(sirtristan); ai.addCard(lance); ai.addCard(dagger); ai.addCard(excalibur2); ai.addCard(lance2); played = ai.playQuest(players, -1, false, false); Assert.IsTrue(played.Contains(dagger)); Assert.IsTrue(played.Contains(lance)); Assert.IsTrue(played.Contains(sirtristan)); Assert.AreEqual(played.Count, 3); //TOURNAMENT TournamentCard tournament = new TournamentCard("Tournament at Camelot", 3, "card_image/tournament/TournamentCard"); Assert.IsFalse(ai.joinTournament(tournament, players)); players [1].AddShields(3); Assert.IsTrue(ai.joinTournament(tournament, players)); //remove shields players [1] = new Player(1); played = ai.playTournament(tournament, players); Assert.IsTrue(played.Contains(lance)); Assert.IsTrue(played.Contains(excalibur)); Assert.AreEqual(played.Count, 2); players [1].AddShields(3); played = ai.playTournament(tournament, players); Assert.IsTrue(played.Contains(sirtristan)); Assert.IsTrue(played.Contains(excalibur)); Assert.IsTrue(played.Contains(lance)); Assert.IsTrue(played.Contains(dagger)); Assert.AreEqual(played.Count, 4); }
// Check to make sure a stage is valid. public int stageValid(List <Card> currStage, int stageNum, bool doPrompt = true) { Card currCard = null; int power = 0; int foeCount = 0; List <WeaponCard> weapons = new List <WeaponCard>(); for (int i = 0; i < currStage.Count; i++) { currCard = currStage[i]; // If the card is a weapon card. if (currCard.GetType() == typeof(WeaponCard)) { WeaponCard currWeapon = (WeaponCard)currCard; for (int x = 0; x < weapons.Count; x++) { if (currWeapon.name == weapons[x].name) { if (doPrompt) { MultiplayerGame.GameManager.logger.warn("Quest setup is invalid: duplicate weapons."); MultiplayerGame.GameManager.getPromptManager().statusPrompt("Quest Invalid: Duplicate weapons."); } return(-1); } } weapons.Add(currWeapon); power += currWeapon.power; // Otherwise, it's a foe card. } else if (currCard.GetType() == typeof(FoeCard)) { FoeCard currFoe = (FoeCard)currCard; // Handle feature foe. if (_questCard.featuredFoe == currFoe.type) { power += currFoe.hiPower; if (doPrompt) { MultiplayerGame.GameManager.logger.info("Using high power for " + currFoe.name + " because it is featured."); } } else if (_questCard.featuredFoe == "*") { power += currFoe.hiPower; } else { power += currFoe.loPower; if (doPrompt) { MultiplayerGame.GameManager.logger.info("Using low power for " + currFoe.name + " because it is NOT featured."); } } foeCount++; } else if (currCard.GetType() == typeof(TestCard)) { if (currStage.Count > 1) //If there is more than one card on this stage { MultiplayerGame.GameManager.logger.info("To many cards on this test stage"); return(-1); } testStage = stageNum; //THE Test stage; numberOfTestStage++; //Increase global test stage object if there is more than one then break return(1); // Invalid card. } else { return(-1); } } if (foeCount > 1 || foeCount <= 0) { if (doPrompt) { MultiplayerGame.GameManager.logger.warn("Quest setup is invalid: each stage must have exactly 1 foe."); MultiplayerGame.GameManager.getPromptManager().statusPrompt("Quest Invalid: Each stage must exactly have 1 foe."); } return(-1); } return(power); }