async def get_char_design_details_by_name(char_name: str, level: int, as_embed: bool = settings.USE_EMBEDS ): pss_assert.valid_entity_name(char_name, 'char_name', min_length=2) pss_assert.parameter_is_valid_integer(level, 'level', min_value=1, max_value=40, allow_none=True) chars_designs_data = await characters_designs_retriever.get_data_dict3() char_design_info = await characters_designs_retriever.get_entity_design_info_by_name( char_name, chars_designs_data) if char_design_info is None: return [f'Could not find a crew named **{char_name}**.'], False else: collections_designs_data = await collections_designs_retriever.get_data_dict3( ) character_design_details = __create_character_design_details_from_info( char_design_info, None, collections_designs_data, level) if as_embed: return character_design_details.get_details_as_embed(), True else: return character_design_details.get_details_as_text_long(), True
def get_char_design_details_by_name(char_name: str, level: int, as_embed: bool = settings.USE_EMBEDS): pss_assert.valid_entity_name(char_name, 'char_name') pss_assert.parameter_is_valid_integer(level, 'level', min_value=1, max_value=40, allow_none=True) char_design_info = character_designs_retriever.get_entity_design_info_by_name(char_name) if char_design_info is None: return [f'Could not find a crew named **{char_name}**.'], False else: char_design_details = CharDesignDetails(char_design_info, level=level) if as_embed: return char_design_details.get_details_as_embed(), True else: return char_design_details.get_details_as_text_long(), True
async def get_char_details_by_name(ctx: Context, char_name: str, level: int, as_embed: bool = settings.USE_EMBEDS) -> Union[List[Embed], List[str]]: pss_assert.valid_entity_name(char_name, 'char_name', min_length=2) pss_assert.parameter_is_valid_integer(level, 'level', min_value=1, max_value=40, allow_none=True) chars_data = await characters_designs_retriever.get_data_dict3() char_info = await characters_designs_retriever.get_entity_info_by_name(char_name, chars_data) if char_info is None: raise NotFound(f'Could not find a crew named `{char_name}`.') else: collections_data = await collections_designs_retriever.get_data_dict3() characters_details_collection = __create_characters_details_collection_from_infos([char_info], chars_data, collections_data, level) if as_embed: return (await characters_details_collection.get_entities_details_as_embed(ctx)) else: return (await characters_details_collection.get_entities_details_as_text())
def get_level_costs(ctx: Context, from_level: int, to_level: int = None, as_embed: bool = settings.USE_EMBEDS) -> Union[List[Embed], List[str]]: if from_level: pss_assert.parameter_is_valid_integer(from_level, 'from_level', 1, to_level - 1) pss_assert.parameter_is_valid_integer(to_level, 'to_level', from_level + 1, 40) else: pss_assert.parameter_is_valid_integer(to_level, 'to_level', 2, 40) from_level = 1 crew_costs = __get_crew_costs(from_level, to_level, lookups.GAS_COSTS_LOOKUP, lookups.XP_COSTS_LOOKUP) legendary_crew_costs = __get_crew_costs(from_level, to_level, lookups.GAS_COSTS_LEGENDARY_LOOKUP, lookups.XP_COSTS_LEGENDARY_LOOKUP) crew_cost_txt = __get_crew_costs_as_text(from_level, to_level, crew_costs) legendary_crew_cost_txt = __get_crew_costs_as_text(from_level, to_level, legendary_crew_costs) if as_embed: embed_color = utils.discord.get_bot_member_colour(ctx.bot, ctx.guild) fields = [ ('Non-legendary crew', '\n'.join(crew_cost_txt), False), ('Legendary crew', '\n'.join(legendary_crew_cost_txt), False) ] result = [utils.discord.create_embed(title='Level costs', fields=fields, colour=embed_color, footer='Note: Gas costs are higher, if "Advanced Training 7" hasn\'t been reseached, yet.')] else: result = ['**Level costs** (non-legendary crew, max research)'] result.extend(crew_cost_txt) result.append(utils.discord.ZERO_WIDTH_SPACE) result.append('**Level costs** (legendary crew, max research)') result.extend(legendary_crew_cost_txt) result.append(utils.discord.ZERO_WIDTH_SPACE) result.append('**Note:** Gas costs are higher, if **Advanced Training 7** hasn\'t been reseached, yet.') return result
def get_level_costs(from_level: int, to_level: int = None) -> list: # If to_level: assert that to_level > from_level and <= 41 # Else: swap both, set from_level = 1 if to_level: pss_assert.parameter_is_valid_integer(from_level, 'from_level', 1, to_level - 1) pss_assert.parameter_is_valid_integer(to_level, 'to_level', from_level + 1, 40) else: pss_assert.parameter_is_valid_integer(from_level, 'from_level', 2, 40) to_level = from_level from_level = 1 crew_costs = _get_crew_costs(from_level, to_level, lookups.GAS_COSTS_LOOKUP, lookups.XP_COSTS_LOOKUP) legendary_crew_costs = _get_crew_costs(from_level, to_level, lookups.GAS_COSTS_LEGENDARY_LOOKUP, lookups.XP_COSTS_LEGENDARY_LOOKUP) crew_cost_txt = _get_crew_cost_txt(from_level, to_level, crew_costs) legendary_crew_cost_txt = _get_crew_cost_txt(from_level, to_level, legendary_crew_costs) result = ['**Level costs** (non-legendary crew, max research)'] result.extend(crew_cost_txt) result.append(settings.EMPTY_LINE) result.append('**Level costs** (legendary crew, max research)') result.extend(legendary_crew_cost_txt) return result, True