Пример #1
0
 def fetched(self, response):
     d = Deferred()
     response.deliverBody(BodyReturner(d, verbose=self.verbose))
     d.addCallback(json.loads)
     if self.verbose or self.debug:
         d.addBoth(self.logLoaded)
     return d.addCallback(IDrawingEngine(self).update)
Пример #2
0
    def update(self, data):
        data = data['data']
        self.games = data
        engine = IDrawingEngine(self)
        for cnt, game in enumerate(data):
            engine.screen.addstr(2 + cnt, 5, game)

        engine.screen.refresh()
        # move the cursor to the player
        curses.setsyx(engine.y, engine.x)
        curses.doupdate()
Пример #3
0
    def update(self, data):
        self.games = data['data']
        engine = IDrawingEngine(self)
        engine.screen.clear()
        engine.screen.addstr(0, 3,
                             "name: %(you)s - score: %(your_score)s" % data)
        for cnt, game in enumerate(self.games):
            engine.screen.addstr(2 + cnt, 5, game)

        engine.screen.refresh()
        # move the cursor to the player
        curses.setsyx(engine.y, engine.x)
        curses.doupdate()
Пример #4
0
 def doMoves(self):
     engine = IDrawingEngine(self)
     c = engine.window.getch()
     if   c == ord('q'): reactor.stop()
     elif c == ord('h'): engine.x -= 1
     elif c == ord('j'): engine.y += 1
     elif c == ord('k'): engine.y -= 1
     elif c == ord('l'): engine.x += 1
     elif c == ord('y'):
             engine.y -= 1
             engine.x -= 1
     elif c == ord('u'):
             engine.y -= 1
             engine.x += 1
     elif c == ord('b'):
             engine.y += 1
             engine.x -= 1
     elif c == ord('n'):
             engine.y += 1
             engine.x += 1
     return c
Пример #5
0
    def update(self, data):
        data = data['data']
        if 'map' in data:
            self.init_map(data['map'])
            self.walk = data['walk']
        if not self.world:
            return
        engine = IDrawingEngine(self)
        engine.screen.clear()
        for cnt, line in enumerate(self.world):
            engine.screen.addstr(cnt, 0, line)

        for tow in data['towers']:
            y, x = tow['x'], tow['y']
            engine.screen.addstr(y, x, 'O')

        for ene in data['enemies']:
            x, y = self.pos_to_coord(ene['pos'], self.walk)
            engine.screen.addstr(y, x, 'X')

        engine.screen.refresh()
        # move the cursor to the player
        curses.setsyx(engine.y, engine.x)
        curses.doupdate()
Пример #6
0
 def handle(self):
     c = self.doMoves()
     if c == ord(' '):
         engine = IDrawingEngine(self)
         coords = "%s,%s" % (engine.y, engine.x)
         IWebWorld(self).update({'place': coords})
Пример #7
0
 def handle(self):
     c = self.doMoves()
     y = IDrawingEngine(self).y
     if c == ord(' ') and y - 2 < len(self.games):
         IWebWorld(self).update({'game': self.games[y - 2]})