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 close(self): super(Manager_PrintScroll, self).close() self.consoles_delete() rog.update_final()
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