| |
- player
class player |
|
Player class. Creates and manages player objects
#Main characteristics
name="_" #Name
pocket=0 #Money
exp=0 #EXP
lv=1 #Level
points=0 #Expendable points
race="_" #Race
charclass="_" #Class
inventory=[] #10 slot inventory
equiparr=[] #Equipped item inventory
belt=[] #Quick access consumable items
status=0 #Paralyzed, burned, bleeding, etc
prestige=0 #Prestige points
prestigelv=1 #Prestige level (unused)
#Attribute and attribute booster variables
INT=1 #Intelligence
DEX=1 #Dexterity
PER=1 #Perception
WIL=1 #Willpower
STR=1 #Strenght
CON=1 #Constitution
CHA=1 #Charisma
intboost=0 #
dexboost=0 #
perboost=0 #
wilboost=0 # Extra attributes given by equipped items
strboost=0 #
conboost=0 #
chaboost=0 #
totatk=1 #Total attack power
totdefn=1 #Total defense power
#Secondary and status variables
HP=0 #Maximum hit points
hp2=0 #Current hit points
MP=0 #Maximum mana points
mp2=0 #Current mana points
END=0 #Endurance
SPD=0 #Speed
stomach=10 #Hunger level
#Stats and achievements
totalfl=0 #Floors explored
steps=0 #Steps
totalatks=0 #Total attacks
totalhits=0 #Total hits
totaldmg=0 #Damage given
totalrcv=0 #Damage taken
kills=0 #Enemies killed
totalgld=0 #Total gold gained
totaltrp=0 #Times stepped on traps
itemspck=0 #Total items picked
itemsdst=0 #Total items destroyed
itemsenc=0 #Total enchants
totalpot=0 #Potions taken
totalsll=0 #Items sold
totalbuy=0 #Items bought
totalspn=0 #Money spent
maxdmg=0 #Maximum damage
maxench=0 #Maximum enchant lv
#Position
xpos=0
ypos=0
zpos=0 |
|
Methods defined here:
- __init__(self, randomv)
- Initialization of the player objects.
Receives a dungeon object, then sets the coordinates of the player object in the entrance tile
It also chooses a random race and class from the ./data/races and ./data/classes files
Needs a random parameter. if 1, the character is generated randomly.
- achievements(self)
- Shows a list of completed achievements.
- addbonuses(self, item)
- Adds bonuses from an item to the player
- attack(self, mob)
- attacks the mob object specified
Returns a string to be displayed in the crawl screen
- bury(self)
- Saves the character into a cemetery file
This file is ../player/cemetery and contains all the player's dead characters.
Similar to save, except more verbose.
Unlike save it does not record things like maximum HP, items or stats, so buried characters can NOT be recovered.
- calcbonus(self, item)
- Generates the string with the attribute boosts for the inventory
- charsheet(self)
- Character sheet.
Main menu to edit, view and configure characters and player options
- enter(self, dungeon, fall)
- Places the player object in a dungeon
if fall==0, the player is placed in the entrance tile
if fall==1, then a random tile is selected
- getatr(self)
- Prints the player attributes on screen.
- invmenu(self)
- Inventory menu and managing.
- levelup(self)
- Levels the player up
- load(self)
- Takes the information from the save file stored in ../player/save and loads it into the player object.
- move(self, dungeon, direction)
- Move function.
Receives a dungeon object to check for obstacles and an integer [1,4] indicating the direction
1 north
2 west
3 south
4 east
5 northwest
6 northeast
7 southwest
8 southeast
Returns an integer:
0 Can't move (Wall or other obstacle)
1 Moved successfully
2 Mob present (Not moved, signaled for attack)
- optmenu(self)
- Player options menu
- pickconsumable(self, object)
- Picks a consumable item from the floor.
It adds it to the consumable inventory, potions to slots 1-3 and food to slots 4-6.
Returns an interger if it has been picked (0:no, 1:yes) and a message.
- pickobject(self, object)
- Pick item from the floor.
This receives an item and adds it to the inventory if the inventory is not full.
Returns 1 and adds the object to the inventory if the object was correctly picked, returns 0 if it wasn't.
- rembonuses(self, item)
- Removes bonuses from an item
- reset(self)
- Changes all player variables to the default values
- save(self)
- Save function. Takes the player attributes and saves them into a text file in ../player/save
If the path or the file do not exist they are created.
- secondary(self)
- Calculates and sets the secondary attributes from the primary ones.
Receives a player object and recalculates HP, MP, END and SPD from the primary attributes.
It also adds the extra HP and MP gained after adding an attribute point or leveling up.
- spend(self)
- Point spending menu.
- statmenu(self)
- Displays character stats on screen
- use(self, item)
- Takes an item object from the player belt and uses it.
Returns a message to be displayed.
- willtest(self)
- Tests if the player has enough willpower to move.
Roll a die [1,20] and add the total willpower
If the roll is less than 20/remaining HP, the test fails
If the player's health is bigger than 5, the player automatically passes the test.
| |