async def fish(self, ctx): await ctx.send('reel casted!') conn_p = sqlite3.connect('databases/players.db') cur_p = conn_p.cursor() player = playerdb.get_player(ctx) #how long to wait before something bites for i in player: rod = i[1] reel = int(i[3]) - 1 money = i[5] points = i[6] time.sleep( random.randint(int(10 / data.rods[rod]["attraction"]), int(20 / data.rods[rod]["attraction"]))) await ctx.send( f'{ctx.author.mention}! something\'s on the line!\ntype "catch" to reel it in!' ) #what fish is caught, based on rarity catch = choice(data.fish_types[reel], 1, data.fish_odds[reel])[0] #the time something is caught baseTime = datetime.now() #makes sure the message is correct def catch_check(msg): return msg.content == "catch" try: #hold until catch is typed by the user or a minute passes #[does this take into account author??] resp = await self.client.wait_for('message', check=catch_check, timeout=60.0) except asyncio.TimeoutError: #if a minute passes, the fish leaves await ctx.send("oop it went away") else: #the odds of catching are calculated based on response time odds = math.exp(-(datetime.now() - baseTime).total_seconds() / 25) * data.rods[rod]["catch"] if random.random() < odds: new_coins = str(money + catch["money"]) new_points = str(points + catch["points"]) cur_p.execute('UPDATE users SET money = ' + new_coins + ', points = ' + new_points + ' WHERE id ="' + str(ctx.author.id) + "_" + str(ctx.guild.id) + '"') conn_p.commit() conn_p.close() await ctx.send(f'{catch["emoji"]}') await ctx.send( f'you caught a {catch["name"]}!\n{catch["points"]} points earned\n{catch["money"]} money earned' ) else: await ctx.send( f'the fish has escaped <a:donkeysad:691789600540196914>')
async def shop(self, ctx): await ctx.send("RODS:\n(type `f!buy [ROD NAME]` to purchase.)") for rod, info in data.rods.items(): if info["shop"]: await ctx.send(str(rod) + "- $" + str(info["cost"])) player = playerdb.get_player(ctx) for i in player: currentReel = data.reel[int(i[2])] await ctx.send("REEL LENGTH " + str(int(i[2]) + 1) + ": $" + str(currentReel["cost"])) break
def OnAddToAll(self, event): name = wx.GetTextFromUser(message='Enter username:'******'Add player', parent=self) if name: if playerdb.get_player(name): return res = playerdb.add_player(name, PLAYER_STATUS_NEUTRAL) if res == 0: self.all_list.InsertImageStringItem(0, name, 2) self.all_list.SetItemData(0, calc_item_data(name)) self.all_list.SortItems(sort_fun) if res == 0 or res == 1: self.init_friend_bozo_list() playerdb.save_db()
def OnRemoveBozo(self, event): name = self.bozo_list.GetStringSelection() if name: self.remove_player(name, self.bozo_list) p = playerdb.get_player(name) if p: p.set_status(PLAYER_STATUS_NEUTRAL) self.all_list.InsertImageStringItem(0, name, 3) self.all_list.SetItemData(0, calc_item_data(name)) self.all_list.SortItems(sort_fun) else: playerdb.remove_player(name) playerdb.save_db() else: wx.Bell()
async def stats(self, ctx): player = playerdb.get_player(ctx) for i in player: await ctx.send( f'your current rod is: {i[1]}\nyour reel length is: {i[3]}\nyour bait is: {i[4]}\nyou have {i[5]} coins\nyour total points is: {i[6]}' )
def OpenPlayerNotesDialog(self, name): p = playerdb.get_player(name) if not p: return if not USE_RESOURCE: dlg = self.res.LoadDialog(self, 'playerdb_player_dlg') else: dlg = wxPython.xrc.wxXmlResource_Get().LoadDialog( self, 'playerdb_player_dlg') grid = gamesgrid.GamesListGrid(dlg) if not USE_RESOURCE: self.res.AttachUnknownControl('games_grid', grid) else: wxPython.xrc.wxXmlResource_Get().AttachUnknownControl( 'games_grid', grid) dlg.SetTitle(name) # Set comment note_edit = wxPython.xrc.XRCCTRL(dlg, 'note_edit', wx.TextCtrl) note_edit.SetValue(playerdb.get_player_comment(name)) # Set status status_box = wxPython.xrc.XRCCTRL(dlg, 'status', wx.RadioBox) # Remember current status status = p.get_status() # Radiobox has another order than the friend/bozo constants if status == PLAYER_STATUS_FRIEND: status_box.SetSelection(0) elif status == PLAYER_STATUS_BOZO: status_box.SetSelection(2) # Set custom flags cf_panel = wxPython.xrc.XRCCTRL(dlg, 'custom_flags_panel', wx.Panel) cf_cb = [] box = wx.StaticBox(cf_panel, -1, 'Flags') sizer = wx.StaticBoxSizer(box, wx.VERTICAL) for i in range(0, NUMBER_CUSTOM_FLAGS): if self.flag_categories[i][0]: cb = wx.CheckBox(cf_panel, 500 + i, self.flag_categories[i][1]) cf_cb.append((cb, i)) cb.SetValue(p.get_custom_flag(i)) if os.name == 'nt': sizer.Add(cb, 0, wx.ALL, 5) else: sizer.Add(cb, 0, 0) cf_panel.SetSizer(sizer) # I really hate those OS checks, but the GUI layout messes up otherwise if os.name == 'nt': sizer.SetSizeHints(cf_panel) # Load games list games = find_by_player(name) if games: games = sort_games(games, 1) # Sort by white rank grid.display_games(games) # Create graph and statistics plot_canvas = RankPlotCanvas(name, dlg) if not USE_RESOURCE: self.res.AttachUnknownControl('plot_canvas', plot_canvas) else: wxPython.xrc.wxXmlResource_Get().AttachUnknownControl( 'plot_canvas', plot_canvas) wx.EVT_CHECKBOX(dlg, wxPython.xrc.XRCID('games_all'), plot_canvas.OnAllGames) wx.EVT_CHECKBOX(dlg, wxPython.xrc.XRCID('games_white'), plot_canvas.OnWhiteGames) wx.EVT_CHECKBOX(dlg, wxPython.xrc.XRCID('games_black'), plot_canvas.OnBlackGames) plot_canvas.display_graph() stats = plotter.create_statistics() if not stats: stats = (0, 0, 0, 0, 0, 0) wxPython.xrc.XRCCTRL(dlg, 'wins', wx.StaticText).SetLabel(format_align(stats[0])) wxPython.xrc.XRCCTRL(dlg, 'losses', wx.StaticText).SetLabel(format_align(stats[1])) wxPython.xrc.XRCCTRL(dlg, 'wins_white', wx.StaticText).SetLabel(format_align(stats[2])) wxPython.xrc.XRCCTRL(dlg, 'losses_white', wx.StaticText).SetLabel(format_align(stats[3])) wxPython.xrc.XRCCTRL(dlg, 'wins_black', wx.StaticText).SetLabel(format_align(stats[4])) wxPython.xrc.XRCCTRL(dlg, 'losses_black', wx.StaticText).SetLabel(format_align(stats[5])) dlg.SetSize(wx.Size(380, 320)) if dlg.ShowModal() == wx.ID_OK: # Transfer comment playerdb.set_player_comment(name, note_edit.GetValue()) # Status sel = status_box.GetSelection() if sel == 0: new_status = PLAYER_STATUS_FRIEND elif sel == 2: new_status = PLAYER_STATUS_BOZO else: new_status = PLAYER_STATUS_NEUTRAL if new_status != status: p.set_status(new_status) self.init_lists() # Transfer custom flags for (cb, i) in cf_cb: p.set_custom_flag(i, cb.IsChecked()) del cf_cb playerdb.save_db() if self.flag_filter: self.init_all_list()