Example #1
0
    /// <summary>
    /// Conditionally Removes an invader based on the Total # of invaders in a space
    /// </summary>
    static async Task RemoveInvaderWhenMax(FearCtx ctx, int invaderMax, params TokenClass[] removeableInvaders)
    {
        foreach (var spirit in ctx.Spirits)
        {
            var options = spirit.AllSpaces.Where(s => {
                TokenCountDictionary counts = ctx.GameState.Tokens[s];
                return(counts.HasAny(removeableInvaders) && counts.InvaderTotal() <= invaderMax);
            }).ToArray();
            if (options.Length == 0)
            {
                return;
            }

            await spirit.RemoveTokenFromOneSpace(options, 1, removeableInvaders);
        }
    }