def client_left(client, server): # client['obj'].conditions['schedule'] = { # 'event_names': all_schedules[client['obj'].uuid_id]['sched'].event_names, # 'event_types': all_schedules[client['obj'].uuid_id]['sched'].event_types # } # update_db_player(players[client['obj'].uuid_id]) send_kwargs = {'type': 'text', 'spacing': 1} Lex.pub_print( self=client['obj'], target=None, send_kwargs={'type': 'text', 'spacing': 1}, first_person = "", target_person = "", third_person = "{} just left.".format(client['obj'].name.capitalize())) logging.debug('%s %s', "LOG | Removing client:", client['obj']) logging.info("----------") print("LOG | Removing client:", client['obj'], "from room:", rooms[client['obj'].location].player_inv) players[client['obj'].uuid_id].player_state = "logged_out" rooms[client['obj'].location].player_inv.remove(client['obj']) # Update_Client.update_player_object(client['obj']) Update_Client.update_player_list(client['obj'])
def combat_flow(self, user_input, input_kwargs, combat_kwargs): # Debug --- print( f"COMBAT | FLOW | Entity: {self.name}, input_kwargs: {input_kwargs}, combat_kwargs: {combat_kwargs}" ) # Determine dmg output --- Combat.calc_dmg(self, user_input, input_kwargs, combat_kwargs) # Establish RT --- if self.entity_type['base'] == "player": self.round_time_set(combat_kwargs['round_time']) Update_Client.update_round_time(self) Lex.pub_print( self=self, target=None, send_kwargs={ 'type': 'text', 'spacing': 1 }, first_person= f"Round time, {combat_kwargs['round_time']} seconds...", target_person="", third_person="", ) # Check death --- self.check_death(user_input, input_kwargs)
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)
def hp_regen(self): if self.vitals['hp_current'] + self.vitals['hp_regen'] > self.vitals['hp_max']: self.vitals['hp_current'] = self.vitals['hp_max'] else: self.vitals['hp_current'] += self.vitals['hp_regen'] Update_Client.update_player_health(self)
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)
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)
def round_time_set(self, round_time): if self.conditions['round_time'] != 0: pass else: self.conditions['round_time'] = round_time self.conditions['init_round_time'] = round_time Update_Client.update_init_round_time(self) all_schedules[self.uuid_id]['sched'].eventabs( time.time() + 1, # event timer 1, # priority (1 = highest) "round_time_dec", # event name "round_time", # event type Character.round_time_dec, # action kwargs={"self": self}) # kwargs
def suit_shield_regen(self): if self.inventory['suit']['contents'].vitals['shield_current'] == 0: pass else: if self.inventory['suit']['contents'].vitals[ 'shield_current'] + self.inventory['suit'][ 'contents'].vitals[ 'shield_regen_current'] > self.inventory['suit'][ 'contents'].vitals['shield_max_current']: self.vitals['hp_current'] = self.vitals['hp_max'] else: self.inventory['suit']['contents'].vitals[ 'shield_current'] += self.inventory['suit'][ 'contents'].vitals['shield_regen_current'] Update_Client.update_suit_shield(self)
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)))
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)
def round_time_dec(self): if self.conditions['round_time'] < 1: # pass all_schedules[self.uuid_id]['sched'].remove_event_name("round_time_dec", "rt") else: self.conditions['round_time'] = self.conditions['round_time'] - 1 print("RT DEC | Reducing RT from", self.conditions['round_time'], "to", self.conditions['round_time'] - 1) all_schedules[self.uuid_id]['sched'].eventabs( time.time() + 1, # event timer 1, # priority (1 = highest) "round_time_dec", # event name "rt", # event type Character.round_time_dec, # action kwargs={"self": self}) # kwargs Update_Client.update_round_time(self)
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.")
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)
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)
def render_map(self, user): coord_dict = {} map_render = {} for each_room in rooms: if rooms[each_room].region == rooms[user.location].region: if rooms[each_room].zone == rooms[user.location].zone: coord_dict[(rooms[each_room].coordinates['x'], rooms[each_room].coordinates['y'])] = { "exits": rooms[each_room].exits, } # print(coord_dict) min_width = min(coord_dict, key=lambda t: t[0])[0] * 2 min_height = min(coord_dict, key=lambda t: t[1])[1] * 2 max_width = (max(coord_dict, key=lambda t: t[0])[0] + 1) * 2 max_height = (max(coord_dict, key=lambda t: t[1])[1] + 1) * 2 print(min_width, max_width, min_height, max_height) self_x = rooms[user.location].coordinates['x'] self_y = rooms[user.location].coordinates['y'] self_room = (rooms[user.location].coordinates['x'], rooms[user.location].coordinates['y']) # print(self_x, self_y, max_width, max_height) for y in range(self_y - (max_height // 2), self_y + (max_height // 2)): for x in range(self_x - (max_width // 2), self_x + (max_width // 2)): # print("Checking:", (x,y)) if (x, y) in coord_dict and x == rooms[ user.location].coordinates['x'] and y == rooms[ user.location].coordinates['y']: map_render[(x, y)] = {'symbol': '|y|[x]|yx|'} map_render[(x, y)]['exits'] = coord_dict[(x, y)]['exits'] elif (x, y) in coord_dict: map_render[(x, y)] = {'symbol': '[|black|x|blackx|]'} map_render[(x, y)]['exits'] = coord_dict[(x, y)]['exits'] else: map_render[(x, y)] = {'symbol': '|black|[x]|blackx|'} map_render[(x, y)]['exits'] = '' if "east" in map_render[(x, y)]["exits"]: map_render[( x, y)]['symbol'] = map_render[(x, y)]['symbol'] + '-' else: map_render[(x, y)]['symbol'] = map_render[ (x, y)]['symbol'] + '|black|-|blackx|' # if "south" in map_render[(x, y)]["exits"]: # map_render[(x,y)]['symbol'] = map_render[(x,y)]['symbol'] + '|br|-|-' # else: # map_render[(x,y)]['symbol'] = map_render[(x,y)]['symbol'] + '|br|?' if x + 1 == self_x + (max_width // 2): map_render[( x, y)]['symbol'] = map_render[(x, y)]['symbol'] + '|br|' # print("Coord Dict:", len(coord_dict)) # print("Final Render:", len(map_render)) the_map = [] for i in map_render: the_map.append(map_render[i]['symbol']) the_map = '{}'.format("".join(the_map)) Update_Client.update_map(user, the_map)
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'])
def calc_dmg(self, user_input, input_kwargs, combat_kwargs): # Establish attack die and attack modifier from ammo, these are defaults # or overridden if items are present weapon_base_dmg = 1 weapon_base_dmg_mod = 0 if self.inventory["r_hand"]["contents"]: weapon_base = combat_kwargs['attribute'] + "_base" weapon_mod_base = combat_kwargs['attribute'] + "_mod" # Override R hand weapon_base_dmg if weapon_base in self.inventory["r_hand"][ "contents"].static_stats: if self.inventory["r_hand"]["contents"].static_stats[ weapon_base]: weapon_base_dmg = self.inventory["r_hand"][ "contents"].static_stats[weapon_base] # Override R hand weapon_base_mod if weapon_mod_base in self.inventory["r_hand"][ "contents"].static_stats: if self.inventory["r_hand"]["contents"].item_inv != []: if self.inventory["r_hand"]["contents"].entity_type[ 'group'] == "gun": weapon_base_dmg_mod = items[ self.inventory["r_hand"]["contents"]. dynamic_stats['ammo_id']].static_stats[weapon_base] # Pull in attacker's appropriate attibute and create a base roll attrib_base = self.core_attributes[combat_kwargs['attribute']]['base'] base_roll = random.randint(1, 12) # Base Attack is simply the attack die multiplied by the base roll base_att = attrib_base + weapon_base_dmg + weapon_base_dmg_mod + base_roll final_dmg = base_att # apply damage if input_kwargs['target'].inventory['suit']['contents'] == None: # client printing options if self.entity_type['base'] == "player": send_kwargs = {'type': 'text', 'spacing': 0} # if AI is performing elif self.entity_type['base'] == "npc": send_kwargs = {'type': 'text', 'spacing': 1} input_kwargs['target'].vitals['hp_current'] = input_kwargs[ 'target'].vitals['hp_current'] - final_dmg if input_kwargs['target'].entity_type['base'] == 'player': Update_Client.update_player_health(input_kwargs['target']) Lex.pub_print( self=self, target=input_kwargs['target'], send_kwargs={ 'type': 'text', 'spacing': 0 }, first_person="AB: {} + WBD: {} + WBDM: {} + BR: {} = {}". format(attrib_base, weapon_base_dmg, weapon_base_dmg_mod, base_roll, base_att), target_person="AB: {} + WBD: {} + WBDM: {} + BR: {} = {}". format(attrib_base, weapon_base_dmg, weapon_base_dmg_mod, base_roll, base_att), third_person="", ) Lex.pub_print( self=self, target=input_kwargs['target'], send_kwargs=send_kwargs, first_person="You hit for {} damage!".format(final_dmg), target_person="|alert| You take {} damage! |alertx|".format( final_dmg), third_person="{} takes the force of the blow.".format( input_kwargs['target'].name), ) else: if input_kwargs['target'].entity_type['base'] == 'player': if input_kwargs['target'].inventory['suit']['contents'].vitals[ 'shield_current'] > 0: if input_kwargs['target'].inventory['suit'][ 'contents'].vitals['shield_current'] < final_dmg: input_kwargs['target'].inventory['suit'][ 'contents'].vitals['shield_current'] = 0 else: input_kwargs['target'].inventory['suit'][ 'contents'].vitals['shield_current'] = input_kwargs[ 'target'].inventory['suit']['contents'].vitals[ 'shield_current'] - final_dmg Lex.pub_print( self=self, target=input_kwargs['target'], send_kwargs={ 'type': 'text', 'spacing': 1 }, first_person= "You see its shield glimmer as you hit for {} damage!". format(final_dmg), target_person= '|self_suit| "Shields absorb {} damage, {}% integrity." |self_suitx|' .format( final_dmg, input_kwargs['target'].inventory['suit'] ['contents'].vitals['shield_current']), third_person= "{}'s suit glimmers as it absorbs the damage.".format( input_kwargs['target'].name), ) else: input_kwargs['target'].vitals['hp_current'] = input_kwargs[ 'target'].vitals['hp_current'] - final_dmg Update_Client.update_player_health(input_kwargs['target']) Lex.pub_print( self=self, target=input_kwargs['target'], send_kwargs={ 'type': 'text', 'spacing': 1 }, first_person="Shields are down! You hit for {} damage!" .format(final_dmg), target_person= '|alert| "Your suit\'s shield is broken and your body takes {} damage!" |alertx|' .format(final_dmg), third_person="", ) return attrib_base, base_roll, final_dmg
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)))