def close(self): super(Manager_Look, self).close() if (self.result and not self.result == "exit"): x, y = self.result rog.look_identify_at(x, y) rog.alert(rog.identity(items))
def drop_pc(pc,item): rog.alert("Place {i} where?{d}".format(d=dirStr,i=item.name)) args=rog.get_direction() if not args: return dx,dy,dz=args if not drop(pc, item): rog.alert("You can't put that there!")
def open_pc(pc): rog.alert("Open what?{d}".format(d=dirStr)) args=rog.get_direction() if not args: return dx,dy,dz=args xto=pc.x+dx yto=pc.y+dy if not openClose(pc, xto, yto): rog.alert("It won't open.")
def inventory_pc(pc,pcInv): if not pc.inv: rog.alert(ALERT_EMPTYCONTAINER) return x=0 y=rog.view_port_y() # items menu item=rog.menu("{}'s Inventory".format(pc.name), x,y, pcInv.items) # viewing an item if not item == -1: keysItems={} # get available actions for this item... if rog.on(item,CANEAT): keysItems.update({"E":"Eat"}) if rog.on(item,CANQUAFF): keysItems.update({"q":"quaff"}) if rog.on(item,CANEQUIP): keysItems.update({"e":"equip"}) if rog.on(item,CANUSE): keysItems.update({"u":"use"}) if rog.on(item,CANOPEN): keysItems.update({"o":"open"}) keysItems.update({"x":"examine"}) keysItems.update({"d":"drop"}) keysItems.update({"t":"throw"}) # opt=rog.menu( "{}".format(item.name), x,y, keysItems, autoItemize=False ) #print(opt) if opt == -1: return opt=opt.lower() rmg=False if opt == "drop": rmg=True; drop_pc(pc,item) elif opt == "equip": rmg=True; equip_pc(pc,item) elif opt == "eat": rmg=True; eat_pc(pc, item) elif opt == "quaff": rmg=True; quaff_pc(pc, item) elif opt == "use": rmg=True; use_pc(pc, item) elif opt == "examine": rmg=True; examine_pc(pc, item) if rmg: rog.drain(pc, 'nrg', NRG_RUMMAGE)
def say(ent:int, string:str, ttype=-1, success=False, ): ''' converse with an entity and msg out that entity's response ''' # TODO: elapse time while talking as interruptable delayed action # temporary: just do a one-time AP cost for each thing said rog.spendAP(rog.pc(), NRG_TALK) rog.spendAP(ent, NRG_TALK) if ttype==-1: message = "{}: {}".format(rog.getname(ent), string) else: talk_string = PERSUASION[ttype][1] success_string = "success" if success else "failure" disposition = get_effective_disposition( ent, rog.get_disposition(ent)) message = "<{} {}> {}: {} Disposition: {} / {}".format( talk_string, success_string, rog.getname(ent), string, disposition//10, MAX_DISPOSITION//10 ) rog.alert(message) # just in case it doesn't get displayed right away. rog.msg(message)
def towel_pc(pc, item): options={} options.update({"W" : "wrap around"}) options.update({"l" : "lie"}) options.update({"s" : "sail"}) options.update({"w" : "wield"}) options.update({"h" : "wear on head"}) options.update({"x" : "wave"}) options.update({"d" : "dry"}) choice=rog.menu("use towel",0,0,options,autoItemize=False) if choice == "wear on head": pass elif choice == "wrap around": dirTo=rog.get_direction() if not args: return dx,dy,dz=args xto = pc.x + dx; yto = pc.y + dy; if (dx==0 and dy==0 and dz==0): pass #wrap around self elif choice == "wield": if rog.on(item, WET): pass #equip it else: rog.alert("You can't wield a towel that isn't wet!") elif choice == "dry": #itSeemsCleanEnough=... if ( itSeemsCleanEnough and not rog.on(item, WET) ): pass #dry self else: if not itSeemsCleanEnough: rog.alert("It doesn't seem clean enough.") elif rog.on(item, WET): rog.alert("It's too wet.")
def splash(self): rog.alert(self.message)
def commands(pc, pcAct): world = rog.world() for act, arg in pcAct: rog.update_base() # actions that take multiple turns busyTask = rog.occupations(pc) if busyTask: if not rog.occupation_elapse_turn(pc): # interrupted ## rog.Input("") pass #----------------# # convert action # #----------------# if act == 'target': 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) 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 == 'move': 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 # fight if there is a monster present mon = rog.monat(xto, yto) if (mon and mon is not 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() if act == "get": action.pickup_pc(pc) return if act == "open": #open or close action.open_pc(pc) return if act == "sprint": #begin sprinting action.sprint_pc(pc) return if act == "throw": #throw an object action.throw_pc(pc) 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.update_base() 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
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.")
def sprint_pc(pc): #if sprint cooldown elapsed if not rog.on(pc, TIRED): sprint(pc) else: rog.alert("You're too tired to sprint.")
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.")
def close(self): super(Manager_Look, self).close() if (self.result and not self.result == "exit"): x,y = self.result rog.alert( rog.identify_symbol_at(x,y) )
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