Пример #1
0
    public void CheatPanelToggle()
    {
        if (GameUtil.CheckSponsorship(players) >= 0 && GameUtil.CheckParticipation(players) > 0)
        {
            if (!cheatPanel.activeSelf)
            {
                cheatPanel.SetActive(true);
                int cheatPanelStageNumber = System.Int32.Parse(cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text.Substring(6)) + 1;

                cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text  = "STAGE " + (cheatPanelStageNumber);
                cheatPanel.transform.Find("CardsInStage").GetComponent <Text>().text = "CARDS IN STAGE " + QuestState.stages[cheatPanelStageNumber].Count;
            }
            else
            {
                int cheatPanelStageNumber = System.Int32.Parse(cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text.Substring(6));

                if (cheatPanelStageNumber >= QuestState.currentQuest.stages)
                {
                    cheatPanel.SetActive(false);
                    cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text  = "STAGE " + 0;
                    cheatPanel.transform.Find("CardsInStage").GetComponent <Text>().text = "CARDS IN STAGE " + 0;
                }
                else
                {
                    cheatPanel.transform.Find("StageNumber").GetComponent <Text>().text  = "STAGE " + (cheatPanelStageNumber + 1);
                    cheatPanel.transform.Find("CardsInStage").GetComponent <Text>().text = "CARDS IN STAGE " + QuestState.stages[cheatPanelStageNumber].Count;
                }
            }
        }
    }
Пример #2
0
    public void RunStoryCard()
    {
        if (currentEvent != null)
        {
            currentEvent.effect.execute(players, currentEvent, this);
        }
        else if (currentTournament != null)
        {
            currentTournament.tournament.execute(null, currentTournament, this);
        }
        else if (currentQuest != null)
        {
            currentQuest.quest.execute(players, currentQuest, this);

            //CHECK HERE IF CARDS TO BE ADDED BY SPONSOR BREAK THE RULES RETURN ALL THESE CARDS TO HIS HAND AND FORCE HIM TO REDECIDE
            if (QuestState.state == "Sponsoring")
            {
                if (!GameUtil.AnyFoes(userInput.cardPrompt.selectedCards) && GameUtil.AnyWeapons(userInput.cardPrompt.selectedCards))
                {
                    //there are foes but no weapons return all cards to hand and start again
                    UIUtil.ReturnToPlayerHand(players[GameUtil.CheckSponsorship(players)], userInput.cardPrompt.selectedCards, this);
                }
            }
        }
    }
Пример #3
0
    //query sponsor for his cards for the quest
    //IF SPONSOR ADDS NOTHING OR WE DO NOT
    //CHECK USER INPUT IF IT DOESN'T FIT INTO REQUIREMENTS END SPONSORSHIP AND END QUEST
    public static void SponsorQuery(Controller game)
    {
        if (game.userInput.UIEnabled)
        {
            if (game.userInput.cardPrompt.isActive)
            {
                //check for as much as the quest stages
                if (game.numIterations < game.currentQuest.stages)
                {
                    //calling check sponsorship for debugging since it should never come in here if there is no player sponsoring
                    List <List <Card> > returnVal = new List <List <Card> >();
                    returnVal = game.players[GameUtil.CheckSponsorship(game.players)].strategy.setupQuest(game.currentQuest.stages, game.players[GameUtil.CheckSponsorship(game.players)].hand, game.currentQuest.foe);

                    if (returnVal != null)
                    {
                        //ai here
                        //conversion
                        for (int i = 0; i < returnVal.Count; i++)
                        {
                            game.sponsorQueriedCards[i] = new List <Card>(returnVal[i]);
                        }

                        // break we are done here
                        game.numIterations = 5;
                        game.userInput.DeactivateUI();
                        UIUtil.UpdatePlayerTurn(game);
                        UIUtil.PopulatePlayerBoard(game);
                    }
                    else if (game.userInput.cardPrompt.doneAddingCards)
                    {
                        game.sponsorQueriedCards[game.numIterations] = new List <Card>(game.userInput.cardPrompt.selectedCards);
                        game.userInput.DeactivateUI();
                        game.numIterations++;
                        game.userInput.ActivateCardUIPanel("What FOE or TEST cards do you want to use for this Quest?");
                    }
                }
                else
                {
                    game.userInput.DeactivateUI();
                    UIUtil.UpdatePlayerTurn(game);
                    UIUtil.PopulatePlayerBoard(game);

                    Debug.Log("all cards have been selected");
                    //we are done

                    for (int i = 0; i < game.sponsorQueriedCards.Length; i++)
                    {
                        if (game.sponsorQueriedCards[i] != null)
                        {
                            for (int j = 0; j < game.sponsorQueriedCards[i].Count; j++)
                            {
                                Debug.Log(i.ToString() + ": " + game.sponsorQueriedCards[i][j].name);
                            }
                        }
                    }
                }
            }
        }
    }
Пример #4
0
    public void EndQuest(Controller game)
    {
        int numDrawCount = 0;

        for (int i = 0; i < QuestState.stages.Length; i++)
        {
            if (QuestState.stages[i] != null)
            {
                numDrawCount += QuestState.stages[i].Count + 1;
            }
        }

        for (int i = 0; i < numDrawCount; i++)
        {
            game.players[GameUtil.CheckSponsorship(game.players)].hand.Add(GameUtil.DrawFromDeck(game.adventureDeck, 1)[0]);
        }

        if (QuestState.state == "PlayingQuest")
        {
            int kingsUsed = 0;
            if (game.kingsRecognition)
            {
                kingsUsed += 2;
            }
            for (int i = 0; i < QuestState.amours.Length; i++)
            {
                if (QuestState.amours[i] != null && QuestState.amours[i].Count > 0)
                {
                    GameUtil.DiscardCards(game.adventureDeck, QuestState.amours[i], game.adventureDeckDiscardPileUIButton);
                }
            }

            for (int i = 0; i < game.numPlayers; i++)
            {
                if (game.players[i].participating)
                {
                    game.players[i].addShields(game.currentQuest.getStages() + kingsUsed);
                }
            }
            if (kingsUsed == 2)
            {
                game.kingsRecognition = false;
            }
        }

        //reset static values
        QuestState.state                = "FindingSponsor";
        QuestState.currentQuest         = null;
        QuestState.numberOfParticipants = 0;
        QuestState.currentStage         = 0;
        QuestState.sponsorIndex         = 0;
        QuestState.questDrawer          = 0;
        QuestState.round                = 0;
        QuestState.testBidSubmitted     = false;
        QuestState.bidsOver             = false;
        QuestState.testBids             = null;

        //DO I NEED TO UPDATE TURNS
        game.currentPlayerIndex = QuestState.questDrawer;

        //Initializing the list of quest stages;
        System.Array.Clear(QuestState.stages, 0, QuestState.stages.Length);
        System.Array.Clear(QuestState.amours, 0, QuestState.amours.Length);
        if (QuestState.testBids != null)
        {
            System.Array.Clear(QuestState.testBids, 0, QuestState.testBids.Length);
        }


        //Maybe add this to a function

        //Check for players with over 12 cards
        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 " + (game.players[game.currentPlayerIndex].hand.Count - 12).ToString() + " Cards");
        }

        game.isDoneStoryEvent = true;
    }
Пример #5
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");
                    }
                }
            }
        }
    }