Пример #1
0
 public Transport(string sName)
 {
     this.sName          = sName;
     this.dPrice         = 200;
     this.dMortgageValue = 100;
     this.dRent          = 50;
     this.owner          = Banker.access();
 }
Пример #2
0
 public override bool availableForPurchase()
 {
     //if owned by bank then available
     if (this.owner == Banker.access())
     {
         return(true);
     }
     return(false);
 }
Пример #3
0
 public override string landOn(ref Player player)
 {
     if ((this.getOwner() != Banker.access()) && (this.getOwner() != player))
     {
         this.payRent(ref player);
         return(string.Format("You landed on a Utility and  rolled a total of {0}. So your rent is {0} x {1} = ${2}.", player.getLastMove(), Utility.rentMultiplier, (player.getLastMove() * Utility.rentMultiplier)));
     }
     else
     {
         return(base.landOn(ref player));
     }
 }
Пример #4
0
 public override string landOn(ref Player player)
 {
     //Pay rent if needed
     if ((this.getOwner() != Banker.access()) && (this.getOwner() != player) && !this.IsMortgaged)
     {
         //pay rent
         Console.WriteLine($">>>>>>>>>>{player.getName()}, you should pay ${this.getRent()} to {this.getOwner().getName()} for landing {this.getName()}<<<<<<<<<<");
         this.payRent(ref player);
         return(base.landOn(ref player) + string.Format("Rent has been paid for {0} of ${1} to {2}.", this.getName(), this.getRent(), this.getOwner().getName()));
     }
     else
     {
         return(base.landOn(ref player));
     }
 }
        public override void checkBankrupt()
        {
            if (this.getBalance() <= 0)
            {
                //raise the player bankrupt event if there are subscribers
                if (playerBankrupt != null)
                {
                    this.playerBankrupt(this, new EventArgs());
                }

                //return all the properties to the bank
                Banker b = Banker.access();
                foreach (Property p in this.getPropertiesOwnedFromBoard())
                {
                    p.setOwner(b);
                }
                //set isInactive to true
                this.isInactive = true;
            }
        }
Пример #6
0
        public override void checkBankrupt()
        {
            if (this.getBalance() <= 0)
            {
                //raise the player bankrupt event if there are subscribers
                if (playerBankrupt != null)
                {
                    this.playerBankrupt(this, new EventArgs());
                }

                //return all the properties to the bank
                Banker b = Banker.access();
                foreach (Property p in this.getPropertiesOwnedFromBoard())
                {
                    p.setOwner(b);
                }
                //set isInactive to true
                this.isInactive = true;

                int    activePlayerCount = 0;
                Player winner            = new Player();
                foreach (Player p in Board.access().getPlayers())
                {
                    //if player is active
                    if (!p.isNotActive())
                    {
                        activePlayerCount++;
                        winner = p;
                    }
                }

                //if less than two active players display winner
                if (activePlayerCount < 2)
                {
                    Console.WriteLine("\n\n>>>>>>>>>{0} has won the game!<<<<<<<<<<\n\n", winner.getName());
                    Console.WriteLine(">>>>>>>>>>The game is now over. Please press enter to exit.<<<<<<<<<");
                    Console.ReadLine();
                    Environment.Exit(0);
                }
            }
        }
Пример #7
0
        public override void checkBankrupt()
        {
            if (this.getBalance() <= 0)
            {
                if (playerBankrupt != null)
                {
                    this.playerBankrupt(this, new EventArgs());
                }

                Banker b = Banker.access();
                foreach (Property p in this.getPropertiesOwnedFromBoard())
                {
                    p.setOwner(b);
                }
                this.isInactive = true;

                int    activePlayerCount = 0;
                Player winner            = new Player();
                foreach (Player p in Board.access().getPlayers())
                {
                    if (!p.isNotActive())
                    {
                        activePlayerCount++;
                        winner = p;
                    }
                }

                if (activePlayerCount < 2)
                {
                    Console.WriteLine("\n\n>>>>>>>>>{0} has won the game!<<<<<<<<<<\n\n", winner.getName());
                    Console.WriteLine(">>>>>>>>>>The game is now over. Please press enter to exit.<<<<<<<<<");
                    Console.ReadLine();
                    Environment.Exit(0);
                }
            }
        }
Пример #8
0
 public Utility(String name)
 {
     this.sName = name;
     this.owner = Banker.access();
 }
Пример #9
0
 public Property(string sName)
 {
     this.sName = sName;
     this.owner = Banker.access();
 }