Exemple #1
0
    /// <summary>
    /// Prompts unit stacks capable of casting unit creation spells to do so
    /// </summary>
    /// <param name="summoners">Unit stacks capable of casting unit creation spells</param>
    /// <returns>Whether a unit creation spell was cast</returns>
    private bool CastUnitCreationSpells(List <UnitStack> summoners)
    {
        bool             result   = false;
        List <UnitStack> monsters = new List <UnitStack>();

        for (int i = 0; i < summoners.Count; i++)
        {
            List <Spell> conjurations = summoners[i].GetUnitType().GetSpellsOfType(Spell.SpellType.UNIT_CREATION);
            Province     origin       = summoners[i].GetProvinceToRetreat();
            for (int j = 0; j < conjurations.Count; j++)
            {
                UnitStack summonedStack = conjurations[j].Create(summoners);
                if (summonedStack != null)
                {
                    result = true;
                    summonedStack.SetProvinceToRetreat(origin);
                    monsters.Add(summonedStack);
                }
            }
        }
        summoners.AddRange(monsters);
        return(result);
    }