示例#1
0
        private IEnumerator DecideSkill()
        {
            //Várunk, hogy a főszál beérjen a lockhoz
            while (controller.GetTurnWaitStatus())
            {
                yield return(null);
            }

            GetCurrentContext();
            Debug.Log($"Card count: {cardCount}\nCurrent key: {controller.GetCurrentKey()}");
            for (var id = 0; id < cardCount; id++)
            {
                if (Module_Controller.instance.GetClientModule().AskCardSkillStatus(playerKey, id) == SkillState.NotDecided)
                {
                    //GetSkillChoiceFromAIBrain
                    SkillState choice = Bot_Behaviour.ChooseSkill(id, cardsInHand, cardsOnField, opponentCards, winAmount);
                    Module_Controller.instance.GetInputModule().ReportSkillStatusChange(SkillState.Use, id, false);

                    controller.StartCoroutine(HandleSkills());

                    //Skill lock
                    yield return(controller.WaitForEndOfSkill());
                }
            }

            //Gondolkodási idő
            yield return(new WaitForSeconds(0.05f));

            //Az AI végzett a körével a döntések után
            Module_Controller.instance.GetDataModule().GetPlayerWithKey(playerKey).SetStatus(PlayerTurnStatus.Finished);

            controller.TurnFinished();
        }
示例#2
0
        private IEnumerator ChooseActiveStat()
        {
            //Várunk, hogy a főszál beérjen a lockhoz
            while (controller.GetTurnWaitStatus())
            {
                yield return(null);
            }
            this.cardsInHand = Module_Controller.instance.GetDataModule().GetCardsFromPlayer(playerKey, CardListTarget.Hand);
            CardStatType stat = Bot_Behaviour.ChooseFightType(this.cardsInHand);

            field.ReportStatChoice(stat);
        }
        //Dönt az új statról
        public void DecideNewStat(int key)
        {
            GetCurrentContext(key);

            //AI agy segítségét hívjuk a döntésben
            CardStatType newStat = Bot_Behaviour.ChangeFightType(cardsOnField,
                                                                 opponentCards, currentStat);

            modules.GetGameModule().SetActiveStat(newStat);

            //Jelenítsük meg a változást
            modules.GetClientModule().RefreshStatDisplay();
        }
示例#4
0
        private IEnumerator SummonCard()
        {
            //Várunk, hogy a főszál beérjen a lockhoz
            while (controller.GetTurnWaitStatus())
            {
                yield return(null);
            }

            GetCurrentContext();

            //Gondolkodási idő
            yield return(new WaitForSeconds(GameSettings_Controller.drawTempo * UnityEngine.Random.Range(15, 30)));

            //Meghozzuk a döntést
            int cardIndex = Bot_Behaviour.ChooseRightCard(this.cardsInHand, controller.GetActiveStat());

            //Lerakatjuk a kártyát a UI-ban
            field.SummonCard(cardIndex);
        }
示例#5
0
        //Kezeli a képeségekkel járó különböző plusz folyamatokat
        private IEnumerator HandleSkills()
        {
            //Várunk, hogy a főszál beérjen a lockhoz
            while (controller.GetSkillWaitStatus())
            {
                yield return(null);
            }

            Debug.Log($"{agentName}: I handle the skill");

            //Ha cseréről van szó
            if (controller.GetCurrentAction() == SkillEffectAction.Switch)
            {
                int handID = -1;

                //Ha kézből cserélünk
                if (controller.GetCurrentListType() == CardListTarget.Hand)
                {
                    handID = Bot_Behaviour.HandSwitch(
                        Module_Controller.instance.GetDataModule().GetCardsFromPlayer(this.playerKey, CardListTarget.Hand),
                        Module_Controller.instance.GetDataModule().GetCardsFromPlayer(this.playerKey, CardListTarget.Field),
                        Module_Controller.instance.GetDataModule().GetOpponentsCard(this.playerKey),
                        controller.GetActiveStat());

                    Module_Controller.instance.GetSkillModule().SwitchCard(this.playerKey, controller.GetActiveCardID(), handID);
                }
            }

            //Ha skill lopásról van szó
            else if (controller.GetCurrentAction() == SkillEffectAction.SkillUse)
            {
                //Adatgyűjtés
                Card ownCard = Module_Controller.instance.GetDataModule().GetCardFromPlayer(this.playerKey, controller.GetActiveCardID(), CardListTarget.Field);
                List <PlayerCardPairs> cards = Module_Controller.instance.GetDataModule().GetOtherLosers(this.playerKey);
                int index = Bot_Behaviour.WhichSkillToUse(cards);

                Module_Controller.instance.GetInputModule().HandleCardSelection(cards[index].cardPosition, cards[index].playerKey);
                yield break;
            }

            //Ha felélesztésről van szó
            else if (controller.GetCurrentAction() == SkillEffectAction.Revive)
            {
                List <Card> cards  = Module_Controller.instance.GetDataModule().GetCardsFromPlayer(this.playerKey, CardListTarget.Losers);
                int         cardID = Bot_Behaviour.WhomToRevive(cards);
                Module_Controller.instance.GetInputModule().HandleCardSelection(cardID, this.playerKey);
            }

            else if (controller.GetCurrentAction() == SkillEffectAction.Execute)
            {
                List <int> temp = Module_Controller.instance.GetDataModule().GetOtherKeyList(this.playerKey);
                this.choosenPlayersKey = Bot_Behaviour.WhichPlayerToExecute(temp);

                Module_Controller.instance.GetInputModule().ReportNameBoxTapping(this.choosenPlayersKey);
                yield return(controller.WaitForEndOfAction());
            }

            else if (controller.GetCurrentAction() == SkillEffectAction.SwitchOpponentCard)
            {
                List <int> temp = Module_Controller.instance.GetDataModule().GetOtherKeyList(this.playerKey);
                this.choosenPlayersKey = Bot_Behaviour.WhichPlayerToExecute(temp);

                Module_Controller.instance.GetInputModule().ReportNameBoxTapping(this.choosenPlayersKey);
                yield return(controller.WaitForEndOfAction());
            }

            else if (controller.GetCurrentAction() == SkillEffectAction.PickCardForSwitch)
            {
                List <Card> cardsOnField  = Module_Controller.instance.GetDataModule().GetCardsFromPlayer(this.choosenPlayersKey, CardListTarget.Field);
                int         choosenCardID = Bot_Behaviour.WhichCardToSwitch(cardsOnField);
                int         deckCount     = (Module_Controller.instance.GetDataModule().GetDeckAmount(this.choosenPlayersKey)) - 1;
                controller.SetSwitchType(CardListTarget.Deck);
                Module_Controller.instance.GetSkillModule().SwitchCard(this.choosenPlayersKey, choosenCardID, deckCount);
            }

            else if (controller.GetCurrentAction() == SkillEffectAction.CheckWinnerAmount)
            {
                List <int> keyList    = Module_Controller.instance.GetDataModule().GetOtherKeyList(this.playerKey);
                List <int> winAmounts = Module_Controller.instance.GetDataModule().GetOthersWinAmount(this.playerKey);

                int playerID = Bot_Behaviour.WhichPlayerToChoose(winAmounts);
                this.choosenPlayersKey = keyList[playerID];
                Module_Controller.instance.GetInputModule().ReportNameBoxTapping(this.choosenPlayersKey);
            }

            //Ha kézből eldobásról van szó
            else if (controller.GetCurrentAction() == SkillEffectAction.TossCard)
            {
                //Csak akkor dobunk el lapot, ha van a kezünkben
                if (cardsInHand.Count > 1)
                {
                    int cardID = Bot_Behaviour.WhomToToss(cardsInHand);
                    Module_Controller.instance.GetInputModule().HandleCardSelection(cardID, this.playerKey);
                }

                else
                {
                    Debug.Log("Nincs mit eldobni");
                    controller.ActionFinished();
                }
            }

            else if (controller.GetCurrentAction() == SkillEffectAction.SacrificeFromHand)
            {
                int cardID = Bot_Behaviour.WhomToToss(cardsInHand);
                Module_Controller.instance.GetInputModule().HandleCardSelection(cardID, this.playerKey);
            }

            else if (controller.GetCurrentAction() == SkillEffectAction.SacrificeDoppelganger)
            {
                List <Card> cardList = Module_Controller.instance.GetDataModule().GetCardsFromPlayer(this.playerKey, CardListTarget.Hand, CardListFilter.EnemyDoppelganger);
                if (cardList.Count > 0)
                {
                    int cardID = Bot_Behaviour.WhomToToss(cardList);
                    Module_Controller.instance.GetInputModule().HandleCardSelection(cardID, this.playerKey);
                }

                else
                {
                    controller.ActionFinished();
                }
            }

            else if (controller.GetCurrentAction() == SkillEffectAction.Reorganize)
            {
                List <Card> cardsInDeck = Module_Controller.instance.GetDataModule().GetCardsFromPlayer(this.playerKey, CardListTarget.Deck, CardListFilter.None, 6);
                cardsInDeck = Bot_Behaviour.OrganiseCardsInDeck(cardsInDeck, Module_Controller.instance.GetDataModule().GetRNG());
                Module_Controller.instance.GetInputModule().HandleChangeOfCardOrder(cardsInDeck, this.playerKey);
            }

            //Skill lock feloldása
            controller.SkillFinished();
        }
        //Kártyacsere vagy választás
        public IEnumerator CardSelectionEffect(int key, CardListFilter filter, int limit = 0, int otherPlayer = -1)
        {
            GetCurrentContext(key);

            //Ha cseréről van szó
            if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.Switch)
            {
                int handID = -1;

                //Ha kézből cserélünk
                if (modules.GetGameModule().GetCurrentListType() == CardListTarget.Hand)
                {
                    handID = Bot_Behaviour.HandSwitch(
                        modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Hand),
                        modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Field),
                        modules.GetDataModule().GetOpponentsCard(currentKey),
                        currentStat);

                    modules.GetSkillModule().SwitchCard(currentKey, modules.GetGameModule().GetActiveCardID(), handID);
                }
            }

            //Ha skill lopásról van szó
            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.SkillUse)
            {
                //Adatgyűjtés
                Card ownCard = modules.GetDataModule().GetCardFromPlayer(currentKey, modules.GetGameModule().GetActiveCardID(), CardListTarget.Field);
                List <PlayerCardPairs> cards = modules.GetDataModule().GetOtherLosers(currentKey);
                int index = Bot_Behaviour.WhichSkillToUse(cards);

                modules.GetInputModule().HandleCardSelection(cards[index].cardPosition, cards[index].playerKey);
                yield break;
            }

            //Ha felélesztésről van szó
            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.Revive)
            {
                List <Card> cards  = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Losers);
                int         cardID = Bot_Behaviour.WhomToRevive(cards);
                modules.GetInputModule().HandleCardSelection(cardID, currentKey);
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.Execute)
            {
                List <int> temp       = modules.GetDataModule().GetOtherKeyList(currentKey);
                int        choosenKey = Bot_Behaviour.WhichPlayerToExecute(temp);

                modules.GetInputModule().ReportNameBoxTapping(choosenKey);
                yield return(modules.GetGameModule().WaitForEndOfAction());
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.SwitchOpponentCard)
            {
                List <int> temp       = modules.GetDataModule().GetOtherKeyList(currentKey);
                int        choosenKey = Bot_Behaviour.WhichPlayerToExecute(temp);

                modules.GetInputModule().ReportNameBoxTapping(choosenKey);
                yield return(modules.GetGameModule().WaitForEndOfAction());
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.PickCardForSwitch)
            {
                List <Card> cardsOnField  = modules.GetDataModule().GetCardsFromPlayer(otherPlayer, CardListTarget.Field);
                int         choosenCardID = Bot_Behaviour.WhichCardToSwitch(cardsOnField);
                int         deckCount     = (modules.GetDataModule().GetDeckAmount(otherPlayer)) - 1;
                modules.GetGameModule().SetSwitchType(CardListTarget.Deck);
                modules.GetSkillModule().SwitchCard(otherPlayer, choosenCardID, deckCount);
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.CheckWinnerAmount)
            {
                List <int> keyList    = modules.GetDataModule().GetOtherKeyList(currentKey);
                List <int> winAmounts = modules.GetDataModule().GetOthersWinAmount(currentKey);

                int playerID = Bot_Behaviour.WhichPlayerToChoose(winAmounts);

                modules.GetInputModule().ReportNameBoxTapping(keyList[playerID]);
            }

            //Ha kézből eldobásról van szó
            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.TossCard)
            {
                //Csak akkor dobunk el lapot, ha van a kezünkben
                if (cardsInHand.Count > 1)
                {
                    int cardID = Bot_Behaviour.WhomToToss(cardsInHand);
                    modules.GetInputModule().HandleCardSelection(cardID, currentKey);
                }

                else
                {
                    Debug.Log("Nincs mit eldobni");
                    modules.GetGameModule().ActionFinished();
                }
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.SacrificeFromHand)
            {
                int cardID = Bot_Behaviour.WhomToToss(cardsInHand);
                modules.GetInputModule().HandleCardSelection(cardID, currentKey);
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.SacrificeDoppelganger)
            {
                List <Card> cardList = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Hand, filter);
                if (cardList.Count > 0)
                {
                    int cardID = Bot_Behaviour.WhomToToss(cardList);
                    modules.GetInputModule().HandleCardSelection(cardID, currentKey);
                }

                else
                {
                    Debug.Log("Nincs megfelelő lap a kézben");
                    modules.GetGameModule().ActionFinished();
                }
            }

            else if (modules.GetGameModule().GetCurrentAction() == SkillEffectAction.Reorganize)
            {
                List <Card> cardsInDeck = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Deck, CardListFilter.None, limit);
                cardsInDeck = Bot_Behaviour.OrganiseCardsInDeck(cardsInDeck, modules.GetDataModule().GetRNG());
                modules.GetInputModule().HandleChangeOfCardOrder(cardsInDeck, currentKey);
            }
        }