예제 #1
0
    def open_close(self, user_input, input_kwargs):

        if user_input[0] == "open":
            input_kwargs['target'].is_open = True

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

        elif user_input[0] == "close":
            input_kwargs['target'].is_open = False

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

        Update_Client.update_player_inventory(self)
예제 #2
0
    def ammo_unload(self, user_input, input_kwargs):

        if self.inventory['r_hand']['contents'] != input_kwargs['target']:
            WsWrap.ws_send(self.client, {
                'type': 'text',
                'spacing': 1
            }, "That must be in your right hand.")
        else:

            if "is_gun" not in self.inventory['r_hand']['contents'].attributes:
                WsWrap.ws_send(self.client, {
                    'type': 'text',
                    'spacing': 1
                }, "You can't unload that.")
            else:

                if self.inventory['r_hand']['contents'].item_inv == []:
                    WsWrap.ws_send(self.client, {
                        'type': 'text',
                        'spacing': 1
                    }, "It's empty.")
                else:

                    if self.inventory['l_hand']['contents'] != None:
                        WsWrap.ws_send(self.client, {
                            'type': 'text',
                            'spacing': 1
                        }, "You need an empty left hand.")
                    else:

                        clip = items[self.inventory['r_hand']
                                     ['contents'].dynamic_stats['ammo_id']]

                        self.inventory['r_hand']['contents'].dynamic_stats[
                            'loaded'] = False
                        self.inventory['r_hand']['contents'].dynamic_stats[
                            'ammo_id'] = None
                        self.inventory['l_hand']['contents'] = clip
                        self.inventory['r_hand']['contents'].item_inv.remove(
                            clip)

                        Lex.pub_print(
                            self=self,
                            target=input_kwargs['target'],
                            send_kwargs={
                                'type': 'text',
                                'spacing': 1
                            },
                            first_person=
                            "The magazine slides out into your left hand.",
                            target_person="{} unloads {} {}.".format(
                                self.name, Lex.gender(self, "own"),
                                self.inventory['r_hand']['contents'].name),
                            third_person="{} unloads {} {}.".format(
                                self.name, Lex.gender(self, "own"),
                                self.inventory['r_hand']['contents'].name))

        Update_Client.update_player_inventory(self)
예제 #3
0
    def swap_hands(self, user_input, input_kwargs):
        right_hand = self.inventory['r_hand']['contents']
        left_hand = self.inventory['l_hand']['contents']
    
        self.inventory['r_hand']['contents'] = left_hand
        self.inventory['l_hand']['contents'] = right_hand

        Lex.pub_print(
            self=self,
            target=None,
            send_kwargs={'type': 'text', 'spacing': 1},
            first_person = "You swap the items in your hands.",
            target_person = "",
            third_person = "{} swaps the items in {} hands.".format(self.name.capitalize(), Lex.gender(self, "own")))

        Update_Client.update_player_inventory(self)
예제 #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)))
예제 #5
0
    def wear_item(self, user_input, input_kwargs):

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

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

        self.inventory[contents.worn]['contents'] = contents
        self.inventory[contents.worn]['contents'].location = self.uuid_id
        self.inventory[contents.worn]['contents'].location_body['state'] = "worn"
        self.inventory[contents.worn]['contents'].location_body['location'] = contents.worn
        hand['contents'] = None

        Item_Animations.wear_animation(self, user_input, input_kwargs)
        Update_Client.update_player_inventory(self)

        if input_kwargs['target'].entity_type['group'] == 'armor':
            Update_Client.update_suit_shield(self)
예제 #6
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.")
예제 #7
0
    def remove_item(self, user_input, input_kwargs):

        print(self.inventory['suit'])
        for inv in self.inventory:
            if input_kwargs['target'] == self.inventory[inv]['contents']:
                if not self.inventory['r_hand']['contents']:
                    self.inventory['r_hand']['contents'] = input_kwargs['target']
                    self.inventory[inv]['contents'] = None
                    input_kwargs['target'].location_body['state'] = "not_worn"
                    break

                elif not self.inventory['l_hand']['contents']:
                    self.inventory['l_hand']['contents'] = input_kwargs['target']
                    self.inventory[inv]['contents'] = None
                    input_kwargs['target'].location_body['state'] = "not_worn"
                    break
            
        print(self.inventory['suit'])

        Item_Animations.remove_animation(self, user_input, input_kwargs)
        Update_Client.update_player_inventory(self)

        if input_kwargs['target'].entity_type['group'] == 'armor':
            Update_Client.update_suit_shield(self)
예제 #8
0
def check_user(client, server, message):

    # print(message)

    send_kwargs = {'type': 'text', 'spacing': 1}

    if "username" in message:

        user_info = json.loads(message.lower())
        client['uuid_id'] = user_info['username']
        # print("LOG | CHECK USER MSG |", user_info)

    login = check_login(client['uuid_id'])

    if login == False:

        if client['type'] == "guest":

            print(client['guest_progress'])

            if client['guest_progress'] == 'name_input':

                WsWrap.ws_send(
                    client, send_kwargs,
                    "|comp|Welcome! Three questions and you're in the game.|/comp|"
                )
                WsWrap.ws_send(client, send_kwargs,
                               "|w|1. What is your first name?|/w|")
                client['guest_progress'] = 'name_confirm'

            elif client['guest_progress'] == 'name_confirm':

                client['name'] = re.sub("[^a-zA-Z]+", "", message)
                for i in players:

                    if message.capitalize() == i.capitalize():
                        WsWrap.ws_send(
                            client, send_kwargs,
                            '|w| {} is taken. Please choose another. |/w|'.
                            format(client['name'].capitalize()))
                        break

                else:

                    WsWrap.ws_send(
                        client, send_kwargs,
                        '|w|2. {}, is this correct? (y/n)|/w|'.format(
                            client['name'].capitalize()))
                    client['guest_progress'] = 'name_confirm2'

            elif client['guest_progress'] == 'name_confirm2':

                if message == "no" or message == "n":
                    WsWrap.ws_send(
                        client, send_kwargs,
                        "|w|Alright, let's try this again. What is your first name?|/w|"
                    )
                    client['guest_progress'] = 'name_confirm'
                elif message == "yes" or message == "y":
                    WsWrap.ws_send(
                        client, send_kwargs,
                        '|w|3. Great. Are you (m)ale or (f)emale?|/w|')
                    client['guest_progress'] = 'gender_input'

            elif client['guest_progress'] == 'gender_input':

                if message == "male" or message == "m":
                    gender = "male"

                elif message == "female" or message == "f":
                    gender = "female"

                if message != "female" and message != "f" and message != "male" and message != "m":

                    WsWrap.ws_send(client, send_kwargs,
                                   '|w|Please choose (m)ale or (f)emale.|/w|')
                else:

                    WsWrap.ws_send(
                        client, send_kwargs,
                        '|comp|Please stand by. Creating your character...|/comp|'
                    )

                    client['type'] = 'member_authenticated'
                    client['reg'] == "online"

                    inventory = copy.deepcopy(inv)
                    print("Guest:", client)

                    hero = Player(
                        **{
                            "uuid_id": client['uuid_id'],
                            "entity_type": {
                                "base": "player",
                                "group": "registered",
                                "model": None,
                                "sub_model": None
                            },
                            "name": client['name'],
                            "race": "human",
                            "gender": gender,
                            "vitals": {
                                "hp_max": 100,
                                "hp_current": 100,
                                "hp_mod": 0,
                                "hp_regen": 1,
                                "hp_regen_mod": 0,
                                "alive": True
                            },
                            "core_attributes": {
                                "title": "Ensign",
                                "str": {
                                    "base": 8,
                                    "mod": 0
                                },
                                "dex": {
                                    "base": 10,
                                    "mod": 0
                                },
                                "con": {
                                    "base": 8,
                                    "mod": 0
                                },
                                "ins": {
                                    "base": 12,
                                    "mod": 0
                                },
                                "edu": {
                                    "base": 10,
                                    "mod": 0
                                },
                                "soc": {
                                    "base": 10,
                                    "mod": 0
                                },
                                "xp": {
                                    "current": 0,
                                    "buffer": 0,
                                    "absorp_rate_percent": 1
                                }
                            },
                            "conditions": {
                                "stance": "stand",
                                "action": "None",
                                "state": "awake",
                                "round_time": 0,
                                "help": "enabled",
                                "echo": False
                            },
                            "credit": {
                                "credit": 100
                            },
                            "location": "65d56cbe-f276-4055-899c-3244c0c92003",
                            "player_state": "logged_in",
                            "stow_loc": None,
                            "client": client,
                            "unique_id": None
                        })

                    update_user_player(hero)

                    add_new_player_to_db(hero)

                    client['obj'] = hero

                    # for i in all_schedules:
                    #   print(i)

                    Sched_Child.create_new_sched(client['obj'])

                    # update the client
                    client['type'] == 'member_authenticated'

                    # update the player object in the player list
                    players[hero.uuid_id] = hero
                    players[client['obj'].uuid_id].player_state = "online"

                    WsWrap.ws_send_to_all(
                        send_kwargs,
                        "** A new player, {}, just joined the server.".format(
                            hero.name))
                    WsWrap.ws_send(
                        hero.client, send_kwargs,
                        "|comp| Welcome, {}. We've been awaiting your arrival. |compx|"
                        .format(hero.name.capitalize()))

                    WsWrap.ws_send(
                        hero.client, {
                            'type': 'text',
                            'spacing': 0
                        },
                        '|success| For your convenience, help cues are currently {}. Help cues will provide additional context or syntax when you type a command. Some commands may not have help associated with them yet. We are working on this. |successx|'
                        .format(client['obj'].conditions['help'].upper()))
                    WsWrap.ws_send(
                        hero.client, {
                            'type': 'text',
                            'spacing': 1
                        },
                        '|success| Type HELP ON or HELP OFF to toggle this feature. |successx|'
                    )

                    rooms[hero.location].player_inv.append(client['obj'])
                    rooms[hero.location].display_room(hero)

                    # update player settings to the client
                    Update_Client.update_char_info(client['obj'])
                    Update_Client.update_user_settings(client['obj'])
                    Update_Client.update_player_health(client['obj'])
                    Update_Client.update_player_attributes(client['obj'])
                    Update_Client.update_player_list(client['obj'])
                    Update_Client.update_player_inventory(client['obj'])
                    Update_Client.update_central_db(client['obj'])

    else:

        # login = check_login(client['uuid_id'])

        inventory = copy.deepcopy(inv)

        hero = players[login]
        hero.inventory = inventory

        client['obj'] = hero
        client['type'] = "member_authenticated"
        players[client['obj'].uuid_id].player_state = "online"

        rooms[hero.location].player_inv.append(client['obj'])

        print("New Client Connected:", client, client['obj'])
        print("")
        client['id'] = client['obj'].unique_id
        print("Updated Client:", client, client['obj'])
        print("")

        if hero.uuid_id in all_schedules:
            pass
        else:
            Sched_Child.create_new_sched(client['obj'])

        for u in items:
            if items[u].location == client['obj'].uuid_id:
                if "location" in items[u].location_body:
                    # print("LOG: Re-adding item", items[u].name, "to", items[u].location_body['location'])
                    hero.inventory[items[u].location_body['location']][
                        'contents'] = items[u]

        # # check round_time
        # if hero.conditions['round_time'] > 0:
        #   if 'round_time' in all_schedules[hero.uuid_id]['sched'].event_names:
        #     hero.round_time_dec()

        # update the player object in the player list

        client['obj'].client = client

        Lex.pub_print(
            self=client['obj'],
            target=None,
            send_kwargs={
                'type': 'text',
                'spacing': 1
            },
            first_person=
            "|comp| Welcome back, {}. We've been awaiting your arrival. |compx|"
            .format(hero.name.capitalize()),
            target_person="",
            third_person="{} just arrived.".format(
                client['obj'].name.capitalize()))

        WsWrap.ws_send(
            hero.client, {
                'type': 'text',
                'spacing': 0
            },
            '|success| For your convenience, help cues are currently |successx| |y| {}|yx|. |success| Help cues will provide additional context or syntax when you type a command. Some commands may not have help associated with them yet. We are working on this. |successx|'
            .format(client['obj'].conditions['help'].upper()))
        WsWrap.ws_send(
            hero.client, {
                'type': 'text',
                'spacing': 1
            },
            '|success| Type HELP ON or HELP OFF to toggle this feature. |successx|'
        )

        WsWrap.ws_send(
            hero.client, {
                'type': 'text',
                'spacing': 1
            },
            '|success| You may also toggle the input echo on/off by typing "echo". Default is off. |successx|'
        )

        rooms[client['obj'].location].display_room(client['obj'])

        # update player settings to the client
        Update_Client.update_char_info(client['obj'])
        Update_Client.update_user_settings(client['obj'])
        Update_Client.update_player_health(client['obj'])
        Update_Client.update_suit_shield(client['obj'])
        Update_Client.update_player_attributes(client['obj'])
        Update_Client.update_player_list(client['obj'])
        Update_Client.update_player_inventory(client['obj'])
        Update_Client.update_central_db(client['obj'])
예제 #9
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)))
예제 #10
0
    def ammo_load(self, user_input, input_kwargs):

        if self.inventory['r_hand']['contents'] != input_kwargs['target']:
            WsWrap.ws_send(self.client, {
                'type': 'text',
                'spacing': 1
            }, "That must be in your right hand.")
        else:

            if "is_gun" not in input_kwargs['target'].attributes:
                WsWrap.ws_send(self.client, {
                    'type': 'text',
                    'spacing': 1
                }, "That can't be loaded.")
            else:

                if self.inventory['l_hand']['contents'] == None:
                    WsWrap.ws_send(self.client, {
                        'type': 'text',
                        'spacing': 1
                    }, "You need ammo in your left hand.")
                else:

                    s_type = self.inventory['r_hand']['contents'].entity_type[
                        'model']
                    s_mod = self.inventory['r_hand']['contents'].entity_type[
                        'sub_model']
                    c_with = self.inventory['l_hand']['contents'].combines_with
                    logging.debug('%s %s %s', ":", s_mod, c_with)
                    logging.debug('%s %s', ":", "-----------")

                    if s_mod not in c_with:
                        WsWrap.ws_send(self.client, {
                            'type': 'text',
                            'spacing': 1
                        }, "This is the wrong ammo type.")
                    else:

                        # gun loading animation

                        animate_first, animate_target, animate_third = self.inventory[
                            "r_hand"]["contents"].animation_load(
                                self, user_input, input_kwargs)

                        Lex.pub_print(self=self,
                                      target=None,
                                      send_kwargs={
                                          'type': 'text',
                                          'spacing': 1
                                      },
                                      first_person=animate_first,
                                      target_person=animate_target,
                                      third_person=animate_third)

                        # end animation

                        self.inventory["r_hand"]["contents"].dynamic_stats[
                            'loaded'] = True
                        self.inventory["r_hand"]["contents"].dynamic_stats[
                            'ammo_id'] = self.inventory['l_hand'][
                                'contents'].uuid_id
                        self.inventory['r_hand']['contents'].item_inv.append(
                            self.inventory['l_hand']['contents'])
                        self.inventory['l_hand'][
                            'contents'].location = self.inventory['r_hand'][
                                'contents'].uuid_id
                        self.inventory['l_hand']['contents'] = None

        Update_Client.update_player_inventory(self)