/// <summary> /// Handles completion of a game /// </summary> /// <param name="game">Game that completed</param> /// <param name="end">Information about the game's end</param> public void GameCompleted(IGame game, GameEndInformation end) { bool isOnlineGame = game is IRemoteGame; bool isHotseatGame = game.Controller.Players.All(pl => pl.Agent.Type == AgentType.Human); GamePlayer human = game.Controller.Players.FirstOrDefault(pl => pl.Agent.Type == AgentType.Human); bool isPlayedByUs = human != null; bool isVictory = (end.HasWinnerAndLoser && end.Winner == human); var gcqi = new GameCompletedQuestInformation(isOnlineGame, isHotseatGame, isPlayedByUs, isVictory, human, game, end); // Add points per game if (isPlayedByUs) { int points = 0; if (isVictory) { if (isOnlineGame) { points = RewardPoints.OnlineWin; } else if (!isHotseatGame) { points = RewardPoints.LocalWin; } } else { if (isOnlineGame) { points = RewardPoints.OnlineLoss; } else if (!isHotseatGame) { points = RewardPoints.LocalLoss; } } AddPoints(points); } foreach (var quest in _gameSettings.Quests.ActiveQuests.ToList()) { if (quest.Quest.GameCompleted(gcqi)) { ProgressQuest(quest, 1); } } }
/// <summary> /// Returns a value indicating whether the fact that the user just finished a game they were actually playing in should /// advance progress on this quest. /// </summary> public virtual bool GameCompleted(GameCompletedQuestInformation info) => false;