Example #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");
        }
Example #2
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);
            }
        }