def start_rumble(ctx, player): """ start_rumble handles the getting the players and simulating the rumble. """ p1 = get_player(ctx.author.id, ctx.author.name) member = ctx.guild.get_member_named(player) if member == None: return f"{player} is not someone you can fight here." p2 = get_player(member.id, member.name) return rumble(p1, p2)
def get_out(): global counter2 global count counter2 = counter2 + 1 print(count, ": ", counter2) result = roll_dice() change_label(result) if count == 0: main.title(player.get_player(count)) if counter2 % 3 == 0: count += 1 elif count == 1: main.title(player.get_player(count)) if counter2 % 3 == 0: count -= 1
def click(): global count main.title(player.get_player(count)) result = roll_dice() print(player.get_player(count), "(", count, ")", "rolled", result) change_label(result) saver.write_csv(player.get_player(count), result) if count == 0: if result != 6: main.title(player.get_player(count)) count = count + 1 elif count == 1: if result != 6: main.title(player.get_player(count)) count = count - 1
def parse_password(char, input_string): import commands import player temp_password = input_string.split()[0].strip() if temp_password == char.player.stats["password"]: # Check if character is already connected temp_player = player.get_player(char.player.get_name()) if temp_player is not None: char.player = temp_player temp_player.get_peer().quit() _.send_to_char(char, "\n\rReconnecting.", False, True) _.send_to_char(char, "\n\rWelcome to Redemption!\n\rPlease don't feed the mobiles.\n\r\n\r", False, True) char.state = _.STATE_ONLINE _.mobiles.append(char.player) for p in [p for p in _.peers if p.player.get_room() == char.player.get_room() and p is not char]: _.send_to_char(p, "%s has entered the game.\n\r" % char.player.get_name(p.player).capitalize()) commands.do_look(char, "") return else: char.password_count += 1 if char.password_count >= _.MAX_PASSWORDS: _.send_to_char(char, "\n\rIncorrect password.\n\r", False, True) char.state = _.STATE_QUIT return else: _.send_to_char(char, "\n\rIncorrect password. Password: ", False, True) return
async def on_join_mc(fields, conn): conn.sendall(b"handling join") try: if len(fields) != 3: raise Exception("Too many or too few fields") uuid = fields[1] name = fields[2] player = pl.get_player(uuid) if not player: player = pl.Player(uuid, name, last_join=time.time()).save() return player.last_join = time.time() if name != player.name: player.name = name player.save() member = utils.get(server.members, id=player.discord_id) role = utils.get(server.roles, name="Inactive") except Exception as e: log.error("Error in join packet: %s" % e) try: await bot.remove_roles(member, role) await bot.change_nickname(member, player.name) except: pass
def play(pathinfo): content, info = _parse_path(pathinfo) if not content: xbmcgui.Dialog().notification(L(34201), pathinfo['full path']) return singlevideo = pathinfo.get('singlevideo', False) try: showbusy = get_main_addon().getSetting('hidebusydialog') == 'false' get_player(get_generator(content, info, singlevideo), showbusy).run() except quickjson.JSONException as ex: # json_result['error']['code'] == -32602 is the best we get, invalid params if content == 'other' and ex.json_result.get('error', {}).get('code', 0) == -32602 \ and not any(1 for source in quickjson.get_sources('video') if info['path'].startswith(source['file'])): xbmcgui.Dialog().ok(L(ADD_SOURCE_HEADER), L(ADD_SOURCE_MESSAGE).format(info['path'])) else: raise
async def on_token(fields, conn): try: if len(fields) != 4: conn.sendall(b"token failed, report this to staff") raise Exception("Too many or too few fields") try: _ = uuid.UUID(fields[1], version=4) except ValueError: log.error("Bad UUID: %s" % fields[1]) return player = pl.get_player(fields[1]) if not player: player = pl.Player(fields[1], fields[2]) player.save() while True: token = uuid.uuid4().hex[:5] if token not in tokens: break if player.token in tokens: tokens.remove(player.token) player.token = token player.rank = fields[3] player.save() conn.sendall(token.encode()) tokens.append(token) except Exception as e: log.error("Error in token packet: %s" % e)
def get(self): p = player.get_player() if not p.has_won: self.redirect('/room?error=You did not win.') return add_score(p, winning=True) self.render_template('static/html/win.html', {'player':p})
def __init__(self): self.intro = self.Splash() self.prompt = "Action >>" cmd.Cmd.__init__(self) self.player = get_player() self.blocks = get_blocks() self.enemies = get_enemy() self.getRoom("F1") self.notBattle = True # if not in battle continue as normal
def main(): b = mc.foo() c = b.bar() print(c) p = player.get_player() w = world.get_starting_world() print("Player ability:", player.get_ability(p)) print("Monsters:\n" + "\n".join(w)) print(f"Likelihood of failure: {util.square(get_rand_num())}%")
def get_starting_world(): world = [] p = player.get_player() ability = player.get_ability(p) difficulty = util.get_config_var("difficulty") for i in range(util.square(ability) * difficulty): monster = f"Monster {i}" world.append(monster) return world
def post(self): # check player has item player = player.get_player() item = Item.get(self.request.get_by_key_name("item")) if item.location != player: self.error(400) elif item.item_type == 0: # Wand of Digg self.redirect("http://digg.com") # Book of Faces # Tube of You # Spellapedia (learn a random spell?) # Something that teleports else: pass
def do_tell(char, args): import player try: target = args.split()[0] except IndexError: _.send_to_char(char, "Who do you want to tell?\n\r") return target_player = player.get_player(target) if target_player is None: _.send_to_char(char, "You can't find them.\n\r") return try: message = args.split()[1] except IndexError: _.send_to_char(char, "What do you want to tell them?\n\r") return _.send_to_char(char, "You tell %s '%s'\n\r" % (target_player.get_name(), message)) _.send_to_char(target_player.get_peer(), "%s tells you '%s'\n\r" % (char.player.get_name(), message))
def do_tell(peer, args): import player try: target = args.split()[0] except IndexError: peer.account.player.send("Who do you want to tell?\n\r") return target_player = player.get_player(target) if target_player is None: peer.account.player.send("You can't find them.\n\r") return try: message = args.split()[1] except IndexError: peer.account.player.send("What do you want to tell them?\n\r") return peer.account.player.send("{mYou tell %s '{y%s{m'{x\n\r" % (target_player.get_name(), message)) target_player.send("{m%s tells you '{y%s'{m\n\r" % (peer.account.player.get_name(), message))
def do_tell(char, args): import player try: target = args.split()[0] except IndexError: _.send_to_char(char, "Who do you want to tell?\n\r") return target_player = player.get_player(target) if target_player is None: _.send_to_char(char, "You can't find them.\n\r") return try: message = args.split()[1] except IndexError: _.send_to_char(char, "What do you want to tell them?\n\r") return _.send_to_char( char, "You tell %s '%s'\n\r" % (target_player.get_name(), message)) _.send_to_char(target_player.get_peer(), "%s tells you '%s'\n\r" % (char.player.get_name(), message))
def get(self): user = player.get_player() if user.is_alive == False: values = {'player': user, 'room': user.location} self.render_template('static/html/player_dead.html', values) room = user.location players = player.Player.gql("WHERE location = :1", room).run() monsters = monster.Monster.gql("WHERE location = :1", room).run() items = list(players) + list(monsters) if room is None: self.render_template('static/html/room_notfound.html') else: values = {'player': user, 'room': room, 'items': items, 'last_target': self.request.get('last_target'), 'error': self.request.get('error')} self.render_template('static/html/room.html', values)
async def on_rank(fields, conn): try: conn.sendall(b"handling rank") if len(fields) != 3: raise Exception("Too many or too few fields") player = pl.get_player(fields[1]) if not player: log.error("Invalid UUID value: %s" % fields[1]) return rank = fields[2].replace("+", "") try: if rank not in cfg.RANK_ROLES: rank += "s" if rank not in cfg.RANK_ROLES: rank -= "s" raise Exception("Invalid role name: %s" % rank) roles = [r for r in server.roles if r.name in cfg.RANK_ROLES] new_role = utils.get(roles, name=rank) member = utils.get(server.members, id=player.discord_id) if not member: return await bot.remove_roles(member, *roles) await asyncio.sleep(0.5) await bot.add_roles(member, new_role) player.rank = rank player.save() except Exception as e: log.error(e) except Exception as e: log.error("Error in rank packet: %s" % e)
count += 1 elif count == 1: main.title(player.get_player(count)) if counter2 % 3 == 0: count -= 1 def create_viz(): main.destroy() os.system("Rscript Visualization.R") print("Created Viz") # Show GUI main = tk.Tk() main.title(player.get_player(count)) main.geometry("250x250") saver.create_csv() button = Button(main, text="Roll Dice", command=click) button.pack() label = Label(main, text="¯\_(ツ)_/¯") label.pack() close_button = Button(text="Quit", command=create_viz) close_button.pack() #button2 = Button(main, text = "Ich will raus hier!", command = get_out) #button2.pack()
def test_get_player (self): #Valid queries: assert get_player("Username2", "Password") != None assert get_player("Username", "Password") != None #Invalid input: assert get_player("TestUsername", "TestPassword") == None assert get_player(None, None) == None assert get_player(None, "TestPassword") == None assert get_player("TestUsername", None) == None #Mixed input: assert get_player("Username2", "Bad Password") == None assert get_player("Username", "Bad Password") == None assert get_player("Bad Username", "Password") == None assert get_player(None, "Password") == None assert get_player("Username2", None) == None