Exemplo n.º 1
0
        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}
Exemplo n.º 2
0
    def _calculateUnitsSize(self, armyDomain):
        size = 0

        if armyDomain.getUnit().getType() == Common.TYPE_SOLIDER:
            return armyDomain.getCount()

        suiteArmy = armyDomain.getSuite()
        if suiteArmy:
            size += suiteArmy.getCount()

        armyCollection = Army_Factory.getCollectionByGeneral(armyDomain)

        for army in armyCollection:
            if army.getUnit().getType() == Common.TYPE_GENERAL:
                size += self._calculateUnitsSize(army)
                continue

            size += army.getCount()

        return size