// **** 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); }
//Update the current game state (on start of tick) private RiftGame UpdateGameState(RiftGame gameState) { Log("Updating gamestate"); gameState.MyPlatinum = int.Parse(ReadLine()); // my available Platinum Log($"Current platinum: {gameState.MyPlatinum}"); //Update all the zones for (int i = 0; i < gameState.AmountOfZones; i++) { string[] inputs = ReadLine().Split(' '); int zId = int.Parse(inputs[0]); // this zone's ID var zone = gameState.GetZone(zId); int? oldOwner = zone.OwningPlayerID; zone.OwningPlayerID = int.Parse(inputs[1]); // the player who owns this zone (-1 otherwise) zone.OwningPlayerID = zone.OwningPlayerID < 0 ? null : zone.OwningPlayerID; //Keep null zone.AmountPodsPlayer0 = int.Parse(inputs[2]); // player 0's PODs on this zone zone.AmountPodsPlayer1 = int.Parse(inputs[3]); // player 1's PODs on this zone zone.AmountPodsPlayer2 = int.Parse(inputs[4]); // player 2's PODs on this zone (always 0 for a two player game) zone.AmountPodsPlayer3 = int.Parse(inputs[5]); // player 3's PODs on this zone (always 0 for a two or three player game) if (zone.OwningPlayerID != oldOwner) { Log($"Ownership of zone {zone.NodeIndex} changed from {oldOwner} to {zone.OwningPlayerID}"); } } return(gameState); }