Example #1
0
 def __init__(self, host=None, port=None, commander_name=None, bot_name=None, to_bot_q=None, to_gui_q=None):
     self._to_bot = DummyQueue() if to_bot_q is None else to_bot_q
     self._to_gui = DummyQueue() if to_gui_q is None else to_gui_q
     self.to_gui("name", bot_name)
     self.server_host = host
     self.server_port = port
     self.commander = Commander(commander_name)
     # Users who can give the bot non-administrative commands
     self.managers = set(config.MANAGERS)  # names as given from server
     self.chat = Chat(self)
     self.bot = BotEntity(self, bot_name)
     self.inventories = inventory.Inventories(self.bot)
     self.stats = Statistics()
     self.game_ticks = 0
     self.connected = False
     self.logged_in = False
     self.protocol = None
     self.factory = None
     self.entities = None
     self.grid = None
     self.sign_waypoints = None
     self.dimension = None
     self.dimensions = [Dimension(self), Dimension(self), Dimension(self)]
     self.spawn_position = None
     self.game_mode = None
     self.difficulty = None
     self.players = defaultdict(int)
     self.last_tick_time = datetime.now()
     self.period_time_estimation = config.TIME_STEP
     utils.do_later(config.TIME_STEP, self.tick)
     self.shutdown_reason = ""
Example #2
0
 def __init__(self, host=None, port=None, commander_name=None, bot_name=None):
     self.server_host = host
     self.server_port = port
     self.config = config
     self.eventregister = EventRegister(self)
     self.eventregister.setup()
     self.commander = Commander(commander_name)
     self.chat = Chat(self)
     self.stats = Statistics()
     self.bot = BotEntity(self, bot_name)
     self.game_ticks = 0
     self.connected = False
     self.logged_in = False
     self.protocol = None
     self.factory = None
     self.entities = None
     self.inventories = inventory.InvetoryContainer(self)
     self.grid = None
     self.sign_waypoints = None
     self.dimension = None
     self.dimensions = [Dimension(self), Dimension(self), Dimension(self)]
     self.spawn_position = None
     self.game_mode = None
     self.difficulty = None
     self.players = defaultdict(int)
     self.last_tick_time = datetime.now()
     self.period_time_estimation = config.TIME_STEP
     utils.do_later(config.TIME_STEP, self.tick)
Example #3
0
 def tick(self):
     tick_start = datetime.now()
     if self.logged_in:
         self.bot.tick()
         self.chat.tick()
         self.every_n_ticks()
     utils.do_later(self.predict_next_ticktime(tick_start), self.tick)
Example #4
0
 def __init__(self,
              host=None,
              port=None,
              commander_name=None,
              bot_name=None):
     self.server_host = host
     self.server_port = port
     self.config = config
     self.eventregister = EventRegister(self)
     self.eventregister.setup()
     self.commander = Commander(commander_name)
     self.chat = Chat(self)
     self.stats = Statistics()
     self.bot = BotEntity(self, bot_name)
     self.game_ticks = 0
     self.connected = False
     self.logged_in = False
     self.protocol = None
     self.factory = None
     self.entities = None
     self.inventories = inventory.InvetoryContainer(self)
     self.grid = None
     self.sign_waypoints = None
     self.dimension = None
     self.dimensions = [Dimension(self), Dimension(self), Dimension(self)]
     self.spawn_position = None
     self.game_mode = None
     self.difficulty = None
     self.players = defaultdict(int)
     self.last_tick_time = datetime.now()
     self.period_time_estimation = config.TIME_STEP
     utils.do_later(config.TIME_STEP, self.tick)
Example #5
0
 def tick(self):
     tick_start = datetime.now()
     if self.logged_in:
         self.bot.tick()
         self.chat.tick()
         self.every_n_ticks()
         self.game_ticks += 1
     utils.do_later(self.predict_next_ticktime(tick_start), self.tick)
Example #6
0
 def __init__(self,**kwargs):
     '''initialize.
     
     when function '__init__' called by it,
     App.get_running_app().root is None.
     so we have to use App.root widget later.
     by calling function '_initialize'
     '''
     super(DraggableNode,self).__init__(**kwargs)
     utils.do_later(self._initialize,dt=-1)
Example #7
0
 def online_auth(self):
     if config.ONLINE_LOGIN:
         log.msg('doing online login')
         url = "http://login.minecraft.net/?user=%s&password=%s&version=1337" % (config.EMAIL, config.PASSWORD)
         response = yield getPage(url).addErrback(logbot.exit_on_error)
         log.msg("responce from http://login.minecraft.net: %s" % response)
         if ":" not in response:  # TODO well this is blunt approach, should use code with http code check
             self.clean_to_connect = False
             reactor.stop()
         else:
             _, _, self.case_username, self.session_id, _ = response.split(':')
             utils.do_later(10, self.keep_alive)
Example #8
0
    def _update(self,dt):
        '''update.
        if self is out of toolbox,
        remove self from toolbox.

        Args: 
            dt (float): interval of clock event.
        '''
        if (not self.updated) and self.y + self.height < self._old_pos[1]:
            
            utils.do_later(self.toolbox.update_toolbox,self,self._index)
            self.updated = True
            self.updating.cancel()
Example #9
0
 def online_auth(self):
     log.msg('doing online login')
     url = "http://login.minecraft.net/?user=%s&password=%s&version=1337" % (config.EMAIL, config.PASSWORD)
     response = yield getPage(url).addErrback(logbot.exit_on_error)
     log.msg("responce from http://login.minecraft.net: %s" % response)
     if ":" not in response:  # TODO well this is blunt approach, should use code with http code check
         self.clean_to_connect = False
         log.msg("did not authenticate with mojang, quiting")
         reactor.stop()
     else:
         _, _, config.USERNAME, self.session_id, _ = response.split(':')
         log.msg("my username according to Minecraft is %s" % config.USERNAME)
         utils.do_later(10, self.keep_alive)
Example #10
0
 def online_auth(self):
     log.msg('doing online login')
     url = "http://login.minecraft.net/?user=%s&password=%s&version=1337" % (
         config.EMAIL, config.PASSWORD)
     response = yield getPage(url).addErrback(logbot.exit_on_error)
     log.msg("responce from http://login.minecraft.net: %s" % response)
     if ":" not in response:  # TODO well this is blunt approach, should use code with http code check
         self.clean_to_connect = False
         log.msg("did not authenticate with mojang, quiting")
         reactor.stop()
     else:
         _, _, config.USERNAME, self.session_id, _ = response.split(':')
         log.msg("my username according to Minecraft is %s" %
                 config.USERNAME)
         utils.do_later(10, self.keep_alive)
Example #11
0
 def __init__(self,**kwargs):
     '''initialize.
     
     when function '__init__' called by it,
     App.get_running_app().root is None.
     so we have to use App.root widget later.
     by calling function '_initialize'
     '''
     super(Draggable,self).__init__(**kwargs)
     self.cancel = False
     self.updated = False
     self.drag_distance = 0
     app = App.get_running_app()
     self.toolbox = app.toolbox
     self.drag_manager = app.drag_manager
     self.field = app.field
     utils.do_later(self._initialize)
Example #12
0
    def _on_text(self,_,text):

        if text != str(self.default):
            result = self.exec(text)
            if result[1] == 'success':
                try:
                    self.field.add_property(self.widget,self.property_object.name)
                    setattr(
                        self.widget.owned_widget,
                        self.property_object.name,
                        result[0]
                        )
                    self.widget.attach_texture()
                except:
                    pass
            else:
                pass
            utils.do_later(self.widget.attach_texture,dt=1)
Example #13
0
    def on_touch_up(self,touch):
        '''callback of touch up.

        append self to Field object.
        arange position in close widget.
        '''
        self.append_widget()
        self.scaling = False

        if self.collide_point(*touch.pos):
            self.drag_manager.guide(self)
            if self.owned_widget_texture is None and self.updated:
                self.text = ''
                utils.do_later(self.attach_texture)
            if not self.updated:
                self.pos = self._old_pos

        return super(Draggable,self).on_touch_up(touch)
Example #14
0
 def on_death(self):
     log.msg("I am dead")
     self.i_am_dead = True
     utils.do_later(2.0, self.do_respawn)
Example #15
0
    def add_node(self,node,parent=None):

        utils.do_later(self.notify,-1)
        return super(RelationTreeView,self).add_node(node,parent)
Example #16
0
    def on_property_object(self,_,prop):

        if prop is not None:
            utils.do_later(self._on_property_object,_,prop,dt=1)
Example #17
0
 def keep_alive(self):
     log.msg('keep alive to https://login.minecraft.net')
     url = "https://login.minecraft.net/session?name=%s&session=%s" % (config.USERNAME, self.session_id)
     yield getPage(url)
     utils.do_later(config.KEEP_ALIVE_PERIOD, self.keep_alive)
Example #18
0
 def keep_alive(self):
     log.msg('keep alive to https://login.minecraft.net')
     url = "https://login.minecraft.net/session?name=%s&session=%s" % (
         config.USERNAME, self.session_id)
     yield getPage(url)
     utils.do_later(config.KEEP_ALIVE_PERIOD, self.keep_alive)