Skip to content

Commit

Permalink
games: support starting tournaments
Browse files Browse the repository at this point in the history
  • Loading branch information
Annika committed May 30, 2020
1 parent 734a951 commit 79963cb
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion games.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
## by Annika ##
######################

TOUR_SETUP_COMMANDS = [
'/tour autostart 5',
'/tour autodq 2',
'/tour forcetimer on',
'/tour modjoin disallow'
]

class Module:
"""Represents a module, which may contain several commands
"""
Expand All @@ -17,7 +24,8 @@ def __init__(self):
"reverse": self.reverse, "wallrev": self.reverse, "addreversioword": self.addReversioWord,
"removereversioword": self.removeReversioWord, "rmreversioword": self.removeReversioWord,
"addpoint": self.addPoints, "addpoints": self.addPoints, "deletereversioword": self.removeReversioWord,
"showpoints": self.showLB, "lb": self.showLB, "showlb": self.showLB
"showpoints": self.showLB, "lb": self.showLB, "showlb": self.showLB, "tour": self.startTournament,
"tournament": self.startTournament
}

self.reversioWords = data.get("reversioWords")
Expand Down Expand Up @@ -147,6 +155,23 @@ def showLB(self, message):
user = key, points = points[key]
) for key in sortedUsers])
return message.respond(("**Scores**: " + formattedPoints) if formattedPoints else "There are no scores.")

def startTournament(self, message):
"""Starts a tournament
Arguments:
message {Message} -- the Message object that invoked the command
"""
if not message.room: return message.respond("You cannot start a tournament in PMs.")
if not message.sender.can("hostgame", message.room): return message.respond("Permission denied.")
if len(message.arguments) < 2: return message.respond(
"Usage: ``" + config.commandCharacter + "tournament [format]``."
)

format = " ".join(message.arguments[1:])
message.room.say("/tour new " + format + ",elim")
for command in TOUR_SETUP_COMMANDS:
message.room.say(command)

def isInt(self, string):
"""Returns True if a string represents an integer and False otherwise.
Expand Down

0 comments on commit 79963cb

Please sign in to comment.