Esempio n. 1
0
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')
Esempio n. 2
0
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')
Esempio n. 3
0
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')
Esempio n. 4
0
def pickup_pc(pc):
    rog.alert("Pick up what?{d}".format(d=dirStr))
    args=rog.get_direction()
    if not args:
        rog.alert()
        return
    dx,dy,dz=args
    xx,yy=pc.x + dx, pc.y + dy
    
    things=rog.thingsat(xx,yy)
    if pc in things:
        things.remove(pc)

    choice=None
    if len(things) > 1:
        rog.alert("There are multiple things here. Pick up which item?")
        choices = [] #["all",] #should player be able to pickup multiple things at once? Maybe could be a delayed action?
        for thing in things:
            choices.append(thing)
        choice=rog.menu(
            "pick up", rog.view_port_x()+2, rog.view_port_y()+2, choices
            )
    else:
        if things:
            choice=things[0]

    if (choice and not choice == "all"):

        if choice == K_ESCAPE:
            return
        
        #thing is creature! You can't pick up creatures :(
        if choice.isCreature:
            rog.alert("You can't pick that up!")
            return
        #thing is on fire! What are you doing trying to pick it up??
        if rog.on(choice,FIRE):
            answer=""
            while True:
                answer=rog.prompt(0,0,rog.window_w(),1,maxw=1,
                    q="That thing is on fire! Are you sure? y/n",
                    mode='wait',border=None)
                answer=answer.lower()
                if answer == "y" or answer == " " or answer == K_ENTER:
                    rog.alert("You burn your hands!")
                    rog.burn(pc, FIRE_BURN)
                    rog.hurt(pc, FIRE_HURT)
                    break
                elif answer == "n" or answer == K_ESCAPE:
                    return
        # put in inventory
        pocketThing(pc, choice)
    #elif choice == "all":
    #    
    else:
        rog.alert("There is nothing there to pick up.")
Esempio n. 5
0
def _get_gift_for(ent:int) -> tuple:
    opt = rog.prompt(
        0,0,rog.window_w(),4,q='Offer money or possessions? $/i',
        mode='wait',default='$'
        )
    if opt=='$':
        value = rog.prompt(
            0,0,rog.window_w(),4,q='Offer how much money?',
            mode='wait',default=0
            )
    elif opt=='i':
        options = {
            "cancel" : 0,
            "item from inventory" : -100,
            }
        body = world.component_for_entity(rog.pc(), cmp.Body)
        i=-1
        for arm in body.parts[cmp.BPC_Arms].arms:
            i+=1
            if (arm and arm.hand.held.item):
                options.update({"{}".format(item) : item})
        opt = rog.menu("Offer what item?",0,0,menu)
        if opt==-1: return ("money",0,)
        item = options[opt]
        if item==0: return ("money",0,)
        if item==-100:
            # temporary
            # TODO: get from inventory
            return ("money",0,)
        itemn = world.component_for_entity(item, cmp.Name)
        entn = world.component_for_entity(ent, cmp.Name)
        ans = rog.prompt(
            "Offer {ti}{i} to {tn}{n}?".format(
            i=itemn.name,n=entn.name,
            it=TITLES[itemn.title],
            tn=TITLES[entn.title]
            ),
            0,0, mode='wait'
            )
        if ans=='y':
            return ("item",item,)
    return ("money",0,) # if we made it this far
Esempio n. 6
0
def _select_height():
    Chargen.ww=rog.window_w()
    avg = 3 if Chargen.female else 5
    _cm=rog.prompt( Chargen.x1,Chargen.y1+Chargen.iy,Chargen.ww,6,maxw=20,
        q="How tall are you? (press a key from 1 to 9. {} is average)".format(avg),
        mode="wait" )
    try:
        _cm = int(_cm)
    except:
        _cm = avg
    if (_cm==0 or not _cm): _cm=avg
    _cmMult = 1 + (_cm - 5)/20
    
    # save selected data
    Chargen._cm = _cm
    Chargen._cmMult = _cmMult
    # print char data so far
    _printElement("name: {}".format(Chargen._name), Chargen.iy-2)
    _printElement("gender: {}".format(Chargen._genderName), Chargen.iy-1)
    Chargen.iy=_printElement("height: {} / 9".format(Chargen._cm), Chargen.iy)
    print("height chosen: ", Chargen._cm)
Esempio n. 7
0
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)
Esempio n. 8
0
    def __init__(self,
                 name,
                 x,
                 y,
                 bound_w,
                 bound_h,
                 keysItems,
                 autoItemize=True):
        super(Manager_Menu, self).__init__()

        #   init from args      #
        #   - keysItems: {unique id : pointer to menu item}
        #   - keysItems can be manually created and passed in
        #   or automatically created if autoItemize == True
        #       (in which case you pass in an iterable)
        #       iterable can contain strings or an object with attr "name"

        # ensure that all keys are integers
        if not autoItemize:  # if we are given keys by the caller,
            delete = []
            for k, v in keysItems.items():
                if isinstance(k, str):
                    delete.append((
                        k,
                        v,
                    ))
            for (
                    k,
                    v,
            ) in delete:
                keysItems[ord(k)] = v
                del keysItems[k]
        #

        self.name = name
        self.x = x
        self.y = y
        self.bound_w = bound_w  # limits of where the menu can be on screen
        self.bound_h = bound_h
        self.border_w = 1
        self.border_h = 1
        self.view_pos = 0
        if autoItemize:
            self.keysItems = {}
            for k, v in misc.itemize(keysItems):
                self.keysItems.update({k: v})
        else:
            self.keysItems = keysItems
        #   get width and height from items
        widest = 0
        for k, v in self.keysItems.items():
            leni = len(self.get_name(v)) + 2 + self.border_w * 2
            if leni > widest:
                widest = leni
        lenTitlePadding = 4
        borderPadding = 2
        lenn = len(self.name) + borderPadding + lenTitlePadding
        if lenn > widest: widest = lenn
        self.w = widest + self.border_w * 2
        self.h = len(self.keysItems) + self.border_h * 2
        self.drawh = rog.window_h()
        #   make sure it doesn't go off-screen
        if self.x + self.w > rog.window_w():
            self.x = max(0, rog.window_w() - self.w)
        if self.y + self.h > rog.window_h():
            self.y = max(0, rog.window_h() - self.h)
        #   sort
        self.sort()
        #   scrolling
        self.scrolling = (self.drawh < self.h)
        #   draw
        self.con = libtcod.console_new(self.w, self.drawh)
        self.con_text = libtcod.console_new(self.w - self.border_w * 2,
                                            self.h - self.border_h * 2)
        self.draw()
        #   clear buffer
        IO.get_raw_input()
Esempio n. 9
0
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
Esempio n. 10
0
def render_hud(w, h, pc, turn, level):
    def get_color(stat):
        col = COL['white']
        if stat[:3] == 'Lo:':
            col = COL['blue']
        if stat[:3] == 'Hi:':
            col = COL['red']
        return col

    class Stat():
        def __init__(self, x, y, text, color):
            self.x = x
            self.y = y
            self.text = text
            self.color = color

    # Setup #

    get = pc.stats.get
    con = libtcod.console_new(w, h)

    strngStats = "__{name}__|Lo: {hp}|Hi: {mp}|Speed: {spd}/{asp}/{msp}|Hit: {hit}({hitb})|Pow: {dmg}({dmgb})|DV: {dfn}({dfnb})|AV: {arm}({armb})|FIR: {fir}|BIO: {bio}|DLvl: {dlv}|T: {t}".format(
        name=pc.name,
        hp=get('hp'),
        mp=get('mp'),
        spd=get('spd'),
        asp=get('asp'),
        msp=get('msp'),
        dlv=level,
        t=turn,
        hit=get('atk'),
        hitb=pc.stats.atk,
        dmg=get('dmg'),
        dmgb=pc.stats.dmg,
        dfn=get('dfn'),
        dfnb=pc.stats.dfn,
        arm=get('arm'),
        armb=pc.stats.arm,
        fir=get('resfire'),
        bio=get('resbio'),
    )
    stats = strngStats.split('|')
    statLines = [[]]
    tot = 0
    y = 0
    for stat in stats:
        lenStat = len(stat) + 1
        col = get_color(stat)
        new = Stat(tot, y, stat, col)
        tot += lenStat
        if tot >= rog.window_w():
            tot = lenStat
            y += 1
            new.x = 0
            new.y = y
            statLines.append([new])
            continue
        statLines[-1].append(new)

    # Print #
    for line in statLines:
        for stat in line:
            libtcod.console_set_default_foreground(con, stat.color)
            libtcod.console_print(con, stat.x, stat.y, stat.text)
    #

    return con
Esempio n. 11
0
def pickup_pc(pc):
    world = rog.world()
    pos = world.component_for_entity(pc, cmp.Position)
    pcx = pos.x
    pcy = pos.y
    rog.alert("Pick up what?{d}".format(d=dirStr))
    args=rog.get_direction()
    if not args:
        rog.alert()
        return
    dx,dy,dz=args
    xx,yy = pcx + dx, pcy + dy
    
    things=rog.thingsat(xx,yy)
    if pc in things: #can't pick yourself up.
        things.remove(pc)

    choice=None
    if len(things) > 1:
        rog.alert("There are multiple things here. Pick up which item?")
        choices = [] #["all",] #should player be able to pickup multiple things at once? Maybe could be a delayed action?
        for thing in things:
            choices.append(thing)
        choice=rog.menu(
            "pick up", rog.view_port_x()+2, rog.view_port_y()+2, choices
            )
    else:
        if things:
            choice=things[0]

    if (choice and not choice == "all"):

        if choice == K_ESCAPE:
            return
        
        #thing is creature! You can't pick up creatures :( or can you...?
        if world.has_component(choice, cmp.Creature):
            rog.alert("You can't pick that up!")
            return
        #thing is on fire, prompt user & burn persistent rogues
        if rog.on(choice,FIRE):
            answer=""
            while True:
                answer=rog.prompt(0,0,rog.window_w(),1,maxw=1,
                    q="That thing is on fire! Are you sure? y/n",
                    mode='wait',border=None)
                answer=answer.lower()
                if answer == "y" or answer == " " or answer == K_ENTER:
                    rog.alert("You burn your hands!")
                    rog.burn(pc, FIRE_BURN)
                    rog.hurt(pc, FIRE_HURT)
                    break
                elif answer == "n" or answer == K_ESCAPE:
                    return
        # put in inventory
        pocketThing(pc, choice)
##    elif choice == "all":
##        for tt in things:
##            pocketThing(pc, tt)
    else:
        rog.alert("There is nothing there to pick up.")
Esempio n. 12
0
def rest_pc(pc):
    turns=rog.prompt(0,0,rog.window_w(),1,maxw=3,
                     q="How long do you want to rest? Enter number of turns:",
                     mode='wait',border=None)
    for t in range(turns):
        rog.queue_action(pc, wait)
Esempio n. 13
0
def commands(pc, pcAct):
    world = rog.world()

    directional_command = 'move'
    
    for act,arg in pcAct:

##        print(act)
##        print(arg)
        
        rog.update_base()
        
        #----------------#
        # convert action #
        #----------------#
        
        if act =='context-dir':
            act=directional_command
##        if act =='context':
##            pass
        # moving using the menu move keys
        if (act =='menu-nav' and rog.game_state()=="normal"):
            act=directional_command
        
        
        #----------------#
        # perform action #
        #----------------#
#-----------MOUSE ACTION----------------------------#
        
        if act == 'lclick':
            mousex,mousey,z=arg
            if rog.wallat(mousex,mousey):
                return
            pos = world.component_for_entity(pc, cmp.Position)
            print("Left click unimplemented")
##            rog.path_compute(pc.path, pos.x,pos.y, rog.mapx(mousex), rog.mapy(mousey))
            #rog.occupation_set(pc,'path')

        if act == 'rclick':
            pass
        
#------------OTHER ACTION--------------------------#
        
        if act == 'help':
            rog.help()

        # "move-prompt" : True
        # prompt for a direction
        #   and then perform the move action in that direction
        if act == 'move-prompt':
            pass

        # "attack-prompt" : True
        # prompt for a direction
        #   and then perform the attack action in that direction
        if act == 'attack-prompt':
            pass
        
        # "move" : (x_change, y_change, z_change,)
        if act == 'move':
            _Update()
            dx,dy,dz=arg
            pos = world.component_for_entity(pc, cmp.Position)
            actor = world.component_for_entity(pc, cmp.Actor)
            xto=pos.x + dx
            yto=pos.y + dy

            # wait
            if (xto==pos.x and yto==pos.y):
                actor.ap = 0
                return

            # out of bounds
            if ( not rog.is_in_grid_x(xto) or not rog.is_in_grid_y(yto) ):
                return

            # warning for slow move speed
            if rog.allow_warning_msp():
                msp=rog.getms(pc, 'msp')
                if msp <= 10:
                    inp=rog.prompt(
                        0,0,rog.window_w(), 6, mode='wait',
                        q='''Warning: your movement speed is critically slow
(MSP: {}). Are you sure you want to move? y/n'''.format(msp)
                        )
                    if inp!='y':
                        return
                    else:
                        rog.expire_warning_msp() #TODO: when is best time to reset this warning?
            # end if
            
            # choose context-sensitive action #
            
            # fight if there is a monster present
            mon = rog.monat(xto,yto)
            if mon: # and mon != pc):
                action.fight(pc,mon)
            # or move
            elif not rog.solidat(xto,yto):
                # space is free, so we can move
                if action.move(pc, dx,dy):
                    rog.view_center_player()
            else:
                rog.alert("That space is occupied.")
        # end conditional
        
        # "attack" : (x, y, z,)
        if act == 'attack':
            _Update()
            xto,yto,zto=arg
            pos = world.component_for_entity(pc, cmp.Position)
            actor = world.component_for_entity(pc, cmp.Actor)

            # out of bounds
            if ( not rog.is_in_grid_x(xto) or not rog.is_in_grid_y(yto) ):
                return
            
            # fight if there is a monster present
            mon = rog.monat(xto,yto)
            # ... but don't attack yourself!
            if mon == pc:
                rog.alert("You can't fight yourself!")
                return
            
            if mon:
                action.fight(pc,mon)
            else:
                ent = rog.thingat(xto,yto)
                if ent:
                    action.fight(pc,ent)
                else:
                    rog.msg("You strike out at thin air, losing your balance.")
                    actor.ap = 0
                    rog.set_status(
                        pc, cmp.StatusOffBalance,
                        t=2, q=-MISS_BAL_PENALTY
                        )
        # end conditional

        # chat with closest speaking entity;
        #   if multiple good options, prompt for which one.
        if act == "chat-context":
            action.chat_context(pc)
            _Update()
            return
        if act == "change-pos": # change body position
            action.change_bodypos_pc(pc)
            _Update()
            return
        if act == "change-msp": # change speed of movement (walking, running, jogging, etc.)
            action.change_speed_pc(pc)
            _Update()
            return
        if act == "msp-up": # change from walk to powerwalk, to trot, jog, etc.
            action.speed_up_pc(pc)
            _Update()
            return
        if act == "msp-down": # change from sprint to run, to jog, to trot, etc.
            action.slow_down_pc(pc)
            _Update()
            return
        if act == "target-prompt": #target entity + fire / throw / attack
            action.target_pc_generic(pc)
            _Update()
            return
        if act == "get-prompt":
            action.pickup_pc(pc)
            _Update()
            return
        if act == "openclose-prompt": #open or close
            action.open_pc(pc)
            _Update()
            return
        if act == "open-prompt": #open or close
            action.open_pc(pc)
            _Update()
            return
        if act == "close-prompt": #open or close
            action.open_pc(pc)
            _Update()
            return
        if act == "jog": #begin jogging
            action.jog_pc(pc)
            _Update()
            return
        if act == "run": #begin running
            action.run_pc(pc)
            _Update()
            return
        if act == "sprint": #begin sprinting
            action.sprint_pc(pc)
            _Update()
            return

        #unused actions
        '''if act == "bomb":
            action.bomb_pc(pc)
            return'''
        
        #
        #
        # special actions #
        #
        
        if act == 'find player': #useful to immediately show where the player is
            pos = world.component_for_entity(pc, cmp.Position)
            rog.view_center_player()
            rog.update_game()
            rog.update_final()
            rog.game_update() #call all the updates
            rog.alert('press any key to continue...')
            rog.Input(rog.getx(pos.x), rog.gety(pos.y), mode='wait')
            rog.update_base()
            rog.alert('')
            return
        if act == "look":
            pos = world.component_for_entity(pc, cmp.Position)
            rog.routine_look(pos.x,pos.y)
            return
        if act == "move view":
            rog.routine_move_view()
            return
        if act == "fixed view":
            rog.fixedViewMode_toggle()
            return  
        if act == 'select':
            # TESTING
            print(rog.Input(0,0,20))
            return
        if act == 'exit':
            return
Esempio n. 14
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)
Esempio n. 15
0
def __init__Chargen():
    Chargen.pc = None # player character entity
    # points remaining
    Chargen.skillPts=SKILLPOINTS
    Chargen.attPts=ATTRIBUTEPOINTS
    Chargen.statPts=STATPOINTS
    Chargen.traitPts=CHARACTERPOINTS
    # pre-big menu data
    Chargen._name=""
    Chargen._genderName=""
    Chargen._gender=0
    Chargen._pronouns=()
    Chargen._cm=0
    Chargen._cmMult=0
    Chargen._kg=0
    Chargen._kgMult=0
    Chargen._type=''
    Chargen._classID=0
    Chargen._className=""
    Chargen._jobstats={}
    Chargen._jobskills={}
    Chargen._jobmoney=0
    Chargen._jobitems=()
    Chargen._jobkeys=''
    Chargen._jobmass=0
    Chargen.statsCompo=None
    Chargen.fearCompo=None
    Chargen.skillsCompo=None
    Chargen.flags=None
    # multipliers and characteristics (component indicators)
    Chargen.mreach=1
    Chargen.mmsp=1
    Chargen.mmass=1
    Chargen.mass=0
    Chargen.mcm=1
    Chargen.mbodyfat=1
    Chargen.bodyfat=0
    Chargen.mgut=1
    Chargen.mvision=1
    Chargen.astigmatism=False
    Chargen.cancer=False
    Chargen.rapidMetabolism=False
    Chargen.ironGut=False
    Chargen.immunePoison=False
    Chargen.immuneVenom=False
    Chargen.immunePain=False
    Chargen.hemophilia=False
    Chargen.hiv=False
    Chargen.hydrophobia=False
    Chargen.attractedMen=False
    Chargen.attractedWomen=False
    Chargen.fastLearner=False
    # menu dicts
    Chargen.menu={} # <- big meta-menu containing all choices
    Chargen.skilldict={}
##    _skilldict={} # used for getting the skill ID from the skill name
    Chargen.statdict={}
    Chargen.traitdict={}
    Chargen.attdict={}
    # selected data
    Chargen._skillIDs=[]
    Chargen._skillNames=[]
    Chargen._stats=[]
    Chargen._traits=[]
    Chargen._attributes=[]
    # menu states
    Chargen.confirm = False
    Chargen.open_skills=False
    Chargen.open_stats=False
    Chargen.open_traits=False
    Chargen.open_attributes=False
    # menu position / window size
    Chargen.x1 = 0; Chargen.y1 = 0;
    Chargen.xx = 0; Chargen.yy = 3;
    Chargen.iy = 0;
    Chargen.ww = rog.window_w(); Chargen.hh = 5;