Example #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);
    }
Example #2
0
    static async Task DamageInvaderHealthByItsOwnStrife(TokenCountDictionary tokens, HealthToken originalInvader)
    {
        var newInvader = originalInvader.AddDamage(originalInvader.StrifeCount);

        if (newInvader == originalInvader)
        {
            return;
        }

        if (newInvader.IsDestroyed)
        {
            await tokens.Destroy(originalInvader, tokens[originalInvader]);
        }
        else
        {
            tokens.Adjust(newInvader, tokens[originalInvader]);
            tokens.Init(originalInvader, 0);
        }
    }
Example #3
0
    static async Task ReduceInvaderHealthByItsOwnStrife(TokenCountDictionary tokens, HealthToken originalInvader, int minimum)
    {
        int newHealth  = Math.Min(minimum, originalInvader.FullHealth - originalInvader.StrifeCount);
        var newInvader = new HealthToken(originalInvader.Class, newHealth, originalInvader.Damage, originalInvader.StrifeCount);

        if (newInvader == originalInvader)
        {
            return;
        }

        if (newInvader.IsDestroyed)
        {
            await tokens.Destroy(originalInvader, tokens[originalInvader]);
        }
        else
        {
            tokens.Adjust(newInvader, tokens[originalInvader]);
            tokens.Init(originalInvader, 0);
            // !!! Need something at end of turn to restore health.
        }
    }
Example #4
0
 public void Adjust(Token token, int delta) => _tokens.Adjust(token, delta);
Example #5
0
 public void Adjust(int delta) => tokens.Adjust(token, delta);