//event from engine host - triggers sending current game data to players private static void EngineInstance_StartUpdatingTheGame(object sender, EventArgs e) { //start algorithm bool allPlayersReceivedData = MakaoEngineHostGameStateHandler.ExecutePlayersDataSendingAlgorithm (CurrentPlayersData.Count, currentGameSetup.AmountOfDecks, currentGameSetup.AmountOfJokers, currentGameSetup.AmountOfStartCards, DataSenderType.EngineInstanceUpdateData); //if at least on player did not response, end the game if (!allPlayersReceivedData) { synchronizationContext.Post(_ => SendLostConnectionRoomDeletedInfo(), null); } }
//method for sending data about game ended fact to the players private static void EngineInstance_EndTheGame(object sender, EventArgs e) { var logger = NLog.LogManager.GetCurrentClassLogger(); logger.Info($"Procedure of sending info to players about game ended started."); //stop game timer GameStateHolder.StopGameTimer(); //calling the method from game state handler class MakaoEngineHostGameStateHandler.ExecutePlayersDataSendingAlgorithm(CurrentPlayersData.Count, currentGameSetup.AmountOfDecks, currentGameSetup.AmountOfJokers, currentGameSetup.AmountOfStartCards, DataSenderType.GameFinished); }
private static void StartTheGame(SynchronizationContext synchCont) { //start algorithm bool allPlayersReceivedData = MakaoEngineHostGameStateHandler.ExecutePlayersDataSendingAlgorithm (CurrentPlayersData.Count, currentGameSetup.AmountOfDecks, currentGameSetup.AmountOfJokers, currentGameSetup.AmountOfStartCards, DataSenderType.EngineInstanceCreatedData); //event from engine - start updating data sending to players GameStateHolder.EngineInstance.StartUpdatingTheGame += EngineInstance_StartUpdatingTheGame; //event from engine - end the game GameStateHolder.EngineInstance.EndTheGame += EngineInstance_EndTheGame; //if at least on player did not response, end the game if (!allPlayersReceivedData) { synchCont.Post(_ => SendLostConnectionRoomDeletedInfo(), null); } }