Exemple #1
0
 def addCharacter(self):
     newCharacterID = self.getNewCharacterId()
     character = Character(newCharacterID)
     character.setPosition(self.gameManager.getGameMap().getStartPosition())
     self.characters.append(character)
     
     print('CharacterManager::addCharacter: character created; id',
           newCharacterID)
     return newCharacterID
Exemple #2
0
 def reset_default_all_positions(self, characters=None):
     """ Delete all characters files (if characters is None) or only the
         positions of the characters (in array characters) to reset the
         positions """
     for char in self.__all_characters:
         if (characters is None) or (char in characters):
             Character(char).reset_default_positions()
             for c in self.valid_characters:
                 if (c.val == char):
                     c.load_positions()
Exemple #3
0
 def __init__(self, type):
     self.__positions = []
     self.__letters = list(Letter(None).valid_letters())
     self.__symbols = list(Symbol(None).valid_symbols())
     self.__punctuations = list(Punctuation(None).valid_punctuations())
     self.__extendeds = list(Extended(None).valid_extendeds())
     self.__accents = list(Accent(None).valid_accents())
     self.__all_characters = self.__letters + self.__symbols + \
         self.__punctuations + self.__extendeds + self.__accents
     self.valid_characters = []
     self.change_type(type)
     # If data/current/ directory is empty, put the default files in it
     if len(os.listdir('engine/data/current/')) < len(
             self.__all_characters):
         missing_characters = []
         for char in self.__all_characters:
             c = Character(char)
             c.load_positions()
             if c.positions is None:
                 missing_characters.append(char)
         self.reset_default_all_positions(missing_characters)
Exemple #4
0
    def npc_assess(self, **npc_kwargs):

        # alert types:
        # sleep = not performing any tasks
        # awake = moving rooms, searching for targets
        # engaged = engaging a target in combat

        if self.conditions['state'] == "sleep":
            pass

        elif self.conditions['state'] != "sleep":

            players_in_room = Gen.players_in_room(self)

            if players_in_room == []:

                exit = Gen.random_movement(self)

                if exit == None:
                    pass
                else:
                    rand_die = random.randint(1, 1)

                    Character.navigate(self, None, exit)
                    all_schedules[self.uuid_id]['sched'].eventabs(
                        time.time() + rand_die,
                        1,
                        "npc_assess",
                        "npc",
                        Npc.npc_assess,
                        kwargs={"self": self})

            elif players_in_room != []:

                input_kwargs = {}
                input_kwargs['target'] = random.choice(players_in_room)

                if input_kwargs['target'].vitals['alive'] == False:

                    Lex.pub_print(
                        self=self,
                        target=input_kwargs['target'],
                        send_kwargs={
                            'type': 'text',
                            'spacing': 1
                        },
                        first_person="",
                        target_person=
                        f"{Lex.a_an(self.name).capitalize()} smirks at your dead body.",
                        third_person=
                        f"{Lex.a_an(self.name).capitalize()} smirks at {input_kwargs['target'].name}'s dead body."
                    )

                    self.conditions['state'] = "awake"
                    print(
                        f"NPC ASSESS | Entity: {self.name} changing state to: {self.conditions['state']}."
                    )

                else:
                    self.conditions['state'] = "engaged"
                    print(
                        f"NPC ASSESS | Entity: {self.name} changing state to: {self.conditions['state']}."
                    )
                    print("")

                    roll = Gen.random_number(2, 1, 6)
                    combat_choice = Gen.random_number(1, 1, 6)

                    Combat.attack(self, None, input_kwargs)
Exemple #5
0
    def stow_set(self, user_input, input_kwargs):

        stow_item = False

        if len(user_input) == 1 or len(user_input) > 3:
            WsWrap.ws_send(self.client, {
                'type': 'text',
                'spacing': 1
            }, "Syntax: STOW SET (container) or STOW (ITEM)")

        elif user_input[1] == "set":

            input_kwargs['target'] = Input_Handler.target_self_inventory(
                self, user_input[2], input_kwargs)
            self.stow_loc = input_kwargs['target']

            if self.stow_loc == None:
                WsWrap.ws_send(self.client, {
                    'type': 'text',
                    'spacing': 1
                }, "Make sure you are wearing the container.")
            else:
                WsWrap.ws_send(self.client, {
                    'type': 'text',
                    'spacing': 1
                }, "Ok.")

        elif user_input[1] != "set":

            if self.stow_loc == None:
                WsWrap.ws_send(
                    self.client, {
                        'type': 'text',
                        'spacing': 1
                    },
                    "You must first STOW SET (CONTAINER) for a container you are wearing."
                )

            elif self.stow_loc.location_body['state'] != "worn":
                WsWrap.ws_send(self.client, {
                    'type': 'text',
                    'spacing': 1
                }, "You must be wearing that container.")

            elif self.inventory['r_hand']['contents'] != None:
                if user_input[1] in self.inventory['r_hand']['contents'].name:
                    stow_item = True
                    input_kwargs['target'] = self.inventory['r_hand'][
                        'contents']
                    input_kwargs['target_parent'] = self.stow_loc

            elif self.inventory['l_hand']['contents'] != None:
                if user_input[1] in self.inventory['l_hand']['contents'].name:
                    stow_item = True
                    input_kwargs['target'] = self.inventory['l_hand'][
                        'contents']
                    input_kwargs['target_parent'] = self.stow_loc

            else:
                WsWrap.ws_send(self.client, {
                    'type': 'text',
                    'spacing': 1
                }, "You can't stow that.")

            if stow_item == True:
                status, response = Status_Check.item_open_closed(
                    self, user_input, input_kwargs)

                if status == True:
                    if self.stow_loc == input_kwargs['target']:
                        WsWrap.ws_send(self.client, {
                            'type': 'text',
                            'spacing': 1
                        }, "You can't stow something in itself.")
                    else:
                        Character.put_item(self, user_input, input_kwargs)
                else:
                    WsWrap.ws_send(self.client, {
                        'type': 'text',
                        'spacing': 1
                    }, "That is not open.")

        else:
            WsWrap.ws_send(self.client, {
                'type': 'text',
                'spacing': 1
            }, "Error with STOW target.")
Exemple #6
0
 def __init__ (self, val):
     Character.__init__(self, val)