def _alreadyHaveTrait(string): rog.dbox( 0,0,rog.window_w(),4, text='''You already have this trait: "{}". <Press any key to continue>'''.format(string), wrap=True,con=rog.con_final(),disp='mono' ) rog.refresh() rog.Input(rog.window_w()-2,1,mode='wait')
def _insufficientPoints(points, cost, string): rog.dbox( 0,0,rog.window_w(),5, text='''Not enough {} points remaining. (Cost: {} | Points remaining: {}) <Press any key to continue>'''.format(string, cost, points), wrap=False,con=rog.con_final(),disp='mono' ) rog.refresh() rog.Input(rog.window_w()-2,1,mode='wait')
def _maxedSkill(string): rog.dbox( 0,0,rog.window_w(),8, text='''You've reached the maximum skill level in skill: "{}". Please choose another skill, or select "<confirm>" on the "character specs" menu to continue. <Press any key to continue>'''.format(string), wrap=True,con=rog.con_final(),disp='mono' ) rog.refresh() rog.Input(rog.window_w()-2,1,mode='wait')
def _selectFromBigMenu(): ''' run the big menu, return whether any char data has changed ''' libtcod.console_clear(0) libtcod.console_clear(rog.con_final()) _printChargenData() rog.refresh() _drawskills(0) _drawtraits(0) _choice = rog.menu( "character specs", Chargen.xx,10, Chargen.menu.keys() ) if _choice == -1: # Esc Chargen.confirm = True return False selected=Chargen.menu.get(_choice, None) if not selected: print("Failure in _selectFromBigMenu()... information:") print(" selected: ", selected) print(" _choice: ", _choice) return False # selection successful. # figure out what type of option was selected if selected=="confirm": Chargen.confirm = True elif selected=="open-skills": Chargen.open_skills = True elif selected=="close-skills": Chargen.open_skills = False elif selected=="open-stats": Chargen.open_stats = True elif selected=="close-stats": Chargen.open_stats = False elif selected=="open-attributes": Chargen.open_attributes = True elif selected=="close-attributes": Chargen.open_attributes = False elif selected=="open-traits": Chargen.open_traits = True elif selected=="close-traits": Chargen.open_traits = False elif selected in Chargen.skilldict.values(): return _select_skill(selected) elif selected in Chargen.statdict.values(): return _select_stat(selected) elif selected in Chargen.attdict.values(): return _select_attribute(selected) elif selected in Chargen.traitdict.values(): return _select_trait(selected) return False
def _select_gender(): Chargen.ww=rog.window_w() rog.dbox(Chargen.x1,Chargen.y1+Chargen.iy,Chargen.ww,3,text="what is your gender?", wrap=True,border=None,con=rog.con_final(),disp='mono') rog.refresh() _gender='' while (_gender == ''): _menuList={'m':'male','f':'female','n':'nonbinary','*':'random',} _gender=rog.menu("gender select",Chargen.xx,Chargen.yy,_menuList,autoItemize=False) if _gender == -1: _gender = 'random' if _gender == 'nonbinary': _genderName = "nonbinary" # temporary... _genderID = GENDER_OTHER else: #random, male and female if _gender == 'random': _gender = random.choice(("male","female",)) if _gender == 'male': _genderName = "male" _genderID = GENDER_MALE elif _gender == 'female': _genderName = "female" _genderID = GENDER_FEMALE # end while # save selected data Chargen._pronouns = rog._get_pronouns(_genderID) Chargen._gender = _genderID Chargen._genderName = _genderName Chargen.female=(Chargen._genderName=="female") # print char data so far libtcod.console_clear(rog.con_final()) _printElement("name: {}".format(Chargen._name), Chargen.iy-1) Chargen.iy=_printElement("gender: {}".format(Chargen._genderName), Chargen.iy) print("gender chosen: ", Chargen._genderName)
def refresh(self): libtcod.console_blit(self.con, self.view.x, self.view.y, self.view.w, self.view.h, rog.con_final(), rog.view_port_x(), rog.view_port_y()) rog.refresh()
def chargen(sx, sy): world = rog.world() # init x1 = 0 y1 = 0 xx = 0 yy = 4 iy = 0 ww = rog.window_w() hh = 5 # _printElement - local function # draw the string to con_game at (x1,y1) then move y vars down def _printElement(elemStr): #global yy,y1,x1 rog.dbox(x1, y1 + iy, ROOMW, 3, text=elemStr, wrap=False, border=None, con=rog.con_game(), disp='mono') rog.blit_to_final(rog.con_game(), 0, 0) rog.refresh() # get char data from player # name _name = rog.prompt(x1, y1, ww, hh, maxw=20, q="What is your name?", mode="text") _title = "" print("Name chosen: ", _name) _printElement("Name: {}".format(_name)) iy += 1 # load saved game loadedGame = False savedir = os.listdir(os.path.join(os.path.curdir, "save")) for filedir in savedir: if ".save" != filedir[-5:]: continue #wrong filetype try: with open(filedir, "r") as save: line = save.readline() if ("name:{}\n".format(_name) == line): #found a match. Begin reading data pc = loadFromSaveFile(save) return pc except FileNotFoundError: pass except: print("ERROR: Corrupted save file detected.") print("Continuing chargen...") break if not loadedGame: #continue chargen... # gender rog.dbox(x1, y1 + iy, ROOMW, 3, text="What is your gender?", wrap=True, border=None, con=rog.con_final(), disp='mono') rog.refresh() #get added genders _genderList = {} genderFileDir = os.path.join(os.path.curdir, "settings", "genders.txt") try: with open(genderFileDir, "r") as file: for line in file: if "//" in line: continue data = line.split(':') if len(data) < 2: continue gname = data[0] data = data[1].split(',') gpronouns = data _genderList.update({gname: gpronouns}) except FileNotFoundError: print("ALERT: file '{}' not found. Creating new file...") with open(genderFileDir, "w+") as file: file.write("\n") #gender selection _gender = '' while (_gender == ''): _menuList = { 'm': 'male', 'f': 'female', 'n': 'nonbinary', '*': 'random', } #read genders from genders.txt _gender = rog.menu("Gender Select", xx, yy, _menuList, autoItemize=False) if _gender == 'nonbinary': #select gender from list of added genders _menuNonbin = [] for jj in _genderList.keys(): _menuNonbin.append(jj) _menuNonbin.append('add new gender') choice = rog.menu("Nonbinary Genders", xx, yy, _menuNonbin) #add gender if choice == 'add new gender': _genderName, _pronouns = _add_gender() else: _genderName = choice _pronouns = _genderList[_genderName] if _genderName == '': #failed to select or add new gender _gender = '' #prompt user again for gender else: #random, male and female if _gender == 'random': _gender = random.choice(( "male", "female", )) if _gender == 'male': _genderName = "male" _pronouns = ( 'he', 'him', 'his', ) elif _gender == 'female': _genderName = "female" _pronouns = ( 'she', 'her', 'hers', ) print("Gender chosen: ", _genderName) _printElement("Gender: {}".format(_genderName)) iy += 1 # class rog.dbox(x1, y1 + iy, ROOMW, 3, text="What is your profession?", wrap=True, border=None, con=rog.con_final(), disp='mono') rog.refresh() _classList = { } #stores {className : (classChar, classID,)} #all classes #create menu options _menuList = {} #stores {classChar : className} #all playable classes _randList = [] #for random selection. for k, v in jobs.getJobs().items(): # k=ID v=charType if v not in rog.playableJobs(): continue #can't play as this class yet ID = k # get ID of the class typ = v # get chartype of the class name = jobs.getName(ID) _classList.update({name: ( typ, ID, )}) _menuList.update({typ: name}) _randList.append(ID) _menuList.update({'*': 'random'}) #user selects a class _className = rog.menu("Class Select", xx, yy, _menuList, autoItemize=False) #random if _className == 'random': _classID = random.choice(_randList) _className = jobs.getName(_classID) #get the relevant data _type = _classList[_className][0] # get the class Char value _mask = _type _classID = _classList[_className][1] #grant stats / abilities of your chosen class print("Class chosen: ", _className) _printElement("Class: {}".format(_className)) iy += 1 # skill rog.dbox(x1, y1 + iy, ROOMW, 3, text="In which skill are you learned?", wrap=True, border=None, con=rog.con_final(), disp='mono') #rog.refresh() #get list of all skills _skillName = rog.menu("Skill Select", xx, yy, SKILLS.values()) #get the skill ID for skid, name in SKILLS.items(): if name == _skillName: _skillID = name break print("Skill chosen: ", _skillName) #should show ALL skills you're skilled in, not just the one you pick #for skill in jobs.getSkills(_skillID): _printElement("Skills: {}".format(_skillName)) iy += 1 #stats? _stats = {} #gift? _gift = 0 #create pc object from the data given in chargen ## pc = world.create_entity( # USE create_monster function!!!! ## cmp.Position(sx,sy), ## cmp.Name(_name, title=_title,pronouns=_pronouns), ## cmp.Draw('@', COL['white']), ## cmp.Form( ## ) ## pc = rog.create_monster('@',0,0,COL['white'],mutate=0) ## pc.name = _name ## pc.title = _title ## pc.mask = '@' ## pc.job = _className ## pc.gender = _genderName ## pc.pronouns = _pronouns ## pc.faction = FACT_ROGUE ## #add additional skill ## rog.train(pc,_skillID) ## #add specific class stats return pc
def _select_class(): _classList={} #stores {className : (classChar, classID,)} #all classes #create menu options _menuList={} #stores {classChar : className} #all playable classes _randList=[] #for random selection. for k,v in entities.getJobs().items(): # k=ID v=charType ## if v not in rog.playableJobs(): continue #can't play as this class yet ID=k # get ID of the class typ=v # get chartype of the class name=entities.getJobName(ID) _classList.update({name:(typ,ID,)}) _menuList.update({typ:name}) _randList.append(ID) _menuList.update({'*':'random'}) classSelected = False while not classSelected: _printChargenData(showclass=False) rog.dbox( Chargen.x1,Chargen.y1+Chargen.iy,Chargen.ww,3, text="what is your profession?", wrap=True,border=None,con=rog.con_final(),disp='mono' ) rog.refresh() #user selects a class _className = rog.menu( "class select",Chargen.xx,Chargen.yy+Chargen.iy,_menuList, autoItemize=False ) #random if (_className == 'random' or _className == -1): _classID = random.choice(_randList) _className = entities.JOBS[_classID][1] #get the relevant data _type = _classList[_className][0] # get the class Char value _mask = _type _classID = _classList[_className][1] _mass = entities.getJobMass(_classID) _jobstats = entities.getJobStats(_classID).items() _jobskills = entities.getJobSkills(_classID) _jobmoney = entities.getJobMoney(_classID) _jobitems = entities.getJobItems(_classID) _jobkeys = entities.getJobClearance(_classID) # for display by confirmation prompt _classDescription = entities.getJobDescription(_classID) # create class stats info _classStats="" if _jobstats: for k,v in _jobstats: _classStats += "{}: {}, ".format(STATS[k],v) _classStats=_classStats[:-2] # create class items info _classItems = "" if _jobitems: for tupl in _jobitems: name,table,quantity,slot,mat,script = tupl matname = "{} ".format(rog.getMatName(mat)) if mat else "" _classItems += "{}{}, x{}; ".format(matname, name, quantity) _classItems=_classItems[:-2] # info about class && confirmation while True: ph=4 text = '''Class: {name}. {desc} Mass: {kg} KG. Starts with (${money}, {items}). [ {stats} ]'''.format( name=_className, kg=_mass, money=_jobmoney, items=_classItems, desc=_classDescription, stats=_classStats ) rog.dbox( 0,0,rog.msgs_w(),12,text, wrap=True,border=1,con=rog.con_final() ) ans=rog.prompt( 0,rog.window_h()-ph,rog.window_w(),ph, q='''Choose this class? y/n''', mode="wait",default='n',wrap=False ) if ans=='y': classSelected=True break elif ans=='n': libtcod.console_clear(rog.con_final()) rog.refresh() break else: continue # end while # end while # confirmed class selection Chargen._type = _type Chargen._classID = _classID Chargen._className = _className Chargen._jobstats = _jobstats Chargen._jobskills = _jobskills Chargen._jobmoney = _jobmoney Chargen._jobitems = _jobitems Chargen._jobkeys = _jobkeys Chargen._jobmass = _mass #add specific class skills for sk_id,sk_lv in Chargen._jobskills.items(): rog.setskill(Chargen.pc, sk_id, sk_lv) # print char data so far _printChargenData() rog.refresh() print("class chosen: ", _className)
def chargen(sx, sy): ''' character generation function # Create and return the player Thing object, # and get/set the starting conditions for the player # Arguments: # sx, sy: starting position x, y of player entity ''' # TODO: saving/loading game # init world = rog.world() __init__Chargen() # init some global vars for use during chargen height_default = AVG_HUMAN_HEIGHT libtcod.console_clear(0) libtcod.console_clear(rog.con_game()) libtcod.console_clear(rog.con_final()) # # get character data from player input # # name ans="" while (not ans or ans=='0'): ans=rog.prompt( Chargen.x1,Chargen.y1,Chargen.ww,Chargen.hh,maxw=20, q="what is your name?", mode="text" ) Chargen._name = ans _title = 0 # print char data so far print("name chosen: ", Chargen._name) libtcod.console_clear(rog.con_final()) Chargen.iy=_printElement("name: {}".format(Chargen._name), Chargen.iy) # # load saved game loadedGame = False # TODO: forget this -- use Pickle or similar ## savedir=os.listdir(os.path.join( ## os.path.curdir,os.path.pardir,"save")) ## for filedir in savedir: ## if ".save" != filedir[-5:] : ## continue #wrong filetype ## try: ## with open(filedir, "r") as save: ## line = save.readline() ## if ("name:{}\n".format(Chargen._name) == line): ## #found a match. Begin reading data ## pc=loadFromSaveFile(save) ## return pc ## except FileNotFoundError: ## pass ## except: ## print("ERROR: Corrupted save file detected.") ## print("Continuing chargen...") ## break # end for if loadedGame: # load old character (TODO) pass else: # make a new character # create a basic entity for the PC, with no defining characteristics Chargen.skillsCompo = cmp.Skills() Chargen.flags = cmp.Flags(IMMUNERUST,) Chargen.pc = world.create_entity( Chargen.skillsCompo, Chargen.flags) #continue chargen by refining the details of the PC... #gender selection _select_gender() # body type _select_height() _select_mass() # class _select_class() #----------------------------------# # start creating player components # #----------------------------------# # create stats component Chargen.statsCompo=cmp.Stats( hp=BASE_HP, mp=BASE_MP, mpregen=BASE_MPREGEN*MULT_STATS, mass=0, # base mass before weight of water and blood and fat is added encmax=BASE_ENCMAX, resfire=BASE_RESFIRE, rescold=BASE_RESCOLD, resbio=BASE_RESBIO, reselec=BASE_RESELEC, resphys=BASE_RESPHYS, reslight=BASE_RESLIGHT, ressound=BASE_RESSOUND, _str=BASE_STR*MULT_ATT, _con=BASE_CON*MULT_ATT, _int=BASE_INT*MULT_ATT, _agi=BASE_AGI*MULT_ATT, _dex=BASE_DEX*MULT_ATT, _end=BASE_END*MULT_ATT, atk=BASE_ATK*MULT_STATS, dmg=BASE_DMG*MULT_STATS, pen=BASE_PEN*MULT_STATS, dfn=BASE_DFN*MULT_STATS, arm=BASE_ARM*MULT_STATS, pro=BASE_PRO*MULT_STATS, gra=BASE_GRA*MULT_STATS, bal=BASE_BAL*MULT_STATS, ctr=BASE_CTR*MULT_STATS, reach=BASE_REACH*MULT_STATS, spd=BASE_SPD, asp=BASE_ASP, msp=BASE_MSP, sight=0, hearing=0, # senses gained from Body component now. TODO: do the same things for monster gen... scary=BASE_SCARY, beauty=BASE_BEAUTY ) Chargen.fearCompo=cmp.FeelsFear(BASE_COURAGE + PLAYER_COURAGE) #add specific class stats for stat, val in Chargen._jobstats: value=val*MULT_STATS if stat in STATS_TO_MULT.keys() else val Chargen.statsCompo.__dict__[stat] += value # #----------------# # big menu # #----------------# # (attributes/stats/skills/characteristics) # menu loop until uer selects "<confirm>" while(not Chargen.confirm): Chargen.menu={} Chargen.menu.update({"<confirm>" : "confirm"}) _chargen_attributes() _chargen_stats() _chargen_skills() _chargen_traits() _selectFromBigMenu() # end while # choose a personality personality = random.choice(MAIN_PERSONALITIES) ## print("personality: ", personality) # continue creating player entity # # calculate some stats cm = int(height_default * Chargen._cmMult * Chargen.mcm) kg = int((Chargen._jobmass + Chargen.mass) * Chargen._kgMult * Chargen.mmass) # mass stat mods fatratio=DEFAULT_BODYFAT_HUMAN if Chargen._kg >= 5: fatratio += (Chargen._kg-4)/16 elif Chargen._kg < 3: fatratio -= fatratio*(3-Chargen._kg)/3 fatratio += Chargen.bodyfat/100 fatratio *= Chargen.mbodyfat ## print("bodyfat: ", fatratio) # height stat mods reachMult = 1 + (Chargen._cm-5)/20 #/10 reachMult *= Chargen.mreach if Chargen._cm < 5: mspMult = 1 + (Chargen._cm-5)/24 #/12 else: mspMult = 1 + (Chargen._cm-5)/32 #/16 mspMult *= Chargen.mmsp # # create body body, basemass = rog.create_body_humanoid( kg=kg, cm=cm, female=Chargen.female, bodyfat=fatratio) body.hydration = body.hydrationMax * 0.98 body.satiation = body.satiationMax * 0.85 # body temperature meters = cmp.Meters() meters.temp = BODY_TEMP[BODYPLAN_HUMANOID][0] # confirmation # # print char data libtcod.console_clear(rog.con_final()) Chargen.iy=0 Chargen.iy=_printElement("name: {}".format(Chargen._name), Chargen.iy) Chargen.iy=_printElement("gender: {}".format(Chargen._genderName), Chargen.iy) Chargen.iy=_printElement("class: {} ({})".format(Chargen._className, Chargen._type), Chargen.iy) Chargen.iy=_printElement("height: {} cm ({} / 9)".format(cm, Chargen._cm), Chargen.iy) Chargen.iy=_printElement("mass: {} kg ({} / 9)".format(kg, Chargen._kg), Chargen.iy) _drawskills(rog.con_final()) _drawtraits(rog.con_final()) rog.refresh() # # prompt to continue or restart chargen _ans='' while _ans!='y': # roll character ## reroll(statsCompo, Chargen.skillsCompo) _ans=rog.prompt(Chargen.x1,rog.window_h()-4,Chargen.ww,4,maxw=20, q="continue with this character? y/n", #/r (reroll) mode="wait" ) if _ans.lower()=='n': return chargen(sx,sy) ## if _ans.lower()=='r': ## reroll(statsCompo, Chargen.skillsCompo) # end if #----------------------------------# # finish creating player # #----------------------------------# # apply any stat changes from Chargen that haven't been applied Chargen.statsCompo.mass += basemass Chargen.statsCompo.reach = round(reachMult*Chargen.statsCompo.reach) Chargen.statsCompo.msp = round(mspMult*Chargen.statsCompo.msp) if Chargen.fastLearner: world.add_component(pc, cmp.FastLearner()) if Chargen.attractedMen: world.add_component(pc, cmp.AttractedToMen()) if Chargen.attractedWomen: world.add_component(pc, cmp.AttractedToWomen()) #create pc object from the data given in chargen # add components to entity pc=Chargen.pc world.add_component(pc, Chargen.statsCompo) world.add_component(pc, body) world.add_component(pc, meters) world.add_component(pc, cmp.Player()) world.add_component(pc, cmp.Name(Chargen._name, title=_title)) world.add_component(pc, cmp.Draw('@', COL['white'], COL['deep'])) world.add_component(pc, cmp.Position(sx, sy)) world.add_component(pc, cmp.Actor()) world.add_component(pc, cmp.Form( mat=MAT_FLESH, val=VAL_HUMAN*MULT_VALUE )) world.add_component(pc, cmp.Creature( job = Chargen._className, faction = FACT_ROGUE, species = SPECIE_HUMAN )) world.add_component(pc, cmp.SenseSight()) world.add_component(pc, cmp.SenseHearing()) world.add_component(pc, cmp.Mutable()) world.add_component(pc, cmp.Inventory()) world.add_component(pc, cmp.Gender(Chargen._gender)) world.add_component(pc, cmp.Job(Chargen._classID)) world.add_component(pc, cmp.Speaks()) world.add_component(pc, cmp.Personality(personality)) world.add_component(pc, cmp.Wets(BASE_RESWET)) world.add_component(pc, cmp.Dirties(BASE_RESDIRT)) world.add_component(pc, cmp.Bleeds(BASE_RESBLEED)) world.add_component(pc, cmp.FeelsPain(BASE_RESPAIN)) world.add_component(pc, Chargen.fearCompo) world.add_component(pc, cmp.Insulated(BASE_INSUL)) world.add_component(pc, cmp.GetsSick()) # end if # init PC entity pc=Chargen.pc rog.register_entity(pc) rog.add_listener_sights(pc) rog.add_listener_sounds(pc) rog.grid_insert(pc) rog.update_fov(pc) init(pc) # give items for itemdata in Chargen._jobitems: name, func, quantity, eq_const, material, script = itemdata for _ in range(quantity): item = func(name, sx,sy, mat=material) rog._initThing(item) # register (init stats), fill HP, rog.give(pc, item) if script: script(item) if eq_const: rog.equip(pc, item, eq_const) # end for return pc
def _printElement(elemStr,iy): rog.dbox(Chargen.x1,Chargen.y1+iy,Chargen.ww,3,text=elemStr, wrap=False,border=None,con=rog.con_final(),disp='mono') return iy+1
def _select_trait(_trait): pc=Chargen.pc pts = CHARACTERISTICS[_trait][0] # already have if _trait in Chargen._traits: _alreadyHaveTrait(_trait) return False # confirmation prompt description = CHARACTERISTICS_DESCRIPT[_trait] c = "Costs" if pts < 0 else "Gives" description = '{}: {}. {}: {} pts. Points remaining: {}'.format( _trait, description, c, abs(pts), Chargen.traitPts) rog.dbox( 0,0,Chargen.ww,8, text=description, wrap=True, con=rog.con_final() ) inp=rog.prompt(0,10,Chargen.ww,4,q="select this trait? y/n", mode='wait') if inp!='y': return False # insufficient points if Chargen.traitPts < -pts: _insufficientPoints(Chargen.traitPts, -pts, "trait") return False success = False # (attempt to) apply trait data = CHARACTERISTICS[_trait][1] for k,v in data.items(): # meta traits if k=="skillPts": Chargen.skillPts += v success = True elif k=="statPts": Chargen.statPts += v success = True elif k=="attPts": Chargen.attPts += v success = True # component flags elif k=="astigmatism": # TODO: make these apply components in chargen Chargen.astigmatism=True success = True elif k=="cancer": Chargen.cancer=True success = True elif k=="rapidMetabolism": Chargen.rapidMetabolism=True success = True elif k=="ironGut": Chargen.ironGut=True success = True elif k=="immuneVenom": Chargen.immuneVenom=True success = True elif k=="immunePoison": Chargen.immunePoison=True success = True elif k=="immunePain": Chargen.immunePain=True success = True elif k=="hydrophobia": Chargen.hydrophobia=True success = True elif k=="attractedMen": Chargen.attractedMen=True success = True elif k=="attractedWomen": Chargen.attractedWomen=True success = True elif k=="fastLearner": Chargen.fastLearner=True success = True # sub-menu traits elif k=="talent": success = _select_talent() elif k=="trauma": success = _select_trauma() elif k=="addict": success = _select_addict() elif k=="allergy": success = _select_allergy() elif k=="scarred": success = _select_scar() # body stats elif k=="mfat": Chargen.mbodyfat *= v success = True elif k=="fat": Chargen.bodyfat += v success = True elif k=="mgut": Chargen.mgut *= v #(TODO: make these change stats in chargen) success = True elif k=="mvision": Chargen.mvision *= v #(TODO: make these change stats in chargen) success = True # stats elif k=="mmass": Chargen.mmass *= v success = True elif k=="mass": Chargen.mass += v success = True elif k=="mcm": Chargen.mcm *= v success = True elif k=="mreach": Chargen.mreach *= v success = True elif k=="mreach": Chargen.mreach *= v success = True elif k=="mmsp": Chargen.mmsp *= v success = True elif k=="bea": Chargen.statsCompo.bea += v success = True elif k=="idn": Chargen.statsCompo.idn += v success = True elif k=="cou": Chargen.statsCompo.cou += v success = True elif k=="str": Chargen.statsCompo.str += v*MULT_STATS success = True elif k=="agi": Chargen.statsCompo.agi += v*MULT_STATS success = True elif k=="dex": Chargen.statsCompo.dex += v*MULT_STATS success = True elif k=="end": Chargen.statsCompo.end += v*MULT_STATS success = True elif k=="con": Chargen.statsCompo.con += v*MULT_STATS success = True elif k=="int": Chargen.statsCompo.int += v*MULT_STATS success = True elif k=="resbio": Chargen.statsCompo.resbio += v success = True elif k=="resfire": Chargen.statsCompo.resfire += v success = True elif k=="rescold": Chargen.statsCompo.rescold += v success = True elif k=="respain": Chargen.statsCompo.respain += v success = True # end for if success: # trait chosen successfully Chargen.traitPts += pts if Chargen.traitPts <= 0: Chargen.open_traits = False Chargen._traits.append(_trait) print("trait chosen: {} (pts: {})".format(_trait, Chargen.traitPts)) return True return False