def changeMoveType(self, general, move, user=None): generalDomain = Army_Factory.get(general) move = int(move) if move not in [1,2,3,4]: raise exceptions.args.EnumError("Wrong move mode") return super().changeMoveType(generalDomain, move, user)
def move(self, general, path, user=None): general = Army_Factory.get(general) mapPath = [] for coordinate in path: try: x, y, direction = coordinate except ValueError: raise WrongArgumentType() mapPath.append({ 'pos_id': helpers.MapCoordinate.MapCoordinate(x=x, y=y).getPosId(), 'direction': direction }) return super().move(general, mapPath, user)
def loadDetail(self, armyUser, _id, user=None): def load(leader): suite = leader.getSuite() army = Army_Factory.getCollectionByGeneral(leader) # army.extract() armyData = [] for domain in army: if not suite or suite.getId() != domain.getId(): armyData.append(load(domain)) return {'current': leader, 'suite': suite, 'sub_army': armyData} commander = Army_Factory.get(_id) return load(commander)
def moveOutBuild(self, armyDomain, user=None): domain = Army_Factory.get(armyDomain) return super().moveOutBuild(domain, user)
def removeSolidersFromGeneral(self, generalArmy, solidersCollection, user=None): solidersCollection = [objectId(i) for i in solidersCollection] domain = Army_Factory.get(generalArmy) collection = Army_Factory.getByIds(solidersCollection) return super().removeSolidersFromGeneral(domain, collection, user)
def removeSuite(self, generalArmy, solidersArmy, user=None): generalDomain = Army_Factory.get(generalArmy) soliderDomain = Army_Factory.get(solidersArmy) return super().removeSuite(generalDomain, soliderDomain, user)
def updatePathMove(self, general): general = Army_Factory.get(general) return super().updatePathMove(general)
def dissolution(self, armyDomain, user=None): domain = Army_Factory.get(armyDomain) return super().dissolution(domain, user)
def split(self, armyDomain, size, user=None): domain = Army_Factory.get(armyDomain) size = int(size) return super().split(domain, size, user)
def get(self, _id, user=None): return Army_Factory.get(_id)