private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { railroad = (Game1.getLocationFromName("Railroad") as Railroad); startupMessage = true; //Check for JSON Assests //if (this.Helper.ModRegistry.IsLoaded("spacechase0.JsonAssets")) //{ // var api = modHelper.ModRegistry.GetApi<IJsonAssetsAPI>("spacechase0.JsonAssets"); // var trees = api?.GetAllFruitTreeIds(); // var crops = api?.GetAllCropIds(); // //Game1.Get //} var fish = Game1.content.Load <Dictionary <int, string> >("Data\\Fish"); var fruitTrees = Game1.content.Load <Dictionary <int, string> >("Data\\fruitTrees"); var crops = Game1.content.Load <Dictionary <int, string> >("Data\\Crops"); ////Content Packs //foreach (IContentPack contentPack in this.Helper.ContentPacks.GetOwned()) //{ // this.Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}"); //} }
public void CheckforInvisbleRailroads() { ExtensionMethods.niceLayout("checking for some 'vitural' railroads to be made with stations"); City city; foreach (Station station in stations) // max 3 { if (station.getCity() != null) { city = station.getCity(); foreach (City stad in city.getNeighBours()) // itereren over de buren (max 6) { foreach (Railroad road in network) // iterren over de sporen fan de speler (max 30) { if (road.getdestinations()[0].getID() == stad.getID() || road.getdestinations()[1].getID() == stad.getID()) { // controlestructuur of er al een spoor toegevoegd is Railroad spoor = new Railroad(stad, city); network.Add(spoor); Program.logboek.WriteLine(string.Format("virtueel spoor van {0} naar {1}", city.getname(), stad.getname())); break; } } } } } }
public CardBoard() { AddSpace(new Go()); AddSpace(new Empty()); AddSpace(new IncomeTax()); AddSpace(new Empty()); PropertyGroup railroads = new PropertyGroup("Railroads"); Property reading = new Railroad("Reading Railroad", 200, 25, railroads); Property penn = new Railroad("Pennsylvania Railroad", 200, 25, railroads); Property bAndO = new Railroad("B&O Railroad", 200, 25, railroads); Property shortLine = new Railroad("Short Line", 200, 25, railroads); AddSpace(reading); AddSpace(penn); AddSpace(bAndO); AddSpace(shortLine); PropertyGroup utilities = new PropertyGroup("Utilities"); Property electric = new Utility("Electric Company", 150, 0, utilities); Property water = new Utility("Water Works", 150, 0, utilities); AddSpace(water); AddSpace(electric); PropertyGroup brown = new PropertyGroup("Brown", true, 50); Property medAve = new Property("Mediterranean Avenue", 60, new int[] { 2, 10, 30, 90, 160, 250 }, brown); Property baltic = new Property("Baltic Avenue", 60, new int[] { 4, 20, 60, 180, 320, 450 }, brown); AddSpace(medAve); AddSpace(baltic); }
public override void Execute(Player player) { // These four lines of code here are why Board.Move() exists and putting this // logic here feels bad. However, Board.Move() ends by called the // Space.LandedOnBy() method, which just does too much FOR THIS ONE INSTANCE. // So do I ruin some really nice, elegant code for this one divergence, or // do I live with shit like this? List <Property> properties = BoardReference.GetPropertiesInGroup("Railroads"); int distance = BoardReference.FindDistanceToNearestProperty(player.Position, properties); player.Position += distance; player.Position = player.Position % BoardReference.NumSpaces; if (player.Position - distance < 0) { player.Bank += 200; } Railroad railroad = (Railroad)BoardReference.GetSpace(player.Position); if (!railroad.IsOwned) { railroad.SellTo(player); } else if (railroad.Owner != player) { int rent = railroad.CalculateRent(); player.Bank -= (rent * 2); railroad.Owner.Bank += (rent * 2); } }
internal void addPoints(Railroad road) { int lenghtOfTrack = road.getRailLength(); switch (lenghtOfTrack) { case 1: points += 1; break; case 2: points += 2; break; case 3: points += 4; break; case 4: points += 7; break; case 6: points += 15; break; case 8: points += 21; break; default: Program.logboek.WriteLine("you can't add a track of this lenght"); break; } }
public void TestSetLocationsBuildsLocationsList() { var board = new GameBoard(banker); var location = new NullLocation(0, "null"); var railroad = new Railroad(1, "railroad", 10, 10, banker, new Railroad[] {}); var utility = new Utility(2, "utility", 10, 10, banker, new Utility[] {}, new FakeDice()); board.SetLocations(new Location[] { location }, new Railroad[] { railroad }, new Utility[] { utility }); Assert.That(board.Locations.Count(), Is.EqualTo(3)); }
/// <summary> /// Save information about railroad with encrypting /// </summary> /// <param name="railroad">Railroad, that should be saved</param> /// <param name="stream">Stream</param> /// <param name="Key">Key for encrypting</param> /// <param name="IV">Vector for encrypting</param> public void SaveCryptoRailroad(Railroad railroad, Stream stream, byte[] Key, byte[] IV) { GZipStream gzs = new GZipStream(stream, CompressionMode.Compress, true); Rijndael RijndaelAlg = Rijndael.Create(); CryptoStream cs = new CryptoStream(gzs, RijndaelAlg.CreateEncryptor(Key, IV), CryptoStreamMode.Write); SaveRailroad(cs, railroad); cs.Close(); gzs.Close(); }
public void RailroadLandedOn_WhenPlayerOwnsOne_ShouldCharge25DollarsForRent() { PropertyGroup railroads = new PropertyGroup("Railroads"); Space reading = new Railroad("Reading Railroad", 200, 25, railroads); Space penn = new Railroad("Pennsylvania Railroad", 200, 25, railroads); Space bAndO = new Railroad("B & O Railroad", 200, 25, railroads); Space shortLine = new Railroad("Short Line", 200, 25, railroads); reading.LandedOnBy(horse); reading.LandedOnBy(car); Assert.Equal(975, car.Bank); }
/// <summary> /// Create xml document from information about railroad /// </summary> /// <param name="railroad">Railroad</param> /// <returns>XML Document</returns> public XDocument SaveRailroad(Railroad railroad) { XDocument doc = new XDocument(); XElement root = new XElement("Railroad"); doc.AddFirst(root); root.Add(new XAttribute("Name", railroad.Name)); root.Add(new XAttribute("FirstStation", railroad.FirstStation.Name)); root.Add(new XAttribute("LastStation", railroad.LastStation.Name)); foreach (Station st in railroad) root.Add(SaveStation(st)); return doc; }
public void SetUp() { playerOneId = 0; playerTwoId = 1; banker = new TraditionalBanker(new [] { playerOneId, playerTwoId }); var railroads = new List <Railroad>(); readingRailroad = new Railroad(5, "Reading Railroad", 250, 25, banker, railroads); pennsylvaniaRailroad = new Railroad(15, "Pennsylvania Railroad", 250, 25, banker, railroads); boRailroad = new Railroad(25, "B. & O. Railroad", 250, 25, banker, railroads); shortLineRailroad = new Railroad(35, "Short Line Railroad", 250, 25, banker, railroads); railroads.AddRange(new Railroad[] { readingRailroad, pennsylvaniaRailroad, boRailroad, shortLineRailroad }); }
/// <summary> /// Load information about railroad from file /// </summary> /// <param name="stream">Stream, that contains path to the file</param> /// <returns>Railroad</returns> public Railroad LoadRailroad(Stream stream) { BinaryReader br = new BinaryReader(stream); string name = br.ReadString(); Station St1 = LoadStation(stream); Station St2 = LoadStation(stream); Railroad railroad = new Railroad(name, St1, St2); int stationCount = br.ReadInt32(); for (int i = 0; i < stationCount; i++) { railroad.AddStation(LoadStation(stream),i); } br.Close(); return railroad; }
/// <summary> /// Create xml document from information about railroad /// </summary> /// <param name="railroad">Railroad</param> /// <returns>XML Document</returns> public XmlDocument SaveRailroad(Railroad railroad) { xmldoc = new XmlDocument(); XmlElement root = xmldoc.CreateElement("Railroad"); XmlAttribute rname = xmldoc.CreateAttribute("Name"); rname.Value = railroad.Name; root.Attributes.Append(rname); root.SetAttribute("FirstStation", railroad.FirstStation.Name); root.SetAttribute("LastStation", railroad.LastStation.Name); foreach (var st in railroad) root.AppendChild(SaveStation(st)); xmldoc.AppendChild(root); return xmldoc; }
public override IEnumerable<Railroad> GetRailroads() { var railroads = new List<Railroad>(); var readingRailroad = new Railroad(5, "Reading Railroad", 200, 25, banker, railroads); var pennsylvaniaRailroad = new Railroad(15, "Pennsylvania Railroad", 200, 25, banker, railroads); var bAndORailroad = new Railroad(25, "B. & O. Railroad", 200, 25, banker, railroads); var shortLineRailroad = new Railroad(35, "Short Line Railroad", 200, 25, banker, railroads); railroads.AddRange(new Railroad[] { readingRailroad, pennsylvaniaRailroad, bAndORailroad, shortLineRailroad }); return railroads; }
private static void addRailRoads(List <Railroad> netWork, List <City> cities, List <string[]> data) { ExtensionMethods.niceLayout("adding railroads"); City city1 = null, city2 = null; bool isTunnel; int length, amountOfLocomotives; Color kleur; Railroad railroad; foreach (string[] text in data) { findCity(cities, ref city1, ref city2, text); kleur = (Color)Enum.Parse(typeof(Color), text[2], true); //http://stackoverflow.com/questions/16100/how-do-i-convert-a-string-to-an-enum-in-c length = Convert.ToInt32(text[3]); isTunnel = Convert.ToBoolean(Convert.ToInt32(text[4])); amountOfLocomotives = Convert.ToInt32(text[5]); railroad = new Railroad(city1, city2, length, kleur, isTunnel, amountOfLocomotives); netWork.Add(railroad); } Program.logboek.WriteLine(netWork.ToArray().Length + "\tTracks added"); }
Railroad CreateRailroad(string name, int purchasePrice, int initToll, Vector3 pos, Quaternion rotation, float scale) { Railroad railroad = CreateSpace(railroadPrefab, pos, rotation, scale) as Railroad; // Set the text TextMesh textMesh = railroad.GetComponentInChildren <TextMesh>(); textMesh.text = name; // Set the color // set owner marker position Vector3 omp = pos + Quaternion.AngleAxis(railroad.gameObject.transform.rotation.eulerAngles.z, Vector3.forward) * ownerMarkerOffset; railroad.OwnerMarkerPos = omp; railroad.Initialize(name, purchasePrice, initToll, railroadBgColor, mortgageBgColor); return(railroad); }
public void GetNumberOfOwnedRailroadsTest() { Board board = new Board(); Railroad railroad1 = new Railroad("RAILROAD1", "First Railroad", 50, new int[] { 50, 100, 150, 200 }, board); board.Add(railroad1); Railroad railroad2 = new Railroad("RAILROAD2", "Second Railroad", 50, new int[] { 50, 100, 150, 200 }, board); board.Add(railroad2); Railroad railroad3 = new Railroad("RAILROAD3", "Third Railroad", 50, new int[] { 50, 100, 150, 200 }, board); board.Add(railroad3); Player player = new Player(0, "player", 500); Assert.AreEqual(0, Railroad.GetNumberOfOwnedRailroads(player, board)); railroad1.Owner = player; Assert.AreEqual(1, Railroad.GetNumberOfOwnedRailroads(player, board)); railroad2.Owner = player; Assert.AreEqual(2, Railroad.GetNumberOfOwnedRailroads(player, board)); railroad3.Owner = player; Assert.AreEqual(3, Railroad.GetNumberOfOwnedRailroads(player, board)); }
public void RentPriceTest() { Board board = new Board(); Railroad railroad1 = new Railroad("RAILROAD1", "First Railroad", 50, new int[] { 50, 100, 150, 200 }, board); board.Add(railroad1); Railroad railroad2 = new Railroad("RAILROAD2", "Second Railroad", 50, new int[] { 50, 100, 150, 200 }, board); board.Add(railroad2); Railroad railroad3 = new Railroad("RAILROAD3", "Third Railroad", 50, new int[] { 50, 100, 150, 200 }, board); board.Add(railroad3); Player player = new Player(0, "player", 500); Assert.AreEqual(0, railroad1.RentPrice); railroad1.Owner = player; Assert.AreEqual(50, railroad1.RentPrice); railroad2.Owner = player; Assert.AreEqual(100, railroad1.RentPrice); railroad3.Owner = player; Assert.AreEqual(150, railroad1.RentPrice); }
public void Setup() { railroad = new Railroad("RxR"); }
/// <summary> /// Save information about railroad to the file /// </summary> /// <param name="stream">Stream</param> /// <param name="railroad">Railroad, that should be saved</param> public void SaveRailroad(Stream stream, Railroad railroad) { if (railroad != null) { BinaryWriter bw = new BinaryWriter(stream); bw.Write(railroad.Name); SaveStation(stream, railroad.FirstStation); SaveStation(stream, railroad.LastStation); bw.Write(railroad.Count); foreach (var station in railroad) { SaveStation(stream, station); } } stream.Close(); }
private void SetupBoard() { List <Space> spaces = new List <Space>(); PropertyGroup brown = new PropertyGroup("Brown", true, 50); Property medAve = new Property("Mediterranean Avenue", 60, new int[] { 2, 10, 30, 90, 160, 250 }, brown); Property baltic = new Property("Baltic Avenue", 60, new int[] { 4, 20, 60, 180, 320, 450 }, brown); PropertyGroup railroads = new PropertyGroup("Railroads"); Property reading = new Railroad("Reading Railroad", 200, 25, railroads); Property penn = new Railroad("Pennsylvania Railroad", 200, 25, railroads); Property bAndO = new Railroad("B&O Railroad", 200, 25, railroads); Property shortLine = new Railroad("Short Line", 200, 25, railroads); PropertyGroup lightBlue = new PropertyGroup("Light Blue", true, 50); Property oriental = new Property("Oriental Avenue", 100, new int[] { 6, 30, 90, 270, 400, 550 }, lightBlue); Property vermont = new Property("Vermont Avenue", 100, new int[] { 6, 30, 90, 270, 400, 550 }, lightBlue); Property conn = new Property("Connecticut Avenue", 120, new int[] { 8, 40, 100, 300, 450, 600 }, lightBlue); PropertyGroup pink = new PropertyGroup("Pink", true, 100); Property stChuck = new Property("St. Charles Place", 140, new int[] { 10, 50, 150, 450, 625, 750 }, pink); Property states = new Property("States Avenue", 140, new int[] { 10, 50, 150, 450, 625, 750 }, pink); Property virginia = new Property("Virginia Avenue", 160, new int[] { 12, 60, 180, 500, 700, 900 }, pink); PropertyGroup utilities = new PropertyGroup("Utilities"); Property electric = new Utility("Electric Company", 150, 0, utilities); Property water = new Utility("Water Works", 150, 0, utilities); PropertyGroup orange = new PropertyGroup("Orange", true, 100); Property stJames = new Property("St. James Place", 180, new int[] { 14, 70, 200, 550, 750, 950 }, orange); Property tenn = new Property("Tennessee Avenue", 180, new int[] { 14, 70, 200, 550, 750, 950 }, orange); Property newYork = new Property("New York Avenue", 200, new int[] { 16, 80, 220, 600, 800, 1000 }, orange); PropertyGroup red = new PropertyGroup("Red", true, 150); Property ky = new Property("Kentucky Avenue", 220, new int[] { 18, 90, 250, 700, 875, 1050 }, red); Property indiana = new Property("Indiana Avenue", 220, new int[] { 18, 90, 250, 700, 875, 1050 }, red); Property illinois = new Property("Illinois Avenue", 240, new int[] { 20, 100, 300, 750, 925, 1100 }, red); PropertyGroup yellow = new PropertyGroup("Yellow", true, 150); Property atlantic = new Property("Atlantic Avenue", 260, new int[] { 22, 110, 330, 800, 975, 1150 }, yellow); Property ventnor = new Property("Ventnor Avenue", 260, new int[] { 22, 110, 330, 800, 975, 1150 }, yellow); Property marv = new Property("Marvin Gardens", 280, new int[] { 24, 120, 360, 850, 1025, 1200 }, yellow); PropertyGroup green = new PropertyGroup("Green", true, 200); Property pacific = new Property("Pacific Avenue", 300, new int[] { 26, 130, 390, 900, 1100, 1275 }, green); Property carolina = new Property("North Carolina Avenue", 300, new int[] { 26, 130, 390, 900, 1100, 1275 }, green); Property pennAve = new Property("Pennsylvania Avenue", 320, new int[] { 28, 150, 450, 1000, 1200, 1400 }, green); PropertyGroup blue = new PropertyGroup("Blue", true, 200); Property parkPlace = new Property("Park Place", 350, new int[] { 35, 175, 500, 1100, 1300, 1500 }, blue); Property boardwalk = new Property("Boardwalk", 400, new int[] { 50, 200, 600, 1400, 1700, 2000 }, blue); Space chance = new CardSpace("Chance", DeckFactory.Chance()); Space commChest = new CardSpace("Community Chest", DeckFactory.CommunityChest()); spaces = new List <Space> { new Go(), medAve, commChest, baltic, new IncomeTax(), reading, oriental, chance, vermont, conn, new Jail(), stChuck, electric, states, virginia, penn, stJames, commChest, tenn, newYork, new FreeParking(), ky, chance, indiana, illinois, bAndO, atlantic, ventnor, water, marv, new Spaces.GoToJail(), pacific, carolina, commChest, pennAve, shortLine, chance, parkPlace, new LuxuryTax(), boardwalk }; foreach (Space space in spaces) { AddSpace(space); } }
public void init(string pathToPrivateProperty, string pathToRailroads, string pathToUtilities) { try { privateProperties = File.ReadAllLines(pathToPrivateProperty).Skip(1).Select(v => PrivateProperty.FromCsv(v)).ToList(); railRoads = File.ReadAllLines(pathToRailroads).Skip(1).Select(v => Railroad.FromCsv(v)).ToList(); utilityCompanies = File.ReadAllLines(pathToUtilities).Skip(1).Select(v => Utility.FromCsv(v)).ToList(); } catch (DirectoryNotFoundException e) { Form_board.GetInstance.insert_console("Error : Cannot find path : " + e); } }
public void addRailroad(Railroad track) { track.setOccupied(this); amountOfTrains -= track.getRailLength(); network.Add(track); }
/// <summary> /// Serialize information /// </summary> /// <param name="stream">Stream</param> /// <param name="railroad">Railroad</param> public void Serialize(Stream stream, Railroad railroad) { xs.Serialize(stream, railroad); }
private int IntelligentGeneralChoice() { int i = 0; if (this.DestinationCards.Count < 3) { return((int)PlayerAction.DestinationCard); } if (firstloop) { ExtensionMethods.niceLayout("Dijkstra"); double mini = 0; firstloop = false; List <List <Railroad> > shortestpaths = GraphAlgorithms.Dijkstra(AllTracks, citylist, this); List <City> destinations = new List <City>(); ExtensionMethods.niceLayout("Vertaling naar railRoads"); foreach (List <Railroad> path in shortestpaths) { Program.logboek.WriteLine(this.GetDestinationCards()[i].ToString()); int totalamountOfCardsneeded = 0, amountOfStations = 0; foreach (Railroad road in path) { destinations = road.getdestinations(); Program.logboek.WriteLine("\t" + destinations[0].getname() + " - " + destinations[1].getname()); if (!road.isOccupied()) { totalamountOfCardsneeded += road.getAmountOfLocomotives() * 2 + road.getRailLength() + ((road.IsTunnel()) ? 2 : 0); } else { amountOfStations++; } } double trackvalue = (double)(GetDestinationCards()[i].getPoints() + 4 - amountOfStations) / (double)(totalamountOfCardsneeded); // empyrisch, hoe groter hoe beter if (trackvalue > mini) { goalRoute = path; mini = trackvalue; } i++; } i = 1; foreach (Railroad road in goalRoute) { if (road.isOccupied() && road.getPlayer().CompareTo(this) != 0) { if (i / goalRoute.Count > 0.5) { if (road.getdestinations()[0].getStation() == null) { goalStation = road.getdestinations()[0]; return((int)PlayerAction.Station); } else if ((road.getdestinations()[1].getStation() == null)) { goalStation = road.getdestinations()[1]; return((int)PlayerAction.Station); } } } else if (road.isOccupied() == false) { Program.logboek.WriteLine(this.name + " is trying to build a road between: " + road.ToString()); if (ActionsMethods.Pickcards(this, road)) { //goalRoad = road; Maderoad = road; return((int)PlayerAction.Railroad); } } i++; } foreach (Railroad road in goalRoute) { //goalRoad = road; if (!road.isOccupied()) { goalRoad = road; } } } else { return((int)PlayerAction.Traincards); } return((int)PlayerAction.Traincards); }
public void LoadMap(string fileName) { XDocument xdoc; xdoc = XDocument.Load("Assets/StreamingAssets/Maps/" + fileName); XElement root = xdoc.Root; var items = root.Elements("space"); Vector3 pos = startPos; Vector3 increment = new Vector3(), squareIncrement = new Vector3(); Quaternion rot = Quaternion.identity; int edge = 0; foreach (XElement item in items) { string type = item.Attribute("type").Value; if (type == "go" || type == "jail" || type == "parking" || type == "gotojail") { // algorithm needs improving :( // making some parameters int a = edge % 2, b = (edge + 1) % 2; int c = 0, d = 0; if (edge == 0 || edge == 3) { c = -1; } else { c = 1; } if (edge == 1) { d = -1; } else { d = 1; } // position offset if (edge > 0) { pos += new Vector3(a * d * (spaceHeight - spaceWidth) / 2 * scale, b * d * (spaceHeight - spaceWidth) / 2 * scale, 0); } // Create the square space spaces.Add(CreateSpace(spaceTypes[type], pos, Quaternion.identity, scale)); // calculating increments for the next edge increment = new Vector3(b * c * spaceWidth * scale, a * c * spaceWidth * scale, 0); squareIncrement = new Vector3(b * c * (spaceHeight + spaceWidth) / 2 * scale, a * c * (spaceHeight + spaceWidth) / 2 * scale, 0); pos += squareIncrement; rot = Quaternion.Euler(0, 0, (4 - edge) * 90); edge++; } else { if (type == "land") { string pName = item.Element("name").Value; Color gpColor; ColorUtility.TryParseHtmlString(item.Element("group").Value, out gpColor); int pPrice = int.Parse(item.Element("purchasePrice").Value); int uPrice = int.Parse(item.Element("upgradePrice").Value); int[] tolls = new int[6]; XElement tollItems = item.Element("toll"); for (int i = 0; i <= 5; i++) { tolls[i] = int.Parse(tollItems.Element("lvl" + i).Value); } Land newLand = CreateLand(pName, pPrice, uPrice, tolls, gpColor, pos, rot, scale); spaces.Add(newLand); if (!groups.ContainsKey(gpColor)) { List <Land> landList = new List <Land>(); landList.Add(newLand); groups.Add(gpColor, landList); } else { groups[gpColor].Add(newLand); } } else if (type == "railroad") { string name = item.Element("name").Value; int pPrice = int.Parse(item.Element("purchasePrice").Value); int initToll = int.Parse(item.Element("initialToll").Value); Railroad newRailroad = CreateRailroad(name, pPrice, initToll, pos, rot, scale); spaces.Add(newRailroad); } else if (type == "spinner" || type == "chest" || type == "chance" || type == "parkingfee") { spaces.Add(CreateSpace(spaceTypes[type], pos, rot, scale)); } pos += increment; } numSpaces++; } }
public void Initialize(Railroad railroad) { TextRailroadName.text = railroad.PropertyName; TextPurchasePrice.text = "$" + railroad.PurchasePrice.ToString(); }
} // done public static bool BuildRailRoad(Player player, List <City> cities, List <Railroad> totalNetwork) { citylist = cities; City city1, city2; int val = 0; network = totalNetwork; string text = null; if (!(player is IntelligentPlayer)) { foreach (City city in cities) { text += (city.getname() + "\t"); } } Console.WriteLine("Choose between which 2 Cities you want to add an track (give in 1 city at a time) +\n" + text); //getting input from console if (!(player is IntelligentPlayer)) { val = player.ChoseOption(Possibilities.Railroad); city1 = getCity(val); val = player.ChoseOption(Possibilities.Neighbours); city2 = getCity(val); if (city1 != city2) { if (city1.getNeighBours().Contains(city2)) { List <Railroad> possibleRoads = new List <Railroad>(); // alle mogelijke tracks tussen de 2 steden Railroad track = null; foreach (Railroad road in totalNetwork) { if (road.getdestinations().Contains(city1) && road.getdestinations().Contains(city2)) { if (!possibleRoads.Contains(road)) // heb er per ongeluk sommige steden dubbel toegevoegd, heb dit ontdekt bij het debuggen van de code // een testgeoriënteerd ontwerp (met testklassen) zou hier zeker van pas komen { track = road; possibleRoads.Add(road); } } } if (possibleRoads.Count > 1) // bij parallelle steden { Dictionary <string, int> roundOptions = new Dictionary <string, int>(); Program.logboek.WriteLine("er is meer dan 1 mogelijkheid"); //roundOptions.Clear(); foreach (Railroad road in possibleRoads) { roundOptions.Add(Convert.ToString(road.getColor()), (int)road.getColor()); } val = GetInput(roundOptions, player); foreach (Railroad road in totalNetwork) { if (road.getdestinations().Contains(city1) && road.getdestinations().Contains(city2)) { if (road.getColor() == (Color)val) { track = road; } else { totalNetwork.Remove(road); break; } } } } Program.logboek.WriteLine("there is a track between the two cities"); Program.logboek.WriteLine(track.ToString()); bool succesful = Pickcards(player, track); if (succesful) { player.addRailroad(track); player.addPoints(track); track.drawLine(player, Program.form.pictureBox1); } return(succesful); } else { Console.WriteLine("The cities you picked aren't neighbours"); if (!(player is IntelligentPlayer)) { MessageBox.Show("the cities you picked aren't neighbours"); } } } else { Console.WriteLine("You picked twice the same city"); if (!(player is IntelligentPlayer)) { MessageBox.Show("you picked twice the same city"); } } return(false); } else { player.addRailroad(((IntelligentPlayer)player).Maderoad); player.addPoints(((IntelligentPlayer)player).Maderoad); ((IntelligentPlayer)player).Maderoad.drawLine(player, Program.form.pictureBox1); return(true); } }
public void Board() { TitleProperty TempTitleProperty; Boardspace temp; Boardspace nexttemp = null; CurrBoard = new Board(); //Set up double circular linked list of board spaces string BoardSpacesTblFP = System.String.Concat(this.FP, "/Raw Data/BoardSpacesTbl.csv"); var BoardSpacesTbl = new StreamReader(@BoardSpacesTblFP); var line = BoardSpacesTbl.ReadLine(); Boardspace prevtemp = new Boardspace(); //Set up linked list of board spaces while (!BoardSpacesTbl.EndOfStream) { line = BoardSpacesTbl.ReadLine(); var values = line.Split(','); temp = new Boardspace(values[0], values[1]); if (values[1] == "GO") { this.CurrBoard.GoSpace = temp; } else { temp.Previous = prevtemp; prevtemp.Next = temp; } prevtemp = temp; //Console.WriteLine(values[0]); } this.CurrBoard.GoSpace.Previous = prevtemp; prevtemp.Next = this.CurrBoard.GoSpace; BoardSpacesTbl = new StreamReader(@BoardSpacesTblFP); line = BoardSpacesTbl.ReadLine(); temp = this.CurrBoard.GoSpace; do { if (temp.SpaceType == "GO") { this.CurrBoard.GoSpace = new GoSpace(ref temp); } if (temp.SpaceType == "Community Chest") { new CommunityChestCardSpace(temp); } if (temp.SpaceType == "Chance") { new ChanceCardSpace(temp); } if (temp.SpaceType == "Jail") { new Jail(temp); } if (temp.SpaceType == "Income Tax") { new IncomeTaxSpace(temp, this.Banker); } if (temp.SpaceType == "Luxury Tax") { new LuxuryTax(temp, this.Banker); } if (temp.SpaceType == "GO TO JAIL") { new GoToJail(temp); } temp = temp.Next; }while (temp.SpaceName != CurrBoard.GoSpace.SpaceName); string PropertyTblFP = System.String.Concat(this.FP, "/Raw Data/PropertyTbl.csv"); var PropertyTbl = new StreamReader(@PropertyTblFP); Property TempProperty; temp = this.CurrBoard.GoSpace; line = PropertyTbl.ReadLine(); //Set up property while (!PropertyTbl.EndOfStream) { line = PropertyTbl.ReadLine(); //Console.WriteLine(line); var values = line.Split(','); string PropType = values[3]; temp = FindSpaceName(values[1]); TempProperty = new Property(Convert.ToInt64(values[2]), ref temp, this.Banker); //Find out if property is TitleProperty,Railroad or utility and create appropriate object if (PropType == "Title Property") { var values2 = ReturnPropertyData(values[1]); Console.WriteLine(values2[1]); TempTitleProperty = new TitleProperty(values2[1], Convert.ToInt64(values2[2]), Convert.ToInt64(values2[3]), Convert.ToInt64(values2[4]), Convert.ToInt64(values2[5]), Convert.ToInt64(values2[6]), Convert.ToInt64(values2[7]), Convert.ToInt64(values2[8]), Convert.ToInt64(values2[9]), Convert.ToInt64(values2[10]), Convert.ToInt64(values2[11]), Convert.ToInt64(values2[12]), ref TempProperty); Console.WriteLine(this.CurrBoard.GoSpace.Next.GetType()); Console.WriteLine(TempTitleProperty.GetType()); } if (PropType == "Railroad") { Railroad TempRail; TempRail = new Railroad(TempProperty); } if (PropType == "Utility") { Utility TempUtil; TempUtil = new Utility(TempProperty); } //Console.WriteLine(TempProperty.SpaceName); } }
public static bool Prefix(Railroad __instance, ref bool __result) { return(ModEntry.ProcessNoClipping(ref __result)); }
public static bool Pickcards(Player player, Railroad road) { Dictionary <TrainCard, int> traincards = player.GetTraincards(); { int amountOfLocomotives = road.getAmountOfLocomotives(); int railLength = road.getRailLength() - amountOfLocomotives; Color kleur = road.getColor(); bool hasCard = false; int /*temp = 0,*/ maxamount = 0; Console.WriteLine("this track needs {0} locomotives", amountOfLocomotives); if (amountOfLocomotives > 0) { foreach (KeyValuePair <TrainCard, int> playercard in traincards) // met index werken? { if (playercard.Key.getColor() == Color.Locomotief) { hasCard = true; if (playercard.Value >= amountOfLocomotives) { Console.WriteLine("you have enough locomotives"); player.GetTraincards()[playercard.Key] -= amountOfLocomotives; TrainCard card = playercard.Key; for (int i = 0; i < amountOfLocomotives; i++) { usedCardsDeck.Add(card); } break; } else { Console.WriteLine("you don't have enough locomotives to make the track"); if (!(player is IntelligentPlayer)) { MessageBox.Show("you don't have enough locomotives to make the track"); } return(false); } } } if (!hasCard) { Console.WriteLine("you dont have any locomotives"); if (!(player is IntelligentPlayer)) { MessageBox.Show("you don't have enough locomotives to make the track"); } return(false); } } // de maximumwaarde wordt gezocht int amountLoco = 0; foreach (KeyValuePair <TrainCard, int> card in traincards) { if (card.Value > maxamount && card.Key.getColor() != Color.Locomotief) { maxamount = card.Value; } else if (card.Key.getColor() == Color.Locomotief) { amountLoco = card.Value; } } maxamount += amountLoco; if (railLength > 0) { if (railLength <= maxamount) { bool colorfound = false; if (kleur == Color.Grijs) { TrainCard traincard = null; Console.WriteLine("Please chose a color"); //bool firsttime = true; string a = null; Dictionary <TrainCard, int> possibleCard = goodCards(player, railLength); /*misschien beter een dictionary van object int maken*/ Dictionary <string, int> possiblities = new Dictionary <string, int>(); foreach (KeyValuePair <TrainCard, int> de in possibleCard) { a += "\t" + de.Key.ToString(); possiblities.Add(de.Key.ToString(), (int)de.Key.getColor()); } Console.WriteLine(a); if (!(player is IntelligentPlayer)) { int val = GetInput(possiblities, player); traincard = new TrainCard((Color)val); } else { traincard = new TrainCard((Color)possiblities.Values.ToList()[0]); // sorry, heb hiervoor geen intelligentie meer geïmplementeerd } foreach (KeyValuePair <TrainCard, int> card in traincards) { if (card.Key.getColor() == traincard.getColor()) { if (railLength > card.Value) { int temp = card.Value; railLength -= temp; TrainCard tCard = card.Key; for (int i = 0; i < temp; i++) { usedCardsDeck.Add(tCard); } traincards[card.Key] = 0; foreach (KeyValuePair <TrainCard, int> trCard in traincards) { if (trCard.Key.getColor() == Color.Locomotief) { traincards[trCard.Key] -= railLength; tCard = trCard.Key; for (int i = 0; i < railLength; i++) { usedCardsDeck.Add(tCard); } return(true); } } } else { traincards[card.Key] -= railLength; traincard = card.Key; for (int i = 0; i < railLength; i++) { usedCardsDeck.Add(traincard); } return(true); } } } } else { // indien de kleur van het spoort vasligt foreach (KeyValuePair <TrainCard, int> card in traincards) { if (card.Key.getColor() == kleur) { colorfound = true; // indien je voldoende kaarten hebt van die kleur (zonder locomotieven bij te leggen) if (card.Value >= railLength) { traincards[card.Key] -= railLength; player.addRailroad(road); TrainCard trCard = card.Key; for (int i = 0; i < railLength; i++) { usedCardsDeck.Add(trCard); } return(true); } else { foreach (KeyValuePair <TrainCard, int> pair in traincards) { if (pair.Key.getColor() == Color.Locomotief) { int val = traincards[card.Key]; traincards[card.Key] = 0; traincards[pair.Key] -= (railLength - val); TrainCard trCard = card.Key; for (int i = 0; i < railLength - val; i++) { usedCardsDeck.Add(trCard); } return(true); } } } } else if (amountLoco >= railLength) { foreach (KeyValuePair <TrainCard, int> pair in traincards) { if (pair.Key.getColor() == Color.Locomotief) { traincards[pair.Key] -= (railLength); TrainCard trCard = pair.Key; for (int i = 0; i < railLength; i++) { usedCardsDeck.Add(trCard); } return(true); } } } } return(false); if (!colorfound) { if (amountLoco >= railLength) { foreach (KeyValuePair <TrainCard, int> card in traincards) { traincards[card.Key] -= amountLoco; TrainCard trCard = card.Key; for (int i = 0; i < railLength; i++) { usedCardsDeck.Add(trCard); } return(true); } } Console.WriteLine("U heeft geen kaarten van dit type kleur"); if (!(player is IntelligentPlayer)) { MessageBox.Show("you dont have any cards of this type color"); } } } } else { Console.WriteLine("you dont have enough cards of the same type to build the track"); if (!(player is IntelligentPlayer)) { MessageBox.Show("you dont have enough cards of the same type to build the track"); } } } else { player.addRailroad(road); Console.WriteLine("The railroad {0} was successfully added", road.ToString()); ExtensionMethods.WaitForUser(); return(true); } //ExtensionMethods.WaitForUser(); returnLocomotives(traincards, amountOfLocomotives); return(false); } }
private void GameLoop_SaveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e) { railroad = (Game1.getLocationFromName("Railroad") as Railroad); startupMessage = true; }
/// <summary> /// Serialize information /// </summary> /// <param name="stream">Stream</param> /// <param name="railroad">Railroad</param> public void Serialize(Stream stream, Railroad railroad) { dcs.WriteObject(stream, railroad); }