public int GetActiveCardsValue(CardStatType type)
    {
        int sum   = 0;
        int index = 0;

        foreach (Card card in cardsOnField)
        {
            if (type == CardStatType.Power)
            {
                sum += card.GetPower();
            }

            else if (type == CardStatType.Intelligence)
            {
                sum += card.GetIntelligence();
            }

            else if (type == CardStatType.Reflex)
            {
                sum += card.GetReflex();
            }

            index++;
        }

        return(sum);
    }
 //Lekéri az aktuális számára is elérhető adatokat
 private void GetCurrentContext(int key)
 {
     this.currentKey    = key;
     this.cardsOnField  = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Field);
     this.cardCount     = cardsOnField.Count;
     this.opponentCards = modules.GetDataModule().GetOpponentsCard(currentKey);
     this.cardsInHand   = modules.GetDataModule().GetCardsFromPlayer(currentKey, CardListTarget.Hand);
     this.winAmount     = modules.GetDataModule().GetWinnerAmount(currentKey);
     this.currentStat   = modules.GetGameModule().GetActiveStat();
 }
Example #3
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();
        }
        private void Awake()
        {
            //Modulok beállítása
            this.modules = Module_Controller.CreateModuleController(this, factory, client);

            //Interakciók beállítása
            this.interactions = new Interactions(this, modules);

            //Játékfázisok beállítása
            this.orderChangeState     = new OrderChangeState(modules, this, interactions);
            this.preparationState     = new PreparationState(modules, this, interactions);
            this.starterDrawState     = new StarterDrawState(modules, this, interactions);
            this.settingRoleState     = new SettingRoleState(modules, this, interactions);
            this.selectFightTypeState = new SelectFightTypeState(modules, this, interactions);
            this.summonState          = new SummonState(modules, this, interactions);
            this.revealCardsState     = new RevealCardsState(modules, this, interactions);
            this.quickSkillState      = new QuickSkillState(modules, this, interactions);
            this.mainSkillState       = new MainSkillState(modules, this, interactions);
            this.compareState         = new CompareState(modules, this, interactions);
            this.lateSkillState       = new LateSkillState(modules, this, interactions);
            this.cardPutAwayState     = new CardPutAwayState(modules, this, interactions);
            this.blindMatchState      = new BlindMatchState(modules, this, interactions);
            this.resultState          = new ResultState(modules, this, interactions);

            //Játékfázisok és státuszok alapértékezése
            this.currentPhase           = MainGameStates.SetupGame;
            this.currentStat            = CardStatType.NotDecided;
            this.currentAction          = SkillEffectAction.None;
            this.currentSelectionType   = CardListTarget.None;
            this.currentKey             = -1;
            this.currentActiveCard      = -1;
            this.lastWinnerKey          = -1;
            this.phaseChange            = true;
            this.firstRound             = true;
            this.displayedMessageStatus = false;
            this.blindMatch             = false;
            this.actionFinished         = true;
            this.turnFinished           = true;
            this.skillFinished          = true;
            this.changedOrder           = false;
            this.lateSkillKeys          = new List <int>();
            this.instantWin             = false;
            this.negatedSkills          = false;

            rng = new System.Random();
        }
        //Az input alapján módosítjuk az aktív értéktípust az újra
        public void ReportStatChange(CardStatType newStat)
        {
            //Választott érték beállítása
            modules.GetGameModule().SetActiveStat(newStat);

            //Jelenítsük meg a változást
            modules.GetClientModule().RefreshStatDisplay();

            //Ha stat választás fázisban vagyunk: Következő fázis jön
            if (modules.GetGameModule().GetGameState() == MainGameStates.SetStat)
            {
                //Kitörés a wait fázisból
                modules.GetGameModule().TurnFinished();
            }

            //Ellenkező esetben skill okozta a változtatást, jelezzük hogy a skillnek vége
            else
            {
                modules.GetGameModule().ActionFinished();
            }
        }
    //A megadott típus alapján visszaadja a kézben lévő lapok közül az optimális megoldást
    //Hogy ne legyen túl tökéletes a játék és "emberi hibát" is mutasson esélyt rá hogy random döntsön
    //TODO: Képességeket is nézze és vegye számításba
    public static int ChooseRightCard(List <Card> cardsInHand, CardStatType type)
    {
        int choiceValue = UnityEngine.Random.Range(1, randomMaxTreshold);

        //Véletlen döntés
        if (choiceValue < randomMaxTreshold * errorTreshold)
        {
            return(UnityEngine.Random.Range(0, cardsInHand.Count - 1));
        }

        //"Okos" döntés
        else
        {
            int index     = 0;
            int cardValue = 0;

            foreach (Card card in  cardsInHand)
            {
                if (type == CardStatType.Power && card.GetPower() > cardValue)
                {
                    cardValue = card.GetPower();
                    index     = cardsInHand.IndexOf(card);
                }

                else if (type == CardStatType.Intelligence && card.GetIntelligence() > cardValue)
                {
                    cardValue = card.GetIntelligence();
                    index     = cardsInHand.IndexOf(card);
                }

                else if (type == CardStatType.Reflex && card.GetReflex() > cardValue)
                {
                    cardValue = card.GetReflex();
                    index     = cardsInHand.IndexOf(card);
                }
            }

            return(index);
        }
    }
Example #8
0
        //Megnézi, hogy az ellenfelek kártyáinak a megadott statja magasabb-e mint a mi azonos típusú statunk értéke
        public bool IsMyStatIsTheHighest(int playerKey, int statAmount, CardStatType statType)
        {
            int otherCardStat = 0;

            foreach (int key in GetKeyList())
            {
                //Csak az ellenfelek pályájáól kellenek a lapok
                if (key != playerKey)
                {
                    //Megnézünk minden lapot a pályán
                    foreach (Card card in GetCardsFromPlayer(key, CardListTarget.Field))
                    {
                        //A megadott stat típust nézzük minden alkalommal
                        switch (statType)
                        {
                        case CardStatType.Power: otherCardStat = card.GetPower(); break;

                        case CardStatType.Intelligence: otherCardStat = card.GetIntelligence(); break;

                        case CardStatType.Reflex: otherCardStat = card.GetReflex(); break;

                        default: break;
                        }

                        //Ha az adott kártya megadott értéke magasabb vagy egyenlő: false
                        if (otherCardStat >= statAmount)
                        {
                            return(false);
                        }
                    }
                }
            }

            //Ha végignéztünk mindenkit és nem találtunk magasabbat: true
            return(true);
        }
 public void ReportStatChange(CardStatType stat)
 {
     inputModule.ReportStatChange(stat);
 }
 //A Harctípus választó ablak gombjainak függvénye
 public void ChooseStatButton(CardStatType stat)
 {
     activeStatPanel.SetActive(true);
     Destroy(statPanel);
     ReportStatChange(stat);
 }
Example #11
0
 public void ReportStatChoice(CardStatType choice)
 {
     client.ReportStatChange(choice);
 }
    //Az új információk birtokában megváltoztatja vagy sem a harc típusát
    //TODO: AI stuff
    public static CardStatType ChangeFightType(List <Card> activeCards, List <PlayerCardPairs> opponentCards, CardStatType currentStat)
    {
        int result = UnityEngine.Random.Range(0, 2);

        switch (result)
        {
        case 0: return(CardStatType.Power);

        case 1: return(CardStatType.Intelligence);

        case 2: return(CardStatType.Reflex);

        default: return(currentStat);
        }
    }
 //Megadja, hogy váltson-e ki a gép, vagy tartsa benn a kártyáját
 //TODO: AI stuff
 public static int HandSwitch(List <Card> cardsInHand, List <Card> activeCards, List <PlayerCardPairs> opponentCards, CardStatType stat)
 {
     return(UnityEngine.Random.Range(0, cardsInHand.Count - 1));
 }
Example #14
0
 //Megváltoztatja a harc típusát egy megadott értékre
 public void SetActiveStat(CardStatType newStat)
 {
     modules.GetGameModule().SetActiveStat(newStat);
     modules.GetClientModule().RefreshStatDisplay();
 }
 public void SetActiveStat(CardStatType newStat)
 {
     this.currentStat = newStat;
 }