Пример #1
0
        public void ApplyUpdate(GameUpdateMessage message)
        {
            _cities = Patch(_cities, message.CitiesDiff);
            _rawMap = Patch(_rawMap, message.MapDiff);

            foreach (var g in message.Generals)
            {
                _generals.Add(g);
            }
            foreach (var g in _generals)
            {
                if (!message.Generals.Contains(g))
                {
                    message.Generals.Add(g);
                }
            }

            foreach (int city in _cities)
            {
                _allCities.Add(city);
            }

            _map = GameMap.FromRawLists(_rawMap, _allCities, message.Generals, _seen, _lastSeenArmies);
            _map.PrettyPrint();
        }
Пример #2
0
 private void GameUpdated(object data)
 {
     try {
         GameUpdateMessage message = JsonConvert.DeserializeObject <GameUpdateMessage>(data.ToString());
         _game.ApplyUpdate(message);
         (int start, int end, bool is50) = _game.GetAttack();
         _socket.Emit("attack", start, end, is50);
     } catch (Exception e) {
         Console.WriteLine(e.Message);
         Console.WriteLine(e.StackTrace);
     }
 }