private void ResignObservedGame(int gameInWhichSomebodyResigned, StoneColor whoResigned) { var game = GamesYouHaveOpened.FirstOrDefault(gm => gm.Info.IgsIndex == gameInWhichSomebodyResigned); if (game != null) { game.Controller.EndGame(GameEndInformation.CreateResignation(game.Controller.Players[whoResigned], game.Controller.Players)); DestroyGame(game.Info); } }
public override void Process(KgsConnection connection) { var game = connection.Data.GetGame(ChannelId); var controller = game.Controller; var players = game.Controller.Players; var black = game.Controller.Players.Black; var white = game.Controller.Players.White; GameEndInformation gameEndInfo = null; if (Score.IsFloat) { if (Score.Float == 0) { gameEndInfo = GameEndInformation.CreateDraw(controller.Players, new Rules.Scores(0, 0)); } else { if (Score.Float > 0) { gameEndInfo = GameEndInformation.CreateScoredGame(controller.Players.Black, controller.Players.White, new Rules.Scores(Score.Float, 0)); } else { gameEndInfo = GameEndInformation.CreateScoredGame(controller.Players.White, controller.Players.Black, new Rules.Scores(0, -Score.Float)); } } } else { switch (Score.String) { case "B+RESIGN": case "B+FORFEIT": gameEndInfo = GameEndInformation.CreateResignation(white, players); break; case "W+RESIGN": case "W+FORFEIT": gameEndInfo = GameEndInformation.CreateResignation(black, players); break; case "B+TIME": gameEndInfo = GameEndInformation.CreateTimeout(white, players); break; case "W+TIME": gameEndInfo = GameEndInformation.CreateTimeout(black, players); break; case "NO_RESULT": gameEndInfo = GameEndInformation.CreateDraw(players, new Rules.Scores(0, 0)); break; case "UNKNOWN": case "UNFINISHED": default: gameEndInfo = GameEndInformation.CreateCancellation(players); break; } } controller.KgsConnector.EndTheGame(gameEndInfo); }
/// <summary> /// Handles player resignation /// </summary> /// <param name="agent">Agent that resigned</param> private void Agent_Resigned(IAgent agent) { //end game with resignation EndGame(GameEndInformation.CreateResignation(this.Players[agent.Color], this.Players)); LocalResignationHappened(this.Players[agent.Color]); }