def on_game_phase_update(game, notification): """ Manage notification GamePhaseUpdate. :param game: a Network game :param notification: notification received :type game: diplomacy.client.network_game.NetworkGame :type notification: diplomacy.communication.notifications.GamePhaseUpdate """ if notification.phase_data_type == strings.STATE_HISTORY: Game.extend_phase_history(game, notification.phase_data) else: game.set_phase_data(notification.phase_data)
def on_get_phase_history(context, response): """ Manage response for request GetPhaseHistory. :param context: request context :param response: response received :return: a list of game states :type context: RequestFutureContext :type response: responses.DataGamePhases """ phase_history = response.data for game_phase in phase_history: # type: diplomacy.utils.game_phase_data.GamePhaseData Game.extend_phase_history(context.game, game_phase) return phase_history