public IEnumerable <Focus> GetFocusPlayers(TimeSpan now, Replay replay)
        {
            if (replay == null)
            {
                throw new ArgumentNullException(nameof(replay));
            }

            foreach (var unit in replay.Units.Where(unit => unit.TimeSpanBorn == TimeSpan.Zero && unit.TimeSpanDied == now && gameData.GetUnitGroup(unit.Name) == Unit.UnitGroup.Structures && unit.PlayerKilledBy != null))
            {
                var weighting = unit.Name switch
                {
                    string name when name.StartsWith(TownWallUnit) => settings.Weights.TownWall,
                    string name when name.StartsWith(TownGateUnit) => settings.Weights.TownGate,
                    string name when name.StartsWith(TownCannonUnit) => settings.Weights.TownCannon,
                    string name when name.StartsWith(TownMoonwellUnit) => settings.Weights.TownMoonWell,
                    string name when name.StartsWith(TownHallFortKeepUnit) => settings.Weights.TownTownHall,
                    string name when gameData.CoreUnits.Any(core => name.Equals(core)) => settings.Weights.Core,
                    _ => settings.Weights.Structure
                };

                yield return(new Focus(
                                 GetType(),
                                 unit,
                                 unit.PlayerKilledBy,
                                 weighting,
                                 $"{unit.PlayerKilledBy.Character} destroyed {unit.Name}"));
            }
        }
    }
Esempio n. 2
0
        public IEnumerable <Focus> GetPlayers(TimeSpan now, Replay replay)
        {
            foreach (var unit in replay.Units.Where(unit => unit.TimeSpanBorn == TimeSpan.Zero && unit.TimeSpanDied == now && gameData.GetUnitGroup(unit.Name) == Unit.UnitGroup.Structures && unit.PlayerKilledBy != null))
            {
                var points = unit.Name switch
                {
                    string name when name.StartsWith("TownWall") => 200,
                    string name when name.StartsWith("TownGate") => 400,
                    string name when name.StartsWith("TownCannon") => 600,
                    string name when name.StartsWith("TownMoonwell") => 800,
                    string name when name.StartsWith("TownTownHall") => 1000,
                    string name when gameData.CoreUnits.Any(core => name.Equals(core)) => 10000
                };

                yield return(new Focus(GetType(), unit, unit.PlayerKilledBy, settings.Weights.DestroyStructure + points, $"{unit.PlayerKilledBy.HeroId} destroyed {unit.Name}"));
            }
        }
    }