private void Events_RoundFinished(GamePlayer opponent, GameSessionRoundResult result) { if (result.ShipsStillFloating) { return; // game session is only interested in information when to stop } var winner = opponent; _eventBus.OnGameSessionFinished(this, winner); }
private static void Events_RoundFinished(GamePlayer player, GameSessionRoundResult result) { if (result.WasHit && result.WasDestroyed) { Console.WriteLine($"{player.Name} has destroyed the ship - ship has sunk"); } if (result.WasHit && !result.WasDestroyed) { Console.WriteLine($"{player.Name} has hit the ship but the ship is still floating"); } if (!result.WasHit && !result.WasDestroyed) { Console.WriteLine($"{player.Name} has missed the ships"); } if (!result.ShipsStillFloating) { Console.WriteLine($"{player.Name} has destroyed all ships of his opponent - all ships are sunk"); } else { if (_humanPlayer != player) // other player finished the round, now it's human turn but first print the state { PrintPlayerState(player); GoHumanPlayer(); } else // human player finished the round, now it's other player turn { Console.WriteLine(); Console.WriteLine($"Waiting for {_session.Player2.Name} shot"); Console.WriteLine(); } } }
public void OnShipMissed(GamePlayer opponent) { RoundFinished?.Invoke(opponent, GameSessionRoundResult.Missed()); }
public void OnShipHit(GamePlayer player) { RoundFinished?.Invoke(player, GameSessionRoundResult.Hit()); }
public void OnAllShipsSunk(GamePlayer opponent) { RoundFinished?.Invoke(opponent, GameSessionRoundResult.AllSunk()); }
public void OnRoundSkipped(GamePlayer opponent) { RoundFinished?.Invoke(opponent, GameSessionRoundResult.Skipped()); }