def eval(self): self.status.StatusPrompt() self.prompt = Term.format('\n\n[cg1[cc: Attack \n[cg2[cc: Wait\n[cg3[cc: Improve Agriculture\n[cg4[cc: Information\n[cg5[cc: Train\n') choice = super(RootMenu, self).eval(self.choiceList, self.prompt) Term.clear() if choice is not False: choice() else: Term.clear() self.eval()
def selectBorder(self, Loyal=None, location=None): if location != None: self.location = location list = {} length = self.location.borders.__len__() prompt = 'Choose a bordering territory: [cg(1-{0})[cc\n'.format(length) if Loyal is None: for i in range(length): list[str(i)] = self.core.territories[self.location.borders[i]] elif type(Loyal) is type(False): x = 0 for i in range(length): if self.core.territories[self.location.borders[i]].checkLoyalty(self.player) == Loyal: x += 1 list[str(x)] = self.core.territories[self.location.borders[i]] prompt += Term.format("\n[cg{0}[cc: [cb{1}[cc".format(str(x), list[str(x)].name)) if list.__len__() is 0: return False prompt += '\n' prompt = Term.format(prompt) return self.eval(list, prompt)
def eval(self, choices, prompt): try: Input = raw_input(Term.format(prompt)) if Input is '0' or Input is '': return False choice = choices[Input] return choice except KeyError: Term.fprint('[crThat is not a valid choice.[cc\n') del Input return Menu.eval(self, choices, prompt) except: print 'What? {0}'.format(sys.exc_info()[0]) sys.exit() return False
def selectGeneral(self, Loyal=True, location=None): if location is not None: self.location = location list = {} x = 0 prompt = 'Choose a general from the following list: [cg(1-{0})[cc\n'.format(self.location.generals.__len__()) for i in range(self.location.generals.__len__()): if self.location.generals[i].checkLoyalty(self.player) or not Loyal: x += 1 list[str(x)] = self.location.generals[i] prompt += '[cg' + str(x) + '[cc: [cb' + list[str(x)].name + ' [cr(' + str(list[str(x)].strength) + ')[cc\n' prompt += '\n' prompt = Term.format(prompt) input = self.eval(list, prompt) if not input: return False return input