示例#1
0
        //overwrite original virtual method declared in Property class
        public override string landOn(ref Player player)
        {
            //if the following is a jail property and player has gone past then set player in jail
            if(this.isJail == true)
            {
                //enable setIsInJail to true
                player.setIsInJail();
                //don't let player pass GO and don't let collect $200
                player.setLocation(10, false);

                return null;
                //return base.landOn(ref player) + String.Format(player.getName() + " has gone to jail!");
            }
            else
            {
                if(player.getJailStats() == true)
                {
                    return null;
                    //return base.landOn(ref player) + String.Format(player.getName() + " you're now in jail, you cannot pass Go or collect $200.00\nTo Get out of jail you must:\n \t-pay $50\n \t-use a 'Get out of Jail Card'\n \t-or attempt to roll doubles.\n");
                }
                else
                {
                    return base.landOn(ref player) + String.Format(player.getName() + " is visiting jail!");
                }
                //when player is only visiting Jail
                //player.setNotInJail();
            }
        }
        public override string landOn(ref Player player)
        {
            if (this.setJail == true)
            {

              Console.WriteLine("You have gone to jail, you do not pass go you can not collect $200\n");
                player.setIsInJail();
                player.setLocation(10, false);
                return base.landOn(ref player) + String.Format(player.getName().ToString() + " has gone to jail!");
            }
            else
            {
                if (player.getJailStatis() == true)
                {

                    if (player.sendMsg == false)
                    {
                        return null;
                    }

                    return base.landOn(ref player) + String.Format(player.getName().ToString() + " is in jail!..");
                }
                return base.landOn(ref player) + String.Format(player.getName().ToString() + " is just visiting!.");

            }
        }
示例#3
0
文件: Jail.cs 项目: yarhtut/_Monopoly
        public override string landOn(ref Player player)
        {
            //if this is a jail property and user has past go.
            //&& player.passGo()
            if (this.isJail)
            {
                //player landed on jail
                player.setIsInJail();
                //if is a benefit player receives amount else pay amount
                return base.landOn(ref player) + String.Format("{0} has gone to jail.", player.getName());

            }
            else
            {
                //if is a benefit player receives amount else pay amount
                return base.landOn(ref player) + String.Format("{0} just visting jail.", player.getName());

            }
        }
        public void test_PlayerGettersAndSetters()
        {
            Banker theTestBanker = new Banker();
             Player theTestPlayer = new Player();

            //hasRolledDoubles bool
            theTestPlayer.get_hasRolledDoubles();
            theTestPlayer.is_hasRolledDoubles();
            theTestPlayer.hasRolledDoubles = true;
            theTestPlayer.not_hasRolledDoubles();

            //paidFine bool
            theTestPlayer.getPaidFine();
            theTestPlayer.isPaidFine();
            theTestPlayer.notPaidFine();

            //landedInJailByThreeStraightDoubles bool
            theTestPlayer.get_LandedInJailByThreeStraightDoubles();
            theTestPlayer.not_LandedInJailByThreeStraightDoubles();
            theTestPlayer.is_LandedInJailByThreeStraightDoubles();

            //inJail bool
            theTestPlayer.getJailStats();
            theTestPlayer.setIsInJail();
            theTestPlayer.setNotInJail();

            //lastMove int
            theTestPlayer.getLastMove();

            theTestPlayer.getLocation();

            theTestPlayer.getName();

            theTestPlayer.getPropertiesOwned();

            theTestPlayer.getBalance();

            theTestPlayer.getBalance();

            theTestPlayer.hasRolledDoublesInJail();

            theTestPlayer.isNotActive();

            theTestPlayer.get_firstTurnInJail();

            theTestPlayer.not_firstTurnInJail();
        }