示例#1
0
    async def gunsmith(self, ctx, *, arg):
        '''
        This function corresponds to the "?gunsmith <weapon>" command.

        Parameters
        ----------
        ctx
            The context of the command being invoked. Constructed by `discord.py`
        arg
            The arguments of the command, after "?gunsmith"
        '''
        weapon = arg

        logger.info(ctx.message.content)

        if len(weapon) < 3:
            await ctx.send("Please enter a query of 3 or more characters!")
            return

        if not os.path.exists(self.bot.current_state.current_manifest):
            logger.critical(f"Manifest queried does not exist at {self.bot.current_state.current_manifest}")
            await ctx.send("An error occured. Please try again!")
            return

        weapon = weapon.replace("’","'")

        armory = Armory(self.bot.current_state.current_manifest)

        logger.info(f"Searching for '{weapon}'")
        weapons = await armory.get_weapon_details(weapon)

        logger.info(f"# of weapons found: {len(weapons)}")
        result = weapons[0] # TODO: pagination

        logger.info("Constructing weapon result")
        DESCRIPTION = str(result.weapon_base_info) + "\n**" + result.intrinsic.name  + "**"
        embed = discord.Embed(title=result.name, description=DESCRIPTION, color=constants.DISCORD_BG_HEX)
        embed.set_thumbnail(url=result.icon)

        if len(result.weapon_perks) <= 2:
            for perk in result.weapon_perks:
                embed.add_field(name='**' + perk.name + '**', value=perk, inline=True)
        else:
            for perk in result.weapon_perks:
                if perk.name == "Perks":
                    embed.add_field(name='**' + perk.name + '**', value=perk, inline=True)
        
        light_gg_url = "https://www.light.gg/db/items/" + str(result.weapon_hash)
        ending_text_components = [f"[Screenshot]({result.screenshot})", 
                                  f"[light.gg]({light_gg_url})",
                                  "Use -full before weapon name"] # TEMP?
        ending_text = " • ".join(ending_text_components)
        embed.add_field(name="\u200b", value=ending_text, inline=False)

        logger.info("Sending weapon result")
        await ctx.send(embed=embed)
示例#2
0
    async def gunsmith_stats(self, ctx, *, arg):
        '''
        This function corresponds to the "?gunsmith -stats <weapon>" command.

        Parameters
        ----------
        ctx
            The context of the command being invoked. Constructed by `discord.py`
        arg
            The arguments of the command, after "?gunsmith"
        '''
        weapon = arg

        logger.info(ctx.message.content)

        if len(weapon) < 3:
            await ctx.send("Please enter a query of 3 or more characters!")
            return

        if not os.path.exists(self.bot.current_state.current_manifest):
            logger.critical(f"Manifest queried does not exist at {self.bot.current_state.current_manifest}")
            await ctx.send("An error occured. Please try again!")
            return
        
        weapon = weapon.replace("’","'")

        armory = Armory(self.bot.current_state.current_manifest)

        logger.info(f"Searching for '{weapon}'")
        weapons = await armory.get_weapon_details(weapon)

        logger.info(f"# of weapons found: {len(weapons)}")
        result = weapons[0] 

        logger.info("Constructing weapon result")
        STATS = '\n'.join([str(stat) for stat in result.weapon_stats])
        embed = discord.Embed(title=result.name, color=constants.DISCORD_BG_HEX)
        embed.set_thumbnail(url=result.icon)

        embed.add_field(name="**Stats**", value=STATS, inline=True)
        
        light_gg_url = "https://www.light.gg/db/items/" + str(result.weapon_hash)
        ending_text_components = [f"[Screenshot]({result.screenshot})", f"[light.gg]({light_gg_url})"]
        ending_text = " • ".join(ending_text_components)
        embed.add_field(name="\u200b", value=ending_text, inline=False)

        logger.info("Sending weapon stats result")
        await ctx.send(embed=embed)
示例#3
0
    async def default_perks(self, ctx, *, arg):
        '''
        This function corresponds to the "?gunsmith -default <weapon>" command.

        Parameters
        ----------
        ctx
            The context of the command being invoked. Constructed by `discord.py`
        arg
            The arguments of the command, after "?gunsmith -default"
        '''
        weapon = arg

        logger.info(ctx.message.content)

        if len(weapon) < 3:
            await ctx.send("Please enter a query of 3 or more characters!")
            return

        if not os.path.exists(self.bot.current_state.current_manifest):
            logger.critical(f"Manifest queried does not exist at {self.bot.current_state.current_manifest}")
            await ctx.send("An error occured. Please try again!")
            return

        weapon = weapon.replace("’","'")

        armory = Armory(self.bot.current_state.current_manifest)

        weapons = await armory.get_weapon_details(weapon, default=True)

        logger.info(f"# of weapons found: {len(weapons)}")
        result = weapons[0] # TODO: pagination

        logger.info("Constructing weapon result")
        DESCRIPTION = str(result.weapon_base_info) + "\n**" + result.intrinsic.name  + "**\n" + result.description
        embed = discord.Embed(title=result.name, description= DESCRIPTION, color=constants.DISCORD_BG_HEX)
        embed.set_thumbnail(url=result.icon)
        perk = result.weapon_perks[0]
        embed.add_field(name=perk.name, value=perk, inline=True)
        
        light_gg_url = "https://www.light.gg/db/items/" + str(result.weapon_hash)
        embed.add_field(name="\u200b", value=light_gg_url, inline=False)

        logger.info("Sending weapon result")
        await ctx.send(embed=embed)
        return
示例#4
0
    async def compare(self, ctx, *, arg):
        '''
        This function corresponds to the "?gunsmith -compare <weapon> <weapon>" command.

        Parameters
        ----------
        ctx
            The context of the command being invoked. Constructed by `discord.py`
        arg
            The arguments of the command, after "?gunsmith -compare"
        '''
        compare_query = arg

        logger.info(ctx.message.content)

        if len(compare_query) < 3:
            await ctx.send("Please enter a query of 3 or more characters!")
            return

        if not os.path.exists(self.bot.current_state.current_manifest):
            logger.critical(f"Manifest queried does not exist at {self.bot.current_state.current_manifest}")
            await ctx.send("An error occured. Please try again!")
            return

        compare_query = compare_query.replace("’","'")

        armory = Armory(self.bot.current_state.current_manifest)

        logger.info(f"Comparing '{compare_query}'")
        comparison_result = await armory.compare_weapons(compare_query)

        logger.info("Constructing compare result")
        embed = discord.Embed(color=constants.DISCORD_BG_HEX)
        embed.add_field(name=comparison_result.weapons_names[0], 
                        value=comparison_result.get_stats_for_weapon(0), inline=True)
        embed.add_field(name="Stats", 
                        value=comparison_result.common_stat_names, inline=True)
        embed.add_field(name=comparison_result.weapons_names[1], 
                        value=comparison_result.get_stats_for_weapon(1), inline=True)

        logger.info("Sending compare result")
        await ctx.send(embed=embed)
        return
示例#5
0
class Map(object):

    scenes = {
        'central_corridor': CentralCorridor(),
        'death': Death(),
        'finished': Planet(),
        'armory': Armory(),
        'bridge': Bridge(),
        'pod': EscapePod()
    }

    def __init__(self, start_scene):
        self.start_scene = start_scene

    def next_scene(self, scene_name):
        val = Map.scenes.get(scene_name)
        return val

    def opening_scene(self):
        return self.next_scene(self.start_scene)
示例#6
0
    async def perk(self, ctx, *, arg):
        '''
        This function corresponds to the "?gunsmith -perk <perk>" command.

        Parameters
        ----------
        ctx
            The context of the command being invoked. Constructed by `discord.py`
        arg
            The arguments of the command, after "?gunsmith -perk"
        '''
        perk = arg

        logger.info(ctx.message.content)

        if len(perk) < 3:
            await ctx.send("Please enter a query of 3 or more characters!")
            return

        if not os.path.exists(self.bot.current_state.current_manifest):
            logger.critical(f"Manifest queried does not exist at {self.bot.current_state.current_manifest}")
            await ctx.send("An error occured. Please try again!")
            return

        perk = perk.replace("’","'")

        armory = Armory(self.bot.current_state.current_manifest)

        logger.info(f"Searching for '{perk}'")
        perk_result = await armory.get_perk_details(perk)

        logger.info("Constructing perk result")
        DESCRIPTION = "**" + perk_result.name + "**\n" + perk_result.description
        embed = discord.Embed(title=perk_result.category, description=DESCRIPTION, color=constants.DISCORD_BG_HEX)
        embed.set_thumbnail(url=perk_result.icon)

        logger.info("Sending perk result")
        await ctx.send(embed=embed)
        return
示例#7
0
class Map(object):

    scenes = {
        'communication': Communication(),
        'finished': Finished(),
        'disaster': Disaster(),
        'armory': Armory(),
        'engineroom': EngineRoom(),
        'bridge': Bridge(),
        'brig': Brig(),
        'podbay': PodBay()
    }

    def __init__(self, start_scene):
        self.start_scene = start_scene

    def next_scene(self, scene_name):
        val = self.scenes.get(scene_name)
        return val

    def opening_scene(self):
        return self.next_scene(self.start_scene)
示例#8
0
                loc = courtyard
            elif new_loc == "lr":
                loc = lr
            elif new_loc == "reactor":
                loc = reactor
            elif new_loc == "workshop":
                loc = workshop
            elif new_loc == "q":
                print("Exit game")
                run = False
                break
            else:
                print(new_loc)
                loc = player.location
            player.location = loc


game = Game()
armory = Armory("armory")
kitchen = Kitchen("kitchen")
entry = EntryWay("entry way")
walls = Walls("walls")
lr = LivingRoom("living room")
barracks = Barracks("barracks")
courtyard = Courtyard("courtyard")
dining = DiningRoom("dining room")
reactor = Reactor("reactor")
workshop = Workshop("workshop")
name = input("Enter name:  \n")
player = Player(name, 25, 10, courtyard)
game.main()