GitHub PullRequestReviewCommentEvent at 2014-01-18 22:31:39
Repository: sacrificial-integration-tests
Actor: scottjab
Payload: {"comment":{"url":"https://api.github.com/repos/imhotepbot/sacrificial-integration-tests/pulls/comments/8989646","id":8989646,"diff_hunk":"@@ -0,0 +1,401 @@\n+###\n+# Copyright (c) 2012, James Scott\n+# All rights reserved.\n+#   \n+# Redistribution and use in source and binary forms, with or without\n+# modification, are permitted provided that the following conditions are met:\n+#\n+#   * Redistributions of source code must retain the above copyright notice,\n+#     this list of conditions, and the following disclaimer.\n+#   * Redistributions in binary form must reproduce the above copyright notice,\n+#     this list of conditions, and the following disclaimer in the\n+#     documentation and/or other materials provided with the distribution.\n+#   * Neither the name of the author of this software nor the name of\n+#     contributors to this software may be used to endorse or promote products\n+#     derived from this software without specific prior written consent.\n+#\n+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+# ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n+# POSSIBILITY OF SUCH DAMAGE.\n+\n+###\n+import supybot.utils as utils\n+from supybot.commands import *\n+import supybot.plugins as plugins\n+import supybot.ircutils as ircutils\n+import supybot.ircmsgs as ircmsgs\n+import supybot.schedule as schedule\n+import supybot.callbacks as callbacks\n+\n+from random import randint\n+\n+import operator \n+\n+from cah import Game\n+\n+import time\n+\n+class Cah(callbacks.Plugin):\n+    \"\"\"Add the help for \"@plugin help Cah\" here\n+    This should describe *how* to use this plugin.\"\"\"\n+    threaded = True\n+\n+    def __init__(self, irc):\n+        self.__parent = super(Cah, self)\n+        self.__parent.__init__(irc)\n+        self.games = {}\n+\n+    class CahGame(object):\n+        \"\"\"docstring for Game\"\"\"\n+        def __init__(self, irc, channel, numrounds = 5):\n+            self.irc = irc\n+            self.channel = channel\n+            self.game = None\n+            self.canStart = False\n+            self.voting = False\n+            self.canStart = False\n+            self.roundRunning = False\n+            self.running =  False\n+            self.rounds = numrounds\n+            self.maxPlayers= 5\n+            self.players = []\n+            self.acceptingWhiteCards = False\n+            self.cardsPlayed = {}\n+        \n+        def initGame(self):\n+            schedule.addEvent(self.startgame, time.time() + 60, \"start_game_%s\" % self.channel)\n+\n+        ###### UTIL METHODS ##########\n+      \n+        def _msg(self, recip, msg):\n+            self.irc.queueMsg(ircmsgs.privmsg(recip,msg))\n+        \n+        def _printBlackCard(self, recip):\n+            response = \"Question: %s\"\n+            cah = self.game\n+            self._msg(recip, ircutils.mircColor(response % cah.question.text, bg=\"black\", fg=\"white\"))\n+\n+        def _msgHandToPlayer(self, nick):\n+            response = \"Your cards: %s  Please respond with @playcard [channel if in pm] <number> [number]\"\n+            enumeratedHand = []\n+            cah = self.game\n+            for position, card in enumerate(cah.players[nick].card_list):\n+                enumeratedHand.append(\"%s: %s \" % (position + 1, ircutils.bold(card.text)))\n+            self._printBlackCard(nick)\n+            self._msg(nick, ircutils.mircColor(response % ', '.join(enumeratedHand), bg=\"white\", fg=\"black\"))\n+\n+        def _displayPlayedCards(self):\n+            channel = self.channel\n+            responseTemplate = \"%s: (%s)\"\n+            responses = []\n+            response = \"%s\"\n+            for count, nick in enumerate(self.cardsPlayed.keys()):\n+                cardText = []\n+                cards = \", \".join([ircutils.bold(card.text) for card in self.cardsPlayed[nick]])\n+                responses.append(responseTemplate % (count + 1, cards))\n+            response = \";  \".join(responses)\n+            self._msg(channel, \"Played White cards: %s\" % response)\n+\n+        def _findHighScore(self, scores):\n+            highscore = []\n+            for nick, score in scores.iteritems():\n+                if len(highscore) == 0:\n+                    highscore.append([nick, score])\n+                elif highscore[0][1] < score:\n+                    highscore = []\n+                    highscore.append([nick, score])\n+                elif highscore[0][1] == score:\n+                    highscore.append([nick, score])\n+            if len(highscore) > 0:\n+                return (highscore[randint(0, len(highscore) -1)], True)\n+            else:\n+                return (highscore[0], False)\n+\n+\n+        def _tallyVotes(self, votes):\n+            ties = []\n+            winningCanidate = []\n+            canidatesById = []\n+            for nick in self.cardsPlayed.keys():\n+                canidatesById.append(nick)","path":"plugin.py","position":128,"original_position":128,"commit_id":"38c3fa3970dbf608b0d4d3bb31504084915181c9","original_commit_id":"38c3fa3970dbf608b0d4d3bb31504084915181c9","user":{"login":"scottjab","id":1759664,"avatar_url":"https://gravatar.com/avatar/5bcb1510a18aae098971a80b645bd325?d=https%3A%2F%2Fidenticons.github.com%2F82ad1ab8bbb72cf0e6fc8a36d555b74e.png&r=x","gravatar_id":"5bcb1510a18aae098971a80b645bd325","url":"https://api.github.com/users/scottjab","html_url":"https://github.com/scottjab","followers_url":"https://api.github.com/users/scottjab/followers","following_url":"https://api.github.com/users/scottjab/following{/other_user}","gists_url":"https://api.github.com/users/scottjab/gists{/gist_id}","starred_url":"https://api.github.com/users/scottjab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottjab/subscriptions","organizations_url":"https://api.github.com/users/scottjab/orgs","repos_url":"https://api.github.com/users/scottjab/repos","events_url":"https://api.github.com/users/scottjab/events{/privacy}","received_events_url":"https://api.github.com/users/scottjab/received_events","type":"User","site_admin":false},"body":"---\n- \" [C, Cah.CahGame._tallyVotes] Invalid name \\\"winningCanidate\\\" for type variable\n  (should match [a-z_][a-z0-9_]{2,30}$)\"\n","created_at":"2014-01-18T22:31:39Z","updated_at":"2014-01-18T22:31:39Z","html_url":"https://github.com/imhotepbot/sacrificial-integration-tests/pull/2#discussion_r8989646","pull_request_url":"https://api.github.com/repos/imhotepbot/sacrificial-integration-tests/pulls/2","_links":{"self":{"href":"https://api.github.com/repos/imhotepbot/sacrificial-integration-tests/pulls/comments/8989646"},"html":{"href":"https://github.com/imhotepbot/sacrificial-integration-tests/pull/2#discussion_r8989646"},"pull_request":{"href":"https://api.github.com/repos/imhotepbot/sacrificial-integration-tests/pulls/2"}}}}