예제 #1
0
    def add_attribute(self,
                      attribute,
                      show_acquired_msg=True,
                      show_skill_info=False):
        """
        Adds attribute to character.

        Args:
            attribute str: Attribute to acquire.
            show_acquired_msg bool(True): Shows skill acquired message.
            show_skill_info bool(False): Shows skill information page after acquisition.

        Usage:
            .add_attribute('rimuru', 'water blade')
        """

        # Checks if already acquired.
        if self.check_acquired(attribute): return True

        if attribute := self.get_object(attribute, new=True):
            # Add to attributes dictionary, sets quantity to 1 so check_acquired func can work properly.
            attribute = attribute(1)
            self.attributes[attribute.skill_level][attribute.name] = attribute

            # Show acquisition message and/or skill's info page.
            if show_acquired_msg:
                gprint(
                    f"< Acquired: {attribute.skill_level} [{attribute.name}] >"
                )
            if show_skill_info: self.show_info(attribute.name)
            return True
예제 #2
0
 def __init__(self):
     game.mobs_add([
         'tempest serpent', 'giant bat', 'black spider',
         'evil centipede'
     ])
     siprint(
         "\nI've been looking for the cave exit for a bit now.... This cave is so big! Or am I just small?"
     )
     siprint("<< Answer, you are just small. >>")
     siprint("Oh, thanks for that.")
     siprint(
         "\n* But before long some monsters started taking a interest in the small slime. *"
     )
     siprint("\nWhat is that? it looks like a big snake!")
     siprint("<< Answer, analysis indicating [Tempest Serpent]. >>")
     siprint(
         "Still, it's not as scary as Veldora. I should be able to handle it."
     )
     siprint(
         "However, I don't think I have any ways to attack or damage it if it's hostile. Hmmmmmm. I wonder...\n"
     )
     rimuru.add_attribute('water blade')
     siprint(
         "Hey, it worked. Since I already have [Hydraulic Propulsion], I was thinking I could use super high pressure water as a blade attack also."
     )
     gprint(
         "< Tutorial: First target with 'target tempest serpent'. Then attack with 'attack water blade'. >"
     )
     game.actions(self)
예제 #3
0
파일: info.py 프로젝트: 0n1udra/TenseiPy
    def update_reputation(self, faction_name, add_value=1):
        """
        Adds to player standing/reputation.

        Args:
            faction_name str: Character/faction/etc to update.
            add_value int(1): Increase or decrease reputations. Pass in either positive or negative integer.

        Usage:
            rimuru.update_reputation('veldora', 2)
            rimuru.update_reputation('gobta', -1)
        """

        faction_name = faction_name.capitalize()
        # Checks if already have repudiation with faction.
        for _faction_name, reputation_value in self.reputations.items():
            if _faction_name == faction_name:
                gprint(
                    f"\n< [{faction_name}] Reputation Update: {self.reputations[faction_name]} to {self.reputations[faction_name] + add_value} >\n"
                )
                self.reputations[faction_name] += add_value
                return self.reputations[
                    faction_name]  # Returns new value of reputation standing.

        # Adds new faction to reputations list.
        self.reputations[faction_name] = add_value
        gprint(
            f"\n< [{faction_name}] New Reputation: {self.reputations[faction_name]} >"
        )
예제 #4
0
    def add_inventory(self, item, amount=1, show_acquired_msg=True, show_analysis_msg=None):
        """
        Adds item to character (currently only Rimuru) inventory.

        Args:
            item str/obj: Item to add to inventory.
            amount int(None): Amount of specified item to add to inventory. If not specified, will use item's .add_amount value.
            show_acquired_msg bool(True): Show item acquired message.
            show_analysis_msg bool(None): Show analysis complete message.

        Usage:
            .add_inventory('hipokte grass')
        """

        try:
            if item.object_type not in ['item', 'character']: return
        except: item = self.get_object(item, new=True)
        if not item: return False  # Does not have game object to add to inventory.

        # Adds to item quantity variable if already acquired some.
        if self.check_acquired(item):
            self.inventory[item.item_type][item.name].quantity += amount * item.quantity_add
        # Adds new item to inventory.
        else:
            if not item.initialized: item = item()
            self.inventory[item.item_type][item.name] = item
            self.inventory[item.item_type][item.name].quantity += amount * item.quantity_add
            if show_analysis_msg is None: show_analysis_msg = True

        self.update_inventory_capacity()

        if show_acquired_msg: gprint(f"< Acquired: {amount * item.quantity_add}x [{item.name}] >")
        if show_analysis_msg: gprint(f"<< Analysis on [{item.name}] Complete. >>")
        return True
예제 #5
0
    def use_mimic(self, character):
        """
        Use mimicry ability.

        Args:
            character str: Game monster to mimic.

        Usage:
            > mimic tempest serpent
        """

        # Resets mimic state (default Slime).
        if character == 'reset':
            self.current_mimic_species = 'Slime'
            self.current_mimic = None
            self.mimic_object(update_status='')
            gprint("< Mimicry Reset >")
        else:
            # Get's character game object from acquired_mimicries dictionary.
            if new_mimic := self.get_object(character, [*self.mimic_generator()]):
                # Can't mimic items/skills, only mobs that you have acquried.
                try: self.current_mimic_species = new_mimic.species
                except: pass
                else:
                    # Updates relevant player information when mimicry is activated.
                    self.current_mimic = new_mimic
                    self.mimic_object(update_status='Active')
                    gprint(f"< Now Mimicking [{new_mimic.name}] >")
예제 #6
0
        def __init__(self):
            rimuru.add_mimic('slime', show_msg=False)
            print("\n    < Chapter 1 >")
            idots()
            gprint(
                "<< Confirmation Complete. Constructing body that does not require blood... >>\n"
            )
            gprint(
                "<< Confirmation Complete. Acquiring Extra Skill: [Predator]... >>"
            )
            gprint("<< Acquired Extra Skill [Predator]. >>")
            gprint(
                "<< Confirmation Complete. Acquiring: Extra Skill [Sage]... >>"
            )
            gprint("<< Acquired Extra Skill [Sage]. >>")
            rimuru.upgrade_attribute('Sage', 'Great Sage')

            siprint("It's so dark? Where am I? What happened?")
            siprint("I remember now, I got stabbed! A-am I dead?")
            siprint("Was I saved? Can I move? Should I try to say something?")

            # Because I am a dick. There is a 1 in 1,000 chance that you will wake up and just instantly die! kek!
            if extra.get_random(1, 1_000, 666):
                siprint(
                    "\nWAIT! WAIT WHAT'S THAT AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH"
                )
                siprint(
                    "SOMETHING IS EATING MEEEEEEEEEEEEEEEEEEEEEEEEEE!!!!!!!!!!!!!!!"
                )
                print(
                    "\n\nYOU DIED BEFORE YOU COULD EVEN DO ANYTHING, WHAT BAD LUCK YOU HAVE!"
                )
                game.game_over()
예제 #7
0
    def craft_item(self, args):
        """
        Craft item if have necessary material.

        In in-game command, if not specify amount, will show recipe than ask for amount.

        Args:
            arg str: User input, item to craft and amount.

        Usage:
            > craft full potion
            > craft full potion 10
        """

        try: item, craft_amount = parse_input(args)
        except:
            craft_amount = None
            item = args

        item = self.get_object(item, new=True)
        if item is None: return
        if item.object_type != 'item': return


        # 'craft full potion 2', or 'craft full potion' to show recipe then input amount.
        if craft_amount is None:
            # Shows recipe.
            recipe = ''

            print_header('CRAFTING', 5)
            print(f"    Recipe for [{item.name}]:")
            for ingredient, amount in item.recipe.items():
                recipe += F"    {amount}x {ingredient}, "
            print(f"    {recipe[:-2]}")  # [:-2] will cuts off trailing comma and space.
            print(f"\n    Inputting 1 will craft {item.quantity_add}. 0 cancel.\n")

            # Asks for how much to make. note that some items are crafted in batches.
            try:
                craft_amount = int(input("Craft > "))
            except ValueError:
                gprint("< Error: need integer input >")
                return False

        # Let's player enter 0 to cancel.
        if craft_amount <= 0: return False

        # Checks if have all the ingredients.
        for ingredient_name, ingredient_amount in item.recipe.items():
            if self.check_acquired(ingredient_name, ingredient_amount * craft_amount): continue

            gprint("< Missing Ingredient(s) >")
            return False

        # Removes ingredients then adds new crafted item to inventory
        for ingredient_name, ingredient_amount in item.recipe.items():
            self.remove_inventory(ingredient_name, ingredient_amount * craft_amount)
        self.add_inventory(item, craft_amount)
        return True
예제 #8
0
    def activate_skill(self, state='Active'):
        """Activates skill, then updates relevant variables."""

        if state.lower() in self.status:
            return  # If skill is already at that state.

        gprint(f"< {self.skill_level} {self.name}: {state} >")
        self.status = state
        self.update_info()
예제 #9
0
 def __init__(self):
     siprint("Yes, of course.")
     rimuru.update_status('veldora', 'Analyzing')
     gprint(
         "< Starting Analysis: Unique Skill [Unlimited Imprisonment] >"
     )
     rimuru.update_reputation('veldora', 1)
     siprint("I hope you get out quickly Veldora!")
     tempest_serpent_encounter()
예제 #10
0
 def __init__(self):
     siprint(
         "<< Answer, unique skill [Predator] 'predates' targets, stashes in skill's 'stomach'. >>"
     )
     siprint(
         "<< Addendum, after successful analysis of monster, [Mimic] can be used to replicate appearance and skills."
     )
     siprint("Wow, that sounds like a OP skill!")
     gprint(
         "< Tutorial: Try 'info predator' to get more information. >"
     )
예제 #11
0
    def get_location(self, *args):
        """
        Prints and returns player's current location.

        Returns
            str: Name of location or N/A if unknown.
        """

        gprint(
            f"< {self.name} location: {self.current_location if self.current_location else 'N/A'} >"
        )
        return self.current_location
예제 #12
0
파일: info.py 프로젝트: 0n1udra/TenseiPy
    def add_level(self, add_amount=1):
        """
        Add x levels to character's level.

        Args:
            add_amount int(1): To be added to current level.
        """

        gprint(
            f"< [{self.name}] Level Up: {self.level} to {self.level + add_amount}>\n"
        )
        self.level += add_amount
        self.update_info()
예제 #13
0
 def __init__(self):
     if not game.mob_status('tempest serpent'):
         siprint(
             "Wow, what a powerful attack. I should probably use that only when needed."
         )
         siprint("<< Suggestion, Use Unique Skill [Predator]? >>")
         siprint("Oh...? What will that do?")
         siprint(
             "<< Answer, after predation, information and target's skills may be obtained through analysis. >>"
         )
         gprint(
             "< Tutorial: Try 'predate' or 'eat' on targeted mobs that are dead to use [Predator] skill. >"
         )
예제 #14
0
 def __init__(self):
     game.clear_all()
     gprint("< Chapter 2 >\n")
     game.mobs_add(['10* goblin'])
     siprint("Where am I going?")
     siprint(
         "\n* While practicing pronunciation with [Ultrasound Waves]. A pack of [Dire Wolves] shows up *"
     )
     sprint("\nYou strong one.")
     siprint(
         "\nWho's that? Wait... They look like goblins! Should I be nice?"
     )
     game.actions(self)
예제 #15
0
파일: info.py 프로젝트: 0n1udra/TenseiPy
    def set_level(self, level):
        """
        Set character level.

        Args:
            level int: New level for character.

        Usage:
            game_object.update_level(10)
        """

        self.level = level
        self.update_info()
        gprint(f"< [{self.name}] Level: {level} >\n")
예제 #16
0
파일: info.py 프로젝트: 0n1udra/TenseiPy
    def update_titles(self, add_title=None, remove_title=None):
        """
        Add/Remove title from character.

        Args:
            add_title str(None): Add new title to titles list.
            remove_title str(None): Remove title from titles list. Case sensitive.
        """

        if add_title:
            self.titles.append(add_title)
            gprint(f"< [{self.name}] Acquired Title: {add_title} >")
        if remove_title: self.titles.remove(remove_title)
        self.update_info()
예제 #17
0
                    def __init__(self):
                        siprint(
                            "<< Answer, my function is to assist my master to the best of my abilities. >>"
                        )
                        siprint(
                            "<< Information, some of my basic functions are: Analysis, skill control and manipulation, crafting, and more. >>"
                        )
                        gprint(
                            "< Tutorial: Use 'info great sage' to get more information on skill. >"
                        )

                        if rimuru.check_acquired('hipokte grass'):
                            gprint(
                                "< Tutorial: Try 'info hipokte grass'. Then try 'craft full potion'. >"
                            )
예제 #18
0
파일: info.py 프로젝트: 0n1udra/TenseiPy
    def add_protection(self, divine_protection):
        """
        Adds divine protection to character.

        Protections:
        Storm Crest: Veldora to Rimuru
        Protection of Tempest: Rimuru to subs
        Protection of the Storm: True Dragons, Veldora, etc
        Divine Protection of the Labyrinth: Ramiris to subs
        Divine Protection of the Great Demon Lord: Demon Lord to subs
        Protection of The White Ice: Velzado
        """

        self.protections.append(divine_protection)
        self.update_info()
        gprint(f"< [{self.name}] Acquired Blessing: {divine_protection} >")
예제 #19
0
def continue_to(next_location):
    """
    Saves game and continues to next location.

    Args:
        next_location: Next chapter to play.
    """

    rimuru.current_location_object = next_location
    save()

    # Loads next story chapter.
    try:
        next_location(rimuru)
    except:
        gprint("< Error Loading Next Location >")
예제 #20
0
    def meet_requirements(self, user):
        """
        Checks if user meets prerequisite requirements to use skill.

        Args:
            user obj: Character object that is using skill.

        Returns:
            bool: If user meets requirements or not.
        """

        if self.use_requirements:
            # Check if user meets requirement or own prerequisites before using skill.
            for k, v in self.use_requirements.items():
                if not user.check_acquired(k, v):
                    gprint(f"< Skill Requires: {v}x {k} >")
                    return False
        return True
예제 #21
0
def save(level=None, show_msg=True):
    """
    Pickels Rimuru_Tempest object.

    Args:
        level (bool): Update rimuru.current_location_object
        show_msg (bool True): Show Game Saved message.
    """

    global rimuru

    # Can specify what level to save at.
    if level: rimuru.current_location_object = level

    # If called from game_over function, the save will no longer be usable.
    if rimuru.valid_save is None: rimuru.valid_save = True

    pickle.dump(rimuru, open(rimuru.save_path, 'wb'))

    if show_msg: gprint("\n< Game Saved >\n")
예제 #22
0
    def remove_inventory(self, item=None, amount=1):
        """
        Remove item from inventory.

        Args:
            item str(None): Item to remove from inventory.
            amount int(1): How many to remove from inventory. -1 to remove all.

        Usage:
            .remove_inventory('hipokte grass')
            .remove_inventory('magic ore', 5)
            .remove_inventory('water' -1)

            > remove hipokte grass
            > remove magic ore 5
            > remove water -1
        """

        # Parses item and amount from user input.
        try: item, amount = parse_input(item)
        except: pass
        if amount == 0: return False

        item = self.get_object(item)
        if not item: return False
        if item.object_type not in ['item', 'character']: return

        # Removes x amount of said item.
        if (item.quantity - amount) <= 0 or amount <= 0:
            del self.inventory[item.item_type][item.name]
            gprint(f"< Removed Item: [{item.name}] >")
        # Removes item from inventory completely if item's quantity is 0.
        else:
            item.quantity -= amount
            gprint(f"< Removed: {amount}x [{item.name}] >")

        self.update_inventory_capacity()
        return True
예제 #23
0
    def add_mimic(self, mob, show_msg=True):
        """
        Adds new monster mimicry.

        Args:
            mob str/obj: Character object to add to acquired_mimicries list
            show_msg bool(True): Show acquired message.
        """

        if type(mob) is str:
            mob = self.get_object(mob, new=True)()
        if not mob: return False

        # Basically checks if self is the rimuru object (player).
        if not self.mimic_object(): return False

        # Checks if already acquired.
        if mob.name in self.acquired_mimicries[mob.rank]: return None

        # Adds new mob object to usable mimicries dict.
        self.acquired_mimicries[mob.rank][mob.name] = mob

        if show_msg: gprint(f"<< Information, analysis on [{mob.name}] completed. New mimicry available. >>")
예제 #24
0
    def upgrade_attribute(self, skill_from, skill_to):
        """
        Evolve skill.

        Args:
            skill_from str: Original skill.
            skill_to str: Skill to upgrade into.

        Usage:
            .upgrade_attribute('sage', 'great sage')
        """

        # Gets skill object from attributes dict, then
        skill_from = self.check_acquired(skill_from)
        skill_to = self.get_object(skill_to, new=True)
        if not skill_from or not skill_to: return False

        gprint(f"< Evolving {skill_from.skill_level} [{skill_from.name}] >")
        # Removes old attribute and adds new one.
        if self.remove_attribute(skill_from) and self.add_attribute(
                skill_to, show_acquired_msg=False):
            gprint(
                f"< Evolution Successful: {skill_from.skill_level} [{skill_from.name}] to {skill_to.skill_level} [{skill_to.name}] >"
            )
예제 #25
0
 def __init__(self):
     siprint("Let's get moving.")
     if game.mobs_cleared():
         at_cave_exit()
     else:
         siprint(
             "I still sense some enemies around. I should clear them out before they give me trouble."
         )
         if rimuru.check_acquired('sense heat source'):
             siprint(
                 "Oh yeah! I have that new [Sense Heat Source] skill, that might be useful."
             )
             gprint(
                 "< Tutorial: Try Mimicking [Tempest Serpent] and using it's [Sense Heat Source] to locate nearby mobs. '/help' for more info on commands. >"
             )
             gprint(
                 "< Tutorial: While mimicking, use 'stats' to see your's and mimicked monster's attributes and skills. > "
             )
         if rimuru.check_acquired('magic sense'):
             gprint(
                 "< Hint: If acquired [Magic Sense], you can use 'nearby' command to see nearby mobs. >"
             )
예제 #26
0
    def attack(self, user_input, user=None):
        """
        Checks if can attack, and if it was successful.

        Args:
            user_input str: Targets to attack, if multiple, separated by comma ','.
            user obj(None): The one who is attacking.

        Returns:
            bool: If attack was successful.

        Usage:
            > attack water blade
            > attack magic sword
        """

        attack_success = False
        skills = []
        if not user: user = self
        # If using mimic, allows usage of skills/attributes from mimicked mob.

        # TODO set combat to use get_random

        # Parse what attack(s) user wants to use.
        for current_attack in user_input.split(','):
            attack = user.get_object(current_attack)
            # If using mimic but player already has skill, will use player's skill instead of mimicked mob's.
            if not attack:
                try:
                    attack = self.current_mimic.get_object(current_attack)
                except:
                    pass

            if attack:
                # Adds skill to list of attacks to use against enemies.
                if attack.object_type == 'attribute':
                    skills.append(attack)
                elif attack.object_type == 'item':
                    if attack.item_type == 'Weapon': skills.append(attack)
                elif attack.object_type == 'character': continue
            else: continue

        for current_target in self.targeted_mobs:
            if not current_target[0].is_alive: continue
            for current_skill in skills:
                # If target is too high of a level to damage with skill.
                if current_target[0].level > current_skill.damage_level:
                    continue

                # Checking if have resistance.
                if self.check_resistance(current_skill, current_target[0]):
                    gprint(
                        f"<< Warning, {current_target.name} has resistance to {current_skill.damage_type}. >>"
                    )
                    continue

                self.data['kills'] += 1
                current_target[0].is_alive = False
                current_target[0].status = 'Dead'
                attack_success = True

        return attack_success
예제 #27
0
def restart(*args):
    """Restart game."""

    gprint("< Restarting Game... >")
    os.execl(sys.executable, sys.executable, *sys.argv)
예제 #28
0
    def deactivate_skill(self, state=''):
        """Deactivates skill, then updates relevant variables."""

        gprint(f"< {self.skill_level} {self.name}: Deactivated >")
        self.status = state
        self.update_info()
예제 #29
0
        Usage:
            .add_subordinates('Tempest Wolf', 'Ranga')
        """

        # Asks player to set name, if nothing, uses canon name (story accurate name).
        if not new_name:
            while True:
                if new_name := str(
                        input(
                            f"\nChoose name or Enter for default ({canon_name}) > "
                            if canon_name else "Set name > ")).strip():
                    if new_name.isalnum(): break
                # Let's user use default canon name for new subordinate. Requires canon_name argument.
                elif canon_name:
                    new_name = canon_name
                    break
        new_name = new_name.capitalize()

        # Get's game character object and sets relavant variables.
        new_subordinate = self.get_object(game_character, new=True)(new_name)
        new_subordinate.protections.append(self.shared_protection)
        new_subordinate.canon_name = canon_name
        if level: new_subordinate.level = level

        if new_subordinate.species in self.subordinates:
            self.subordinates[new_subordinate.species].append(new_subordinate)
        else:
            self.subordinates[new_subordinate.species] = [new_subordinate]

        gprint(f"< New Subordinate: {new_name} >")