Exemple #1
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");
            }
        }
Exemple #2
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 = "";
         }
     }
 }
Exemple #3
0
        public SellForm(ref Game game_)
        {
            InitializeComponent();
            this.game = game_;
            foreach (Player player in game.players)
            {
                if (player.name != game.GetCurrPlayer().name)
                    listBoxPlayers.Items.Add(player.name);
            }

            foreach (Space s in game.board)
            {
                if (s.GetType() == typeof(Property))
                {
                    Property p = (Property)s;
                    if (p.owner == game.GetCurrPlayer().name)
                        listBoxProperty.Items.Add(p.name);
                }
            }
        }
Exemple #4
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;
        }
Exemple #5
0
 static bool CheckIfJail(Player player, Game game)
 {
     return true;
 }
Exemple #6
0
 public Menu(ref Game game)
 {
     InitializeComponent();
     this.game = game;
     this.ActiveControl = textBoxPlayerName;
 }