Exemplo n.º 1
0
        /// <summary>
        /// Funktion som ritar ut en färgad rektangel runt de gator som ägs av en specifik spelare.
        /// Används av UpdateGraphics-funktionen.
        /// </summary>
        /// <param name="p">Spelare</param>
        private void DrawOwnerRectangle(Player p)
        {
            List<int> indexes = new List<int>();
            for (int i = 0; i < game.board.Count(); ++i)
            {
                if (game.board[i].GetType() == typeof(Property) && ((Property)game.board[i]).owner == p.name)
                {
                    indexes.Add(i - 1);
                }
            }

            foreach (int i in indexes)
            {
                Rectangle r = new Rectangle(0, 0, 0, 0);
                if (i < 10)
                    r = new Rectangle(new Point(86 + (i * 57), 0), new Size(57, 85));
                else if (i >= 10 && i < 20)
                    r = new Rectangle(new Point(599, (i - 10) * 57 + 85), new Size(85, 57));
                else if (i >= 20 && i < 30)
                    r = new Rectangle(new Point(599 - ((i - 19) * 57), 598), new Size(57, 85));
                else if (i >= 30)
                    r = new Rectangle(new Point(0, 598 - ((i - 29) * 57)), new Size(85, 57));

                graphics.DrawRectangle(new Pen(p.color, 3), r);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Analyserar spelets nuvarande situation och kollar om det stämmer överrens med reglerna.
        /// T.ex. om en spelare får köpa den egendom som spelaren står på.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="game"></param>
        public static void CheckState(Player player, Game game)
        {
            player.AllowPlayerToBuyProperty(false);
            Debug.WriteLine("Plats: " + game.board[player.position].name + ", " + PositionType(player, game).ToString());

            if (player.cash < 0)
            {
                kickPlayer(player, game);
            }

            if (PositionType(player, game) == Spaces.GoToJail)
            {
                game.BustPlayer(player);
            }

            else if (PositionType(player, game) == Spaces.AvailableProperty)
            {
                player.AllowPlayerToBuyProperty(game.board[player.position] as Property);
            }

            else if (PositionType(player, game) == Spaces.OwnedProperty)
            {
                player.PayOpponent(game.findPlayer((game.board[player.position] as Property).owner), (game.board[player.position] as Property).rent);
            }

            else if (PositionType(player, game) == Spaces.Bisys)
            {
                game.newBisys();
                player.cash += (game.currentBisys.value);
                Debug.WriteLine(game.currentBisys.message + " " + game.currentBisys.value + " kr");
            }
        }
Exemplo n.º 3
0
 public static void printplayers(Player[] PList)
 {
     Console.WriteLine (PList.Length);
     for(int p = 0; p< PList.Length;p++){
         Console.WriteLine("Player {0} is human ({1}) and has cashmunnies {2}",PList[p],PList[p].isHuman, PList[p].property);
     }
 }
Exemplo n.º 4
0
 private static void kickPlayer(Player player, Game game)
 {
     player.active = false;
     Debug.WriteLine(player.name + " har förlorat!");
     foreach (Space s in game.board)
     {
         if (s is Property)
         {
             if (((Property)s).owner == player.name)
                 ((Property)s).owner = "";
         }
     }
 }
Exemplo n.º 5
0
        public static Player[] InitPlayers(int property, int players, int humans)
        {
            Player[] PList = new Player[players];

            for (int p = 0; p < players; p++) {

                PList[p].property = property;
                PList[p].position = 0;

                if (p < humans) {
                    PList[p].isHuman = true;
                } else {
                    PList[p].isHuman = false;

                }

            }

            //printplayers (PList);
            return PList;
        }
Exemplo n.º 6
0
        static Spaces PositionType(Player player, Game game)
        {
            if (game.board[player.position].GetType() == typeof(GoToJail))
                return Spaces.GoToJail;

            else if (game.board[player.position].GetType() == typeof(Property))
            {
                Property p = (Property)game.board[player.position];
                if (p.owner == player.name)
                    return Spaces.MyProperty;
                else if (p.owner == "")
                    return Spaces.AvailableProperty;
                else
                    return Spaces.OwnedProperty;
            }

            else if (game.board[player.position].GetType() == typeof(BisysSpace))
                return Spaces.Bisys;

            else
                return Spaces.Nothing;
        }
Exemplo n.º 7
0
 static bool CheckIfJail(Player player, Game game)
 {
     return true;
 }
Exemplo n.º 8
0
 public void BustPlayer(Player player)
 {
     Debug.WriteLine(player.name + " fängslas!!!!");
     player.prisoner = true;
     player.GoTo(jailpos);
 }