Пример #1
0
		public void purchase(Owner landed, Property unownedSpace)
		{
			int origMoney = landed.money;
			if (landed.money >= unownedSpace.value) {
				landed.money = landed.money - unownedSpace.value;
				unownedSpace.setOwned (landed);
				landed.properties.Add (unownedSpace);
				Console.WriteLine ("Player " + landed.ID + " pays $" + unownedSpace.value + " from $" + origMoney + " to purchase " + unownedSpace.title);
				Console.WriteLine ("They now have $" + landed.money);
			} else {
				Console.WriteLine ("Not enough money to buy " + unownedSpace.title + "!");
			}
		}
Пример #2
0
		public void payRent(Owner landed, Property ownedSpace) //pay rent from piece to space owner
		{
			int rentOwed = 0;
			if (ownedSpace.title == "Electric Company") {
				bool ownsWW = false;
				foreach(Property p in ownedSpace.player.properties)
				{
					if(p.title == "Water Works")
					{
						ownsWW = true;
					}
				}
				if(ownsWW)
				{
					rentOwed = (10 * this.diceTotal);
				}
			} else if (ownedSpace.title == "Water Works") {
				bool ownsEC = false;
				foreach(Property p in ownedSpace.player.properties)
				{
					if(p.title == "Electric Company")
					{
						ownsEC = true;
					}
				}
				if(ownsEC)
				{
					rentOwed = (10 * this.diceTotal);
				}
			} else {
				rentOwed = ownedSpace.rents [ownedSpace.buildings];
			}
			landed.money = landed.money - rentOwed;
			ownedSpace.player.money = ownedSpace.player.money + rentOwed;
			Console.WriteLine("Player " + landed.ID + " pays Player " + ownedSpace.player.ID + " $" + rentOwed + " and now has $" + landed.money + ". Player " + ownedSpace.player.ID + " now has $" + ownedSpace.player.money);
			if(landed.money < 0)
			{
				Console.WriteLine("Player " + landed.ID + " loses the game");
				gameOver = true;
			}
		}
Пример #3
0
		public Property(string in_title, int in_value, int[] in_rents, int in_mortgage, string in_colorGroup)
		{
			mortgage = in_mortgage;
			value = in_value;
			isMortgaged = false;
			buildings = 0;
			rents = in_rents;
			colorGroup = in_colorGroup;
			player = null; //not yet owned
			Console.WriteLine ("property created");
			title = in_title;
		}
Пример #4
0
		public void setOwned(Owner cplayer)
		{
			player = cplayer;
		}
Пример #5
0
		public Piece(string in_type, string color, int id)
		{
			player = new Owner (color, id);
			type = in_type;
			doubcount = 0;
			isJailed = false;
			location = 0;
			Console.WriteLine (type + " created");
		}