def addCrystal(self, color): assert color.isBasic if self.crystals[color] < 3: self.match.stack.push(stack.Call(self._addCrystal, color), stack.Call(self._removeCrystal, color)) else: self.addToken(color)
def setTerrainCost(self, terrain, cost): """Set the movement cost of the given terrain to *cost*. If *cost* is None, the terrain will not be passable.""" self.match.stack.push( stack.Call(self._setTerrainCost, terrain, cost), stack.Call(self._setTerrainCost, terrain, self.terrainCosts.get(terrain)))
def add(self, id, title, method): if id in (action.id for action in self._list): return i = 0 while i < len(self._list) and self._list[i].title < title: i += 1 action = Action(id, title, method) self.match.stack.push(stack.Call(self._insert, i, action), stack.Call(self._remove, action))
def removeSite(self, site): self.match.stack.push(stack.Call(self._removeSite, site), stack.Call(self._addSite, site))
def setOwner(self, site, player): if site.owner != player: self.match.stack.push(stack.Call(self._setOwner, site, player), stack.Call(self._setOwner, site, site.owner))
def setEnemies(self, site, enemies): self.match.stack.push(stack.Call(self._setEnemies, site, enemies), stack.Call(self._setEnemies, site, site.enemies))
def movePerson(self, person, coords): assert person in self.persons self.match.stack.push( stack.Call(self._movePerson, person, coords), stack.Call(self._movePerson, person, self.persons[person]))
def removePerson(self, person): assert person in self.persons self.match.stack.push( stack.Call(self._removePerson, person), stack.Call(self._addPerson, person, self.persons[person]))
def addPerson(self, person, coords): assert person not in self.persons self.match.stack.push(stack.Call(self._addPerson, person, coords), stack.Call(self._removePerson, person))
def remove(self, effect): self.match.stack.push(stack.Call(self._remove, effect), stack.Call(self._add, effect))
def clear(self): self.match.stack.push(stack.Call(self._setActions, []), stack.Call(self._setActions, self._list))
def remove(self, actionId): for index, action in enumerate(self._list): if action.id == actionId: self.match.stack.push(stack.Call(self._remove, action), stack.Call(self._insert, index, action)) break
def removeCrystal(self, color): assert color.isBasic and self.crystals[color] > 0 self.match.stack.push(stack.Call(self._removeCrystal, color), stack.Call(self._addCrystal, color))
def setState(self, state): assert isinstance(state, State) if state != self.state: self.stack.push(stack.Call(self._setState, state), stack.Call(self._setState, self.state)) self.updateActions()