/// <summary>
        /// Creates a command to move your character on the playing field.
        /// </summary>
        public void MovePlayer(int x, int y)
        { //TODO: Übergabe der Richtung und Anzahl Schritte
            if (_isConnected)
            {
                if (_gameSession_ID != null && _currentStatus == Status.Busy)
                {
                    CommandGameMove command = new CommandGameMove(_client_ID, x, y);
                    SendCommandToServer(command);

                    CommandFeedback feedback = EvaluateFeedback();
                    if (feedback is CommandFeedbackOK)
                    {
                    }
                    else if (feedback is CommandFeedbackEndOfTurn)
                    {
                        Thread updateThread = new Thread(new ThreadStart(() => WaitForNextTurn()));
                        updateThread.Start();
                    }
                    else if (feedback is CommandFeedbackGameException)
                    {
                        throw ((CommandFeedbackGameException)feedback).GameException;
                    }
                    else
                    {
                        throw new CommandNotRecognizedException();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void TrapTestSpikefield()
        {
            Level level8 = new Level(MAX_PLAYER);

            Hero    player30 = new Hero("hero", new Archer(), 11, 9);
            Monster player31 = new Monster("monster", new Knight(), 7, 7);
            Monster player32 = new Monster("monster", new Knight(), 18, 7);
            Monster player33 = new Monster("monster", new Knight(), 9, 7);

            Field field9 = new Field(12, 9, new SpikeField());

            level8.AddPlayerToLevel(player30);
            level8.AddPlayerToLevel(player31);
            level8.AddPlayerToLevel(player32);
            level8.AddPlayerToLevel(player33);
            level8.AddFieldToLevel(field9);

            CommandManager cm5 = new CommandManager();

            CommandGameMove cmove = new CommandGameMove("2f2de19a291c41b5ae950faa11162e07", 12, 9);

            cmove.SourcePlayer = player30;
            cmove.Level        = level8;

            cm5.AddCommand(cmove);
            cm5.ProcessPendingTransactions();

            Assert.AreEqual(4, player30.Life);
        }
Ejemplo n.º 3
0
        public void TrapTestLaserbeam()
        {
            Level level9 = new Level(MAX_PLAYER);

            Hero    player34 = new Hero("hero", new Archer(), 11, 9);
            Monster player35 = new Monster("monster", new Knight(), 7, 7);
            Monster player36 = new Monster("monster", new Knight(), 18, 7);
            Monster player37 = new Monster("monster", new Knight(), 9, 7);

            Field field10 = new Field(12, 9, new LaserBeam(true));

            level9.AddPlayerToLevel(player34);
            level9.AddPlayerToLevel(player35);
            level9.AddPlayerToLevel(player36);
            level9.AddPlayerToLevel(player37);
            level9.AddFieldToLevel(field10);

            CommandManager cm6 = new CommandManager();

            CommandGameMove cmove13 = new CommandGameMove("2f2de19a291c41b5ae950faa11162e07", 12, 9);

            cmove13.SourcePlayer = player34;
            cmove13.Level        = level9;

            cm6.AddCommand(cmove13);
            cm6.ProcessPendingTransactions();

            Assert.AreEqual(3.5, player34.Life);
        }
Ejemplo n.º 4
0
        public void MonsterCantCollecteKey()
        {
            Level level11 = new Level(MAX_PLAYER);

            Monster player7 = new Monster("monster", new Archer(), 10, 10);
            Field   field22 = new Field(10, 11, new Floor());

            field22.Item = Key.GetInstance();
            level11.AddPlayerToLevel(player7);
            level11.AddFieldToLevel(field22);
            field22.Item.IsVisible = true;
            Assert.IsTrue(field22.Item.IsVisible);

            CommandGameMove cmove2 = new CommandGameMove("23156asd1a56sd", 10, 11);

            cmove2.SourcePlayer = player7;
            cmove2.Level        = level11;

            CommandManager cm3 = new CommandManager();

            cm3.AddCommand(cmove2);
            cm3.ProcessPendingTransactions();

            Assert.IsFalse(player7.HasKey);
            Assert.IsNotNull(field22.Item);
            Assert.IsTrue(field22.Item is Key);
        }
Ejemplo n.º 5
0
        public void ManualTrapdoorAttackAndTrapHidden()
        {
            Level level7 = new Level(MAX_PLAYER);

            Hero player2 = new Hero("hero", new Archer(), 11, 9);

            Field field2 = new Field(12, 9, new Trapdoor());
            Field field5 = new Field(11, 9, new Floor());

            level7.AddPlayerToLevel(player2);
            level7.AddFieldToLevel(field2);
            level7.AddFieldToLevel(field5);

            CommandManager cm7 = new CommandManager();

            CommandGameMove cmove7 = new CommandGameMove("2f2de19a291c41b5ae950faa11162e07", 12, 9);

            cmove7.SourcePlayer = player2;
            cmove7.Level        = level7;

            cm7.AddCommand(cmove7);

            cm7.ProcessPendingTransactions();

            Assert.AreEqual(4.25, player2.Life);
            Assert.AreEqual(11, player2.XPosition);
            Assert.AreEqual(9, player2.YPosition);
        }
Ejemplo n.º 6
0
        public void HeroCollecteKey()
        {
            Level level12 = new Level(MAX_PLAYER);

            Hero  player8 = new Hero("hero", new Archer(), 10, 10);
            Field field23 = new Field(10, 11, new Floor());

            field23.Item = Key.GetInstance();
            level12.AddPlayerToLevel(player8);
            level12.AddFieldToLevel(field23);
            field23.Item.IsVisible = true;
            Assert.IsTrue(field23.Item.IsVisible);

            CommandGameMove cmove3 = new CommandGameMove("23156asd1a56sd", 10, 11);

            cmove3.SourcePlayer = player8;
            cmove3.Level        = level12;

            CommandManager cm2 = new CommandManager();

            cm2.AddCommand(cmove3);
            cm2.ProcessPendingTransactions();

            Assert.IsTrue(player8.HasKey);
            Assert.IsNull(field23.Item);
        }
Ejemplo n.º 7
0
        public void MoveInRange()
        {
            Hero player12 = new Hero("hero", new Knight(), 16, 12);

            //move down
            CommandGameMove cmove7 = new CommandGameMove("54s56s45df66s", 16, 13);

            cmove7.SourcePlayer = player12;

            Assert.IsTrue(cmove7.VerifyMoveRange());

            //move up
            CommandGameMove cmove8 = new CommandGameMove("54s56s45df66s", 16, 11);

            cmove8.SourcePlayer = player12;

            Assert.IsTrue(cmove8.VerifyMoveRange());

            //move right
            CommandGameMove cmove9 = new CommandGameMove("54s56s45df66s", 17, 12);

            cmove9.SourcePlayer = player12;

            Assert.IsTrue(cmove9.VerifyMoveRange());

            //move left
            CommandGameMove cmove10 = new CommandGameMove("54s56s45df66s", 15, 12);

            cmove10.SourcePlayer = player12;

            Assert.IsTrue(cmove10.VerifyMoveRange());

            //move out of range
            CommandGameMove cmove11 = new CommandGameMove("54s56s45df66s", 16, 14);

            cmove11.SourcePlayer = player12;

            Assert.IsFalse(cmove11.VerifyMoveRange());

            //move out of range
            CommandGameMove cmove12 = new CommandGameMove("54s56s45df66s", 18, 12);

            cmove12.SourcePlayer = player12;

            Assert.IsFalse(cmove12.VerifyMoveRange());

            //move out of range
            CommandGameMove cmove13 = new CommandGameMove("54s56s45df66s", 18, 13);

            cmove13.SourcePlayer = player12;

            Assert.IsFalse(cmove13.VerifyMoveRange());
        }
Ejemplo n.º 8
0
        public void ItemOnTargetField()
        {   //need number of max. clients
            Level level6 = new Level(MAX_PLAYER);

            Monster player13 = new Monster("monster", new Archer(), 2, 3);
            Monster player14 = new Monster("monster", new Archer(), 3, 3);
            Monster player15 = new Monster("monster", new Archer(), 4, 3);

            Hero  player16 = new Hero("hero", new Knight(), 10, 10);
            Field field7   = new Field(10, 11, new Floor());
            Field field8   = new Field(10, 13, new Floor());
            Field field9   = new Field(10, 12, new Floor());

            field7.Item = new DefenseBoost(2);
            field9.Item = new AttackBoost(3);

            level6.AddPlayerToLevel(player13);
            level6.AddPlayerToLevel(player14);
            level6.AddPlayerToLevel(player15);
            level6.AddPlayerToLevel(player16);
            level6.AddFieldToLevel(field7);
            level6.AddFieldToLevel(field8);
            level6.AddFieldToLevel(field9);

            CommandGameMove cmove14 = new CommandGameMove("234hug2haa1248325sdf5", 10, 11);

            cmove14.SourcePlayer = player16;
            cmove14.Level        = level6;

            CommandManager cm3 = new CommandManager();

            cm3.AddCommand(cmove14);
            cm3.ProcessPendingTransactions();

            Assert.AreEqual(0.5, player16.DefenseBoost);
            Assert.AreEqual(null, field7.Item);
            Assert.AreEqual(null, field8.Item);

            CommandGameMove cmove16 = new CommandGameMove("234hug2haa1248325sdf5", 10, 12);

            cmove16.SourcePlayer = player16;
            cmove16.Level        = level6;

            cm3.AddCommand(cmove16);
            cm3.ProcessPendingTransactions();

            Assert.AreEqual(0.75, player16.AttackBoost);
            Assert.AreEqual(null, field9.Item);
        }
Ejemplo n.º 9
0
        public void TrapTargetField()
        {   //need number of max. clients
            Level level7 = new Level(MAX_PLAYER);

            Monster player8  = new Monster("monster", new Archer(), 2, 3);
            Monster player9  = new Monster("monster", new Archer(), 3, 3);
            Monster player10 = new Monster("monster", new Archer(), 4, 3);

            Hero  player11 = new Hero("hero", new Archer(), 10, 10);
            Field field5   = new Field(10, 11, new SpikeField());
            Field field6   = new Field(10, 12, new LaserBeam());

            level7.AddPlayerToLevel(player8);
            level7.AddPlayerToLevel(player9);
            level7.AddPlayerToLevel(player10);
            level7.AddPlayerToLevel(player11);
            level7.AddFieldToLevel(field5);
            level7.AddFieldToLevel(field6);

            field6.FieldType.OnNextRound();

            CommandGameMove cmove5 = new CommandGameMove("2f2de19a291c41b5ae950faa11162e07", 10, 11);

            cmove5.SourcePlayer = player11;
            cmove5.Level        = level7;

            CommandManager cm2 = new CommandManager();

            cm2.AddCommand(cmove5);
            cm2.ProcessPendingTransactions();

            Assert.AreEqual(4, player11.Life);

            CommandGameMove cmove6 = new CommandGameMove("2f2de19a291c41b5ae950faa11162e07", 10, 12);

            cmove6.SourcePlayer = player11;
            cmove6.Level        = level7;
            cm2.AddCommand(cmove6);
            cm2.ProcessPendingTransactions();

            Assert.AreEqual(2.5, player11.Life);
        }
Ejemplo n.º 10
0
        public void CantCollectInvisibleKey()
        {
            Level level10 = new Level(MAX_PLAYER);

            Hero  player6 = new Hero("hero", new Archer(), 10, 10);
            Field field21 = new Field(10, 11, new Floor());

            field21.Item = Key.GetInstance();
            level10.AddPlayerToLevel(player6);
            level10.AddFieldToLevel(field21);

            CommandGameMove cmove1 = new CommandGameMove("23156asd1a56sd", 10, 11);

            cmove1.SourcePlayer = player6;
            cmove1.Level        = level10;

            CommandManager cm1 = new CommandManager();

            cm1.AddCommand(cmove1);
            cm1.ProcessPendingTransactions();

            Assert.IsFalse(player6.HasKey);
        }
Ejemplo n.º 11
0
        public void AttackWithoutRemainingMoves()
        {   //need number of max. clients
            Level level1 = new Level(MAX_PLAYER);

            Hero    player3 = new Hero("hero", new Knight(), 10, 18);
            Monster player4 = new Monster("monster", new Archer(), 8, 14);
            Monster player5 = new Monster("monster", new Knight(), 13, 1);
            Monster player6 = new Monster("monster", new Archer(), 2, 2);
            Field   field1  = new Field(10, 17, new Floor());
            Field   field2  = new Field(9, 17, new SpikeField());
            Field   field3  = new Field(8, 17, new Floor());
            Field   field4  = new Field(8, 16, new Floor());
            Field   field5  = new Field(8, 15, new Floor());

            field3.Item = new AttackBoost(3);

            level1.AddPlayerToLevel(player3);
            level1.AddPlayerToLevel(player4);
            level1.AddPlayerToLevel(player5);
            level1.AddPlayerToLevel(player6);
            level1.AddFieldToLevel(field1);
            level1.AddFieldToLevel(field2);
            level1.AddFieldToLevel(field3);
            level1.AddFieldToLevel(field4);
            level1.AddFieldToLevel(field5);

            CommandManager cm1 = new CommandManager();

            //move to field (10, 17)
            CommandGameMove cmove1 = new CommandGameMove("adua5as7da5sd5", 10, 17);

            cmove1.SourcePlayer = player3;
            cmove1.Level        = level1;
            cm1.AddCommand(cmove1);
            cm1.ProcessPendingTransactions();

            //move to field with trap (9, 17)
            CommandGameMove cmove2 = new CommandGameMove("adua5as7da5sd5", 9, 17);

            cmove2.SourcePlayer = player3;
            cmove2.Level        = level1;
            cm1.AddCommand(cmove2);
            cm1.ProcessPendingTransactions();

            //move to field with item (8, 17)
            CommandGameMove cmove3 = new CommandGameMove("adua5as7da5sd5", 8, 17);

            cmove3.SourcePlayer = player3;
            cmove3.Level        = level1;
            cm1.AddCommand(cmove3);
            cm1.ProcessPendingTransactions();

            //move to field with item (8, 16)
            CommandGameMove cmove4 = new CommandGameMove("adua5as7da5sd5", 8, 16);

            cmove4.SourcePlayer = player3;
            cmove4.Level        = level1;
            cm1.AddCommand(cmove4);
            cm1.ProcessPendingTransactions();

            //move to field with item (8, 15)
            CommandGameMove cmove5 = new CommandGameMove("adua5as7da5sd5", 8, 15);

            cmove5.SourcePlayer = player3;
            cmove5.Level        = level1;
            cm1.AddCommand(cmove5);
            cm1.ProcessPendingTransactions();

            //attack monster (8, 14)
            CommandGameAttack cattack1 = new CommandGameAttack("adua5as7da5sd5", "6a6sd465a4s9");

            cattack1.SourcePlayer = player3;
            cattack1.TargetPlayer = player4;
            cattack1.Level        = level1;
            cm1.AddCommand(cattack1);
            cm1.ProcessPendingTransactions();
        }
Ejemplo n.º 12
0
        public void GameSzenario1()
        {   //need number of max. clients
            Level level1 = new Level(MAX_PLAYER);

            Hero    player3 = new Hero("hero", new Knight(), 10, 18);
            Monster player4 = new Monster("monster", new Archer(), 8, 16);
            Monster player5 = new Monster("monster", new Knight(), 13, 1);
            Monster player6 = new Monster("monster", new Archer(), 2, 2);
            Field   field1  = new Field(10, 17, new Floor());
            Field   field2  = new Field(9, 17, new SpikeField());
            Field   field3  = new Field(8, 17, new Floor());

            field3.Item = new AttackBoost(3);

            CommandManager cm1 = new CommandManager();

            level1.AddPlayerToLevel(player3);
            level1.AddPlayerToLevel(player4);
            level1.AddPlayerToLevel(player5);
            level1.AddPlayerToLevel(player6);
            level1.AddFieldToLevel(field1);
            level1.AddFieldToLevel(field2);
            level1.AddFieldToLevel(field3);

            //move to field (10, 17)
            CommandGameMove cmove1 = new CommandGameMove("adua5as7da5sd5", 10, 17);

            cmove1.SourcePlayer = player3;
            cmove1.Level        = level1;
            cm1.AddCommand(cmove1);
            cm1.ProcessPendingTransactions();

            Assert.AreEqual(4, player3.PlayerRemainingMoves);
            Assert.IsTrue(10 == player3.XPosition && 17 == player3.YPosition);


            //move to field with trap (9, 17)
            CommandGameMove cmove2 = new CommandGameMove("adua5as7da5sd5", 9, 17);

            cmove2.SourcePlayer = player3;
            cmove2.Level        = level1;
            cm1.AddCommand(cmove2);
            cm1.ProcessPendingTransactions();

            Assert.AreEqual(3, player3.PlayerRemainingMoves);
            Assert.IsTrue(9 == player3.XPosition && 17 == player3.YPosition);
            Assert.AreEqual(4.25, player3.Life);


            //move to field with item (8, 17)
            CommandGameMove cmove3 = new CommandGameMove("adua5as7da5sd5", 8, 17);

            cmove3.SourcePlayer = player3;
            cmove3.Level        = level1;
            cm1.AddCommand(cmove3);
            cm1.ProcessPendingTransactions();

            Assert.AreEqual(2, player3.PlayerRemainingMoves);
            Assert.IsTrue(8 == player3.XPosition && 17 == player3.YPosition);
            Assert.AreEqual(0.75, player3.AttackBoost);


            //attack monster (8, 16)
            CommandGameAttack cattack1 = new CommandGameAttack("adua5as7da5sd5", "6a6sd465a4s9");

            cattack1.SourcePlayer = player3;
            cattack1.TargetPlayer = player4;
            cattack1.Level        = level1;
            cm1.AddCommand(cattack1);
            cm1.ProcessPendingTransactions();

            Assert.AreEqual(0, player3.PlayerRemainingMoves);
            Assert.IsTrue(8 == player3.XPosition && 17 == player3.YPosition);
            Assert.IsTrue(8 == player4.XPosition && 16 == player4.YPosition);
            Assert.AreEqual(1.25, player4.Life);
        }
Ejemplo n.º 13
0
        public void InvalidTargetField()
        {
            Level level5 = new Level(MAX_PLAYER);

            //targetfield is equal current field
            Hero  player3 = new Hero("hero", new Knight(), 18, 18);
            Field field1  = new Field(18, 18, new Floor());

            level5.AddPlayerToLevel(player3);
            level5.AddFieldToLevel(field1);

            CommandGameMove cmove1 = new CommandGameMove("2f2de19a291c41b5ae950faa11162e07", 18, 18);

            cmove1.SourcePlayer = player3;
            cmove1.Level        = level5;

            Assert.IsTrue(cmove1.TargetFieldIsInvalid());


            //targetfield is a wall
            Hero  player4 = new Hero("hero", new Knight(), 8, 8);
            Field field2  = new Field(8, 9, new Wall());

            level5.AddPlayerToLevel(player4);
            level5.AddFieldToLevel(field2);

            CommandGameMove cmove2 = new CommandGameMove("2f2de19a291c41b5ae950faa11162e07", 8, 9);

            cmove2.SourcePlayer = player4;
            cmove2.Level        = level5;

            Assert.IsTrue(cmove2.TargetFieldIsInvalid());


            //targetfield is blocked by another player
            Hero    player5 = new Hero("hero", new Knight(), 2, 2);
            Monster player6 = new Monster("monster", new Archer(), 2, 3);
            Field   field3  = new Field(2, 3, new Floor());

            level5.AddPlayerToLevel(player5);
            level5.AddPlayerToLevel(player6);
            level5.AddFieldToLevel(field3);

            CommandGameMove cmove3 = new CommandGameMove("2f2de19a291c41b5ae950faa11162e07", 2, 3);

            cmove3.SourcePlayer = player5;
            cmove3.Level        = level5;

            Assert.IsTrue(cmove3.TargetFieldIsInvalid());


            //targetfield is valid
            Hero  player7 = new Hero("hero", new Knight(), 1, 1);
            Field field4  = new Field(1, 2, new Floor());

            level5.AddPlayerToLevel(player7);
            level5.AddFieldToLevel(field4);

            CommandGameMove cmove4 = new CommandGameMove("2f2de19a291c41b5ae950faa11162e07", 1, 2);

            cmove4.SourcePlayer = player7;
            cmove4.Level        = level5;

            Assert.IsFalse(cmove4.TargetFieldIsInvalid());

            CommandManager cm1 = new CommandManager();

            cm1.AddCommand(cmove4);
            cm1.ProcessPendingTransactions();

            Assert.AreEqual(4, player7.PlayerRemainingMoves);


            //targetfield is diagonal
            Hero  player8 = new Hero("hero", new Knight(), 5, 5);
            Field field5  = new Field(6, 6, new Floor());

            level5.AddPlayerToLevel(player8);
            level5.AddFieldToLevel(field5);

            CommandGameMove cmove5 = new CommandGameMove("5a45dsf5s4as5d4as8", 6, 6);

            cmove5.SourcePlayer = player8;
            cmove5.Level        = level5;

            Assert.IsFalse(cmove5.VerifyMoveRange());
        }
Ejemplo n.º 14
0
        public void SwappingItems()
        {//need number of max. clients
            Hero    player5 = new Hero("hero", new Knight(), 12, 1);
            Monster player6 = new Monster("monster", new Archer(), 2, 3);
            Monster player7 = new Monster("monster", new Archer(), 10, 11);
            Monster player8 = new Monster("monster", new Archer(), 11, 10);
            Field   field3  = new Field(12, 2, new Floor());
            Field   field4  = new Field(12, 3, new Floor());
            Field   field5  = new Field(12, 4, new Floor());

            field3.Item = new DefenseBoost(2);
            field4.Item = new DefenseBoost(3);
            field5.Item = new DefenseBoost(1);

            CommandGameMove cmove3 = new CommandGameMove("1jhb2h48325sdf5", 12, 2);

            cmove3.SourcePlayer = player5;

            Level level1 = new Level(MAX_PLAYER);

            level1.AddPlayerToLevel(player5);
            level1.AddPlayerToLevel(player6);
            level1.AddPlayerToLevel(player7);
            level1.AddPlayerToLevel(player8);
            level1.AddFieldToLevel(field3);
            level1.AddFieldToLevel(field4);
            level1.AddFieldToLevel(field5);

            cmove3.Level = level1;

            CommandManager cm2 = new CommandManager();

            cm2.AddCommand(cmove3);
            cm2.ProcessPendingTransactions();

            Assert.IsNotNull(player5.DefenseItem);
            Assert.AreEqual(0.5, player5.DefenseBoost);
            Assert.IsNull(field3.Item);

            CommandGameMove cmove4 = new CommandGameMove("1jhb2h48325sdf5", 12, 3);

            cmove4.SourcePlayer = player5;
            cmove4.Level        = level1;
            cm2.AddCommand(cmove4);
            cm2.ProcessPendingTransactions();

            Assert.IsNotNull(player5.DefenseItem);
            Assert.AreEqual(0.75, player5.DefenseBoost);
            Assert.IsNull(field4.Item);

            CommandGameMove cmove5 = new CommandGameMove("1jhb2h48325sdf5", 12, 4);

            cmove5.SourcePlayer = player5;
            cmove5.Level        = level1;
            cm2.AddCommand(cmove5);
            cm2.ProcessPendingTransactions();

            Assert.IsNotNull(player5.DefenseItem);
            Assert.AreEqual(0.75, player5.DefenseBoost);
            Assert.IsNotNull(field5.Item);
        }