コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
ファイル: BotRunner.cs プロジェクト: net-daemon/daemonbot
    public BotResult HelpMessage()
    {
        var result = new BotResult()
        {
            Title = "Help",
        };

        result.Fields.Add(("Usage", "Type command to bot user or in the bot channel"));

        var builder = new StringBuilder();

        // builder.AppendLine("**Commands:**");
        builder.AppendLine(">>> - **help**, displays this message :smile:");

        foreach (var plugin in _plugins)
        {
            var pluginCommands = plugin.GetCommandsAndDecriptions();
            if (pluginCommands is object)
            {
                foreach (var(command, description) in pluginCommands)
                {
                    builder.AppendLine($" - **{command}**, {description}");
                }
            }
        }
        result.Fields.Add(("Commands", builder.ToString()));

        return(result);
    }
コード例 #5
0
ファイル: EmptyMove.cs プロジェクト: Djohnnie/CSharpWars
    public override BotResult Go()
    {
        // Build result based on current properties.
        var botResult = BotResult.Build(BotProperties);

        botResult.Move = BotProperties.CurrentMove;

        return(botResult);
    }
コード例 #6
0
        public override BotResult Go()
        {
            var botResult = new BotResult(BotProperties)
            {
                Move = BotProperties.CurrentMove
            };

            return(botResult);
        }
コード例 #7
0
        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();
        }
コード例 #8
0
ファイル: RangedAttack.cs プロジェクト: Djohnnie/CSharpWars
    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);
    }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: MeleeAttack.cs プロジェクト: swipswaps/CSharpWars
        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);
        }
コード例 #11
0
        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);
        }
コード例 #12
0
        private void GetBotReponse(IUserResponse message)
        {
            ChatResult result;

            if (currentUser == null)
            {
                result = bot.Chat(message.Text);
            }
            else
            {
                result = bot.Chat(new ChatRequest(message.Text, currentUser));
            }

            Console.WriteLine("PrintMessage: " + result.BotMessage);

            IBotResult botResponse = new BotResult(result, message);

            hub.Publish <IBotResult>(botResponse);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: Teleport.cs プロジェクト: swipswaps/CSharpWars
        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);
        }