def validateStatus(self): for power in [x for x in self.powers if x.orders]: # ------------------------------------------------------- # Make sure all units are ordered (in non-NO_CHECK games) # ------------------------------------------------------- if 'DEFAULT_UNORDERED' not in self.rules: [self.error.append( 'UNIT LEFT UNORDERED: %s, ' % power.name + unit) for unit in power.units if unit not in power.orders] for unit, order in power.orders.items(): # ----------------------------------------------------- # Convert NO_CHECK "ORDER"s to "INVALID" as appropriate # ----------------------------------------------------- if unit[:5] == 'ORDER': word = self.expandOrder(order.split()) word = self.addUnitTypes(word) word = self.map.defaultCoast(word) valid = self.validOrder(power, ' '.join(word[:2]), ' '.join(word[2:]), report=0) if not valid: power.orders['INVALID ' + unit[6:]] = order del power.orders[unit] # ------------------------------------------------------- # Non-NO_CHECK. Validate the order and report all errors # ------------------------------------------------------- else: valid = self.validOrder(power, unit, order) if valid == -1 and not order.endswith(' ?'): power.orders[unit] += ' ?' elif valid == 1 and order.endswith(' ?'): power.orders[unit] = power.orders[unit][:-2] # ------------------------------------------------------------- # Go validate the rest of the data read in from the status file # ------------------------------------------------------------- Game.validateStatus(self)
def validateStatus(self): sizes = [len(x.centers) for x in self.powers if x.centers] if sizes: self.smallest, self.largest = min(sizes), max(sizes) for rule in ['NO_CHECK']: if rule in self.rules: self.error += [rule + ' RULE IS INVALID IN CRYSTAL BALL'] Game.validateStatus(self)
def validateStatus(self): for power in [x for x in self.powers if x.orders]: # ------------------------------------------------------- # Make sure all units are ordered (in non-NO_CHECK games) # ------------------------------------------------------- if 'DEFAULT_UNORDERED' not in self.rules: [self.error.append( 'UNIT LEFT UNORDERED: %s, ' % power.name + unit) for unit in power.units if unit not in power.orders] for unit, order in power.orders.items(): # ----------------------------------------------------- # Convert NO_CHECK "ORDER"s to "INVALID" as appropriate # ----------------------------------------------------- if unit[:5] == 'ORDER': word = self.expandOrder(order.split()) word = self.addUnitTypes(word) word = self.map.defaultCoast(word) if not self.validOrder(power, ' '.join(word[:2]), ' '.join(word[2:]), report=0): power.orders['INVALID ' + unit[6:]] = order del power.orders[unit] # ------------------------------------------------------- # Non-NO_CHECK. Validate the order and report all errors # ------------------------------------------------------- else: self.validOrder(power, unit, order) # ------------------------------------------------------------- # Go validate the rest of the data read in from the status file # ------------------------------------------------------------- Game.validateStatus(self)
def validateStatus(self): # ------------------------------------------------------------ # Parsing offers needs to be done after all powers are loaded, # thus not in finishPowerData(), because it checks whether an # ordered unit has an owner. # ------------------------------------------------------------ for power in self.powers: for offer in power.sheet: self.parseOffer(power, offer) self.validateOffers(power) self.map = self.map or Map.Map() # ------------------------------------------------- # If the map's flow already holds any INCOME phase, # leave it alone. Otherwise, add a single INCOME # phase into the flow after the first ADJUSTMENTS. # ------------------------------------------------- if self.map.flow: for item in [x.split(':')[1] for x in self.map.flow]: if 'INCOME' in item.split(','): break else: for flow, item in enumerate(self.map.flow): if 'ADJUSTMENTS' in item.split(':')[1].split(','): self.map.flow[flow] = item.replace( 'ADJUSTMENTS', 'ADJUSTMENTS,INCOME') break (where, what) = [(x+1,y) for (x,y) in enumerate(self.map.seq) if y.endswith('ADJUSTMENTS')][0] self.map.seq.insert(where, what.replace('ADJUSTMENTS','INCOME')) if self.rotate: self.error += ['CONTROL ROTATION IS INVALID IN PAYOLA'] self.error += [rule + ' RULE IS INVALID IN PAYOLA' for rule in ('PROXY_OK', 'NO_CHECK') if rule in self.rules] for power in self.powers: if power.centers: if type(power.accept) not in (str, unicode): power.initAccept() else: self.checkAccept(power) if power.balance is None and not power.isEliminated(False, True): self.error += ['NO BALANCE FOR ' + power.name] # for subvar in ('ZEROSUM', 'EXCHANGE', 'FLAT_TAX'): # if subvar in self.rules: # self.variant = subvar.lower() + ' ' + self.variant Game.validateStatus(self)