Ejemplo n.º 1
0
        public void DoWork()
        {
            Host        host = new Host();
            RedPlayer   r1   = new RedPlayer("紅1", host);
            RedPlayer   r2   = new RedPlayer("紅2", host);
            BluePlayer  b1   = new BluePlayer("藍1", host);
            BluePlayer  b2   = new BluePlayer("藍2", host);
            GreenPlayer g1   = new GreenPlayer("綠1", host);
            GreenPlayer g2   = new GreenPlayer("綠2", host);

            host.AddPlayer(r1); host.AddPlayer(r2);
            host.AddPlayer(b1); host.AddPlayer(b2);
            host.AddPlayer(g1); host.AddPlayer(g2);

            r1.Kill(b1.id);
            r2.KillAll();
            b1.Blood(b2.id);
            b2.Blood(b1.id);
            g1.Kill(r2.id);
            g2.BloodAll();
            r2.KillAll();
            r2.KillAll();
            r2.KillAll();
            r2.KillAll();
        }
Ejemplo n.º 2
0
    /**
     * roll a die an incur an effect accordinly
     */
    private static void Tavern()
    {
        var result = Random.Range(1, 7);

        if (result <= 2)
        {
            FightGenericEnemy();
        }
        else if (result == 3)
        {
            GameControl.ChangeGold(-1);
            AdventureDeck._deckText = "You gambled and lost 1 gold";
        }
        else if (result >= 4 && result <= 5)
        {
            GameControl.ChangeGold(1);
            AdventureDeck._deckText = "You gambled and gained 1 gold";
        }
        else
        {
            if (GameControl.TurnTracker == 0)
            {
                BluePlayer.MoveRegion("M", 16, "M13");
            }
            else
            {
                YellowPlayer.MoveRegion("M", 16, "M13");
            }
            AdventureDeck._deckText = "You rolled a 6 and were transported to the temple";
        }
    }
Ejemplo n.º 3
0
 /**
  * Resets the game
  */
 public static void EndGame()
 {
     if (BluePlayer.lives < 1)
     {
         YellowPlayer.Wins += 1;
     }
     else
     {
         BluePlayer.Wins += 1;
     }
     AdventureDeck._deckText = "Game ended and reset";
     BluePlayer.MoveRegion("O", 24, "O1");
     BluePlayer.lives          = Player.StartingLives;
     BluePlayer.strength       = Player.StartingStrength;
     BluePlayer.strengthTrophy = 0;
     BluePlayer.fateTokens     = Player.StatingFateTokens;
     BluePlayer.gold           = Player.StartingGold;
     BluePlayer.alignment      = "";
     BluePlayer.Turns          = 0;
     YellowPlayer.MoveRegion("O", 24, "O13");
     YellowPlayer.lives          = Player.StartingLives;
     YellowPlayer.strength       = Player.StartingStrength;
     YellowPlayer.strengthTrophy = 0;
     YellowPlayer.fateTokens     = Player.StatingFateTokens;
     YellowPlayer.gold           = Player.StartingGold;
     YellowPlayer.alignment      = "";
     YellowPlayer.Turns          = 0;
     SetAlignments();
     TurnCount          = 0;
     DiceRoll.RollCount = 0;
     TurnTracker        = 0;
 }
Ejemplo n.º 4
0
        public void BluePlayerCreateTest()
        {
            Map map = Map.GetInstance;

            map.CleanArena();
            BluePlayer     player     = new BluePlayer(1, 1, 1, 1, new Coordinates(5, 5));
            MapManagerStub mapManager = new MapManagerStub();

            map.AddMapObj(player);
            Assert.True(map.getMapContainer()[5, 5][0] is BluePlayer, "not a blue player");
            map.removeMap();
        }
Ejemplo n.º 5
0
        public void BluePlayerPlantBlueBombTest()
        {
            Map map = Map.GetInstance;

            map.CleanArena();
            MapManagerStub mapManager = new MapManagerStub();
            BluePlayer     player     = new BluePlayer(1, 1, 1, 1, new Coordinates(5, 5));

            mapManager.PlaceBomb(player);
            Assert.True(map.getMapContainer()[5, 5][0] is BlueBomb, "not a blue bomb");
            map.removeMap();
        }
Ejemplo n.º 6
0
 //TODO: All these methods should move to a dedicated service
 public async Task <PostScoreViewModel> Save(League league, Db db)
 {
     if (!BluePlayer.IsNoE() && !RedPlayer.IsNoE())
     {
         await SavePlayerScore(league, db);
     }
     else
     {
         await SaveTeamScore(league, db);
     }
     return(this);
 }
Ejemplo n.º 7
0
    /**
     * Calls the respective player's TakeTurn method based on the
     * TurnTracker value. Called in this class's Update method.
     */
    private static void Main()
    {
        switch (TurnTracker)
        {
        case 0:
            BluePlayer.TakeTurn();
            break;

        case 1:
            YellowPlayer.TakeTurn();
            break;
        }
    }
Ejemplo n.º 8
0
    /**
     * Roll 2 dice and compare to player strength. Will be teleported based on result
     */
    private static void MinesCrypt()
    {
        var result = Random.Range(1, 7) + Random.Range(1, 7) + Random.Range(1, 7) - GameControl.GetStrength();

        if (GameControl.TurnTracker == 0)
        {
            if (result == 1)
            {
                BluePlayer.MoveRegion("I", 8, "I1");
                AdventureDeck._deckText = "result of 1: transported to plain of peril";
            }
            else if (result >= 2 && result <= 3)
            {
                BluePlayer.MoveRegion("M", 16, "M1");
                AdventureDeck._deckText = "result of 2-3: transported to the portal of power";
            }
            else if (result >= 4 && result <= 5)
            {
                BluePlayer.MoveRegion("M", 16, "M9");
                AdventureDeck._deckText = "result of 4-5: transported to the warlock's cave";
            }
            else if (result >= 6)
            {
                BluePlayer.MoveRegion("O", 24, "O19");
                AdventureDeck._deckText = "result of 6+: transported to the tavern";
            }
        }
        else
        {
            if (result == 1)
            {
                YellowPlayer.MoveRegion("I", 8, "I1");
                AdventureDeck._deckText = "result of 1: transported to plain of peril";
            }
            else if (result >= 2 && result <= 3)
            {
                YellowPlayer.MoveRegion("M", 16, "M1");
                AdventureDeck._deckText = "result of 2-3: transported to the portal of power";
            }
            else if (result >= 4 && result <= 5)
            {
                YellowPlayer.MoveRegion("M", 16, "M9");
                AdventureDeck._deckText = "result of 4-5: transported to the warlock's cave";
            }
            else if (result >= 6)
            {
                YellowPlayer.MoveRegion("O", 24, "O19");
                AdventureDeck._deckText = "result of 6+: transported to the tavern";
            }
        }
    }
Ejemplo n.º 9
0
        public void BlueBombGetColorTest()
        {
            Map map = Map.GetInstance;

            map.CleanArena();
            MapManagerStub mapManager = new MapManagerStub();
            BluePlayer     player     = new BluePlayer(1, 1, 1, 1, new Coordinates(5, 5));

            mapManager.PlaceBomb(player);
            BlueBomb bomb = map.getMapContainer()[5, 5][0] as BlueBomb;

            Assert.Equal(Color.FromKnownColor(KnownColor.Blue), bomb.GetColor());
            map.removeMap();
        }
Ejemplo n.º 10
0
        public void BombDecoratorTest()
        {
            Map map = Map.GetInstance;

            map.CleanArena();
            MapManagerStub mapManager = new MapManagerStub();
            BluePlayer     player     = new BluePlayer(1, 1, 1, 1, new Coordinates(5, 5));

            mapManager.PlaceBomb(player);
            BlueBomb bomb = map.getMapContainer()[5, 5][0] as BlueBomb;

            Assert.Equal(2, bomb.decorations.Count);
            map.removeMap();
        }
Ejemplo n.º 11
0
        // --  Constructor -- //

        public Level()
        {
            width  = 1280;
            height = 720;
            tile   = new Tile();

            redPlayer  = new RedPlayer();
            bluePlayer = new BluePlayer();

            grid   = new Tile[width / tile.GetSize, height / tile.GetSize];
            sorter = new TileSorter(grid.Length);

            AddBorder();
        }
Ejemplo n.º 12
0
 /**
  * Checks if the player has a talisman. If so, transport them to Crown of Command
  */
 private static void ValleyOfFire()
 {
     if (!GameControl.CheckTalisman())
     {
         return;
     }
     if (GameControl.TurnTracker == 0)
     {
         BluePlayer.MoveRegion("C", 1, "C1");
     }
     else
     {
         YellowPlayer.MoveRegion("C", 1, "C1");
     }
     Crown();
 }
Ejemplo n.º 13
0
        public void LeftTest()
        {
            Console.WriteLine("Upward Movement");
            Level2 TestLevel2 = new Level2();

            Movement   instance = new Movement();
            RedPlayer  actualR  = new RedPlayer();
            BluePlayer actualB  = new BluePlayer();

            instance.Left(actualR, actualB, TestLevel2);
            int expectedR = actualR.GetX - 40;
            int expectedB = actualB.GetX - 40;


            instance.Left(actualR, actualB, TestLevel2);
            Assert.AreEqual(expectedR, actualR.GetX);
        }
Ejemplo n.º 14
0
        public void testDown()
        {
            Console.WriteLine("Downward Movement");
            Level2 TestLevel2 = new Level2();

            TestLevel2.AddRedPlayer(12, 8);

            Movement   instance = new Movement();
            RedPlayer  actualR  = new RedPlayer();
            BluePlayer actualB  = new BluePlayer();

            instance.Down(TestLevel2.GetRedPlayer, actualB, TestLevel2);
            int expectedR = actualR.GetY - 40;
            int expectedB = actualB.GetY - 40;


            instance.Down(actualR, actualB, TestLevel2);
            Assert.AreEqual(expectedR, actualR.GetY);
        }
Ejemplo n.º 15
0
 /**
  * Roll 2 dice. If the result is less than the player's strength, transport them
  * to the Plain of Peril
  */
 private static void PortalOfPower()
 {
     if (Random.Range(1, 7) + Random.Range(1, 7) <= GameControl.GetStrength())
     {
         AdventureDeck._deckText = "successful roll - transported to Plain of Peril";
         if (GameControl.TurnTracker == 0)
         {
             BluePlayer.MoveRegion("I", 8, "I1");
         }
         else
         {
             YellowPlayer.MoveRegion("I", 8, "I1");
         }
     }
     else
     {
         AdventureDeck._deckText = "Unsuccessful roll";
     }
 }
Ejemplo n.º 16
0
        private async Task SavePlayerScore(League league, Db db)
        {
            if (BluePlayerScore <= 0 && RedPlayerScore <= 0)
            {
                throw new Exception("Invalid scores, both must be greater zero.");
            }
            if (BluePlayer.IsNoE() || RedPlayer.IsNoE())
            {
                throw new Exception("One or more player names empty.");
            }

            var bluePlayer = await GetOrCreatePlayer(BluePlayer, league, db);

            var redPlayer = await GetOrCreatePlayer(RedPlayer, league, db);

            var game = await CreateGame(RedPlayerScore, BluePlayerScore, league, db);

            await CreatePosition(game, redPlayer, PlayerPositionTypes.Red, db);
            await CreatePosition(game, bluePlayer, PlayerPositionTypes.Blue, db);
        }
Ejemplo n.º 17
0
    /**
     * Fight the sentinal and if won, cross into the middle region
     */
    private static int FightSentinal()
    {
        var sentinalStrength = 8;
        var SentinalResult   = sentinalStrength + Random.Range(1, 7);
        var playerResult     = GameControl.GetStrength() + Random.Range(1, 7);
        var diff             = playerResult - SentinalResult;

        if (diff > 0)
        {
            AdventureDeck._deckText =
                "You fought the sentinal and won (" + playerResult + " vs " + SentinalResult + ")";
            if (GameControl.TurnTracker == 0)
            {
                BluePlayer.MoveRegion("M", 16, "M4");
            }
            else
            {
                YellowPlayer.MoveRegion("M", 16, "M4");
            }
            Player.Done = true;
            GameControl.AlternateTurnTracker();
        }
        else if (diff < 0)
        {
            AdventureDeck._deckText =
                "You fought the sentinal and lost (" + playerResult + " vs " + SentinalResult + ")";
            Player.Done = false;
            GameControl.ChangeLives(-1);
        }
        else
        {
            AdventureDeck._deckText =
                "You fought the sentinel and tied (" + playerResult + " vs " + SentinalResult + ")";
            Player.Done = true;
            GameControl.AlternateTurnTracker();
        }

        return(diff);
    }
Ejemplo n.º 18
0
        // -- Standard Operations -- //

        public Tile CreateTile(String tileName)
        {
            switch (tileName.ToLower())
            {
            case "bluebutton":
                BlueButton blueButton = new BlueButton();
                return(blueButton);

            case "blueflame":
                BlueFlame blueFlame = new BlueFlame();
                return(blueFlame);

            case "blueplayer":
                BluePlayer bluePlayer = new BluePlayer();
                return(bluePlayer);

            case "redbutton":
                RedButton redButton = new RedButton();
                return(redButton);

            case "redflame":
                RedFlame redFlame = new RedFlame();
                return(redFlame);

            case "redplayer":
                RedPlayer redPlayer = new RedPlayer();
                return(redPlayer);

            case "wall":
                Wall wall = new Wall();
                return(wall);

            default:
                return(null);
            }
        }
Ejemplo n.º 19
0
 void Awake()
 {
     BlueCharacterData = BlueCharacter.GetComponent <BluePlayer>();
     RedCharacterData  = RedCharacter.GetComponent <RedPlayer>();
 }
Ejemplo n.º 20
0
        public void BluePlayerColorTest()
        {
            BluePlayer player = new BluePlayer(1, 1, 1, 1, new Coordinates(5, 5));

            Assert.Equal(Color.FromKnownColor(KnownColor.Blue), player.GetColor());
        }