예제 #1
0
        public void tryToRecoverCondition()
        {
            if (this.currentConditions.Count == 0)
            {
                return;
            }

            List <Condition> cdnsToRemove = new List <Condition>();

            string key;
            int    currentModifier;

            foreach (Condition cdn in this.currentConditions)
            {
                key             = DnDCalculator.determineSavingThrowKey(cdn);
                currentModifier = DnDCalculator.determineModifier(this.stats[key]);
                bool savingThrowSuccess = DnDCalculator.savingThrow(currentModifier);
                if (savingThrowSuccess)
                {
                    cdnsToRemove.Add(cdn);
                }
            }

            //This is done to avoid in place modifiction of our collection:
            foreach (Condition cdn in cdnsToRemove)
            {
                Debug.Log(this.name + " REMOVED CONDITION : " + cdn);
                this.currentConditions.Remove(cdn);
            }
            Debug.Log("STOP ROUND");
        }
예제 #2
0
        private int rollForDamage(Pokemon player)
        {
            System.Random rand     = new System.Random();
            string        key      = DnDCalculator.determineStat(this.attackType);
            int           stat     = player.stats[key];
            int           modifier = DnDCalculator.determineModifier(stat);

            return(rand.Next(this.threshold.lower + modifier, this.threshold.upper));
        }
예제 #3
0
        public void addCondition(Condition cdn, PokeType attackType)
        {
            string key              = DnDCalculator.determineSavingThrowKey(cdn);
            int    modifier         = DnDCalculator.determineModifier(this.stats[key]);
            bool   isSuperEffective = determineIsSuperEffective(attackType);

            if (isSuperEffective)
            {
                modifier -= 2;
            }
            //Determine if saving throw succeeds:
            bool savingThrowSuccess = DnDCalculator.savingThrow(modifier);

            if (!savingThrowSuccess && !this.currentConditions.Contains(cdn))
            {
                this.currentConditions.AddLast(cdn);
            }
        }