예제 #1
0
        private void ChanceCard2Action(MonopolyPlayer p)
        {
            // Pay poor tax  : Pay 15
            Console.WriteLine("Pay poor tax  : Pay 15");

            int price = 15;
            Dictionary <MoneyType, int> inputPay = p.getInput(price);
            int counter = 1;

            int change = p.ValidateGetInputPrice(price, inputPay, "pay");

            while (change < 0 && counter <= 5)
            {
                inputPay = p.getInput(price);
                counter++;
            }
            if (counter > 5)
            {
                return;
            }

            // check if change exist
            if (change > 0)
            {
                // change always true
                Dictionary <MoneyType, int> inputChange = p.getInput(change);
                if (p.ValidateGetInputPrice(change, inputChange, "receive") != 0)
                {
                    return;
                }
                p.Receive(inputChange);
                _bank.WithdrawMoney(inputChange);
            }

            //  pay to bank
            _bank.DepositMoney(inputPay);
            p.Pay(inputPay);
        }
예제 #2
0
        private void CommunityCard2Action(MonopolyPlayer p)
        {
            // Doctor's fee : pay 50
            Console.WriteLine("Doctor's fee : pay 50");

            int price = 50;
            Dictionary <MoneyType, int> inputPay = p.getInput(price);
            int counter = 1;
            int change  = p.ValidateGetInputPrice(price, inputPay, "pay");

            while (change < 0 && counter <= 5)
            {
                inputPay = p.getInput(price);
                counter++;
            }
            if (counter > 5)
            {
                return;
            }

            // check if change exist
            if (change > 0)
            {
                // change always true
                Dictionary <MoneyType, int> inputChange = p.getInput(change);
                if (p.ValidateGetInputPrice(change, inputChange, "receive") != 0)
                {
                    return;
                }
                p.Receive(inputChange);
                _bank.WithdrawMoney(inputChange);
            }

            // receive money from bank
            _bank.DepositMoney(inputPay);
            p.Pay(inputPay);
        }