async def roll(par, msg, player): gear = load_gear() rollables = {} for key, value in gear.items(): if value['rarity'] != '0': rollables[key] = value raritytable = define_raritytable() rarity = 'common' RNG = randint(0, 100) for key, value in raritytable.items(): if value > RNG: rarity = key all_with_rarity = [] for key, value in gear.items(): if value['rarity'] == rarity: all_with_rarity.append(key) drop = choice(all_with_rarity) if player.inventory['gold'] < 100: return 'Not enough gold' await player.give_item('gold', -100) await player.give_item(drop, 1) return 'Rolled **{}** for 100 gold'.format(drop)
def item_info(item): item2 = item item = load_gear()[item] endstring = '' endstring += item['description'] + '\n\n' endstring += 'Rarity: **{}** \n'.format(item['rarity']) endstring += 'Position: **{}** \n\n'.format(item['position']) for stat, value in item['stats'].items(): endstring += '{}: **{}** \n'.format(stat, value) if len(item['abilities']) > 0: endstring += '\n Grants Abilities: \n' for ability in item['abilities']: endstring += '**{}** \n'.format(ability) return form.basic(item2, endstring)
def all_items(): data = load_gear() groups = {} for key, value in data.items(): groups[value['position']] = [] for key, value in data.items(): groups[value['position']].append((key, value)) for group_name, group in groups.items(): print(group) itemlist = '' for group_name, group in groups.items(): itemlist += '\n **{}** \n'.format(group_name) for key, value in group: itemlist += '{} \n'.format(key) return itemlist
def define_raritytable(): raritytable = {} raritytable['very common'] = 100 raritytable['common'] = 50 raritytable['rare'] = 20 raritytable['very rare'] = 10 raritytable['epic'] = 5 raritytable['legendary'] = 1 return raritytable selltable = define_selltable() raritytable = define_raritytable() gear = load_gear() async def sell_item(par, msg, player): cha = msg.channel try: name = par[1] amount = player.inventory[par[1]] except: await cha.send('Item not found.') return try: sellamount = int(par[2]) except:
async def info(par, player, cha): if len(par) < 2: await cha.send(embed=form.info()) return if par[1] in ['b', 'battle', 'battles']: if len(par) < 3: await cha.send(embed=form.basic('Battles', all_battles(player))) return else: embed = Battles.battle_info(par[2]) await cha.send(embed=embed) return if par[1] in ['a', 'abilities', 'ability']: if len(par) < 3: await cha.send(embed=form.basic('Abilities', all_abilities(player)) ) return else: embed = abilitiy_info(par[2]) await cha.send(embed=embed) return if par[1] in ['e', 'enemy']: if len(par) < 3: await cha.send(embed=form.basic('Enemies', all_enemies())) return else: embed = enemy_info(par[2]) if embed != None: await cha.send(embed=embed) return embed = None if player.status[0] == 'battle': battle = GET.battle(player.status[1]) if par[2] in [en.name for en in battle.side1 + battle.side2]: enemy = [ en for en in battle.side1 + battle.side2 if en.name == par[2] ][0] embed = ingame_enemy_info(enemy) else: embed = form.basic( 'Not found', 'enemy not found (enemy not found in battle)') return else: embed = form.basic('Not found', 'enemy not found (not in battle)') return if embed != None: await cha.send(embed=embed) return else: await cha.send(embed=form.basic('Not found', 'enemy not found') ) return if par[1] in ['user', 'player', 'u']: if len(par) < 3: await cha.send( embed=form.basic('Not enough arguments', 'specify a User')) return if par[2] == 'self': searched_player = player else: searched_player = GET.player_by_name(par[2]) searched_player = GET.player(searched_player) if searched_player is None: await cha.send(embed=form.basic('Not found', 'Player not found')) return else: await cha.send(embed=user_info(searched_player, player)) return if par[1] in ['item', 'gear', 'i']: if len(par) < 3: await cha.send(embed=form.basic('Items', all_items())) return items = load_gear() if par[2] not in items: await cha.send(embed=form.basic('Not found', 'Item not found')) return await cha.send(embed=item_info(par[2])) return if par[1] in ['ef', 'effect']: if len(par) < 3: await cha.send(embed=form.basic('Effects', all_effects())) return effects = load_effects() if par[2] not in effects: await cha.send(embed=form.basic('Not found', 'Effect not found')) return await cha.send(embed=effect_info(par[2])) return if len(par) == 2: all_data = {} all_data['ef'] = load_effects() all_data['e'] = load_enemies() all_data['i'] = load_gear() all_data['a'] = load_abilities() all_data['b'] = load_battles()[1] all_data2 = all_data.copy() singular_data = {} for category, value in all_data2.items(): for key, value2 in value.items(): singular_data[key] = value2 singular_data[key]['category'] = category results = [] for key, value in singular_data.items(): if par[1] == key: if len(results) < 1: results.append((key, value)) else: results[0] = (key, value) if par[1] in key: results.append((key, value)) print(results) if len(results) < 1: return cat = results[0][1] print(cat) cat = cat['category'] key = results[0][0] par = ['info', cat, key] print(par) await info(par, player, cha)
async def info(par, player, cha): if len(par) < 2: await cha.send(embed=form.info()) return if par[1] in ['b', 'battle', 'battles']: if len(par) < 3: await cha.send(embed=form.basic('Battles', all_battles(player))) else: embed = Battles.battle_info(par[2]) await cha.send(embed=embed) if par[1] in ['a', 'abilities', 'ability']: if len(par) < 3: await cha.send(embed=form.basic('Abilities', all_abilities(player))) else: embed = abilitiy_info(par[2]) await cha.send(embed=embed) if par[1] in ['e', 'enemy']: if len(par) < 3: await cha.send(embed=form.basic('Enemies', all_enemies())) else: embed = enemy_info(par[2]) if embed != None: await cha.send(embed=embed) return embed = None if player.status[0] == 'battle': battle = GET.battle(player.status[1]) if par[2] in [en.name for en in battle.side1 + battle.side2]: enemy = [en for en in battle.side1 + battle.side2 if en.name == par[2]][0] embed = ingame_enemy_info(enemy) else: embed = form.basic('Not found', 'enemy not found (enemy not found in battle)') else: embed = form.basic('Not found', 'enemy not found (not in battle)') if embed != None: await cha.send(embed=embed) return else: await cha.send(embed=form.basic('Not found', 'enemy not found')) if par[1] in ['user', 'player', 'u']: if len(par) < 3: await cha.send(embed=form.basic('Not enough arguments', 'specify a User')) return if par[2] == 'self': searched_player = player else: searched_player = GET.player_by_name(par[2]) searched_player = GET.player(searched_player) if searched_player is None: await cha.send(embed=form.basic('Not found', 'Player not found')) else: await cha.send(embed=user_info(searched_player, player)) if par[1] in ['item', 'gear', 'i']: if len(par) < 3: await cha.send(embed=form.basic('Items', all_items())) return items = load_gear() if par[2] not in items: await cha.send(embed=form.basic('Not found', 'Item not found')) return await cha.send(embed=item_info(par[2])) if par[1] in ['ef', 'effect']: if len(par) < 3: await cha.send(embed=form.basic('Effects', all_effects())) return effects = load_effects() if par[2] not in effects: await cha.send(embed=form.basic('Not found', 'Effect not found')) return await cha.send(embed=effect_info(par[2]))