private void SlowUpdate(object state) { //Do heavycomputing and send changed population on tiles GameHub.Current.Clients.All.SendAsync("Cl_CompressedUpdate", GZIPCompress.Compress(game.UpdateTilePopulation())); }
//TODO: Check if capital and apply Overtake Enemy public async Task AttackTile(int x, int y, bool halfPopulation, string connectionID) { //Game is not running, should not accept input if (!gamestate.Equals(Gamestate.InGame)) { return; } Faction playerFaction = playerManager.GetFaction(connectionID); if (game.GetTileAtPosition(x, y).GetShortType().Equals("C")) { //Capital Tile => Apply overtake Enemy modifier and end game if needed or disable Faction string updatedTiles = game.AttackCapital(x, y, halfPopulation, playerFaction); if (updatedTiles != null) { await GameHub.Current.Clients.All.SendAsync("Cl_CompressedUpdate", GZIPCompress.Compress(updatedTiles)); } //A Faction won, all others have been eliminated if (game.GetAllFactions().Count == 1) { await GameHub.Current.Clients.Group(playerFaction.ToString()).SendAsync("Cl_GameEnded", "Your Faction won! You were part of: "); EndGame(); } } else if (game.AttackTile(x, y, halfPopulation, playerFaction) && game.GetTileAtPosition(x, y).Coin.Equals(Coin.None)) { //Normal Attack Tile t = game.GetTileAtPosition(x, y); await GameHub.Current.Clients.All.SendAsync("Cl_TileUpdate", x, y, t.Faction.ToString(), t.Population, t.Coin.ToString()); await GameHub.Current.Clients.Group(playerFaction.ToString()).SendAsync("Cl_FastTick", game.GetFreePopulationFromFaction(playerFaction)); } else { //Tile has Coin on it -> Use Coin first string updatedTiles = game.AttackTileWithCoin(x, y, playerFaction); if (updatedTiles != null) { await GameHub.Current.Clients.All.SendAsync("Cl_CompressedUpdate", GZIPCompress.Compress(updatedTiles)); } } }