示例#1
0
    def join_game(self, message, user):
        if self.stage == "pregame" and len(self.players) < config.roulette['max_players']:
            amt = locale.format(
                "%d", config.roulette['entry'], grouping=True)

            if user not in self.players and len(message['body'].split(" ")) < 3:
                self.respond(
                    message['from'], "To enter this game it will cost you %s isk. To confirm, please type %sroulette join confirm" % (amt, config.xmpp['trigger']))
            elif user not in self.players and message['body'].split(" ")[2] == "confirm":
                if balance.get(user) > config.roulette['entry']:
                    if balance.take(user, config.roulette['entry']):
                        self.pot += config.roulette['entry']
                        self.players.append(user)
                        self.respond(message['from'],
                                     "You have been added to the active game. %s isk has been debited from your account [%d/%d]" % (amt,len(self.players), config.roulette['max_players']))
                    else:
                        self.respond(message['from'], "An error occured debiting your account. Please ask an admin for assistance. You were not entered into the game.")
                else:
                    self.respond(message['from'], "You do not have the funds to do that.")
            else:
                self.respond(message['from'],
                             "You are already in the active game.")
        else:
            self.respond(
                message['from'], "You are not able to join a game at this time. Maybe one is already active/full?")
示例#2
0
 def new_game(self, message, user):
     amt = locale.format("%d", config.roulette['entry'], grouping=True)
     if not self.stage and len(message['body'].split(" ")) < 3:
         self.respond(message['from'], "It will cost you %s to start a new game. To open a new game, please type %sroulette new confirm" % (amt, config.xmpp['trigger']))
     elif not self.stage and message['body'].split(" ")[2] == "confirm":
         if balance.get(user) > config.roulette['entry']:
             if balance.take(user, config.roulette['entry']):
                 self.pot += config.roulette['entry']
                 self.stage = "pregame"
                 self.players.append(user)
                 self.host = user
                 self.respond(
                     message['from'], "A new game has been started and you have been added to it. %s isk has been debited from your account [%d/%d]" % (amt, len(self.players), config.roulette['max_players']))
             else:
                 self.respond(message['from'], "An error occured debiting your account. Please ask an admin for assistance. You were not entered into the game.")
         else:
             self.respond(message['from'], "You do not have the funds to do that.")
     else:
         self.respond(
             message['from'], "A game is already active. Please wait until that game is finished before starting a new game.")