Beispiel #1
0
        public Trade(PA3BackEnd.src.Monopoly.MonopolyGame monopolyGame, RoutedEventHandler routedEvent)
        {
            InitializeComponent();
            this.monopolyGame = monopolyGame;


            properties0 = new List <int>();
            properties1 = new List <int>();

            this.routedEvent = routedEvent;

            cover = new Rectangle();
            cover.SetValue(Grid.RowSpanProperty, 4);
            cover.SetValue(Grid.ColumnSpanProperty, 4);
            cover.Fill    = Brushes.White;
            cover.Opacity = 0.5;

            CardHolderPlayer0.Add_EventHandler(PlayerOneGives);
            CardHolderPlayer1.Add_EventHandler(PlayerTwoGives);

            for (int i = 0; i < monopolyGame.amountOfPlayers; i++)
            {
                if (i == monopolyGame.currentPlayerID - 1)
                {
                    continue;
                }

                ComboBoxSelectPlayer.Items.Add($"Player {i+1} ({PA3BackEnd.src.Monopoly.MonopolyGame.GetUserTokenName(i+1)})");
            }

            CardHolderPlayer0.ClearDeeds();
            foreach (var prop in monopolyGame.GetPropertiesOwnedByPlayer())
            {
                if (monopolyGame.HasAnyBuildingsOnIt(prop))
                {
                    continue;
                }
                CardHolderPlayer0.Add_Deed(prop);
            }

            CardHolderPlayer1.ClearDeeds();

            ComboBoxSelectPlayer.SelectedIndex = 0;
            textblockmoney.Text = $"${0}";
        }
Beispiel #2
0
        private void ComboBoxSelectPlayer_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Reset();
            CardHolderPlayer1.ClearDeeds();
            index = ComboBoxSelectPlayer.SelectedIndex;
            if (index >= monopolyGame.currentPlayerID - 1)
            {
                index++;
            }

            foreach (var prop in monopolyGame.GetPropertiesOwnedByPlayer(index))
            {
                if (monopolyGame.HasAnyBuildingsOnIt(prop))
                {
                    continue;
                }

                CardHolderPlayer1.Add_Deed(prop);
            }

            if (monopolyGame.GetBalanceOfPlayer(index) < 0)
            {
                MoneySlider.Minimum = 0;
            }
            else
            {
                MoneySlider.Minimum = -1 * monopolyGame.GetBalanceOfPlayer(index);
            }

            if (monopolyGame.currentPlayerBalance < 0)
            {
                MoneySlider.Maximum = 0;
            }
            else
            {
                MoneySlider.Maximum = monopolyGame.currentPlayerBalance;
            }

            MoneySlider.Value = 0;
        }