Example #1
0
 def reinit(self, includeFlags=6):
     Power.reinit(self, includeFlags)
     #	-----------------------------------
     #	Initialize the transient parameters
     #	-----------------------------------
     if includeFlags & 5:
         self.list, self.notes = {'SOONER': [], 'LATER': []}, {}
Example #2
0
	def reinit(self, includeFlags = 6):
		Power.reinit(self, includeFlags)
		#	-----------------------------------
		#	Initialize the transient parameters
		#	-----------------------------------
		if includeFlags & 5:
			self.list, self.notes = {'SOONER': [], 'LATER': []}, {}
Example #3
0
	def reinit(self, includeFlags = 6):
		Power.reinit(self, includeFlags)
		#	-----------------------------------
		#	Initialize the transient parameters
		#	-----------------------------------
		if includeFlags & 5:
			self.orders = {}
Example #4
0
	def initialize(self, game):
		Power.initialize(self, game)
		if 'VASSAL_DUMMIES' in game.rules and self.isDummy(): return
		victory = game.victory[0]
		if self.abbrev:
			if 'ZEROSUM' in game.rules: self.funds['+'] = 10 * len(self.centers)
			self.balance = (self.income(len(self.centers))
						or (victory >> 1) * len(self.units))
			self.initAccept()
		elif self.type == 'INVESTOR': self.balance = 0
Example #5
0
	def __repr__(self):
		text = Power.__repr__(self).decode('latin-1')
		if self.elect:
			text += 'ELECT %s\n' % ' '.join(map(':'.join, self.elect.items()))
		for power in self.sent: text += 'SENT %s\n' % power
		if self.accept and not self.isEliminated(False, True):
			text += 'ACCEPT %s\n' % self.accept
		if self.state: text += 'STATE %s\n' % self.state
		for offer in self.sheet: text += '%s\n' % offer
		return text.encode('latin-1')
Example #6
0
	def isEliminated(self, public = False, personal = False):
		if not Power.isEliminated(self, public, personal): return False
		if not (self.homes and self.game.phase == 'M' and
			'GARRISON' in self.game.rules): return True
		save = next = self.game.phase
		while next not in 'AM':
			self.game.phase = self.game.findNextPhase()
			next = self.game.phase.split()[-1][0]
		self.game.phase = save
		return next != 'A'
Example #7
0
 def isEliminated(self, public=False, personal=False):
     if not Power.isEliminated(self, public, personal): return False
     if not (self.homes and self.game.phase == 'M'
             and 'GARRISON' in self.game.rules):
         return True
     save = next = self.game.phase
     while next not in 'AM':
         self.game.phase = self.game.findNextPhase()
         next = self.game.phase.split()[-1][0]
     self.game.phase = save
     return next != 'A'
Example #8
0
	def reinit(self, includeFlags = 6):
		Power.reinit(self, includeFlags)
		#	-----------------------------------
		#	Initialize the transient parameters
		#	-----------------------------------
		if includeFlags & 4:
			self.overpaid, self.offers, self.sent = 0, [], []
			self.accept = self.fullAccept = None
		if includeFlags & 5:
			self.sheet = []
		self.liquid = self.left = None
		#	----------------------------------------------
		#	The two attributes below are ZeroSum-specific
		#	----------------------------------------------
		self.gained, self.lost = [], []
		#	-------------------------------------------
		#	And here are two that are Exchange-specific
		#	-------------------------------------------
		if includeFlags & 4:
			self.elect, self.state = {}, ''
Example #9
0
	def __repr__(self):
		text = Power.__repr__(self).decode('latin-1')
		if self.orders: text += 'ORDERS\n'
		for unit, order in self.orders.items():
			#	-----------------------------
			#	Handle "REORDER", "INVALID",
			#	and "ORDER" (NO_CHECK) orders
			#	-----------------------------
			if unit[0] not in 'RIO': text += unit + ' '
			text += order + '\n'
		return text.encode('latin-1')
Example #10
0
 def __repr__(self):
     text = Power.__repr__(self).decode('latin-1')
     for listName, orders in self.list.items():
         if orders: text += '%s\n%s\n' % (listName, '\n'.join(orders))
     return text.encode('latin-1')
Example #11
0
 def __init__(self, game, name, type=None):
     Power.__init__(self, game, name, type)
Example #12
0
	def isEliminated(self, public = False, personal = False):
		return (personal or not self.balance) and Power.isEliminated(
			self, public, personal)
Example #13
0
	def resign(self, gmResign = 0):
		if not self.centers: self.balance = 0
		Power.resign(self, gmResign)
Example #14
0
	def __repr__(self):
		text = Power.__repr__(self).decode('latin-1')
		for listName, orders in self.list.items():
			if orders: text += '%s\n%s\n' % (listName, '\n'.join(orders))
		return text.encode('latin-1')
Example #15
0
	def __init__(self, game, name, type = None):
		Power.__init__(self, game, name, type)