Example #1
0
 def restrict_pos(self):
     x1 = rog.view_port_x()
     x2 = x1 + rog.view_w() - 1
     y1 = rog.view_port_y()
     y2 = y1 + rog.view_h() - 1
     self.x = maths.restrict(self.x, x1, x2)
     self.y = maths.restrict(self.y, y1, y2)
Example #2
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.")
Example #3
0
 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()
Example #4
0
def dialogue(ent:int, style=0):
    ''' wrapper dialogue function
        Greet, introduce self if first time meeting,
        Then choose a dialogue type and execute the dialogue.
    '''
    world=rog.world()
    if not world.has_component(ent,cmp.Speaks):
        return False
    dispcompo=world.component_for_entity(ent,cmp.Disposition)
    personality=world.component_for_entity(ent,cmp.Personality).personality
    entn = world.component_for_entity(ent,cmp.Name)

    # greetings / rejections
    reaction = greet(ent, style=style)
    dispcompo.disposition += reaction
    if reaction < 0: # refuse to chat
        rejection(ent, personality, dispcompo.disposition, style=style)
        return False
    
        # introductions
    if not world.has_component(ent,cmp.Introduced):
        response,success = talk_introduce(
            ent,personality,dispcompo.disposition,style=style)
    else:
        # greet (haven't seen you in a bit)
        # TODO: once they've greeted you, add Greeted component
        #   then they no longer say anything when you press the
        #   chat key on them. Greeted component could be a status
        #   that wears off in an hour or so.
        response,success = talk_greeting(
            ent,personality,dispcompo.disposition,style=style)
    say(ent, response)
    
    # dialogue menu
    menu={"*" : "goodbye"}
    _menu={}
    for k,v in PERSUASION.items():
        if k==TALK_GREETING: continue
        menu[v[0]] = v[1]
        _menu[v[1]] = k
    opt = rog.menu(
        "{}{}".format(TITLES[entn.title],entn.name),
        rog.view_port_x(),rog.view_port_y(),
        menu,
        autoItemize=False
        )
    if opt==-1:
        return False
    if opt=="goodbye":
        return False
    result = _menu[opt]
    
    # perceived value for use by _talk function
    value = 0
    if result==TALK_ASKFAVOR:
        # TODO: implement favor dialogue menu
        value,npc_offer = _ask_favor(ent)
    elif result==TALK_BARTER:
        # TODO: implement trading dialogue menu
        value,pc_offer,npc_offer = _get_trade(ent)
    elif result==TALK_BRIBERY:
        type_gift,val = _get_gift_for(ent)
        if type_gift=="money": # val is a quantity of $
            value = val//MULT_VALUE
        elif type_gift=="item": # val is an item
            value = rog.get_value(val)
    
    # execute the dialogue
    response,success = _FUNCS[result](
        ent, personality, dispcompo.disposition,
        value=value, style=style
        )
    say(ent,response,result,success)
    return True
Example #5
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.")