private void findSuitableFoe(ref List <FoeCard> foeCards, QuestCard questCard, int stagePower, bool isOne) { bool stageSet = false; while (!stageSet) { while (true) { if (foeCards.Count == 0) { Debug.LogError("Error on sponsorQuest Check"); return; } if (isOne && foeCards [0].power(questCard) < stagePower) { stageSet = true; break; } else if (!isOne && foeCards [0].power(questCard) > stagePower) { stageSet = true; break; } else { foeCards.RemoveAt(0); } } } }
public override bool doIParticipateInQuest(QuestCard quest) { Debug.Log("AskingAI to participate in quest"); bool c1 = false; bool c2 = false; int lowestBP = 0; int count = 0; Card [] tempHand = getOnlyType("weapon"); tempHand = sortHand(tempHand); int totalIncrementsBy10 = -1; int lastBP = -1; //Handle c1 for (int i = 0; i < tempHand.Length; i++) { if (lastBP == -1) { lastBP = tempHand[i].getBP(); totalIncrementsBy10 = 1; } else if (tempHand[i].getBP() >= lastBP + 10) { lastBP = tempHand[i].getBP(); totalIncrementsBy10++; } } Debug.Log("totalIncrementsBy10: " + totalIncrementsBy10); Debug.Log("lastBP: " + lastBP); if (totalIncrementsBy10 >= quest.getStages()) { c1 = true; Debug.Log("condition 1 is true"); } //Handle c2 count = 0; for (int i = 0; i < hand.Length; i++) { if (hand [i].getType().Equals("foe") && hand [i].getBP() <= 25) { count++; } } if (count >= 2) { Debug.Log("condition 2 is true"); c2 = true; } if (c1 && c2) { Debug.Log("Conditions met, participating in quest"); return(true); } else { Debug.Log("Conditions not met."); return(false); } }
public override bool ParticipateInQuest(QuestCard questCard, Hand hand) { List <BattleCard> yourCards = hand.BattleCards; List <BattleCard> discardableFoeCards = new List <BattleCard>(); List <BattleCard> WepsAndAllies = new List <BattleCard>(); foreach (BattleCard card in yourCards) { if (card is FoeCard) { if (card.BattlePoints < 20) { discardableFoeCards.Add(card); } } else if ((card is WeaponCard) || (card is AllyCard)) { WepsAndAllies.Add(card); } if ((WepsAndAllies.Count / questCard.StageCount >= 2) && (discardableFoeCards.Count >= 2)) { return(true); } } return(false); }
private bool canSponsor(Player ai, QuestCard questCard) { int differentPower = 0; List <Card> hand = ai.hand; List <WeaponCard> weaponCards = extractWeapons(hand); List <FoeCard> foeCards = extractFoes(hand); List <TestCard> testCards = extractTests(hand); if (testCards.Count > 0) { differentPower++; } foeCards.Sort((x, y) => x.power(questCard).CompareTo(y.power(questCard))); foeCards.Reverse(); for (int y = 0; y < foeCards.Count; y++) { if (y + 1 < foeCards.Count) { if (foeCards [y].power(questCard) != foeCards [y + 1].power(questCard)) { differentPower += 1; } } else { differentPower += 1; } if (differentPower == questCard.stages) { return(true); } } return(false); }
protected List <BattleCard> playableInQuest(QuestCard questCard, Hand hand) { List <BattleCard> playable = new List <BattleCard>(); List <BattleCard> lastPlay = questCard.GetLastHistory(hand.Player); List <BattleCard> fullHistory = questCard.GetFullHistory(hand.Player); List <Amour> amours = hand.GetDistinctCards <Amour>(); List <AllyCard> allies = hand.GetCards <AllyCard>(); List <WeaponCard> weapons = hand.GetDistinctCards <WeaponCard>(); // Amour can only be played once. foreach (BattleCard card in fullHistory) { if (card is Amour) { amours.Clear(); break; } } weapons.Sort((x, y) => x.BattlePoints.CompareTo(y.BattlePoints)); allies.Sort((x, y) => x.BattlePoints.CompareTo(y.BattlePoints)); playable.AddRange(amours.Cast <BattleCard>()); playable.AddRange(allies.Cast <BattleCard>()); playable.AddRange(weapons.Cast <BattleCard>()); return(playable); }
public void SetupCard(QuestCard card) { UiCardSimple cardScreen = GameObject.Instantiate <UiCardSimple> ( _prefabCardA, _container ); cardScreen.Rotation = UnityEngine.Random.Range(-1f, 1f); cardScreen.GetComponent <RectTransform>().SetAsFirstSibling(); cardScreen.SetupCard(card); cardScreen.OnDrop += () => { if (_cards.Count <= 1) { Ui.ShowScreenTown(); } }; cardScreen.OnRemoved += () => { if (_cards.Count <= 1) { Hide(); } _cards.Remove(cardScreen); }; _cards.Add(cardScreen); }
public override List <BattleCard> PlayCardsInQuest(QuestCard questCard, Hand hand) { List <BattleCard> playing = new List <BattleCard>(); List <BattleCard> lastPlay = questCard.GetLastHistory(hand.Player); List <BattleCard> playable = playableInQuest(questCard, hand); if (questCard.CurrentStage == questCard.StageCount) { // Play best valid combination. playing = playable; } else { // Increment by 10. int lastBattlePoints = 0; lastPlay.ForEach(c => lastBattlePoints += c.BattlePoints); int currentBattlePoints = 0; foreach (BattleCard card in playable) { currentBattlePoints += card.BattlePoints; playing.Add(card); if (currentBattlePoints >= lastBattlePoints + 10) { break; } } } hand.Player.Match.Log(hand.Player.Username + " plays " + Utils.Stringify.CommaList <BattleCard>(playing)); return(playing); }
public void SetupStoryCardCheck() { if (drawnStoryCard != null) { Debug.Log("DRAWN STORY CARD: " + drawnStoryCard.name); UIUtil.EmptyPanel(questStagePanel); questStageBPTotal.text = ""; questStageNumber.text = ""; //setup quest , tournament or event if (drawnStoryCard.type == "Event Card") { currentEvent = (EventCard)drawnStoryCard; } else if (drawnStoryCard.type == "Tournament Card") { userInput.ActivateBooleanCheck("Do you want to participate?"); currentTournament = (TournamentCard)drawnStoryCard; } else if (drawnStoryCard.type == "Quest Card") { //store player that first drew the quest card QuestState.questDrawer = currentPlayerIndex; userInput.ActivateBooleanCheck("Do you want to sponsor this quest?"); currentQuest = (QuestCard)drawnStoryCard; } numIterations = 0; UIUtil.AddCardToPanel(UIUtil.CreateUIElement(drawnStoryCard, cardPrefab), questPanel); drawnStoryCard = null; } }
public int power(QuestCard quest) { if (!quest.featuredFoe.Equals("") && _name.Contains(quest.featuredFoe) || quest.featuredFoe.Equals("*")) { return(_hiPower); } return(_loPower); }
public List <List <Card> > sponsorQuest(QuestCard questCard, List <Player> players) { if (sponsorQuestBehaviour.sponsor(_playerId, someoneCouldWin(questCard.stages, players), players, questCard)) { return(sponsorQuestBehaviour.setup1(questCard, this)); } return(null); }
public int GetStageBP(int index, QuestCard q) { strategyUtil util = new strategyUtil(); int sum = 0; Debug.Log("GetStageBP index: " + index.ToString()); if (index >= QuestState.stages.Length) { Debug.Log("Invalid index given to GetStageBP"); return(-2); } if (QuestState.stages[index] == null) { Debug.Log("null index given to GetStageBP"); return(-2); } if (QuestState.stages[index].Count < 1) { Debug.Log("Blank Stage"); return(-2); } if (QuestState.stages[index][0] == null) { Debug.Log("Blank Stage"); return(-2); } if (QuestState.stages[index][0].type != "Foe Card" && QuestState.stages[index][0].type != "Test Card") { Debug.Log("First card in stage[" + index.ToString() + "] is not a Foe or Test card"); return(-2); } else { if (QuestState.stages[index][0].type == "Test Card") { return(-1); } else { //We have a foe and weapon card sum += util.getContextBP((FoeCard)QuestState.stages[index][0], QuestState.currentQuest.foe); for (int i = 1; i < QuestState.stages[index].Count; i++) { if (QuestState.stages[index][i].type != "Weapon Card") { Debug.Log("Invalid quest stage config, stage[" + index.ToString() + "] has a " + QuestState.stages[index][i].type + " at index " + i.ToString() + "."); return(-2); } else { sum += ((WeaponCard)QuestState.stages[index][i]).battlePoints; } } } return(sum); } }
// Get power from card. public int getPowerFromCard(Card c) { if (c.GetType() == typeof(WeaponCard)) { WeaponCard currWeapon = (WeaponCard)c; return(currWeapon.power); } if (c.GetType() == typeof(AmourCard)) { AmourCard currAmour = (AmourCard)c; return(currAmour.power); } if (c.GetType() == typeof(AllyCard)) { AllyCard currAlly = (AllyCard)c; int currAllyPower = currAlly.power; //Quest Condition if (_storyCard.GetType() == typeof(QuestCard)) { QuestCard currQuest = (QuestCard)_storyCard; //Same Quest if (currAlly.questCondition == currQuest.name) { currAllyPower += currAlly.bonusPower; } } //Ally Condition if (currAlly.allyCondition != null) { //Go Through The Players for (int x = 0; x < _players.Count; x++) { List <Card> currInPlay = _players[x].inPlay; for (int i = 0; i < currInPlay.Count; i++) { //If ally card if (currInPlay[i].GetType() == typeof(AllyCard)) { AllyCard compareAlly = (AllyCard)currInPlay[i]; if (currAlly.allyCondition == compareAlly.name) { currAllyPower += currAlly.bonusPower; return(currAllyPower); } } } } } return(currAllyPower); } return(0); }
public QuestCard(string card_name, int quest_points, string ability, string set_information, string scenario_title, List <string> scenario_symbols, string sequence) : base(card_name, engagement_cost: -1, threat_strength: -1, attack: -1, defense: -1, quest_points: quest_points, hp: -1, encounter_set: "", traits: null, ability: ability, shadow_effect_icon: "", card_type: "QUEST", set_information: set_information, scenario_title: scenario_title) { this.scenario_symbols = scenario_symbols; this.sequence = sequence; this.progress_tokens_added = 0; next_quest_stage = null; }
public void Test_QuestCard() { QuestCard questCard = new QuestCard("Quest", 5, "Jim", "gg.png"); Assert.AreEqual(questCard.name, "Quest"); Assert.AreEqual(questCard.stages, 5); Assert.AreEqual(questCard.featuredFoe, "Jim"); Assert.AreEqual(questCard.asset, "gg.png"); }
//TODO: when test is implemented put second last as test //SETUP 2 public List <List <Card> > setup2(QuestCard questCard, Player ai) { //TODO: Set up the quest //An algorithm to satisfy the constraints and rules of SETUP 2 //create a minimum quest setup, smallest and weakest number of cards (foes + weapons) //note: weapons should only be used to separate same power in this case //Stack up last monster to be highest possible and replace last foe with strongest one if applicable //since you already selected the weakest monsters with minimal weapons, this is already implemented //quest setup is finished, return List<List<Card>> List <List <Card> > returnedStages = new List <List <Card> > (); List <WeaponCard> weaponCards = extractWeapons(ai.hand); List <FoeCard> foeCards = extractFoes(ai.hand); List <TestCard> testCards = extractTests(ai.hand); //Sort and just POP the last one into each stage Foe weaponCards.Sort((x, y) => x.bp.CompareTo(y.bp)); foeCards.Sort((x, y) => x.power(questCard).CompareTo(y.power(questCard))); int stageModifier = 1; if (testCards.Count > 0) { stageModifier = 2; } //Add the stages for (int i = 0; i < questCard.stages - stageModifier; i++) { returnedStages.Add(new List <Card> ()); if (returnedStages.Count > 1) { //Find previous stage power int stagePower = ((FoeCard)returnedStages[returnedStages.Count - 2][0]).power(questCard); //Does not beat previous stage if (foeCards[0].power(questCard) < stagePower) { findSuitableFoe(ref foeCards, questCard, stagePower, true); } } returnedStages [returnedStages.Count - 1].Add(foeCards[0]); foeCards.RemoveAt(0); } if (testCards.Count > 0) { returnedStages.Add(new List <Card> ()); returnedStages [returnedStages.Count - 1].Add(testCards[0]); } returnedStages.Add(new List <Card> ()); returnedStages [returnedStages.Count - 1].Add(foeCards [foeCards.Count - 1]); int bossPower = ((FoeCard)returnedStages [returnedStages.Count - 1] [0]).power(questCard); setupBoss(ref returnedStages, ref weaponCards, questCard, 40); return(returnedStages); }
// Sets up the stages based on the story card. public void setupStages() { logger.info("Setting up stages for quest: " + _storyCard.name); // Get the number of stages for the quest. QuestCard questCard = (QuestCard)_storyCard; // Setup the stages. for (int i = 0; i < (5 - questCard.stages); i++) { Stages[4-i].SetActive(false); } }
public void Process(QuestCard card) { // card = card ?? QuestCards.GetCardByType(QuestCardType.NewTurn); if (card != null) { card.OnNextCardChoosen = Process; //Ui.SetupCard(card); } }
public bool joinQuest(QuestCard storyCard, List <Player> players) { if (strategyNumber == 1) { return(participateQuestBehaviour.join1(_playerId, storyCard.stages, players)); } else { return(participateQuestBehaviour.join2(_playerId, storyCard.stages, players)); } }
void begin_game() { cur_state = GAMESTATE.GAME_START; cur_quest = QuestCard.PASSAGE_THROUGH_MIRKWOOD_1B(); cur_player = players[0]; for (int i = 0; i < 6; i++) { cur_player.draw_card(); //mulligan blah } begin_resource_phase(); }
public static QuestCard PASSAGE_THROUGH_MIRKWOOD_1B() { QuestCard the_card = new QuestCard("Passage Through Mirkwood 1B - Flies and Spiders", quest_points: 8, ability: "", set_information: "???", scenario_title: "PASSAGE THROUGH MIRWOOD", new List <string>() { "TREE", "SPIDER", "ORC" }, "1B"); the_card.set_next_quest_stage(PASSAGE_THROUGH_MIRKWOOD_2B()); return(the_card); }
public bool StoryCardDone() { if (isDoneStoryEvent) { //discard story card into story discard pile if (currentEvent != null) { List <Card> cards = new List <Card>(); cards.Add(currentEvent); GameUtil.DiscardCards(storyDeck, cards, storyDeckDiscardPileUIButton); // storyDeckDiscardPileUIButton.myCard = currentEvent; //storyDeckDiscardPileUIButton.ChangeTexture(); //storyDeck.discard.Add(currentEvent); } else if (currentQuest != null) { List <Card> cards = new List <Card>(); cards.Add(currentQuest); GameUtil.DiscardCards(storyDeck, cards, storyDeckDiscardPileUIButton); //storyDeckDiscardPileUIButton.myCard = currentQuest; //storyDeckDiscardPileUIButton.ChangeTexture(); //storyDeck.discard.Add(currentQuest); } else if (currentTournament != null) { List <Card> cards = new List <Card>(); cards.Add(currentTournament); GameUtil.DiscardCards(storyDeck, cards, storyDeckDiscardPileUIButton); //storyDeckDiscardPileUIButton.myCard = currentTournament; //storyDeckDiscardPileUIButton.ChangeTexture(); //storyDeck.discard.Add(currentTournament); } isDoneStoryEvent = false; currentEvent = null; currentQuest = null; currentTournament = null; //reset players participation GameUtil.ResetPlayers(players); UIUtil.EmptyPanel(questPanel); System.Array.Clear(queriedCards, 0, queriedCards.Length); //reset turn to draw new story card drawStoryCard = true; GameUtil.ToggleDeckAnimation(storyDeckUIButton, drawStoryCard); userInput.DeactivateUI(); // just in case UIUtil.UpdatePlayerTurn(this); // go to next turn return(true); } return(false); }
public static QuestCard YOU_WIN() { QuestCard the_card = new QuestCard("YOU WIN", quest_points: 10, ability: "WINNER", set_information: "???", scenario_title: "PASSAGE THROUGH MIRKWOOD", new List <string>() { "TREE", "SPIDER", "ORC" }, "2B"); the_card.set_as_winning_stage(); return(the_card); }
public static QuestCard PASSAGE_THROUGH_MIRKWOOD_3B_DONT_LEAVE_THE_PATH() { QuestCard the_card = new QuestCard("Passage Through Mirkwood 3B - A Chosen Path - Don't Leave the Path!", quest_points: 100000, ability: "When Revealed: Each player must search the encounter deck and discard pile for 1 Spider card of his choice, and add it to the staging area. The players must find and defeat Ungoliant's Spawn to win this game.", set_information: "???", scenario_title: "PASSAGE THROUGH MIRKWOOD", new List <string>() { "TREE", "SPIDER", "ORC" }, "2B"); the_card.set_next_quest_stage(YOU_WIN()); return(the_card); }
public static QuestCard PASSAGE_THROUGH_MIRKWOOD_3B_BEORNS_PATH() { QuestCard the_card = new QuestCard("Passage Through Mirkwood 3B - A Chosen Path - Beorn's Path ", quest_points: 10, ability: "Players cannot defeat this stage while Ungoliant's Spawn is in play. If players defeat this stage, they have won the game.", set_information: "???", scenario_title: "PASSAGE THROUGH MIRKWOOD", new List <string>() { "TREE", "SPIDER", "ORC" }, "2B"); the_card.set_next_quest_stage(YOU_WIN()); return(the_card); }
public override bool ParticipateInQuest(QuestCard questCard, Hand hand) { foreach (Player player in questCard.Match.Players) { if ((player != hand.Player) && (player.Hand.Count > hand.Count)) { //if you don't have the most cards (or tied for most), don't join return(false); } } return(true); }
public void SetupCard(QuestCard card) { card.OnAnswer = SetupCardAnswer; card.OnAnswerResources = SetupCardAnswerResources; _cardFront.SetMessage(card.GetQuestion()); _cardFront.SetButton1(card.GetAction1()); _cardFront.SetButton2(card.GetAction2()); _cardBack.SetResources(null); }
public bool doISponsorAQuest(Player[] players, QuestCard quest) { int hasTest = 0; //either 0 or 1, and we use int rather than bool to use it in quest stage calculations int lowestBP = 0; int totalFoes = 0; //hand = sortHand (); bool result = true; for (int i = 0; i < players.Length; i++) { if (players [i].getRank() == 0) { if ((quest.getStages() + players [i].getShields()) >= 5) { return(false); } } else if (players [i].getRank() == 1) { if ((quest.getStages() + players [i].getShields()) >= 7) { return(false); } } else if (players [i].getRank() == 2) { if ((quest.getStages() + players [i].getShields()) >= 10) { return(false); } } } for (int i = 0; i < hand.Length; i++) { if (hand [i].getType().Equals("test")) { hasTest = 1; break; } if (hand[i].getType().Equals("foe") && hand[i].getBP() > lowestBP) { totalFoes++; lowestBP = hand [i].getBP(); } } if (quest.getStages() > totalFoes + hasTest) { return(true); } return(false); } //strategy 1 and 2 run this the exact same way, so no switch statement needed... yet
void start_next_quest() { QuestCard next_quest = cur_quest.get_next_stage(); if (next_quest.is_won_quest()) { Debug.Log("---------------------OMG U WON---------------------"); } else { cur_quest = next_quest; } }
public void finishQuest() { if (players == null) { return; } for (int i = 0; i < players.Length; i++) { players[i].addShields(stageNum + extraShields); } quest = null; inProgress = false; }
public ActiveQuest(QuestCard _quest, int _extraShields) { log.Init(); quest = _quest; stageNum = _quest.getStages(); players = null; currentStage = 0; highestBid = -1; inProgress = false; totalCardsUsed = 0; highestBidder = null; extraShields = _extraShields; testPhase = 0; }