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()
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
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
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
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
def u(self): l = [] if self.spell: l.append(uT("Spell: {}".format(self.spell.name))) elif self.is_open(): l.append(uT("Spell: -------")) else: l.append(uT("Spell: XXXXXXX")) if self.opened: l.append(uT("Opened Breach")) return uA(uF(uP(l),'top'),'opened') else: l.append(uB("Open: {} Ae".format(self.costOpen), self.open_)) l.append(uB("Turn: {} Ae".format(self.costTurn), self.turn_)) return uPad(uF(uP(l),'top'),left=1,right=1)