Ejemplo n.º 1
0
 def select(self):
     self.set_result(rog.monat(rog.mapx(self.x), rog.mapy(self.y)))
Ejemplo n.º 2
0
 def select(self):
     self.set_result((
         rog.mapx(self.x),
         rog.mapy(self.y),
     ))
Ejemplo n.º 3
0
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