Storycraft: add a terse progress string to the output when messaging players.

this is so that people know when they should start wrapping their
story up.
This commit is contained in:
Brian S. Stephan 2011-01-09 22:17:22 -06:00
parent e9c22d33f3
commit 10cbe1944f
1 changed files with 23 additions and 2 deletions

View File

@ -443,13 +443,17 @@ class Storycraft(Module):
player = self._get_player_by_id(line.player_id)
return_msg = 'Line logged.'
# get progress, so user knows how much time is left
progress_str = self._get_progress_string_for_game(game)
# message the new owner
if player.nick == nick:
# simpily notify them they're up again
return_msg = 'Line logged. Please add another.'
return_msg = 'Line logged. Please add another. ' + progress_str
else:
# notify the new owner, too
self.irc.reply(connection, player.nick, 'You have a new line in storycraft #{0:d}: \'{1:s}\''.format(game_id, last_line.line))
self.irc.reply(connection, player.nick, 'You have a new line in storycraft #{0:d}: \'{1:s}\' {2:s}'.format(game_id, last_line.line, progress_str))
# get the default settings
settings = self._get_storycraft_settings()
@ -564,6 +568,23 @@ class Storycraft(Module):
return status_str
def _get_progress_string_for_game(self, game):
"""Get a terse summary of the game's progress."""
if game.round_mode == 1:
lines = self._get_lines_for_game(game.id)
num_lines = len(lines)
progress = '(lines: {0:d}/{1:d}'.format(num_lines, game.game_length)
if num_lines == game.game_length - 1:
progress = progress + ' LAST LINE'
progress = progress + ')'
return progress
else:
return ''
def _add_new_game(self, round_mode, game_length, line_length, random_method, lines_per_turn, nick, userhost):
"""Add a new game to the system."""