richwhilecooper

New player class and how I'm using it so far in my adventure

Nov 26th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.43 KB | None | 0 0
  1. ###Player Class NEW PLAYER CLASS######################################
  2.  
  3. class Player():
  4.     def __init__(self,player_name):
  5.         self.name = player_name
  6.         self.health = None
  7.         self.inventory = []
  8.  
  9.     def set_inventory(self,inventory_list):
  10.         self.inventory = inventory_list
  11.  
  12.     def get_inventory(self):
  13.         return self.inventory
  14.  
  15.     def set_health(self,health_points):
  16.         self.health = health_points
  17.  
  18.     def get_health(self):
  19.         return self.health
  20.  
  21.     def describe(self):
  22.         print ("You name is, ", self.name)
  23.         print ("You are carrying:")
  24.         for item in self.inventory:
  25.             print (item[0], item[1])
  26.         print ()
  27.         print ("Your health is :", self.health)
  28.  
  29.  
  30. #####THE BIT OF MAIN THAT USES THE NEW PLAYER CLASS#####################
  31.     ###STATUS
  32.     elif command =="Status":
  33.         protag.describe()
  34.     ###GET
  35.     elif command =="Get":
  36.         if room_item is not None:
  37.             get_what = input("What will you get? >>> ")
  38.             if get_what in room_item.item:
  39.                 inventory = protag.inventory
  40.                 got = [room_item.item,room_item.item_description]
  41.                 inventory.append(got)
  42.                 print ("You got the ", room_item.item)
  43.                 room_item.item = None
  44.                 room_item.item_description = None
  45.                
  46.             else:
  47.                 print ("You can't get that!")
Advertisement
Add Comment
Please, Sign In to add comment