// **** Status readers //Read game state/parameters (init) private RiftGame GetGameFromInitialInput() { var game = new RiftGame(); string[] inputs = ReadLine().Split(' '); game.AmountOfPlayers = int.Parse(inputs[0]); // the amount of players (2 to 4) game.MyPlayerID = int.Parse(inputs[1]); // my player ID (0, 1, 2 or 3) game.AmountOfZones = int.Parse(inputs[2]); // the amount of zones on the map game.AmountOfZoneLinks = int.Parse(inputs[3]); // the amount of links between all zones //Read nodes for (int i = 0; i < game.AmountOfZones; i++) { inputs = ReadLine().Split(' '); RiftZone rz = new RiftZone() { NodeIndex = int.Parse(inputs[0]), PlatimumSource = int.Parse(inputs[1]) }; game.AddOrReplaceZone(rz); } //Link nodes for (int i = 0; i < game.AmountOfZoneLinks; i++) { inputs = ReadLine().Split(' '); var z1 = game.GetZone(int.Parse(inputs[0])); var z2 = game.GetZone(int.Parse(inputs[1])); z1.LinkedNodes.Add(z2); z2.LinkedNodes.Add(z1); } return(game); }
public void AddOrReplaceZone(RiftZone zone) { if (Zones.Keys.Contains(zone.NodeIndex)) { Zones[zone.NodeIndex] = zone; } else { Zones.Add(zone.NodeIndex, zone); } _zonesList.Add(zone); }