Example #1
0
        public static void HandleHarvest(int fromClient, Packet packet)
        {
            int clientIDCheck = packet.ReadInt();

            if (fromClient != clientIDCheck)
            {
                Console.WriteLine($"Player with ID: \"{fromClient}\" has assumed the wrong client ID: \"{clientIDCheck}\"!");
            }

            Player         player      = Server.clients[fromClient].Player;
            HexCoordinates coordinates = packet.ReadHexCoordinates();

            if (player.Tribe != null)
            {
                if (GameLogic.Harvest(player.Tribe.Id, coordinates))
                {
                    ServerSend.BroadcastHarvest(player.Tribe.Id, coordinates);
                    Console.WriteLine("Player: " + player.Name + "of tribe" + player.Tribe.Id.ToString() + " successfully harvested ressource at " + coordinates.ToString() + ".");
                    return;
                }
                Console.WriteLine("Player: " + player.Name + "of tribe" + player.Tribe.Id.ToString() + " failed to harvest ressource at " + coordinates.ToString() + ".");
            }
        }