Exemple #1
0
    public void DiscardCardAddition()
    {
        if (selectedCard != null)
        {
            //all ally cards activated are added to the board and active allies
            if (selectedCard.type == "Ally Card")
            {
                //ally cards always get added to active allies
                AllyCard ally = (AllyCard)selectedCard;
                players[currentPlayerIndex].activeAllies.Add(ally);
                players[currentPlayerIndex].hand.Remove(selectedCard);
                UIUtil.AddCardToPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab), playerAllyPanels[currentPlayerIndex]);
            }
            else
            {
                bool removed = userInput.CheckDiscardCard(selectedCard);
                if (removed)
                {
                    //add card back to player
                    players[currentPlayerIndex].hand.Add(selectedCard);
                    UIUtil.PopulatePlayerBoard(this);
                }
                else
                {
                    //add it into the panel
                    players[currentPlayerIndex].hand.Remove(selectedCard);

                    //Debug.Log(selectedCard.name);
                    userInput.AddToUIDiscardPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab));
                }
            }

            selectedCard = null;
        }
    }
Exemple #2
0
    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;
        }
    }
Exemple #3
0
    public void CardAdditionCheck()
    {
        if (selectedCard != null)
        {
            //all ally cards activated are added to the board and active allies
            if (selectedCard.type == "Ally Card")
            {
                //ally cards always get added to active allies
                AllyCard ally = (AllyCard)selectedCard;
                players[currentPlayerIndex].activeAllies.Add(ally);
                players[currentPlayerIndex].hand.Remove(selectedCard);
                UIUtil.AddCardToPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab), playerAllyPanels[currentPlayerIndex]);
            }
            else
            {
                //check cards for removal from card panel
                bool removedCard = userInput.CheckCard(selectedCard);

                if (removedCard)
                {
                    //removed card from panel So add it back to hand
                    players[currentPlayerIndex].hand.Add(selectedCard);
                    UIUtil.AddCardToPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab), handPanel);
                }
                else
                {
                    bool addToPanel = true;

                    //CLUSTERFUCK
                    addToPanel = EventCheck(QuestCheck(TournamentCheck()));

                    //result
                    if (addToPanel)
                    {
                        //add it into the panel
                        players[currentPlayerIndex].hand.Remove(selectedCard);
                        userInput.AddToUICardPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab));
                    }
                    else
                    {
                        //return it to hand since we didn't delete it from player we are fine
                        UIUtil.AddCardToPanel(UIUtil.CreateUIElement(selectedCard, cardPrefab), handPanel);
                    }
                }
            }

            //maybe we can check for certain cards like mordred here with some state
            selectedCard = null;
        }
    }
Exemple #4
0
    public void execute(List <Player> players, Card storyCard, Controller game)
    {
        //FIND A SPONSOR FOR THE QUEST
        if (QuestState.state == "FindingSponsor")
        {
            QuestState.currentQuest = game.currentQuest;
            QueryingUtil.SponsorCheck(game);

            if (game.numIterations >= game.numPlayers)
            {
                game.numIterations = 0;

                Debug.Log("CheckSponsorship" + GameUtil.CheckSponsorship(game.players));
                if (GameUtil.CheckSponsorship(game.players) != -1)
                {
                    QuestState.state = "Sponsoring";

                    QuestState.invalidQuestSubmitted = false;

                    game.userInput.DeactivateUI();
                    game.userInput.ActivateCardUIPanel("What FOE or TEST cards would you like to add?");
                }
                else
                {
                    game.isDoneStoryEvent = true;
                }
            }
        }

        // GET SPONSOR'S CARDS FOR THE QUEST
        if (QuestState.state == "Sponsoring")
        {
            //Displays a prompt for the player if the quest they submitted is invalid.
            if (QuestState.invalidQuestSubmitted)
            {
                InvalidQuestPrompt(game);
            }
            else
            {
                QueryingUtil.SponsorQuery(game);

                if (game.numIterations >= game.currentQuest.stages)
                {
                    QuestState.stages = new List <Card> [game.currentQuest.stages];
                    System.Array.Copy(game.sponsorQueriedCards, QuestState.stages, game.currentQuest.stages);
                    game.numIterations = 0;

                    if (ValidQuest())
                    {
                        QuestState.state = "CheckingForParticipants";
                        UIUtil.UpdatePlayerTurn(game);
                        game.userInput.DeactivateUI();
                        game.userInput.ActivateBooleanCheck("Participate in the QUEST?");
                    }
                    else
                    {
                        QuestState.invalidQuestSubmitted = true;

                        for (int i = 0; i < game.sponsorQueriedCards.Length; i++)
                        {
                            if (game.sponsorQueriedCards[i] != null)
                            {
                                for (int j = 0; j < game.sponsorQueriedCards[i].Count; j++)
                                {
                                    game.players[game.currentPlayerIndex].hand.Add(game.sponsorQueriedCards[i][j]);
                                    UIUtil.AddCardToPanel(UIUtil.CreateUIElement(game.sponsorQueriedCards[i][j], game.cardPrefab), game.handPanel);
                                    game.sponsorQueriedCards[i].RemoveAt(j);
                                    j--;
                                }
                            }
                        }

                        UIUtil.PopulatePlayerBoard(game);
                        game.userInput.DeactivateUI();
                        game.userInput.ActivateBooleanCheck("Invalid Quest Submitted. Please try again.");
                    }
                }
            }
        }

        //CHECKING FOR QUEST PARTICIPANTS
        if (QuestState.state == "CheckingForParticipants")
        {
            QueryingUtil.ParticipationCheck("Quest", game);

            if (game.numIterations >= game.numPlayers)
            {
                Debug.Log("Done Participation Check");
                if (GameUtil.CheckParticipation(game.players) < 1)
                {
                    EndQuest(game);
                }
                else
                {
                    QuestState.state  = "PlayingQuest";
                    QuestState.amours = new List <Card> [game.numPlayers];

                    for (int i = 0; i < QuestState.amours.Length; i++)
                    {
                        QuestState.amours[i] = new List <Card>();
                    }

                    QuestState.testBids         = new int[game.numPlayers];
                    QuestState.testBidSubmitted = false;
                    QuestState.bidsOver         = false;

                    DrawForStageStart(game);
                    //game.populatePlayerBoard();
                    //game.populateQuestBoard(false);
                    UIUtil.PopulatePlayerBoard(game);
                    UIUtil.PopulateQuestBoard(game, false);
                    game.numIterations = 0;
                    game.userInput.DeactivateUI();
                    if (QuestState.stages[QuestState.currentStage][0].type == "Test Card")
                    {
                        QuestState.round = 0;
                        TestCard tempTestCard = (TestCard)QuestState.stages[0][0];
                        string[] minBidString = new string[1];
                        minBidString[0] = GetMinRequiredBid().ToString();
                        game.userInput.ActivateUserInputCheck("A Test is in play, the minimum bid is: " + GetMinRequiredBid().ToString());
                    }
                    else
                    {
                        game.userInput.ActivateCardUIPanel("Play Ally, Weapon and/or Amour cards for this stage of the quest");
                    }
                }
            }
        }

        //QUEST GAMEPLAY HERE
        else if (QuestState.state == "PlayingQuest")
        {
            if (QuestState.currentStage >= game.currentQuest.getStages() || GameUtil.CheckParticipation(game.players) < 1)
            {
                Debug.Log("Called EndQuest here");
                EndQuest(game);
            }
            else
            {
                if (QuestState.stages[QuestState.currentStage][0].type == "Test Card")
                {
                    if (!QuestState.bidsOver)
                    {
                        TestQuery(game);
                        if (GameUtil.CheckParticipation(game.players) < 2 && QuestState.testBidSubmitted == true)
                        {
                            //check for test card thing

                            QuestState.bidsOver = true;
                            game.userInput.DeactivateUI();
                            //game.populatePlayerBoard();
                            UIUtil.PopulatePlayerBoard(game);
                            game.userInput.ActivateCardUIPanel("Please submit " + (Mathf.Max(QuestState.testBids[game.currentPlayerIndex] - game.players[game.currentPlayerIndex].calculateBid(game.currentQuest.name, game.players), 0)).ToString() + " cards to discard.");
                        }
                    }
                    else
                    {
                        DiscardCards(game);
                    }
                }
                else
                {
                    QueryingUtil.CardQuerying("Quest", game);

                    //get player's cards for the quest
                    if (game.userInput.cardPrompt.selectedCards.Count > 0)
                    {
                        //game.populateQuestBoard(false);

                        UIUtil.PopulateQuestBoard(game, false);
                    }
                    if (game.numIterations >= game.numPlayers)
                    {
                        for (int i = 0; i < game.queriedCards.Length; i++)
                        {
                            if (GameUtil.CheckSponsorship(game.players) == i)
                            {
                                continue;
                            }
                            if (!game.players[i].participating)
                            {
                                continue;
                            }

                            int sum = 0;

                            if (game.queriedCards[i] != null)
                            {
                                for (int j = 0; j < game.queriedCards[i].Count; j++)
                                {
                                    if (game.queriedCards[i][j] == null)
                                    {
                                        continue;
                                    }

                                    if (game.queriedCards[i][j].type == "Weapon Card")
                                    {
                                        Debug.Log("Weapon Card at " + j.ToString() + " bp value is " + ((WeaponCard)game.queriedCards[i][j]).battlePoints.ToString());
                                        sum += ((WeaponCard)game.queriedCards[i][j]).battlePoints;
                                    }
                                    else if (game.queriedCards[i][j].type == "Amour Card")
                                    {
                                        QuestState.amours[i].Add(game.queriedCards[i][j]);
                                        game.queriedCards[i].RemoveAt(j);
                                        j--;
                                    }
                                }

                                if (QuestState.amours[i] != null)
                                {
                                    for (int j = 0; j < QuestState.amours[i].Count; j++)
                                    {
                                        AmourCard tempAmourCard = (AmourCard)QuestState.amours[i][j];
                                        sum += tempAmourCard.battlePoints;
                                    }
                                }

                                sum += game.players[i].CalculateBP(storyCard.name, players);
                                if (sum < GetStageBP(QuestState.currentStage, game.currentQuest))
                                {
                                    Debug.Log("Stage Failed Result: GetStageBP = " + GetStageBP(QuestState.currentStage, game.currentQuest).ToString() + " Sum of player strength = " + sum.ToString());
                                    game.players[i].participating = false;
                                }
                            }
                        }
                    }
                }
            }

            if (game.numIterations >= game.numPlayers)
            {
                Debug.Log("currentStage: " + QuestState.currentStage);
                //game.populateQuestBoard(true);
                UIUtil.PopulateQuestBoard(game, true);

                if (!(QuestState.stages[QuestState.currentStage][0].type == "Test Card"))
                {
                    QuestState.previousQuestBP = GetStageBP(QuestState.currentStage, QuestState.currentQuest);
                }

                QuestState.currentStage++;
                if (QuestState.currentStage >= game.currentQuest.getStages())
                {
                    EndQuest(game);
                }
                else if (GameUtil.CheckParticipation(game.players) < 1)
                {
                    EndQuest(game);
                }
                else
                {
                    DrawForStageStart(game);
                    UIUtil.PopulatePlayerBoard(game);
                    game.numIterations = 0;
                    game.userInput.DeactivateUI();
                    System.Array.Clear(game.queriedCards, 0, game.queriedCards.Length);

                    //check for discard at the end of each stage
                    game.playerStillOffending = GameUtil.PlayerOffending(game.players);

                    if (game.playerStillOffending)
                    {
                        game.numIterations = 0;
                        //find first offending player
                        while (!game.players[game.currentPlayerIndex].handCheck() && game.numIterations < game.numPlayers)
                        {
                            //doesn't need to discard update turn
                            game.numIterations++;
                            UIUtil.UpdatePlayerTurn(game);
                        }
                        game.userInput.ActivateDiscardCheck("You need to Discard " + (players[game.currentPlayerIndex].hand.Count - 12).ToString() + " Cards");
                    }

                    if (QuestState.stages[QuestState.currentStage][0].type == "Test Card")
                    {
                        QuestState.round = 0;
                        TestCard tempTestCard = (TestCard)QuestState.stages[QuestState.currentStage][0];
                        string[] minBidString = new string[1];
                        minBidString[0] = GetMinRequiredBid().ToString();
                        game.userInput.ActivateUserInputCheck("A Test is in play, the minimum bid you must make is: " + (GetMinRequiredBid()).ToString());
                    }
                    else
                    {
                        game.userInput.ActivateCardUIPanel("Play Ally, Weapon and/or Amour cards for this stage of the quest");
                    }
                }
            }
        }
    }