def all_abilities(player): data = load_abilities() abilitylist = '' for key, value in data.items(): if key in player.abilities: abilitylist += '**{}** \n'.format(key) else: abilitylist += '{} \n'.format(key) return abilitylist
def abilitiy_info(ability): data = load_abilities() print(data) if ability not in data: return form.basic('Not found', 'ability not found') endstring = '' abilitydata = data[ability] endstring += abilitydata['description'] + '\n\n' endstring += 'Targets ' if abilitydata['target'][0] == 'enemy_all': endstring += ' all enemies' elif abilitydata['target'][0] == 'ally_all': endstring += ' all allies' else: endstring += str(abilitydata['target'][1]) if abilitydata['target'][1] == 1: if abilitydata['target'][0] == 'enemy': endstring += ' enemy' if abilitydata['target'][0] == 'ally': endstring += ' ally' else: if abilitydata['target'][0] == 'enemy': endstring += ' enemies' if abilitydata['target'][0] == 'ally': endstring += ' allies' endstring += '.\n' dmg = abilitydata['damage'] if abilitydata['damage'][0] > 0 or abilitydata['damage'][1] > 0: endstring += 'Deals **{} (+ {}% of strength) (+ {}% of precision)** damage \n'.format( dmg[0], dmg[1] * 100, dmg[2] * 100) if abilitydata['damage'][0] < 0 or abilitydata['damage'][1] < 0: endstring += 'Heals for **{} (+ {}% of strength) (+ {}% of precision)** damage \n'.format( dmg[0], dmg[1] * 100, dmg[2] * 100) mdmg = abilitydata['magic_damage'] if mdmg[0] > 0 or mdmg[1] > 0: endstring += 'Deals **{} (+ {}% of intelligence) (+ {}% of precision)** magic damage \n'.format( mdmg[0], mdmg[1] * 100, dmg[2] * 100) if mdmg[0] < 0 or mdmg[1] < 0: endstring += 'Heals for **{} (+ {}% of intelligence) (+ {}% of precision)** damage \n'.format( mdmg[0], mdmg[1] * 100, dmg[2] * 100) if 'random_multiplier' in abilitydata: ra = abilitydata['random_multiplier'] endstring += 'Random Multiplier of **{}%** to **{}%** \n'.format( ra[0] * 100, ra[1] * 100) if 'crit_chance' in abilitydata: cr = abilitydata['crit_chance'] endstring += 'Chance of **{}%** to mulitiply damage by **{}**% \n'.format( cr[0] * 100, cr[1] * 100) ef = abilitydata['effects'] if len(ef) > 1: endstring += '\n' endstring += 'Gives the target(s) the following effects: ' for full_effect in ef[:-2]: effect = full_effect[0] duration = full_effect[1] effect = '**{}**'.format(effect) endstring += '**{}** ( {} turns)'.format(effect, duration) if len(full_effect) > 2: endstring += ' ({}% chance)'.format(full_effect[2] * 100) endstring += ', ' if len(ef[-2]) > 2: endstring += '**{0}** ( {1} turns) ({2}% chance)'.format( ef[-2][0], str(ef[-2][1]), str(ef[-2][2]) * 100) else: endstring += '**{0}** ( {1} turns) '.format( ef[-2][0], str(ef[-2][1])) if len(ef[-1]) > 2: endstring += 'and **{0}** ( {1} turns) ({2}% chance)'.format( ef[-2][0], str(ef[-2][1]), str(ef[-2][2]) * 100) else: endstring += 'and **{0}** ( {1} turns) '.format( ef[-1][0], str(ef[-1][1])) elif len(ef) == 1: endstring += '\n' endstring += 'Gives the target(s) the following effect: ' endstring += '**{0}** ( {1} turns)'.format(ef[0][0], str(ef[0][1])) print(endstring) return form.basic('Ability info', endstring)
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)