Esempio n. 1
0
    def enter_door(self, user_input, input_kwargs):

        print(input_kwargs)
        if input_kwargs['target'] == None:
            WsWrap.ws_send(self.client, {'type': 'text', 'spacing': 1}, "Usage: go <door>. For navigation, just use n, s, o, up, down, etc.")
        else:

            if not "is_door" in input_kwargs['target'].attributes:
                Lex.pub_print(
                    self=self,
                    target=input_kwargs['target'],
                    send_kwargs={'type': 'text', 'spacing': 1},
                    first_person = "You walk towards {}.".format(Lex.a_an(input_kwargs['target'].name)),
                    target_person = "",
                    third_person = "{} walks towards {}.".format(self.name.capitalize(), Lex.a_an(input_kwargs['target'].name)))

            elif input_kwargs['target'].is_open == False:
                WsWrap.ws_send(self.client, {'type': 'text', 'spacing': 1}, "That is closed.")
            
            else:

                Lex.pub_print(
                    self=self,
                    target=input_kwargs['target'],
                    send_kwargs={'type': 'text', 'spacing': 1},
                    first_person = "You enter {}.".format(Lex.a_an(input_kwargs['target'].name)),
                    target_person = "",
                    third_person = "{} enters {}.".format(self.name.capitalize(), Lex.a_an(input_kwargs['target'].name)))

                print(input_kwargs['target'])
                if rooms[input_kwargs['target'].room_target['target']].entity_type['group'] == "holodeck":

                    Holodeck.enter_holo(self, user_input, input_kwargs)

                else:

                    rooms[self.location].player_inv.remove(self)
                    print(self.location)
                    self.location = input_kwargs['target'].room_target['target']
                    print(self.location)
                    rooms[self.location].player_inv.append(self)
                    rooms[self.location].display_room(self)

                    Lex.pub_print(
                        self=self,
                        target=None,
                        send_kwargs={'type': 'text', 'spacing': 1},
                        first_person = "",
                        target_person = "",
                        third_person = "{} just arrived.".format(self.name.capitalize()))

        rooms[self.location].render_map(self)
Esempio n. 2
0
    def animation_load(self, user, user_input, input_kwargs):
        print(user.inventory)

        first_person = "You side-load {} into your {} and it immediately spins up, humming with energy.".format(
            Lex.a_an(user.inventory['l_hand']['contents'].name),
            user.inventory['r_hand']['contents'].name)
        target_person = ""
        third_person = "{} side-loads {} into {} {}.".format(
            user.name, Lex.a_an(user.inventory['l_hand']['contents'].name),
            Lex.gender(user, "own"),
            Lex.a_an(user.inventory['r_hand']['contents'].name))

        return first_person, target_person, third_person
Esempio n. 3
0
    def search_target(self, user_input, input_kwargs):

        inv_dropped = []
        
        for i in input_kwargs['target'].inventory:

            inv_item = input_kwargs['target'].inventory[i]['contents']

            if input_kwargs['target'].inventory[i]['contents'] == None:
                pass
            else:
                inv_dropped.append(input_kwargs['target'].inventory[i]['contents'].name)
                inv_item.location = self.location
                input_kwargs['target'].inventory[i]['contents'] = None
                rooms[self.location].item_inv.append(inv_item)

        if inv_dropped == []:

            Lex.pub_print(
            self=self,
            target=None,
            send_kwargs={'type': 'text', 'spacing': 0},
            first_person = "You pat down {} but it had nothing of value.".format(Lex.a_an(input_kwargs['target'].name), ", ".join(inv_dropped)),
            target_person = "",
            third_person = "{} searches {}.".format(self.name.capitalize(), Lex.a_an(input_kwargs['target'].name)))

        else:

            Lex.pub_print(
                self=self,
                target=None,
                send_kwargs={'type': 'text', 'spacing': 0},
                first_person = "You pat down {} and find {}.".format(Lex.a_an(input_kwargs['target'].name), ", ".join(inv_dropped)),
                target_person = "",
                third_person = "{} searches {}.".format(self.name.capitalize(), Lex.a_an(input_kwargs['target'].name)))

        Lex.pub_print(
            self=self,
            target=None,
            send_kwargs={'type': 'text', 'spacing': 1},
            first_person = "The {} decays away.".format(input_kwargs['target'].name),
            target_person = "",
            third_person = "The {} decays away.".format(input_kwargs['target'].name))

        del all_schedules[input_kwargs['target'].uuid_id]
        rooms[self.location].npc_inv.remove(input_kwargs['target'])
Esempio n. 4
0
    def put_item(self, user_input, input_kwargs):

        if self.inventory['r_hand']['contents'] == input_kwargs['target']:
            hand = self.inventory['r_hand']

        elif self.inventory['l_hand']['contents'] == input_kwargs['target']:
            hand = self.inventory['l_hand']

        input_kwargs['target_parent'].item_inv.append(hand['contents'])
        hand['contents'] = None

        Update_Client.update_player_inventory(self)

        Lex.pub_print(
                self=self,
                target=None,
                send_kwargs={'type': 'text', 'spacing': 1},
                first_person = "You put {} in {}.".format(Lex.a_an(input_kwargs['target'].name), Lex.a_an(input_kwargs['target_parent'].name)),
                target_person = "",
                third_person = "{} puts {} in {}.".format(self.name.capitalize(), Lex.a_an(input_kwargs['target'].name), Lex.a_an(input_kwargs['target_parent'].name)))
Esempio n. 5
0
    def drop_item(self, user_input, input_kwargs):

        if self.inventory['r_hand']['contents'] == input_kwargs['target']:
            self.inventory['r_hand']['contents'] = None
            input_kwargs['target'].location = self.location
            input_kwargs['target'].location_body['location'] = None
            rooms[self.location].item_inv.append(input_kwargs['target'])

            print("[LOG]: Dropped item:", self.inventory['r_hand']['contents'])

            Lex.pub_print(
                self=self,
                target=input_kwargs['target'],
                send_kwargs={'type': 'text', 'spacing': 1},
                first_person = "You drop {}.".format(Lex.a_an(input_kwargs['target'].name)),
                target_person = "",
                third_person = "{} drops {}.".format(self.name.capitalize(), Lex.a_an(input_kwargs['target'].name)))

            Update_Client.update_player_inventory(self)

        elif self.inventory['l_hand']['contents'] == input_kwargs['target']:
            self.inventory['l_hand']['contents'] = None
            input_kwargs['target'].location = self.location
            input_kwargs['target'].location_body['location'] = None
            rooms[self.location].item_inv.append(input_kwargs['target'])

            print("[LOG]: Dropped item:", self.inventory['l_hand']['contents'])

            Lex.pub_print(
                self=self,
                target=input_kwargs['target'],
                send_kwargs={'type': 'text', 'spacing': 1},
                first_person = "You drop {}.".format(Lex.a_an(input_kwargs['target'].name)),
                target_person = "",
                third_person = "{} drops {}.".format(self.name.capitalize(), Lex.a_an(input_kwargs['target'].name)))

            Update_Client.update_player_inventory(self)

        else:
            WsWrap.ws_send(self.client, {'type': 'text', 'spacing': 1}, "You don't have that.")
Esempio n. 6
0
    def entity_description(self, user, user_input, input_kwargs):

        if self.vitals['alive'] == True:

            first_person_value = "{}".format(self.description['desc'])
            target_person_value = ""
            third_person_value = "{} observes {}.".format(self.description['name'], Lex.a_an(self.description['name']))

        else:

            first_person_value = "{} is dead. {}".format(Lex.gender(self.description['name'], "pro").capitalize(), self.description['desc']),               
            target_person_value = "{} observes your dead body.".format(self.description['name'])
            third_person_value = "{} observes {}.".format(self.description['name'], Lex.a_an(self.description['name']))

        Lex.pub_print(
            self=user,
            target=input_kwargs['target'],
            send_kwargs={'type': 'text', 'spacing': 1},
            first_person = first_person_value,
            target_person = target_person_value,
            third_person = third_person_value,
            )
Esempio n. 7
0
    def docking(self, user_input, input_kwargs, destination):

        ship_id = rooms[self.location].ship_id

        print("Ship_ID:", ship_id)
        print("Ship was in room:", items[ship_id].location)

        items[ship_id].location = destination
        rooms[destination].item_inv.append(items[ship_id])

        all_schedules[self.uuid_id]['sched'].eventabs(
            time.time() + 1,
            1,
            "ship_ai",
            "print",
            Lex.pub_print,
            kwargs={
                'self':
                self,
                'target':
                input_kwargs['target'],
                'first_person':
                'The ship safely completes its docking. Outside, you see {}. {}'
                .format(
                    Lex.a_an(rooms[items[ship_id].location].name).lower(),
                    rooms[items[ship_id].location].description),
                'target_person':
                '',
                'third_person':
                'The ship safely completes its docking. Outside, you see {}. {}'
                .format(
                    Lex.a_an(rooms[items[ship_id].location].name).lower(),
                    rooms[items[ship_id].location].description)
            })

        print("Ship now in room:", destination)
        print("Inv of this room:", rooms[destination].item_inv)
Esempio n. 8
0
    def attack(self, user_input, input_kwargs):

        # Combat flow parameters ---

        combat_kwargs = {
            "round_time": 5,
            "combat_action": "attack",
            "attribute": "str"
        }

        # input_kwargs['round_time'] = round_time

        # input_kwargs["combat_action"] = "attack"

        # if player is performing
        if self.entity_type['base'] == "player":
            ent_label = "player"
            ent_name = self.name.capitalize()
            send_kwargs = {'type': 'text', 'spacing': 0}

        # if AI is performing
        elif self.entity_type['base'] == "npc":
            send_kwargs = {'type': 'text', 'spacing': 0}
            ent_label = "npc"
            ent_name = Lex.a_an(self.name).capitalize()

        # catch other errors
        else:
            ent_label = ""
            ent_name = "|error: no ent name|"

        # ---

        # LOG for reviewing attacks
        if self.entity_type['base'] == "npc":
            print("COMBAT | AI | CMD: ATTACK |", self.name, "attacking",
                  input_kwargs['target'].name)
        else:
            print("COMBAT | PLAYER | CMD: ATTACK |", self.name, "attacking",
                  input_kwargs['target'].name)

        # Determine if unarmed or armed attack and set nouns for rest of function
        if self.inventory["r_hand"]["contents"]:
            weapon = self.inventory["r_hand"]["contents"].name
        else:
            weapon = "fist"

        if self.inventory["r_hand"]['contents'] == None:
            Lex.pub_print(
                self=self,
                target=input_kwargs['target'],
                send_kwargs=send_kwargs,
                first_person="|self_text| You swing a fist at {}! |self_textx|"
                .format(Lex.a_an(input_kwargs['target'].name)),
                target_person="{} swings a fist at you!".format(
                    Lex.a_an(self.name).capitalize()),
                third_person="{} swings a fist at {}!".format(
                    ent_name, Lex.a_an(input_kwargs['target'].name)))

        else:
            Lex.pub_print(
                self=self,
                target=input_kwargs['target'],
                send_kwargs=send_kwargs,
                first_person="|self_text| You swing {} at {}! |self_textx|".
                format(Lex.a_an(weapon),
                       Lex.a_an(input_kwargs['target'].name)),
                target_person="{} swings {} at you!".format(
                    ent_name, Lex.a_an(weapon)),
                third_person="{} swings {} at {}!".format(
                    ent_name, Lex.a_an(weapon),
                    Lex.a_an(input_kwargs['target'].name)))

        # Run post-attack combat flow
        Combat.combat_flow(self, user_input, input_kwargs, combat_kwargs)
Esempio n. 9
0
    def fire_gun(self, user_input, input_kwargs):

        # Combat flow parameters ---

        combat_kwargs = {
            "round_time": 5,
            "combat_action": "fire_gun",
            "attribute": "dex"
        }

        # ---

        mag = items[self.inventory["r_hand"]
                    ["contents"].dynamic_stats['ammo_id']]
        mag.dynamic_stats['current_capacity'] -= 1

        Lex.pub_print(
            self=self,
            target=None,
            send_kwargs={
                'type': 'text',
                'spacing': 0
            },
            first_person="|self_speech| You fire your {} at {}! |self_speechx|"
            .format(self.inventory["r_hand"]["contents"].name,
                    Lex.a_an(input_kwargs['target'].name)),
            target_person="",
            third_person="{} fires {} {} at {}!".format(
                self.name, Lex.gender(self, "own"),
                self.inventory["r_hand"]["contents"].name,
                Lex.a_an(input_kwargs['target'].name)))

        # Run post-attack combat flow
        Combat.combat_flow(self, user_input, input_kwargs, combat_kwargs)

        if mag.dynamic_stats['current_capacity'] < 1:

            self.inventory["r_hand"]["contents"].dynamic_stats[
                'loaded'] = False
            self.inventory["r_hand"]["contents"].dynamic_stats[
                'ammo_id'] = None
            self.inventory["r_hand"]["contents"].item_inv.remove(
                items[mag.uuid_id])
            del items[mag.uuid_id]

            Lex.pub_print(
                self=self,
                target=None,
                send_kwargs={
                    'type': 'text',
                    'spacing': 1
                },
                first_person=
                "|alert|You're dry!|alertx| You release the empty {} and it casually falls to the ground out of sight."
                .format(mag.name),
                target_person="",
                third_person=
                "{} releases a spent magazine from {} {} and it falls aside.".
                format(self.name, Lex.gender(self, "own"),
                       self.inventory["r_hand"]["contents"].name))
        else:
            pass
Esempio n. 10
0
    def navigate(self, user_input, name):

        name = name

        travel_verb_first = "travel"
        travel_verb_third = "travels"

        if name in rooms[self.location].exits:
            exit_room = rooms[self.location].exits[name]

            if self.entity_type['base'] == "npc":
                rooms[self.location].npc_inv.remove(self)
                self.location = exit_room
                rooms[self.location].npc_inv.append(self)

                print("AI |", self.name, "moving rooms.")

                if self.entity_type['group'] != "human":
                    Lex.pub_print(
                        self=self,
                        target=None,
                        send_kwargs={'type': 'text', 'spacing': 1},
                        first_person = "",
                        target_person = "",
                        third_person = "|alert|{} just arrived.|alertx|".format(Lex.a_an(self.name).capitalize()))

                else:
                    Lex.pub_print(
                        self=self,
                        target=None,
                        send_kwargs={'type': 'text', 'spacing': 1},
                        first_person = "",
                        target_person = "",
                        third_person = "|alert|{} just arrived.|alertx|".format(self.name.capitalize()))

            else:
                rooms[self.location].player_inv.remove(self)

                Lex.pub_print(
                    self=self,
                    target=None,
                    send_kwargs={'type': 'text', 'spacing': 1},
                    first_person = "You {} {}.".format(travel_verb_first, name),
                    target_person = "",
                    third_person = "{} {} {} {}.".format(self.core_attributes['title'], self.name.capitalize(), travel_verb_third, name))

                self.location = exit_room
                rooms[self.location].player_inv.append(self)
                rooms[self.location].display_room(self)

                Lex.pub_print(
                    self=self,
                    target=None,
                    send_kwargs={'type': 'text', 'spacing': 1},
                    first_person = "",
                    target_person = "",
                    third_person = "{} {} just arrived.".format(self.core_attributes['title'], self.name.capitalize()))
            

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

        rooms[self.location].render_map(self)
Esempio n. 11
0
    def get_item(self, user_input, input_kwargs):

        all_ok = False
        obj_generator = False

        if input_kwargs['target'] in Gen.items_in_room(self):

            print(input_kwargs['target'], input_kwargs['target'].attributes)

            if "obj_generator" in input_kwargs['target'].attributes:
                print("obj_gen")
            else:
                rooms[input_kwargs['target'].location].item_inv.remove(input_kwargs['target'])

            all_ok = True

        elif input_kwargs['target_parent'] is not None:

            container = items[input_kwargs['target_parent'].uuid_id]
            items[input_kwargs['target_parent'].uuid_id].item_inv.remove(input_kwargs['target'])

            all_ok = True

        elif input_kwargs['target'] == self.inventory['r_hand']['contents'] or input_kwargs['target'] == self.inventory['l_hand']['contents']:
            WsWrap.ws_send(self.client, {'type': 'text', 'spacing': 1}, "You already have that.")

        if all_ok == True:

            if self.inventory['r_hand']['contents'] == None:
                hand = self.inventory['r_hand']
                input_kwargs['target'].location = self.uuid_id
                input_kwargs['target'].location_body['location'] = "r_hand"
                self.inventory['r_hand']['contents'] = input_kwargs['target']
                Update_Client.update_player_inventory(self)

            elif self.inventory['l_hand']['contents'] == None:
                hand = self.inventory['l_hand']
                input_kwargs['target'].location = self.uuid_id
                input_kwargs['target'].location_body['location'] = "l_hand"
                self.inventory['l_hand']['contents'] = input_kwargs['target']
                Update_Client.update_player_inventory(self)

        if input_kwargs['target_parent'] is not None:

            Lex.pub_print(
                self=self,
                target=input_kwargs['target'],
                send_kwargs={'type': 'text', 'spacing': 1},
                first_person = "You pull {} out from inside of {}.".format(Lex.a_an(input_kwargs['target'].name), Lex.a_an(container.name)),
                target_person = "",
                third_person = "{} pulls {} from inside of {}.".format(self.name, Lex.a_an(input_kwargs['target'].name), Lex.a_an(container.name)))

        else:

            Lex.pub_print(
                self=self,
                target=None,
                send_kwargs={'type': 'text', 'spacing': 1},
                first_person = "You pickup {} in your {}.".format(Lex.a_an(input_kwargs['target'].name), hand['name']),
                target_person = "",
                third_person = "{} picks up {}.".format(self.name.capitalize(), Lex.a_an(input_kwargs['target'].name)))
Esempio n. 12
0
    def check_death(self, user_input, input_kwargs):

        if input_kwargs['target'].vitals['hp_current'] <= 0:

            if input_kwargs['target'].entity_type['base'] == "npc":

                Lex.pub_print(
                    self=self,
                    target=None,
                    send_kwargs={'type': 'text', 'spacing': 1},
                    first_person = "|npc|{} crumples into a heap and dies.|npcx|".format(Lex.a_an(input_kwargs['target'].name).capitalize()),
                    target_person = "",
                    third_person = "|npc|{} crumples into a heap and dies.|npcx|".format(Lex.a_an(input_kwargs['target'].name).capitalize()))
            
                input_kwargs['target'].conditions['stance'] = "lying"
                input_kwargs['target'].conditions['state'] = "sleep"
                input_kwargs['target'].vitals['alive'] = False
                
                # clear the event schedule
                ent_sched = all_schedules[input_kwargs['target'].uuid_id]['sched']
                list(map(ent_sched.cancel, ent_sched.queue))

            elif input_kwargs['target'].entity_type['base'] == "player":
            
                input_kwargs['target'].conditions['stance'] = "lying"
                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 = "|alert|You crumple into a heap and die.|alertx|",
                    third_person = "{} crumples into a heap and dies.".format(input_kwargs['target'].name).capitalize())