public OccupiedCastleEvent(string userId, Guid castleId, BattleLogAggregate log, DateTime runningAt) : base(string.IsNullOrEmpty(userId) ? Guid.NewGuid().ToString() : userId, runningAt, runningAt) { OwnerUserId = userId; CastleId = castleId; BattleLog = log; }
public OccupiedSiegeInCastleEvent(string userId, Guid castleId, BattleLogAggregate battle, List <SoldierAggregate> soldiers, DateTime runningAt) : base(string.IsNullOrEmpty(userId) ? Guid.NewGuid().ToString() : userId, runningAt, runningAt) { CastleId = castleId; Soldiers = soldiers; BattleLog = battle; }
public FailedAttackSiegeEvent(string userId, Guid castleId, BattleLogAggregate log) : base(userId, DateTime.UtcNow, DateTime.UtcNow) { CastleId = castleId; BattleLog = log; }
public DefendedSiegeEvent(Guid castleId, BattleLogAggregate log, string createdBy) : base(createdBy, DateTime.UtcNow, DateTime.UtcNow) { CastleId = castleId; BattleLog = log; }
public CastleHasBeenOccupiedEvent(string userId, Guid castleId, BattleLogAggregate log, DateTime runningAt) : base(userId, runningAt, runningAt) { CastleId = castleId; BattleLog = log; }
public DefendedCastleEvent(string userId, Guid castleId, BattleLogAggregate log, DateTime runningAt) : base(userId, runningAt, runningAt) { CastleId = castleId; BattleLog = log; }
public FailedAttackCastleEvent(string userId, Guid castleId, BattleLogAggregate log, DateTime runningAt) : base(string.IsNullOrEmpty(userId) ? Guid.NewGuid().ToString() : userId, runningAt, runningAt) { CastleId = castleId; BattleLog = log; }
public BattleLogAggregate AttackSequence(Guid id, CastleAggregate atCastle, string attackingId, string defendingId, List <SoldierAggregate> attacking, List <SoldierAggregate> defending, int attackingBooststrength = 0, int defendingBooststrength = 0) { int dIndex = 0, aIndex = 0; var battle = new BattleLogAggregate { Id = id, // clone object Attacking = attacking.Select(e => new SoldierAggregate() { Id = e.Id, IsDead = e.IsDead, CastleTroopType = e.CastleTroopType == null ? null : new CastleTroopType() { AttackStrength = e.CastleTroopType.AttackStrength, Health = e.CastleTroopType.Health, MovementSpeed = e.CastleTroopType.MovementSpeed, ProductionSpeed = e.CastleTroopType.ProductionSpeed, ResourceType = e.CastleTroopType.ResourceType, Icon = e.CastleTroopType.Icon, RedArmyIcon = e.CastleTroopType.RedArmyIcon, BlueArmyIcon = e.CastleTroopType.BlueArmyIcon } }).ToList(), Defending = defending.Select(e => new SoldierAggregate() { Id = e.Id, IsDead = e.IsDead, CastleTroopType = e.CastleTroopType == null ? null : new CastleTroopType() { AttackStrength = e.CastleTroopType.AttackStrength, Health = e.CastleTroopType.Health, MovementSpeed = e.CastleTroopType.MovementSpeed, ProductionSpeed = e.CastleTroopType.ProductionSpeed, ResourceType = e.CastleTroopType.ResourceType, Icon = e.CastleTroopType.Icon, RedArmyIcon = e.CastleTroopType.RedArmyIcon, BlueArmyIcon = e.CastleTroopType.BlueArmyIcon } }).ToList(), Logs = new List <BattleAttackingLogAggregate>() }; while (dIndex < defending.Count && aIndex < attacking.Count) { // defending attack attacking var hit = R.NextDouble(); var wallStrength = attacking[aIndex].CastleTroopType.IsOverComeWalls ? 0 : atCastle.Strength; attacking[aIndex].CastleTroopType.Health -= Math.Round(hit * defending[dIndex].CastleTroopType.AttackStrength + defendingBooststrength + wallStrength, MidpointRounding.AwayFromZero); battle.Logs.Add(new BattleAttackingLogAggregate() { OwnerUserId = defendingId, AttackingSoldierId = defending[dIndex].Id, DefendingSoldierId = attacking[aIndex].Id, Hit = hit, Booststrength = defendingBooststrength, WallStrength = wallStrength }); if (attacking[aIndex].CastleTroopType.Health <= 0) { aIndex++; } if (aIndex >= attacking.Count) { break; } // attacking attack defending hit = R.NextDouble(); defending[dIndex].CastleTroopType.Health -= Math.Round(hit * attacking[aIndex].CastleTroopType.AttackStrength + attackingBooststrength, MidpointRounding.AwayFromZero); battle.Logs.Add(new BattleAttackingLogAggregate() { OwnerUserId = attackingId, AttackingSoldierId = attacking[aIndex].Id, DefendingSoldierId = defending[dIndex].Id, Hit = hit, Booststrength = attackingBooststrength }); if (defending[dIndex].CastleTroopType.Health <= 0) { dIndex++; } } return(battle); }
public SiegeHasBeenOccupiedEvent(string userId, Guid castleId, BattleLogAggregate battle, DateTime runningAt) : base(userId, runningAt, runningAt) { CastleId = castleId; BattleLog = battle; }