Skip to content

Instantly share code, notes, and snippets.

@AndrioCelos
Created August 15, 2018 15:00
Show Gist options
  • Save AndrioCelos/9b6b8a08202790fe462af00989fde7d7 to your computer and use it in GitHub Desktop.
Save AndrioCelos/9b6b8a08202790fe462af00989fde7d7 to your computer and use it in GitHub Desktop.
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace Monopoly {
/// <summary>Represents the game board.</summary>
public class Board {
/// <summary>The name of the board.</summary>
public string Name;
/// <summary>The spaces on the board.</summary>
public Space[] Spaces;
/// <summary>The colours of the districts as seen on the board.</summary>
public string[] DistrictColours;
/// <summary>The Chance cards in play.</summary>
public Card[] ChanceCards;
/// <summary>The Community Chest cards in play.</summary>
public Card[] CommunityChestCards;
/// <summary>The number of Chance cards remaining.</summary>
public short ChanceCardsRemaining;
/// <summary>The number of Community Chest cards remaining.</summary>
public short CommunityChestCardsRemaining;
public static Board InitialiseUK() {
Board board = new Board();
board.Name = "UK";
board.Spaces = new Space[40];
// # Type Name Group Price House price Rent 1 2 3 4 Hotel
board.Spaces[ 0] = new Space( 0, SpaceType.GoSpace , "Go" );
board.Spaces[ 1] = new Space( 1, SpaceType.PropertySpace , "Old Kent Road" , 0, 60, 50, new int[] { 2, 10, 30, 90, 160, 250 });
board.Spaces[ 2] = new Space( 2, SpaceType.CommunityChestSpace, "Community Chest" );
board.Spaces[ 3] = new Space( 3, SpaceType.PropertySpace , "Whitechapel Road" , 0, 60, 50, new int[] { 4, 20, 60, 180, 320, 450 });
board.Spaces[ 4] = new Space( 4, SpaceType.IncomeTaxSpace , "Income Tax" );
board.Spaces[ 5] = new Space( 5, SpaceType.RailroadSpace , "Kings Cross Station" , 200);
board.Spaces[ 6] = new Space( 6, SpaceType.PropertySpace , "The Angel Islington" , 1, 100, 50, new int[] { 6, 30, 90, 270, 400, 550 });
board.Spaces[ 7] = new Space( 7, SpaceType.ChanceSpace , "Chance" );
board.Spaces[ 8] = new Space( 8, SpaceType.PropertySpace , "Euston Road" , 1, 100, 50, new int[] { 6, 30, 90, 270, 400, 550 });
board.Spaces[ 9] = new Space( 9, SpaceType.PropertySpace , "Pentonville Road" , 1, 120, 50, new int[] { 8, 40, 100, 300, 450, 600 });
board.Spaces[10] = new Space(10, SpaceType.JailSpace , "Jail" );
board.Spaces[11] = new Space(11, SpaceType.PropertySpace , "Pall Mall" , 2, 140, 100, new int[] { 10, 50, 150, 450, 625, 750 });
board.Spaces[12] = new Space(12, SpaceType.UtilitySpace , "Electric Company" , 150);
board.Spaces[13] = new Space(13, SpaceType.PropertySpace , "Whitehall" , 2, 140, 100, new int[] { 10, 50, 150, 450, 625, 750 });
board.Spaces[14] = new Space(14, SpaceType.PropertySpace , "Northumberland Avenue" , 2, 160, 100, new int[] { 12, 60, 180, 500, 700, 900 });
board.Spaces[15] = new Space(15, SpaceType.RailroadSpace , "Marylebone Station" , 200);
board.Spaces[16] = new Space(16, SpaceType.PropertySpace , "Bow Street" , 3, 180, 100, new int[] { 14, 70, 200, 550, 750, 950 });
board.Spaces[17] = new Space(17, SpaceType.CommunityChestSpace, "Community Chest" );
board.Spaces[18] = new Space(18, SpaceType.PropertySpace , "Marlborough Street" , 3, 180, 100, new int[] { 14, 70, 200, 550, 750, 950 });
board.Spaces[19] = new Space(19, SpaceType.PropertySpace , "Vine Street" , 3, 200, 100, new int[] { 16, 80, 220, 600, 800, 1000 });
board.Spaces[20] = new Space(20, SpaceType.FreeParkingSpace , "Free Parking" );
board.Spaces[21] = new Space(21, SpaceType.PropertySpace , "Strand" , 4, 220, 150, new int[] { 18, 90, 250, 700, 875, 1050 });
board.Spaces[22] = new Space(22, SpaceType.ChanceSpace , "Chance" );
board.Spaces[23] = new Space(23, SpaceType.PropertySpace , "Fleet Street" , 4, 220, 150, new int[] { 18, 90, 250, 700, 875, 1050 });
board.Spaces[24] = new Space(24, SpaceType.PropertySpace , "Trafalgar Square" , 4, 240, 150, new int[] { 20, 100, 300, 750, 925, 1100 });
board.Spaces[25] = new Space(25, SpaceType.RailroadSpace , "Fenchurch Street Station" , 200);
board.Spaces[26] = new Space(26, SpaceType.PropertySpace , "Leicester Square" , 5, 260, 150, new int[] { 22, 110, 330, 800, 975, 1150 });
board.Spaces[27] = new Space(27, SpaceType.PropertySpace , "Coventry Street" , 5, 260, 150, new int[] { 22, 110, 330, 800, 975, 1150 });
board.Spaces[28] = new Space(28, SpaceType.UtilitySpace , "Water Works" , 150);
board.Spaces[29] = new Space(29, SpaceType.PropertySpace , "Piccadilly" , 5, 280, 150, new int[] { 24, 120, 360, 850, 1025, 1200 });
board.Spaces[30] = new Space(30, SpaceType.GoToJailSpace , "Go to Jail" );
board.Spaces[31] = new Space(31, SpaceType.PropertySpace , "Regent Street" , 6, 300, 200, new int[] { 26, 130, 390, 900, 1100, 1275 });
board.Spaces[32] = new Space(32, SpaceType.PropertySpace , "Oxford Street" , 6, 300, 200, new int[] { 26, 130, 390, 900, 1100, 1275 });
board.Spaces[33] = new Space(33, SpaceType.CommunityChestSpace, "Community Chest" );
board.Spaces[34] = new Space(34, SpaceType.PropertySpace , "Bond Street" , 6, 320, 200, new int[] { 28, 150, 450, 1000, 1200, 1400 });
board.Spaces[35] = new Space(35, SpaceType.RailroadSpace , "Liverpool Street Station" , 200);
board.Spaces[36] = new Space(36, SpaceType.ChanceSpace , "Chance" );
board.Spaces[37] = new Space(37, SpaceType.PropertySpace , "Park Lane" , 7, 350, 200, new int[] { 35, 175, 500, 1100, 1300, 1500 });
board.Spaces[38] = new Space(38, SpaceType.SuperTaxSpace , "Super Tax" );
board.Spaces[39] = new Space(39, SpaceType.PropertySpace , "Mayfair" , 7, 400, 200, new int[] { 50, 200, 600, 1400, 1700, 2000 });
board.DistrictColours = new string[] { "5", "11", "13", "7", "4", "8", "9", "12" };
board.ChanceCards = new Card[16];
board.ChanceCardsRemaining = 16;
board.ChanceCards[ 0] = new Card(false, "Advance to Go.", "Collect $200", Chance.GoToGo);
board.ChanceCards[ 1] = new Card(false, "The bank pays you a dividend of $50.", null, g => Chance.Money(g, 50));
board.ChanceCards[ 2] = new Card(false, "Go back 3 spaces.", null, g => Chance.GoRelative(g, -3));
board.ChanceCards[ 3] = new Card(false, "Advance to the nearest utility.", "If unowned, you may buy it from the bank. If owned, roll the dice and pay the owner ten times the amount rolled.", Chance.GoToUtility);
board.ChanceCards[ 4] = new Card(false, "Go directly to jail.", "Do not pass Go; do not collect $200.", Chance.GoToJail);
board.ChanceCards[ 5] = new Card(false, "Pay poor tax of $15.", null, g => Chance.Money(g, -15));
board.ChanceCards[ 6] = new Card(false, "Advance to Pall Mall.", "If you pass Go, collect $200.", g => g.GoToSpace(11));
board.ChanceCards[ 7] = new Card(false, "You have been elected chairman of the board. Pay each player $50.", null, g => Chance.PayEveryone(g, 50));
board.ChanceCards[ 8] = new Card(false, "Advance to the nearest railroad and pay the owner twice the rent to which they would otherwise be entitled.", "If the railroad is not owned, you may buy it from the bank.", Chance.GoToRailroad);
board.ChanceCards[ 9] = new Card(false, "Take a ride from Kings Cross.", "If you pass Go, collect $200.", g => g.GoToSpace(5));
board.ChanceCards[10] = new Card(false, "Advance to the nearest railroad and pay the owner twice the rent to which they would otherwise be entitled.", "If the railroad is not owned, you may buy it from the bank.", Chance.GoToRailroad);
board.ChanceCards[11] = new Card(false, "Take a walk on the board walk. Advance to Mayfair.", null, g => g.GoToSpace(39));
board.ChanceCards[12] = new Card(false, "Your building loan matures. Collect $150.", null, g => Chance.Money(g, 150));
board.ChanceCards[13] = new Card(false, "Advance to Trafalgar Square.", null, g => g.GoToSpace(24));
board.ChanceCards[14] = new Card(false, "Get out of jail free!", "This card may be kept until needed or sold.", g => Chance.GetOutOfJailFree(g, false));
board.ChanceCards[15] = new Card(false, "Make general repairs on all your property.", "For each house, pay $25; for each hotel, $100.", g => Chance.StreetRepairs(g, 25, 100));
board.CommunityChestCards = new Card[15];
board.CommunityChestCardsRemaining = 15;
board.CommunityChestCards[ 0] = new Card(true, "Grand opera opening. Collect $50 from every other player.", null, g => Chance.PayEveryone(g, -50));
board.CommunityChestCards[ 1] = new Card(true, "Receive, for services, $25.", null, g => Chance.Money(g, 25));
board.CommunityChestCards[ 2] = new Card(true, "Advance to Go.", "Collect $200.", Chance.GoToGo);
board.CommunityChestCards[ 3] = new Card(true, "Pay hospital $100.", null, g => Chance.Money(g, -100));
board.CommunityChestCards[ 4] = new Card(true, "Doctor's fee: pay $50.", null, g => Chance.Money(g, -50));
board.CommunityChestCards[ 5] = new Card(true, "Get out of jail free!", "This card may be kept until needed or sold.", g => Chance.GetOutOfJailFree(g, true));
board.CommunityChestCards[ 6] = new Card(true, "From sale of stock, you get $45.", null, g => Chance.Money(g, 45));
board.CommunityChestCards[ 7] = new Card(true, "You inherit $100.", null, g => Chance.Money(g, 100));
board.CommunityChestCards[ 8] = new Card(true, "Go to jail.", "Go directly to Jail. Do not pass Go; do not collect $200.", Chance.GoToJail);
board.CommunityChestCards[ 9] = new Card(true, "Life insurance matures; collect $100.", null, g => Chance.Money(g, 100));
board.CommunityChestCards[10] = new Card(true, "You have won second prize in a beauty contest. Collect $10.", null, g => Chance.Money(g, 10));
board.CommunityChestCards[11] = new Card(true, "Christmas fund matures; collect $100.", null, g => Chance.Money(g, 100));
board.CommunityChestCards[12] = new Card(true, "You are assessed for street repairs: $40 per house, $115 per hotel.", null, g => Chance.StreetRepairs(g, 40, 115));
board.CommunityChestCards[13] = new Card(true, "Bank error in your favour; collect $200.", null, g => Chance.Money(g, 200));
board.CommunityChestCards[14] = new Card(true, "Income tax refund; collect $20.", null, g => Chance.Money(g, 20));
return board;
}
public static Board InitialiseUS() {
Board board = new Board();
board.Name = "UK";
board.Spaces = new Space[40];
// # Type Name Group Price House price Rent 1 2 3 4 Hotel
board.Spaces[ 0] = new Space( 0, SpaceType.GoSpace , "Go" );
board.Spaces[ 1] = new Space( 1, SpaceType.PropertySpace , "Mediterranean Avenue" , 0, 60, 50, new int[] { 2, 10, 30, 90, 160, 250 });
board.Spaces[ 2] = new Space( 2, SpaceType.CommunityChestSpace, "Community Chest" );
board.Spaces[ 3] = new Space( 3, SpaceType.PropertySpace , "Baltic Avenue" , 0, 60, 50, new int[] { 4, 20, 60, 180, 320, 450 });
board.Spaces[ 4] = new Space( 4, SpaceType.IncomeTaxSpace , "Income Tax" );
board.Spaces[ 5] = new Space( 5, SpaceType.RailroadSpace , "Reading Railroad" , 200);
board.Spaces[ 6] = new Space( 6, SpaceType.PropertySpace , "Oriental Avenue" , 1, 100, 50, new int[] { 6, 30, 90, 270, 400, 550 });
board.Spaces[ 7] = new Space( 7, SpaceType.ChanceSpace , "Chance" );
board.Spaces[ 8] = new Space( 8, SpaceType.PropertySpace , "Vermont Avenue" , 1, 100, 50, new int[] { 6, 30, 90, 270, 400, 550 });
board.Spaces[ 9] = new Space( 9, SpaceType.PropertySpace , "Connecticut Avenue" , 1, 120, 50, new int[] { 8, 40, 100, 300, 450, 600 });
board.Spaces[10] = new Space(10, SpaceType.JailSpace , "Jail" );
board.Spaces[11] = new Space(11, SpaceType.PropertySpace , "St. Charles Place" , 2, 140, 100, new int[] { 10, 50, 150, 450, 625, 750 });
board.Spaces[12] = new Space(12, SpaceType.UtilitySpace , "Electric Company" , 150);
board.Spaces[13] = new Space(13, SpaceType.PropertySpace , "States Avenue" , 2, 140, 100, new int[] { 10, 50, 150, 450, 625, 750 });
board.Spaces[14] = new Space(14, SpaceType.PropertySpace , "Virginia Avenue" , 2, 160, 100, new int[] { 12, 60, 180, 500, 700, 900 });
board.Spaces[15] = new Space(15, SpaceType.RailroadSpace , "Pennsylvania Railroad" , 200);
board.Spaces[16] = new Space(16, SpaceType.PropertySpace , "St. James Place" , 3, 180, 100, new int[] { 14, 70, 200, 550, 750, 950 });
board.Spaces[17] = new Space(17, SpaceType.CommunityChestSpace, "Community Chest" );
board.Spaces[18] = new Space(18, SpaceType.PropertySpace , "Tennessee Avenue" , 3, 180, 100, new int[] { 14, 70, 200, 550, 750, 950 });
board.Spaces[19] = new Space(19, SpaceType.PropertySpace , "New York Avenue" , 3, 200, 100, new int[] { 16, 80, 220, 600, 800, 1000 });
board.Spaces[20] = new Space(20, SpaceType.FreeParkingSpace , "Free Parking" );
board.Spaces[21] = new Space(21, SpaceType.PropertySpace , "Kentucky Avenue" , 4, 220, 150, new int[] { 18, 90, 250, 700, 875, 1050 });
board.Spaces[22] = new Space(22, SpaceType.ChanceSpace , "Chance" );
board.Spaces[23] = new Space(23, SpaceType.PropertySpace , "Indiana Avenue" , 4, 220, 150, new int[] { 18, 90, 250, 700, 875, 1050 });
board.Spaces[24] = new Space(24, SpaceType.PropertySpace , "Illinois Avenue" , 4, 240, 150, new int[] { 20, 100, 300, 750, 925, 1100 });
board.Spaces[25] = new Space(25, SpaceType.RailroadSpace , "B&O Railroad" , 200);
board.Spaces[26] = new Space(26, SpaceType.PropertySpace , "Atlantic Avenue" , 5, 260, 150, new int[] { 22, 110, 330, 800, 975, 1150 });
board.Spaces[27] = new Space(27, SpaceType.PropertySpace , "Ventnor Avenue" , 5, 260, 150, new int[] { 22, 110, 330, 800, 975, 1150 });
board.Spaces[28] = new Space(28, SpaceType.UtilitySpace , "Water Works" , 150);
board.Spaces[29] = new Space(29, SpaceType.PropertySpace , "Marven Gardens" , 5, 280, 150, new int[] { 24, 120, 360, 850, 1025, 1200 });
board.Spaces[30] = new Space(30, SpaceType.GoToJailSpace , "Go to Jail" );
board.Spaces[31] = new Space(31, SpaceType.PropertySpace , "Pacific Avenue" , 6, 300, 200, new int[] { 26, 130, 390, 900, 1100, 1275 });
board.Spaces[32] = new Space(32, SpaceType.PropertySpace , "North Carolina Avenue", 6, 300, 200, new int[] { 26, 130, 390, 900, 1100, 1275 });
board.Spaces[33] = new Space(33, SpaceType.CommunityChestSpace, "Community Chest" );
board.Spaces[34] = new Space(34, SpaceType.PropertySpace , "Pennsylvania Avenue" , 6, 320, 200, new int[] { 28, 150, 450, 1000, 1200, 1400 });
board.Spaces[35] = new Space(35, SpaceType.RailroadSpace , "Short Line Railroad" , 200);
board.Spaces[36] = new Space(36, SpaceType.ChanceSpace , "Chance" );
board.Spaces[37] = new Space(37, SpaceType.PropertySpace , "Park Place" , 7, 350, 200, new int[] { 35, 175, 500, 1100, 1300, 1500 });
board.Spaces[38] = new Space(38, SpaceType.SuperTaxSpace , "Luxury Tax" );
board.Spaces[39] = new Space(39, SpaceType.PropertySpace , "Boardwalk" , 7, 400, 200, new int[] { 50, 200, 600, 1400, 1700, 2000 });
board.DistrictColours = new string[] { "6", "11", "13", "7", "4", "8", "9", "12" };
board.ChanceCards = new Card[16];
board.ChanceCardsRemaining = 16;
board.ChanceCards[ 0] = new Card(false, "Advance to Go.", "Collect $200", Chance.GoToGo);
board.ChanceCards[ 1] = new Card(false, "The bank pays you a dividend of $50.", null, g => Chance.Money(g, 50));
board.ChanceCards[ 2] = new Card(false, "Go back 3 spaces.", null, g => Chance.GoRelative(g, -3));
board.ChanceCards[ 3] = new Card(false, "Advance to the nearest utility.", "If unowned, you may buy it from the bank. If owned, roll the dice and pay the owner ten times the amount rolled.", Chance.GoToUtility);
board.ChanceCards[ 4] = new Card(false, "Go directly to jail.", "Do not pass Go; do not collect $200.", Chance.GoToJail);
board.ChanceCards[ 5] = new Card(false, "Pay poor tax of $15.", null, g => Chance.Money(g, -15));
board.ChanceCards[ 6] = new Card(false, "Advance to St. Charles Place.", "If you pass Go, collect $200.", g => g.GoToSpace(11));
board.ChanceCards[ 7] = new Card(false, "You have been elected chairman of the board. Pay each player $50.", null, g => Chance.PayEveryone(g, 50));
board.ChanceCards[ 8] = new Card(false, "Advance to the nearest railroad and pay the owner twice the rent to which they would otherwise be entitled.", "If the railroad is not owned, you may buy it from the bank.", Chance.GoToRailroad);
board.ChanceCards[ 9] = new Card(false, "Take a ride from the Reading Railroad.", "If you pass Go, collect $200.", g => g.GoToSpace(5));
board.ChanceCards[10] = new Card(false, "Advance to the nearest railroad and pay the owner twice the rent to which they would otherwise be entitled.", "If the railroad is not owned, you may buy it from the bank.", Chance.GoToRailroad);
board.ChanceCards[11] = new Card(false, "Take a walk on the board walk.", null, g => g.GoToSpace(39));
board.ChanceCards[12] = new Card(false, "Your building loan matures. Collect $150.", null, g => Chance.Money(g, 150));
board.ChanceCards[13] = new Card(false, "Advance to Illinois Avenue.", null, g => g.GoToSpace(24));
board.ChanceCards[14] = new Card(false, "Get out of jail free!", "This card may be kept until needed or sold.", g => Chance.GetOutOfJailFree(g, false));
board.ChanceCards[15] = new Card(false, "Make general repairs on all your property.", "For each house, pay $25; for each hotel, $100.", g => Chance.StreetRepairs(g, 25, 100));
board.CommunityChestCards = new Card[15];
board.CommunityChestCardsRemaining = 15;
board.CommunityChestCards[ 0] = new Card(true, "Grand opera opening. Collect $50 from every other player.", null, g => Chance.PayEveryone(g, -50));
board.CommunityChestCards[ 1] = new Card(true, "Receive, for services, $25.", null, g => Chance.Money(g, 25));
board.CommunityChestCards[ 2] = new Card(true, "Advance to Go.", "Collect $200.", Chance.GoToGo);
board.CommunityChestCards[ 3] = new Card(true, "Pay hospital $100.", null, g => Chance.Money(g, -100));
board.CommunityChestCards[ 4] = new Card(true, "Doctor's fee: pay $50.", null, g => Chance.Money(g, -50));
board.CommunityChestCards[ 5] = new Card(true, "Get out of jail free!", "This card may be kept until needed or sold.", g => Chance.GetOutOfJailFree(g, true));
board.CommunityChestCards[ 6] = new Card(true, "From sale of stock, you get $45.", null, g => Chance.Money(g, 45));
board.CommunityChestCards[ 7] = new Card(true, "You inherit $100.", null, g => Chance.Money(g, 100));
board.CommunityChestCards[ 8] = new Card(true, "Go to jail.", "Go directly to Jail. Do not pass Go; do not collect $200.", Chance.GoToJail);
board.CommunityChestCards[ 9] = new Card(true, "Life insurance matures; collect $100.", null, g => Chance.Money(g, 100));
board.CommunityChestCards[10] = new Card(true, "You have won second prize in a beauty contest. Collect $10.", null, g => Chance.Money(g, 10));
board.CommunityChestCards[11] = new Card(true, "Christmas fund matures; collect $100.", null, g => Chance.Money(g, 100));
board.CommunityChestCards[12] = new Card(true, "You are assessed for street repairs: $40 per house, $115 per hotel.", null, g => Chance.StreetRepairs(g, 40, 115));
board.CommunityChestCards[13] = new Card(true, "Bank error in your favour; collect $200.", null, g => Chance.Money(g, 200));
board.CommunityChestCards[14] = new Card(true, "Income tax refund; collect $20.", null, g => Chance.Money(g, 20));
return board;
}
public static Board InitialiseJunior() {
Board board = new Board();
board.Name = "Junior";
board.Spaces = new Space[32];
// # Type Name Group Price
board.Spaces[ 0] = new Space( 0, SpaceType.GoSpace , "Go" );
board.Spaces[ 1] = new Space( 1, SpaceType.ChanceSpace , "Chance" );
board.Spaces[ 2] = new Space( 2, SpaceType.PropertySpace , "Balloon Stand" , 0, 1);
board.Spaces[ 3] = new Space( 3, SpaceType.PropertySpace , "Cotton Candy" , 0, 1);
board.Spaces[ 4] = new Space( 4, SpaceType.ChanceSpace , "Chance" );
board.Spaces[ 5] = new Space( 5, SpaceType.RailroadSpace , "Yellow Line Railroad" );
board.Spaces[ 6] = new Space( 6, SpaceType.PropertySpace , "Puppet Show" , 1, 2);
board.Spaces[ 7] = new Space( 7, SpaceType.PropertySpace , "Magic Show" , 1, 2);
board.Spaces[ 8] = new Space( 8, SpaceType.IncomeTaxSpace , "Fireworks" );
board.Spaces[ 9] = new Space( 9, SpaceType.ChanceSpace , "Chance" );
board.Spaces[10] = new Space(10, SpaceType.JailSpace , "Lunch" );
board.Spaces[11] = new Space(11, SpaceType.PropertySpace , "Roller Coaster" , 2, 2);
board.Spaces[12] = new Space(12, SpaceType.PropertySpace , "Paddle Boats" , 2, 2);
board.Spaces[13] = new Space(13, SpaceType.RailroadSpace , "Green Line Railroad" );
board.Spaces[14] = new Space(14, SpaceType.PropertySpace , "Haunted House" , 3, 3);
board.Spaces[15] = new Space(15, SpaceType.PropertySpace , "Video Arcade" , 3, 3);
board.Spaces[16] = new Space(16, SpaceType.FreeParkingSpace , "Mr. Monopoly's Loose Change" );
board.Spaces[17] = new Space(17, SpaceType.ChanceSpace , "Chance" );
board.Spaces[18] = new Space(18, SpaceType.PropertySpace , "Pony Ride" , 4, 3);
board.Spaces[19] = new Space(19, SpaceType.PropertySpace , "Water Slide" , 4, 3);
board.Spaces[20] = new Space(20, SpaceType.ChanceSpace , "Chance" );
board.Spaces[21] = new Space(21, SpaceType.RailroadSpace , "Blue Line Railroad" );
board.Spaces[22] = new Space(22, SpaceType.PropertySpace , "Helicopter Ride" , 5, 4);
board.Spaces[23] = new Space(23, SpaceType.PropertySpace , "Miniature Golf" , 5, 4);
board.Spaces[24] = new Space(24, SpaceType.SuperTaxSpace , "Water Show" );
board.Spaces[25] = new Space(25, SpaceType.ChanceSpace , "Chance" );
board.Spaces[26] = new Space(26, SpaceType.GoToJailSpace , "Bus to Lunch" );
board.Spaces[27] = new Space(27, SpaceType.PropertySpace , "Bumper Cars" , 6, 4);
board.Spaces[28] = new Space(28, SpaceType.PropertySpace , "Ferris Wheel" , 6, 4);
board.Spaces[29] = new Space(29, SpaceType.RailroadSpace , "Red Line Railroad" );
board.Spaces[30] = new Space(30, SpaceType.PropertySpace , "Loop-the-Loop" , 7, 5);
board.Spaces[31] = new Space(31, SpaceType.PropertySpace , "Merry-Go-Round" , 7, 5);
board.DistrictColours = new string[] { "5", "11", "13", "7", "4", "8", "9", "12" };
board.ChanceCards = new Card[24];
board.ChanceCardsRemaining = 24;
board.ChanceCards[ 0] = new Card(false, "Free ticket booth (district A)", null, g => Chance.FreeTicketBooth(g, 0));
board.ChanceCards[ 1] = new Card(false, "Free ticket booth (district B)", null, g => Chance.FreeTicketBooth(g, 1));
board.ChanceCards[ 2] = new Card(false, "Free ticket booth (district B)", null, g => Chance.FreeTicketBooth(g, 1));
board.ChanceCards[ 3] = new Card(false, "Free ticket booth (district C)", null, g => Chance.FreeTicketBooth(g, 2));
board.ChanceCards[ 4] = new Card(false, "Free ticket booth (district D)", null, g => Chance.FreeTicketBooth(g, 3));
board.ChanceCards[ 5] = new Card(false, "Free ticket booth (district D)", null, g => Chance.FreeTicketBooth(g, 3));
board.ChanceCards[ 6] = new Card(false, "Free ticket booth (district E)", null, g => Chance.FreeTicketBooth(g, 4));
board.ChanceCards[ 7] = new Card(false, "Free ticket booth (district F)", null, g => Chance.FreeTicketBooth(g, 5));
board.ChanceCards[ 8] = new Card(false, "Free ticket booth (district F)", null, g => Chance.FreeTicketBooth(g, 5));
board.ChanceCards[ 9] = new Card(false, "Free ticket booth (district G)", null, g => Chance.FreeTicketBooth(g, 6));
board.ChanceCards[10] = new Card(false, "Free ticket booth (district H)", null, g => Chance.FreeTicketBooth(g, 7));
board.ChanceCards[11] = new Card(false, "Free ticket booth (district H)", null, g => Chance.FreeTicketBooth(g, 7));
board.ChanceCards[12] = new Card(false, "Pay $3 to take the bus to lunch.", null, Chance.GoToJail);
board.ChanceCards[13] = new Card(false, "Take a ride on the Red Line Railroad,", "and roll again.", g => g.GoToSpace(29));
board.ChanceCards[14] = new Card(false, "Take a ride on the Green Line Railroad,", "and roll again.", g => g.GoToSpace(13));
board.ChanceCards[15] = new Card(false, "Take a ride on the Blue Line Railroad,", "and roll again.", g => g.GoToSpace(21));
board.ChanceCards[16] = new Card(false, "Go to the Bumper Cars.", null, g => g.GoToSpace(27));
board.ChanceCards[17] = new Card(false, "Go to the Merry-Go-Round.", null, g => g.GoToSpace(31));
board.ChanceCards[18] = new Card(false, "Go to the Video Arcade.", null, g => g.GoToSpace(15));
board.ChanceCards[19] = new Card(false, "Go to the Loop-the-Loop.", null, g => g.GoToSpace(30));
board.ChanceCards[20] = new Card(false, "Go to the Water Slide.", null, g => g.GoToSpace(19));
board.ChanceCards[21] = new Card(false, "Go to the Water Show,", "and pay $2.", g => g.GoToSpace(24));
board.ChanceCards[22] = new Card(false, "Go to the Firework Show,", "and pay $2.", g => g.GoToSpace(8));
board.ChanceCards[23] = new Card(false, "Go to Go.", "Collect $2 allowance as you pass.", Chance.GoToGo);
return board;
}
public static Board InitialiseIRC() {
Board board = new Board();
board.Name = "IRC";
board.Spaces = new Space[40];
// # Type Name Group Price House price Rent 1 2 3 4 Hotel
board.Spaces[ 0] = new Space( 0, SpaceType.GoSpace , "Go" );
board.Spaces[ 1] = new Space( 1, SpaceType.PropertySpace , "GeekShed" , 0, 60, 50, new int[] { 2, 10, 30, 90, 160, 250 });
board.Spaces[ 2] = new Space( 2, SpaceType.CommunityChestSpace, "Community Chest" );
board.Spaces[ 3] = new Space( 3, SpaceType.PropertySpace , "synIRC" , 0, 60, 50, new int[] { 4, 20, 60, 180, 320, 450 });
board.Spaces[ 4] = new Space( 4, SpaceType.IncomeTaxSpace , "Income Tax" );
board.Spaces[ 5] = new Space( 5, SpaceType.RailroadSpace , "irssi" , 200);
board.Spaces[ 6] = new Space( 6, SpaceType.PropertySpace , "GIMPnet" , 1, 100, 50, new int[] { 6, 30, 90, 270, 400, 550 });
board.Spaces[ 7] = new Space( 7, SpaceType.ChanceSpace , "Chance" );
board.Spaces[ 8] = new Space( 8, SpaceType.PropertySpace , "ExplosionIRC" , 1, 100, 50, new int[] { 6, 30, 90, 270, 400, 550 });
board.Spaces[ 9] = new Space( 9, SpaceType.PropertySpace , "KampungChat" , 1, 120, 50, new int[] { 8, 40, 100, 300, 450, 600 });
board.Spaces[10] = new Space(10, SpaceType.JailSpace , "Jail" );
board.Spaces[11] = new Space(11, SpaceType.PropertySpace , "Snoonet" , 2, 140, 100, new int[] { 10, 50, 150, 450, 625, 750 });
board.Spaces[12] = new Space(12, SpaceType.UtilitySpace , "Mibbit" , 150);
board.Spaces[13] = new Space(13, SpaceType.PropertySpace , "Geveze" , 2, 140, 100, new int[] { 10, 50, 150, 450, 625, 750 });
board.Spaces[14] = new Space(14, SpaceType.PropertySpace , "OltreIrc" , 2, 160, 100, new int[] { 12, 60, 180, 500, 700, 900 });
board.Spaces[15] = new Space(15, SpaceType.RailroadSpace , "WeeChat" , 200);
board.Spaces[16] = new Space(16, SpaceType.PropertySpace , "Mozilla" , 3, 180, 100, new int[] { 14, 70, 200, 550, 750, 950 });
board.Spaces[17] = new Space(17, SpaceType.CommunityChestSpace, "Community Chest" );
board.Spaces[18] = new Space(18, SpaceType.PropertySpace , "IRC-Hispano" , 3, 180, 100, new int[] { 14, 70, 200, 550, 750, 950 });
board.Spaces[19] = new Space(19, SpaceType.PropertySpace , "EsperNet" , 3, 200, 100, new int[] { 16, 80, 220, 600, 800, 1000 });
board.Spaces[20] = new Space(20, SpaceType.FreeParkingSpace , "Free Parking" );
board.Spaces[21] = new Space(21, SpaceType.PropertySpace , "Chatzona" , 4, 220, 150, new int[] { 18, 90, 250, 700, 875, 1050 });
board.Spaces[22] = new Space(22, SpaceType.ChanceSpace , "Chance" );
board.Spaces[23] = new Space(23, SpaceType.PropertySpace , "OFTC" , 4, 220, 150, new int[] { 18, 90, 250, 700, 875, 1050 });
board.Spaces[24] = new Space(24, SpaceType.PropertySpace , "Rizon" , 4, 240, 150, new int[] { 20, 100, 300, 750, 925, 1100 });
board.Spaces[25] = new Space(25, SpaceType.RailroadSpace , "mIRC" , 200);
board.Spaces[26] = new Space(26, SpaceType.PropertySpace , "IRCHighway" , 5, 260, 150, new int[] { 22, 110, 330, 800, 975, 1150 });
board.Spaces[27] = new Space(27, SpaceType.PropertySpace , "GameSurge" , 5, 260, 150, new int[] { 22, 110, 330, 800, 975, 1150 });
board.Spaces[28] = new Space(28, SpaceType.UtilitySpace , "IRCCloud" , 150);
board.Spaces[29] = new Space(29, SpaceType.PropertySpace , "QuakeNet" , 5, 280, 150, new int[] { 24, 120, 360, 850, 1025, 1200 });
board.Spaces[30] = new Space(30, SpaceType.GoToJailSpace , "Go to Jail" );
board.Spaces[31] = new Space(31, SpaceType.PropertySpace , "DALnet" , 6, 300, 200, new int[] { 26, 130, 390, 900, 1100, 1275 });
board.Spaces[32] = new Space(32, SpaceType.PropertySpace , "Undernet" , 6, 300, 200, new int[] { 26, 130, 390, 900, 1100, 1275 });
board.Spaces[33] = new Space(33, SpaceType.CommunityChestSpace, "Community Chest" );
board.Spaces[34] = new Space(34, SpaceType.PropertySpace , "EFnet" , 6, 320, 200, new int[] { 28, 150, 450, 1000, 1200, 1400 });
board.Spaces[35] = new Space(35, SpaceType.RailroadSpace , "HexChat" , 200);
board.Spaces[36] = new Space(36, SpaceType.ChanceSpace , "Chance" );
board.Spaces[37] = new Space(37, SpaceType.PropertySpace , "IRCNet" , 7, 350, 200, new int[] { 35, 175, 500, 1100, 1300, 1500 });
board.Spaces[38] = new Space(38, SpaceType.SuperTaxSpace , "Super Tax" );
board.Spaces[39] = new Space(39, SpaceType.PropertySpace , "freenode" , 7, 400, 200, new int[] { 50, 200, 600, 1400, 1700, 2000 });
board.DistrictColours = new string[] { "5", "11", "13", "7", "4", "8", "9", "12" };
board.ChanceCards = new Card[16];
board.ChanceCardsRemaining = 16;
board.ChanceCards[ 0] = new Card(false, "Advance to Go.", "Collect $200", Chance.GoToGo);
board.ChanceCards[ 1] = new Card(false, "The bank pays you a dividend of $50.", null, g => Chance.Money(g, 50));
board.ChanceCards[ 2] = new Card(false, "Go back 3 spaces.", null, g => Chance.GoRelative(g, -3));
board.ChanceCards[ 3] = new Card(false, "Advance to the nearest utility.", "If unowned, you may buy it from the bank. If owned, roll the dice and pay the owner ten times the amount rolled.", Chance.GoToUtility);
board.ChanceCards[ 4] = new Card(false, "Go directly to jail.", "Do not pass Go; do not collect $200.", Chance.GoToJail);
board.ChanceCards[ 5] = new Card(false, "Pay poor tax of $15.", null, g => Chance.Money(g, -15));
board.ChanceCards[ 6] = new Card(false, "Advance to Pall Mall.", "If you pass Go, collect $200.", g => g.GoToSpace(11));
board.ChanceCards[ 7] = new Card(false, "You have been elected chairman of the board. Pay each player $50.", null, g => Chance.PayEveryone(g, 50));
board.ChanceCards[ 8] = new Card(false, "Advance to the nearest railroad and pay the owner twice the rent to which they would otherwise be entitled.", "If the railroad is not owned, you may buy it from the bank.", Chance.GoToRailroad);
board.ChanceCards[ 9] = new Card(false, "Take a ride from Kings Cross.", "If you pass Go, collect $200.", g => g.GoToSpace(5));
board.ChanceCards[10] = new Card(false, "Advance to the nearest railroad and pay the owner twice the rent to which they would otherwise be entitled.", "If the railroad is not owned, you may buy it from the bank.", Chance.GoToRailroad);
board.ChanceCards[11] = new Card(false, "Take a walk on the board walk. Advance to Mayfair.", null, g => g.GoToSpace(39));
board.ChanceCards[12] = new Card(false, "Your building loan matures. Collect $150.", null, g => Chance.Money(g, 150));
board.ChanceCards[13] = new Card(false, "Advance to Trafalgar Square.", null, g => g.GoToSpace(24));
board.ChanceCards[14] = new Card(false, "Get out of jail free!", "This card may be kept until needed or sold.", g => Chance.GetOutOfJailFree(g, false));
board.ChanceCards[15] = new Card(false, "Make general repairs on all your property.", "For each house, pay $25; for each hotel, $100.", g => Chance.StreetRepairs(g, 25, 100));
board.CommunityChestCards = new Card[15];
board.CommunityChestCardsRemaining = 15;
board.CommunityChestCards[ 0] = new Card(true, "Grand opera opening. Collect $50 from every other player.", null, g => Chance.PayEveryone(g, -50));
board.CommunityChestCards[ 1] = new Card(true, "Receive, for services, $25.", null, g => Chance.Money(g, 25));
board.CommunityChestCards[ 2] = new Card(true, "Advance to Go.", "Collect $200.", Chance.GoToGo);
board.CommunityChestCards[ 3] = new Card(true, "Pay hospital $100.", null, g => Chance.Money(g, -100));
board.CommunityChestCards[ 4] = new Card(true, "Doctor's fee: pay $50.", null, g => Chance.Money(g, -50));
board.CommunityChestCards[ 5] = new Card(true, "Get out of jail free!", "This card may be kept until needed or sold.", g => Chance.GetOutOfJailFree(g, true));
board.CommunityChestCards[ 6] = new Card(true, "From sale of stock, you get $45.", null, g => Chance.Money(g, 45));
board.CommunityChestCards[ 7] = new Card(true, "You inherit $100.", null, g => Chance.Money(g, 100));
board.CommunityChestCards[ 8] = new Card(true, "Go to jail.", "Go directly to Jail. Do not pass Go; do not collect $200.", Chance.GoToJail);
board.CommunityChestCards[ 9] = new Card(true, "Life insurance matures; collect $100.", null, g => Chance.Money(g, 100));
board.CommunityChestCards[10] = new Card(true, "You have won second prize in a beauty contest. Collect $10.", null, g => Chance.Money(g, 10));
board.CommunityChestCards[11] = new Card(true, "Christmas fund matures; collect $100.", null, g => Chance.Money(g, 100));
board.CommunityChestCards[12] = new Card(true, "You are assessed for street repairs: $40 per house, $115 per hotel.", null, g => Chance.StreetRepairs(g, 40, 115));
board.CommunityChestCards[13] = new Card(true, "Bank error in your favour; collect $200.", null, g => Chance.Money(g, 200));
board.CommunityChestCards[14] = new Card(true, "Income tax refund; collect $20.", null, g => Chance.Money(g, 20));
return board;
}
public int IndexOfNext(Func<Space, bool> predicate, int startIndex) {
for (int i = (startIndex + 1) % this.Spaces.Length; i != startIndex; i = (i + 1) % this.Spaces.Length) {
if (predicate.Invoke(this.Spaces[i])) return i;
}
return -1;
}
public bool TryParseSpace(string input, out int spaceIndex) {
input = input.Replace(" ", "");
spaceIndex = -1;
int side = -1; int number = 0;
// Allow 'chance 1' etc.
var match = Regex.Match(input, @"^\s*(.*)\s+(\d+)\s*$");
if (match.Success) {
number = int.Parse(match.Groups[2].Value);
input = match.Groups[1].Value;
} else {
// Allow 'south Chance' etc.
match = Regex.Match(input, @"^(?:(?<N>n(?:orth)?)|(?<S>s(?:outh)?)|(?<E>e(?:ast)?)|(?<W>w(?:est)?))(?<Place>C(?!a).*)", RegexOptions.IgnoreCase);
// Northumberland Avenue and North Carolina Avenue don't count.
if (!match.Success) {
match = Regex.Match(input, @"^(?<Place>C.*?)(?:(?<N>n(?:orth)?)|(?<S>s(?:outh)?)|(?<E>e(?:ast)?)|(?<W>w(?:est)?))$", RegexOptions.IgnoreCase);
}
if (match.Success) {
if (match.Groups["S"].Success)
side = 0;
else if (match.Groups["W"].Success)
side = 1;
else if (match.Groups["N"].Success)
side = 2;
else
side = 3;
input = match.Groups["Place"].Value;
}
}
// Since there is more than one Chance or Community Chest space, you must specify a number or a side of the board for those.
SpaceType spaceType;
if (input.Equals("Chance", StringComparison.InvariantCultureIgnoreCase)) spaceType = SpaceType.ChanceSpace;
else if (input.EndsWith("Chest", StringComparison.InvariantCultureIgnoreCase)) spaceType = SpaceType.CommunityChestSpace;
else spaceType = 0;
if (spaceType != 0 && side < 0 && number <= 0) {
spaceIndex = -2;
return false;
}
int currentSide = 0;
for (int i = 0; i < this.Spaces.Length; ++i) {
var space = this.Spaces[i];
var name = space.Name.Replace(" ", "");
if (side >= 0) {
if (space.Type == SpaceType.GoSpace || space.Type == SpaceType.JailSpace || space.Type == SpaceType.FreeParkingSpace || space.Type == SpaceType.GoToJailSpace)
++currentSide;
if (currentSide % 4 != side) continue;
}
if (spaceType != 0) {
if (space.Type == spaceType) {
if (number < 0) {
// Specified a side.
spaceIndex = i;
return true;
} else {
// Specified a number.
--number;
if (number == 0) {
spaceIndex = i;
return true;
}
}
}
} else if (name.StartsWith(input, StringComparison.InvariantCultureIgnoreCase)) {
if (name.Length == input.Length) {
// Exact match (needed to avoid ambiguity between 'Go' and 'Go to Jail')
spaceIndex = i;
return true;
} else {
if (spaceIndex < 0)
spaceIndex = i;
else {
// Ambiguous search text
spaceIndex = -2;
return false;
}
}
}
}
if (number > 0) spaceIndex = -1; // Specified a number greater than the number of matching spaces.
return spaceIndex >= 0;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment