コード例 #1
0
    def basicInput(self, key):
        """

        :param key:
        :return:
        """

        if str(key) in ("Q", "q"):
            raise urwid.ExitMainLoop()
        elif str(key) in ("lL"):
            if isinstance(self.loop.widget, uC):
                self.loop.widget = urwid.Overlay(uLineB(w.log, title="Log"), w.u(),
                                                 "center", ('relative', 60),
                                                 "middle", ('relative', 60))
                return
            else:
                self.redraw()
        elif str(key) in ("A"):
            self.activePlayer.end_turn()
            self.next_turn()
        elif self.activePlayer != self.monster:
            if str(key) in ("12345"):
                self.activePlayer.buy_(None, w.buyzone[int(key) - 1])
            elif str(key) in ("zZ"):
                self.activePlayer.buyCharge_(None)
            elif str(key) in ("abcde"):
                idx = ord(key) - 97
                if idx < len(self.activePlayer.phand):
                    self.activePlayer.play_(None, idx)
                else:
                    log("No hay carta {}".format(idx+1))
        else:
            return
コード例 #2
0
 def u(self):
     cb = uC([ b.u() for b in self.breaches ])
     i = uLB(urwid.SimpleFocusListWalker([
                        uT("Name: {}".format(self.name)),
                        uT("Life: {}".format(self.life)),
                        uT("Aether: {}".format(self.aether)),
                        uT("Charges: {}/{}  Cost: {}".format(self.charges, self.maxCharges, self.costCharges)),
                        uT("Action: {}".format(self.action)),
                        uT("Deck: {} cards".format(len(self.pdeck)))
                         ])
     )
     p1 = uP([self.playZone.u(), self.phand.u(self.play_)])
     cp = uC([("weight", 3, p1),
              ("weight", 1, uLineB(self.pdiscard.u_narrow(), title="{} cards".format(len(self.pdiscard))))])
     p = uLineB(uA(uP([(5 , cb), ("weight", 1, i), ("weight", 2, cp)]),"default"), title=self.name)
     return p
コード例 #3
0
 def u(self):
     mc = uC([
         ('weight',2,uT(str(self.world.turn_order))),
         ('weight', 10, uP([(500,self.deck.u())])),
         urwid.Padding(urwid.BigText(str(self.life), urwid.font.HalfBlock5x4Font()), 'right', width='clip',right=1),
     ])
     m = uLineB(uA(uF(mc),'default'), title=self.name)
     return m
コード例 #4
0
 def main(self):
     palette = [
         ('banner', 'black', 'light gray'),
         ('default', 'default', 'default'),
         ('active', 'yellow', 'default'),
         ('opened', 'black', 'yellow'), ]
     lb = uA(uLB([uB("New Game", self.newGame)]),"default")
     menu = uA(uLineB(lb),"active")
     bg = urwid.SolidFill('\N{MEDIUM SHADE}')
     self.loop = urwid.MainLoop(urwid.Overlay(menu, bg , "center", ('relative', 60), "middle", ('relative', 60)), palette,unhandled_input=self.basicInput)
     self.loop.run()
コード例 #5
0
    def u(self):
        lb, lp = [], []
        for idx, d in enumerate(self.buyzone):
            if len(d) == 0:
                lb.append(uT("{} - Empty".format(idx)))
            else:
                tipus = d[0]
                lb.append(uT(
                    "{} -> ({}) Cost: {} -- Name: {} -- Action: {}".format(idx + 1, len(d), tipus.cost, tipus.name,
                                                                           tipus.action.txt)))
        for p in self.players:
            lp.append(uA(p.u(),"active") if self.activePlayer == p else p.u())

        lBuy = uF(uT("NO BUY DECKS"),'middle') if len(lb) == 0 else uLB(lb)
        cPlayers = uF(uT("NO PLAYERS"),'middle') if len(lp) == 0 else uC(lp)
        bMonster = uF(uT("NO MONSTER"),'middle') if w.monster is None else (uA(w.monster.u(),'active') if w.monster == self.activePlayer else w.monster.u())

        full = uP([("weight", 1, bMonster), (10, lBuy), ("weight", 2, uLineB(cPlayers,title="Gravehold: {}".format(self.gravehold)))])
        p = uC([("weight", 4, full), ("weight", 1, w.log)])
        return p
コード例 #6
0
 def popup(self, choices, f, title = None, create=None, extra_params=None):
     """
     :param choices: choices for the popup
     :param f: function to execute when a choice is clicked
     :param title: title for the popup
     :param create: True if during creation phase
     :return: True
     """
     l = []
     for idx, c in enumerate(choices):
         #urwid.connect_signal(button, "click", f, idx)
         if extra_params is not None:
             l.append(uA(uB(str(c), f, (idx, extra_params)), None, focus_map="reversed"))
         else:
             l.append(uA(uB(str(c),f,idx), None, focus_map="reversed"))
     lb = uLineB(uLB(urwid.SimpleFocusListWalker(l)),title=title)
     if create:
         self.loop.widget = urwid.Overlay(lb, urwid.SolidFill('\N{MEDIUM SHADE}'), "center", ('relative', 60),
                                          "middle", ('relative', 60))
     else:
         self.loop.widget = urwid.Overlay(lb, w.u(), "center", ('relative', 60), "middle", ('relative', 60))
     return