Exemple #1
0
 def print(self, index):
     #todo: pass colored indeces into dbox func. to allow colored messages
     x = rog.msgs_x()
     y = rog.msgs_y()
     w = rog.msgs_w()
     h = rog.msgs_h()
     rog.dbox(x, y, w, h, self.msgs[index], border=None, margin=0)
Exemple #2
0
 def printall_get_wrapped_msgs(self):
     w = rog.msgs_w()
     return '\n'.join( textwrap.fill( msg, w-2) for msg in reversed(self.msgs) )
Exemple #3
0
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)