Example #1
0
        public void BuffSpellTest()
        {
            // Set up
            Monster monster = new Monster();

            string[] buffSpells = { "BSRK", "HAST", "AURA", "BARR", "BLNK", "SAFE", "SHEL", "WALL", "Drink" };
            // Ignore Spirit and Intelligence for now as they may be irrelevant

            // Cast each spell and ensure they add the right buff and return the right result message
            foreach (string name in buffSpells)
            {
                Spell spell = SpellManager.GetSpellByName(name);
                Buff  buff  = (Buff)Enum.Parse(typeof(Buff), spell.Status);
                spell.Accuracy = 255;

                SpellResult res = SpellManager.CastSpell(monster, monster, spell, 1);
                Assert.IsTrue(monster.GetBuffStacks(buff) > 0);
                monster.RemoveBuff(buff);
                Assert.AreEqual(0, monster.GetBuffStacks(buff));

                // AURA and BARR have unique messages and are covered in other tests
                if (spell.Name == "AURA" || spell.Name == "BARR")
                {
                    continue;
                }
                Assert.AreEqual(spell.SuccessMessage, res.Results[0]);
            }
        }
    private IEnumerator CastSpell()
    {
        areaOfEffect.On(crystalColor * 0.3f);                                   // Show area
        yield return(new WaitForSeconds(spellSelfStun));                        // Allow spell aiming while self-stunned

        areaOfEffect.Off();                                                     // Hide area

        // Start spell coroutine
        StartCoroutine(SpellEffect());
        Casting = false;

        // If other player was hit
        var hits = Physics.OverlapSphere(areaOfEffect.transform.position, areaCollider.radius, 1 << 14);

        if (hits.Any(c => c.name == other.name))
        {
            // Notify that spell was a hit
            spellResult = SpellResult.Hit;
            Tutorial.SetCheckFor(ID, Tutorial.Phases.Casting_Spells, true);
        }
        else
        {
            spellResult = SpellResult.Missed;
        }
    }
Example #3
0
        public void LIFETest()
        {
            // Setup
            Monster monster = new Monster();

            monster.HP = monster.HPMax = 100;
            Spell spell = SpellManager.GetSpellByName("LIFE");

            spell.Accuracy = 255;

            // Ensure LIFE has no effect normally
            SpellResult resFail = SpellManager.CastSpell(monster, monster, spell, 16);

            Assert.AreEqual("Ineffective", resFail.Results[0]);

            // Ensure LIFE fails if multi-casted, even against undead
            monster.Families.Add(MonsterFamily.Undead);
            Assert.AreEqual("Ineffective", SpellManager.CastSpell(monster, monster, spell, 16, true).Results[0]);
            Assert.AreEqual("Ineffective", SpellManager.CastSpell(monster, monster, spell, 16, true).Results[0]);
            Assert.AreEqual("Ineffective", SpellManager.CastSpell(monster, monster, spell, 16, true).Results[0]);
            Assert.AreEqual("Ineffective", SpellManager.CastSpell(monster, monster, spell, 16, true).Results[0]);
            Assert.AreEqual("Ineffective", SpellManager.CastSpell(monster, monster, spell, 16, true).Results[0]);
            Assert.AreEqual("Ineffective", SpellManager.CastSpell(monster, monster, spell, 16, true).Results[0]);
            Assert.IsFalse(monster.IsDead());

            // Ensure LIFE kills undead creatures
            monster.Name = "Spooky Ghost";
            SpellResult resUndead = SpellManager.CastSpell(monster, monster, spell, 16);

            Assert.AreEqual(monster.Name + " fell", resUndead.Results[0]);
            Assert.AreEqual("Collapsed", resUndead.Results[1]);
            Assert.IsTrue(monster.IsDead());

            // TODO: Ensure proper messages are returned
        }
Example #4
0
        public void BARRTest()
        {
            // Setup
            Monster monster = new Monster();
            Spell   spell   = SpellManager.GetSpellByName("BARR");

            spell.Accuracy = 255;
            string[] expectedMessages = { "Fire", "Soul", "Bolt", "Death", "Poison", "Critical Hit!", "Ice" };
            for (int i = 0; i < expectedMessages.Length; i++)
            {
                expectedMessages[i] += " Df";
            }

            // Test SpellResult messages and ensure they're there and in order
            // Iterate starting at index n and move towards the end, testing in that order
            for (int i = 0; i < (expectedMessages.Length - 1); i++)
            {
                SpellResult res        = SpellManager.CastSpell(monster, monster, spell, i + 1);
                int         startIndex = (expectedMessages.Length - 1) - i;
                int         endIndex   = (expectedMessages.Length - 1);
                for (int j = startIndex, ii = 0; j <= endIndex; j++, ii++)
                {
                    Assert.AreEqual(expectedMessages[j], res.Results[ii]);
                }
            }
        }
Example #5
0
        public void AURATest()
        {
            // Setup
            Monster monster = new Monster();
            Spell   spell   = SpellManager.GetSpellByName("AURA");

            spell.Accuracy = 255;
            string[] expectedMessages = { "Red", "Orange", "Blue", "Black", "Green", "Yellow", "White" };
            for (int i = 0; i < expectedMessages.Length; i++)
            {
                expectedMessages[i] += " Aura";
            }

            // Test SpellResult messages and ensure they're there and in order
            // Iterate starting at index n and move towards the end, testing in that order
            for (int i = 0; i < (expectedMessages.Length - 1); i++)
            {
                SpellResult res        = SpellManager.CastSpell(monster, monster, spell, i + 1);
                int         startIndex = (expectedMessages.Length - 1) - i;
                int         endIndex   = (expectedMessages.Length - 1);
                for (int j = startIndex, ii = 0; j <= endIndex; j++, ii++)
                {
                    Assert.AreEqual(expectedMessages[j], res.Results[ii]);
                }
            }
        }
Example #6
0
        public void PEEPTest()
        {
            // Setup
            Monster monster = new Monster();
            Spell   spell   = SpellManager.GetSpellByName("PEEP");

            spell.Accuracy = 255;
            TempStatus[] tempStatOrder = { TempStatus.Venom, TempStatus.Sleep, TempStatus.Mini, TempStatus.Mute, TempStatus.Paralysis, TempStatus.Confuse };
            Dictionary <TempStatus, string> expectedMessages = new Dictionary <TempStatus, string>();

            expectedMessages[TempStatus.Venom]     = "Devenomed";
            expectedMessages[TempStatus.Sleep]     = "Scared"; // TODO: Verify this message
            expectedMessages[TempStatus.Paralysis] = "Can move";
            expectedMessages[TempStatus.Mute]      = "Can speak";
            expectedMessages[TempStatus.Confuse]   = "Normal";
            expectedMessages[TempStatus.Mini]      = "Grew";

            // Cast spells up to max spell level, and check that only the proper statuses are removed
            for (int i = 0; i < 16; i++)
            {
                foreach (TempStatus stat in tempStatOrder)
                {
                    monster.AddTempStatus(stat);
                }
                SpellManager.CastSpell(monster, monster, spell, i + 1);
                // Level 1 removes both Venom and Sleep
                Assert.IsFalse(monster.HasTempStatus(tempStatOrder[0]));
                for (int j = 1; j < (i < 5 ? i : 5); j++)
                {
                    Assert.IsFalse(monster.HasTempStatus(tempStatOrder[j]));
                }
                for (int k = i + 1; k < tempStatOrder.Length; k++)
                {
                    Assert.IsTrue(monster.HasTempStatus(tempStatOrder[k]));
                }
            }

            // Check that results messages return expected values
            foreach (TempStatus status in tempStatOrder)
            {
                monster.AddTempStatus(status);
                SpellResult result = SpellManager.CastSpell(monster, monster, spell, 16);
                Assert.AreEqual(expectedMessages[status], result.Results[0]);
            }

            // Ensure multiple results messages are returned if multiple statuses are cured
            TempStatus[] multStat = { TempStatus.Confuse, TempStatus.Sleep, TempStatus.Venom };
            foreach (TempStatus status in multStat)
            {
                monster.AddTempStatus(status);
            }
            SpellResult res = SpellManager.CastSpell(monster, monster, spell, 16);

            Assert.AreEqual(3, res.Results.Count);
            foreach (TempStatus status in multStat)
            {
                Assert.IsTrue(res.Results.Contains(expectedMessages[status]));
            }
        }
    private IEnumerator WaitSpellCD()
    {
        // Just wait until CD is over
        yield return(new WaitForSeconds(spellCooldown));

        SwitchCrystal(value: true);
        spellResult = SpellResult.Undefined;
        RemoveCC("-> Spell");
    }
Example #8
0
        public void HEALTest()
        {
            // Setup
            Spell   spell   = SpellManager.GetSpellByName("HEAL");
            Monster monster = new Monster();

            PermStatus[] permStatOrder = { PermStatus.Darkness, PermStatus.Poison, PermStatus.Curse, PermStatus.Amnesia, PermStatus.Toad, PermStatus.Stone, PermStatus.KO };
            Dictionary <PermStatus, string> expectedMessages = new Dictionary <PermStatus, string>();

            expectedMessages[PermStatus.Darkness] = "Can see";
            expectedMessages[PermStatus.Poison]   = "Poison left";
            expectedMessages[PermStatus.Curse]    = "Uncursed";
            expectedMessages[PermStatus.Amnesia]  = "Remembers";
            expectedMessages[PermStatus.Toad]     = "Regained form";
            expectedMessages[PermStatus.Stone]    = "Normal body";
            expectedMessages[PermStatus.KO]       = ""; // TODO: Find this message

            // Cast spells up to max spell level, and check that only the proper statuses are removed
            for (int i = 0; i < 16; i++)
            {
                foreach (PermStatus stat in permStatOrder)
                {
                    monster.AddPermStatus(stat);
                }
                SpellManager.CastSpell(monster, monster, spell, i + 1);
                for (int j = 0; j < (i < 7 ? i : 7); j++)
                {
                    Assert.IsFalse(monster.HasPermStatus(permStatOrder[j]));
                }
                for (int k = i + 1; k < permStatOrder.Length; k++)
                {
                    Assert.IsTrue(monster.HasPermStatus(permStatOrder[k]));
                }
            }

            // Check that results messages return expected values
            foreach (PermStatus stat in permStatOrder)
            {
                monster.AddPermStatus(stat);
                SpellResult result = SpellManager.CastSpell(monster, monster, spell, 16);
                Assert.AreEqual(expectedMessages[stat], result.Results[0]);
            }

            // Ensure multiple results messages are returned if multiple statuses are cured
            PermStatus[] multStat = { PermStatus.Amnesia, PermStatus.Poison, PermStatus.Curse };
            foreach (PermStatus status in multStat)
            {
                monster.AddPermStatus(status);
            }
            SpellResult res = SpellManager.CastSpell(monster, monster, spell, 16);

            Assert.AreEqual(3, res.Results.Count);
            foreach (PermStatus status in multStat)
            {
                Assert.IsTrue(res.Results.Contains(expectedMessages[status]));
            }
        }
        /// <summary>
        /// Checks spelling in specified text fragments. For each fragment returns a separate array error prompts.
        /// <see href="https://tech.yandex.ru/speller/doc/dg/reference/checkTexts-docpage/" />.
        /// </summary>
        public SpellResult[] CheckTexts(string[] text, string lang, int options, string format)
        {
            if (text == null)
            {
                throw new ArgumentNullException("text");
            }
            if (lang == null)
            {
                throw new ArgumentNullException("lang");
            }
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }

            IRestRequest request = new RestRequest("checkTexts", Method.POST);

            foreach (string s in text)
            {
                request.AddParameter("text", s);
            }

            if (!string.IsNullOrEmpty(lang))
            {
                request.AddParameter("lang", lang);
            }
            if (!string.IsNullOrEmpty(format))
            {
                request.AddParameter("format", format);
            }
            request.AddParameter("options", options);

            IRestResponse <List <List <Error> > > response = _restClient.Execute <List <List <Error> > >(request);

            if (!ReferenceEquals(response.ErrorException, null))
            {
                throw response.ErrorException;
            }

            var results = new SpellResult[text.Length];

            for (int i = 0; i < results.Length; i++)
            {
                results[i] = new SpellResult {
                    Errors = response.Data[i]
                };
                results[i].Errors.ForEach(x => x.Row = i);
            }
            return(results);
        }
Example #10
0
        private bool SpellMessageReturn(Spell spell)
        {
            Monster monster = new Monster();

            monster.Name   = "Bob";
            spell.Accuracy = 255;
            SpellResult res = SpellManager.CastSpell(monster, monster, spell, 16);

            if (spell.Status == "KO")
            {
                return(string.Equals("Bob fell", res.Results[0]) && string.Equals(spell.SuccessMessage, res.Results[1]));
            }

            return(string.Equals(spell.SuccessMessage, res.Results[0]));
        }
Example #11
0
 private void CheckResult()
 {
     if (lineRenderer.positionCount != 0)
     {
         lineRenderer.positionCount = 0;
         SpellResult spellResult = SpellManager.GetSpell();
         if (spellResult == null)
         {
             magicCircleHandler.CastFailed();
         }
         else
         {
             magicCircleHandler.CastSpell(spellResult);
         }
         SpellManager.ResetSpells();
     }
 }
Example #12
0
        public static SpellResult CheckSpelling(string text, Language language, Options options = Options.Default, TextFormat textFormat = TextFormat.Plain)
        {
            Lang lang;

            switch (language)
            {
            case Language.rus: lang = Lang.Ru; break;

            case Language.eng: lang = Lang.En; break;

            default: throw new ArgumentException("Язык только русский или английский", "language");
            }

            IYandexSpeller speller = new YandexSpeller();
            SpellResult    res     = speller.CheckText(text, lang, options, textFormat);

            return(res);
        }
Example #13
0
        public IEnumerator CastExperienceTest()
        {
            yield return(SetUp());

            SpellResult spellResult = new SpellResult()
            {
                Index = 0, Coverage = 1
            };

            magicCircleHandler.CastSpell(spellResult);

            battleManager.DrawFight();

            Assert.AreEqual(ExpType.Cast.GetExp(), mockDataIO.LocalGameData.exp);

            TearDown();

            yield return(null);
        }
    public void CastSpell(SpellResult spellResult)
    {
        SpellData   spellData   = spellHandler.GetSpellData(spellResult.Index);
        GameObject  spell       = Instantiate(spellData.Spell, magicCircle.transform.position, magicCircle.transform.rotation);
        SpellAttack spellAttack = spell.GetComponent <SpellAttack>();

        spellAttack.coverage = spellResult.Coverage;

        spellAttack.SetBattleManager(battleManager, experienceManager);

        cooldownShower.SetUpCoolDown(spellData.Cooldown);
        //Other option: Say: good, lame, awful etc
        SuccessCastSpellWithCoverage?.Invoke(spellResult.Coverage);
        SuccessCastSpellDelegateEvent?.Invoke();

        magicCircleInput.Reset();
        magicCircle.SetActive(false);

        castEffectHandler.CastSpellEffect(spellData.ElementType);
    }
Example #15
0
        public IEnumerator AllExperienceTest()
        {
            yield return(SetUp());

            SpellResult spellResult = new SpellResult()
            {
                Index = 0, Coverage = 1
            };

            magicCircleHandler.CastSpell(spellResult);

            yield return(new WaitForSeconds(10));

            battleManager.RedFighterDied();

            Assert.AreEqual(ExpType.Cast.GetExp() + ExpType.Hit.GetExp() + ExpType.Kill.GetExp(), mockDataIO.LocalGameData.exp);

            TearDown();

            yield return(null);
        }
Example #16
0
    public SpellResult GetSpell()
    {
        List <CoverageResult> coverageResults = new List <CoverageResult>();

        int   index = defaultUnchangedValue;
        float max   = defaultUnchangedValue;

        for (int i = 0; i < recognizeablePatterns.Count; i++)
        {
            float result      = recognizeablePatterns[i].Pattern.GetResult();
            float minCoverage = recognizeablePatterns[i].Pattern.GetMinCoverage();

            coverageResults.Add(new CoverageResult(recognizeablePatterns[i].Id, result, minCoverage));

            if ((minCoverage <= result) && (result > max))
            {
                index = recognizeablePatterns[i].Id;
                max   = result;
            }
        }

        Recognize?.Invoke(coverageResults);

        if (index != defaultUnchangedValue)
        {
            SpellResult spellResult = new SpellResult
            {
                Index    = index,
                Coverage = max,
            };

            return(spellResult);
        }
        else
        {
            return(null);
        }
    }
Example #17
0
 public static SpellResult CreateSpellResult(global::System.Guid ID)
 {
     SpellResult spellResult = new SpellResult();
     spellResult.ID = ID;
     return spellResult;
 }
Example #18
0
 public void AddToSpellResultSet(SpellResult spellResult)
 {
     base.AddObject("SpellResultSet", spellResult);
 }
 public void SpellResultTest()
 {
     // Ensure spellResults act as expected and things stay within bounds
     SpellResult spellRes = new SpellResult();
 }