Esempio n. 1
0
    public HealthToken(HealthTokenClass tokenClass, int fullHealth, int damage = 0, int strifeCount = 0)
    {
        Class       = tokenClass;
        FullHealth  = fullHealth;
        Damage      = damage;
        StrifeCount = strifeCount;

        _summaryString = Initial + "@" + RemainingHealth
                         + (strifeCount == 0 ? "" : new string( '^', StrifeCount ));
    }
Esempio n. 2
0
    public async Task <int> Destroy(int countToDestroy, HealthTokenClass invaderClass)
    {
        countToDestroy = Math.Min(countToDestroy, Tokens.Sum(invaderClass));
        int remaining = countToDestroy;         // capture

        while (remaining > 0)
        {
            var next = Tokens.OfType(invaderClass).Cast <HealthToken>()
                       .OrderByDescending(x => x.FullHealth)
                       .ThenBy(x => x.StrifeCount)
                       .ThenBy(x => x.Damage)
                       .First();
            remaining -= await Destroy(remaining, next);
        }

        return(countToDestroy);
    }
Esempio n. 3
0
    public async Task <string> Exec(
        BuildingEventArgs args,
        TokenCountDictionary tokens,
        GameState gameState
        )
    {
        if (!tokens.HasInvaders())
        {
            return("No invaders");
        }

        BuildingEventArgs.BuildType buildType = args.GetBuildType(tokens.Space);

        this.tokens    = tokens;
        this.buildType = buildType;
        this.gameState = gameState;

        if (await StopBuildWithDiseaseBehavior())
        {
            return(tokens.Space.Label + " build stopped by disease");
        }

        // Determine type to build
        int townCount = tokens.Sum(Invader.Town);
        int cityCount = tokens.Sum(Invader.City);
        HealthTokenClass invaderToAdd = townCount > cityCount ? Invader.City : Invader.Town;

        // check if we should
        bool shouldBuild = buildType switch {
            BuildingEventArgs.BuildType.CitiesOnly => invaderToAdd == Invader.City,
            BuildingEventArgs.BuildType.TownsOnly => invaderToAdd == Invader.Town,
            _ => true,
        };

        // build it
        if (shouldBuild)
        {
            await tokens.AddDefault(invaderToAdd, 1, AddReason.Build);
        }

        return(invaderToAdd.Label);
    }
Esempio n. 4
0
 public DahanGroupBinding(TokenCountDictionary tokens, RemoveReason destoryReason = RemoveReason.Destroyed)
 {
     _tokens        = tokens;
     _tokenGroup    = TokenType.Dahan;
     _destroyReason = destoryReason;
 }
Esempio n. 5
0
 HealthToken IIslandTokenApi.GetDefault(HealthTokenClass tokenClass) => TokenDefaults[tokenClass];