public void BotResult_Build_From_BotProperties_Should_Copy_Properties() { // Arrange var bot = new BotDto { X = 1, Y = 2, Orientation = PossibleOrientations.East, CurrentHealth = 99, CurrentStamina = 999, Memory = new Dictionary<String, String>().Serialize() }; var arena = new ArenaDto { Width = 1, Height = 1 }; var botProperties = BotProperties.Build(bot, arena, new List<BotDto>()); botProperties.MoveDestinationX = 3; botProperties.MoveDestinationY = 4; // Act var result = BotResult.Build(botProperties); // Assert result.Should().NotBeNull(); result.X.Should().Be(bot.X); result.Y.Should().Be(bot.Y); result.Orientation.Should().Be(bot.Orientation); result.CurrentHealth.Should().Be(bot.CurrentHealth); result.CurrentStamina.Should().Be(bot.CurrentStamina); result.Memory.Should().BeEquivalentTo(bot.Memory.Deserialize<Dictionary<String, String>>()); result.Messages.Should().BeEquivalentTo(new List<String>()); result.Move.Should().Be(PossibleMoves.Idling); result.LastAttackX.Should().Be(botProperties.MoveDestinationX); result.LastAttackY.Should().Be(botProperties.MoveDestinationY); }
public override BotResult Go() { // Build result based on current properties. var botResult = BotResult.Build(BotProperties); botResult.Move = PossibleMoves.TurningRight; switch (BotProperties.Orientation) { case PossibleOrientations.North: botResult.Orientation = PossibleOrientations.East; break; case PossibleOrientations.East: botResult.Orientation = PossibleOrientations.South; break; case PossibleOrientations.South: botResult.Orientation = PossibleOrientations.West; break; case PossibleOrientations.West: botResult.Orientation = PossibleOrientations.North; break; } return(botResult); }
public override BotResult Go() { // Build result based on current properties. var botResult = BotResult.Build(BotProperties); var botsInMaximumVicinity = FindBotsInVicinity(1); var botsInMediumVicinity = FindBotsInVicinity(2); var botsInMinimumVicinity = FindBotsInVicinity(3); foreach (var bot in botsInMinimumVicinity) { botResult.InflictDamage(bot.Id, Constants.SELF_DESTRUCT_MIN_DAMAGE); } foreach (var bot in botsInMediumVicinity) { botResult.InflictDamage(bot.Id, Constants.SELF_DESTRUCT_MED_DAMAGE); } foreach (var bot in botsInMaximumVicinity) { botResult.InflictDamage(bot.Id, Constants.SELF_DESTRUCT_MAX_DAMAGE); } botResult.CurrentHealth = 0; botResult.Move = PossibleMoves.SelfDestruct; return(botResult); }
public override BotResult Go() { // Build result based on current properties. var botResult = BotResult.Build(BotProperties); botResult.Move = BotProperties.CurrentMove; return(botResult); }
public void BotResult_GetInflictedDamage_Should_Return_Zero_For_Unknown_BotId() { // Arrange var bot = new BotDto(); var arena = new ArenaDto(); var botProperties = BotProperties.Build(bot, arena, new List<BotDto>()); var botResult = BotResult.Build(botProperties); // Act var result = botResult.GetInflictedDamage(Guid.NewGuid()); // Assert result.Should().BeZero(); }
public override BotResult Go() { // Build result based on current properties. var botResult = BotResult.Build(BotProperties); var victimizedBot = FindVictimizedBot(); if (victimizedBot != null) { botResult.InflictDamage(victimizedBot.Id, Constants.RANGED_DAMAGE); } botResult.Move = PossibleMoves.RangedAttack; return(botResult); }
public void BotResult_InflictDamage_Once_Should_Correctly_Register_Damage() { // Arrange var bot = new BotDto(); var arena = new ArenaDto(); var botProperties = BotProperties.Build(bot, arena, new List<BotDto>()); var botResult = BotResult.Build(botProperties); var botId = Guid.NewGuid(); var damage = 123; // Act botResult.InflictDamage(botId, damage); // Assert botResult.GetInflictedDamage(botId).Should().Be(damage); }
public override BotResult Go() { // Build result based on current properties. var botResult = BotResult.Build(BotProperties); var victimizedBot = FindVictimizedBot(); if (victimizedBot != null) { var backstab = victimizedBot.Orientation == BotProperties.Orientation; botResult.InflictDamage(victimizedBot.Id, backstab ? Constants.MELEE_BACKSTAB_DAMAGE : Constants.MELEE_DAMAGE); } botResult.Move = PossibleMoves.MeleeAttack; return(botResult); }
public void BotResult_InflictDamage_Twice_Should_Correctly_Register_All_Damage() { // Arrange var bot = new BotDto(); var arena = new ArenaDto(); var botProperties = BotProperties.Build(bot, arena, new List<BotDto>()); var botResult = BotResult.Build(botProperties); var botId = Guid.NewGuid(); var firstDamage = 123; var secondDamage = 234; // Act botResult.InflictDamage(botId, firstDamage); botResult.InflictDamage(botId, secondDamage); // Assert botResult.GetInflictedDamage(botId).Should().Be(firstDamage + secondDamage); }
public override BotResult Go() { // Build result based on current properties. var botResult = BotResult.Build(BotProperties); // Only perform move if enough stamina is available. if (BotProperties.CurrentStamina - Constants.STAMINA_ON_MOVE >= 0) { var destinationX = BotProperties.X; var destinationY = BotProperties.Y; switch (BotProperties.Orientation) { case PossibleOrientations.North: destinationY--; break; case PossibleOrientations.East: destinationX++; break; case PossibleOrientations.South: destinationY++; break; case PossibleOrientations.West: destinationX--; break; } if (!WillCollide(destinationX, destinationY)) { botResult.CurrentStamina -= Constants.STAMINA_ON_MOVE; botResult.Move = PossibleMoves.WalkForward; botResult.X = destinationX; botResult.Y = destinationY; } } return(botResult); }
public override BotResult Go() { // Build result based on current properties. var botResult = BotResult.Build(BotProperties); // Only perform move if enough stamina is available. if (BotProperties.CurrentStamina - Constants.STAMINA_ON_TELEPORT >= 0) { NormalizeDestination(); var victimizedBot = FindVictimizedBot(); if (victimizedBot != null) { botResult.Teleport(victimizedBot.Id, botResult.X, botResult.Y); } botResult.CurrentStamina -= Constants.STAMINA_ON_TELEPORT; botResult.Move = PossibleMoves.Teleport; botResult.X = BotProperties.MoveDestinationX; botResult.Y = BotProperties.MoveDestinationY; } return(botResult); }