コード例 #1
0
        public static void HandleFight(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 (GameLogic.PlayerInRange(coordinates, player))
            {
                GameLogic.Fight(player, coordinates);
                ServerSend.BroadcastFight(player, coordinates);
                Console.WriteLine("Player: " + player.Name + "of tribe" + player.Tribe.Id.ToString() + " successfully fought a building at " + coordinates.ToString() + ".");
            }
            else
            {
                Console.WriteLine("Player: " + player.Name + "of tribe" + player.Tribe.Id.ToString() + " failed to fight a building at " + coordinates.ToString() + ".");
            }
        }