From 05630712d60d42beaf18bfbaf64a9cd435b5d7e3 Mon Sep 17 00:00:00 2001 From: James Scott Date: Thu, 13 Dec 2012 23:33:27 -0500 Subject: [PATCH 1/8] Fixing the object issue when iterating over nicks --- plugin.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin.py b/plugin.py index fb1b6be..b4bf204 100644 --- a/plugin.py +++ b/plugin.py @@ -81,13 +81,13 @@ class Cah(callbacks.Plugin): cah = self.game self._msg(recip, response % cah.question.text) - def _msgHandToPlayer(self, player): + def _msgHandToPlayer(self, nick, hand): response = "Your cards: %s Please respond with @card [number]" enumeratedHand = [] - for position, card in enumerate(player.card_list): + for position, card in enumerate(hand.card_list): enumeratedHand.append("%s: %s" % (position + 1, card.txt)) - self._printBlackCard(player.name) - self._msg(player, response % ', '.join(enumeratedHand)) + self._printBlackCard(nick) + self._msg(nick, response % ', '.join(enumeratedHand)) def _tallyVotes(self, votes): talliedVotes = {} @@ -146,8 +146,8 @@ class Cah(callbacks.Plugin): cah.next_round() #Print Black Card to channel. self._printBlackCard(self.channel) - for player in cah.players: - self._msgHandToPlayer(player) + for nick, hand in enumerate(cah.players): + self._msgHandToPlayer(nick, hand) self._msg(channel, "The white cards have been PMed to the players, you have 60 seconds to choose.") #TODO: do we need a round flag? schedule.addEvent(self.endround, time.time() + 60, "round_%s" % channel) From c25a39d061f6dc0a68dd02daa33d4516da522d6e Mon Sep 17 00:00:00 2001 From: James Scott Date: Thu, 13 Dec 2012 23:39:07 -0500 Subject: [PATCH 2/8] lets try it this way --- plugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin.py b/plugin.py index b4bf204..d5f77cb 100644 --- a/plugin.py +++ b/plugin.py @@ -81,10 +81,11 @@ class Cah(callbacks.Plugin): cah = self.game self._msg(recip, response % cah.question.text) - def _msgHandToPlayer(self, nick, hand): + def _msgHandToPlayer(self, nick): response = "Your cards: %s Please respond with @card [number]" enumeratedHand = [] - for position, card in enumerate(hand.card_list): + cah = self.game + for position, card in enumerate(cah[nick].card_list): enumeratedHand.append("%s: %s" % (position + 1, card.txt)) self._printBlackCard(nick) self._msg(nick, response % ', '.join(enumeratedHand)) @@ -147,7 +148,7 @@ class Cah(callbacks.Plugin): #Print Black Card to channel. self._printBlackCard(self.channel) for nick, hand in enumerate(cah.players): - self._msgHandToPlayer(nick, hand) + self._msgHandToPlayer(nick) self._msg(channel, "The white cards have been PMed to the players, you have 60 seconds to choose.") #TODO: do we need a round flag? schedule.addEvent(self.endround, time.time() + 60, "round_%s" % channel) From f3de8020d40fc58e867037224f965fd5f5e57b1c Mon Sep 17 00:00:00 2001 From: James Scott Date: Thu, 13 Dec 2012 23:41:15 -0500 Subject: [PATCH 3/8] blah --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index d5f77cb..ad84933 100644 --- a/plugin.py +++ b/plugin.py @@ -147,7 +147,7 @@ class Cah(callbacks.Plugin): cah.next_round() #Print Black Card to channel. self._printBlackCard(self.channel) - for nick, hand in enumerate(cah.players): + for nick in self.players: self._msgHandToPlayer(nick) self._msg(channel, "The white cards have been PMed to the players, you have 60 seconds to choose.") #TODO: do we need a round flag? From b2d4aba66cb4eb94f3e8c8361fb46b600d14de1d Mon Sep 17 00:00:00 2001 From: James Scott Date: Thu, 13 Dec 2012 23:43:30 -0500 Subject: [PATCH 4/8] should pull a playerlist --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index ad84933..98c007d 100644 --- a/plugin.py +++ b/plugin.py @@ -85,7 +85,7 @@ class Cah(callbacks.Plugin): response = "Your cards: %s Please respond with @card [number]" enumeratedHand = [] cah = self.game - for position, card in enumerate(cah[nick].card_list): + for position, card in enumerate(cah.players[nick].card_list): enumeratedHand.append("%s: %s" % (position + 1, card.txt)) self._printBlackCard(nick) self._msg(nick, response % ', '.join(enumeratedHand)) From 586a3dbb966c214b68595183f04cbdb6bb27a088 Mon Sep 17 00:00:00 2001 From: James Scott Date: Thu, 13 Dec 2012 23:45:19 -0500 Subject: [PATCH 5/8] card.text not card.txt --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index 98c007d..8548894 100644 --- a/plugin.py +++ b/plugin.py @@ -86,7 +86,7 @@ class Cah(callbacks.Plugin): enumeratedHand = [] cah = self.game for position, card in enumerate(cah.players[nick].card_list): - enumeratedHand.append("%s: %s" % (position + 1, card.txt)) + enumeratedHand.append("%s: %s" % (position + 1, card.text)) self._printBlackCard(nick) self._msg(nick, response % ', '.join(enumeratedHand)) From db4771bbf3521f65fb679f1cb1566fd2346efc5d Mon Sep 17 00:00:00 2001 From: James Scott Date: Thu, 13 Dec 2012 23:52:03 -0500 Subject: [PATCH 6/8] small fixes and stoppign for the night, time for a HUGE pull request --- cah.py | 3 +-- plugin.py | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cah.py b/cah.py index 6d21847..bc082da 100644 --- a/cah.py +++ b/cah.py @@ -147,8 +147,7 @@ if __name__=="__main__": round['hands']['Jazz'].showHand() print "\nBear's hand the hard way:" - for index, card in enumerate(round['hands']['Bear'].card_list): + for index, card in enumerate(game.players['Bear'].card_list): print '%s: %s' % (index + 1, card.text) - diff --git a/plugin.py b/plugin.py index 8548894..ae490f1 100644 --- a/plugin.py +++ b/plugin.py @@ -86,7 +86,7 @@ class Cah(callbacks.Plugin): enumeratedHand = [] cah = self.game for position, card in enumerate(cah.players[nick].card_list): - enumeratedHand.append("%s: %s" % (position + 1, card.text)) + enumeratedHand.append("%s: %s " % (position + 1, ircutils.bold(card.text))) self._printBlackCard(nick) self._msg(nick, response % ', '.join(enumeratedHand)) @@ -275,7 +275,7 @@ class Cah(callbacks.Plugin): channel = ircutils.toLower(msg.args[0]) if channel in self.games: games[channel].close() - del games[channel] + games[channel].pop() irc.reply("Game stopped.") else: irc.reply("Game not running.") From 9b8dc8f72151bea3d046cbb34924638a49d9b851 Mon Sep 17 00:00:00 2001 From: James Scott Date: Thu, 13 Dec 2012 23:53:57 -0500 Subject: [PATCH 7/8] one last bug before pull --- plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index ae490f1..1d79256 100644 --- a/plugin.py +++ b/plugin.py @@ -274,8 +274,8 @@ class Cah(callbacks.Plugin): def scah(self, irc, msg, args): channel = ircutils.toLower(msg.args[0]) if channel in self.games: - games[channel].close() - games[channel].pop() + self.games[channel].close() + self.games[channel].pop() irc.reply("Game stopped.") else: irc.reply("Game not running.") From 1184fb7f9b6fe1a14d20482b8ffe10582277f668 Mon Sep 17 00:00:00 2001 From: James Scott Date: Thu, 13 Dec 2012 23:55:09 -0500 Subject: [PATCH 8/8] pop! --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index 1d79256..9f2b99d 100644 --- a/plugin.py +++ b/plugin.py @@ -275,7 +275,7 @@ class Cah(callbacks.Plugin): channel = ircutils.toLower(msg.args[0]) if channel in self.games: self.games[channel].close() - self.games[channel].pop() + self.games.pop(channel) irc.reply("Game stopped.") else: irc.reply("Game not running.")