Exemplo n.º 1
0
    /// <summary>
    /// Restores all of the tokens to their default / healthy state.
    /// </summary>
    static public void HealTokens(TokenCountDictionary counts)
    {
        void RestoreAllToDefault(Token token)
        {
            if (token is not HealthToken ht || ht.Damage == 0)
            {
                return;
            }
            int num = counts[token];

            counts.Adjust(ht.Healthy, num);
            counts.Adjust(token, -num);
        }

        void HealGroup(TokenClass group)
        {
            foreach (var token in counts.OfType(group).ToArray())
            {
                RestoreAllToDefault(token);
            }
        }

        HealGroup(Invader.City);
        HealGroup(Invader.Town);
        HealGroup(TokenType.Dahan);
    }
Exemplo n.º 2
0
 static public bool Has(this TokenCountDictionary counts, TokenClass inv)
 => counts.OfType(inv).Any();
Exemplo n.º 3
0
 static public int Sum(this TokenCountDictionary counts, TokenClass generic)
 => counts.OfType(generic).Sum(k => counts[k]);