Esempio n. 1
0
    def getDebugInfo(self):
        data = Avatar.getDebugInfo(self)

        def safeAppend(attrName, prettyPrint=None):
            if hasattr(self, attrName):
                data.append(
                    (attrName, getattr(self, attrName) if prettyPrint is None
                     else prettyPrint(getattr(self, attrName))))
            return

        safeAppend('AIState', prettyPrint=lambda x: AIState.getStateName(x))
        safeAppend('profile')
        if hasattr(self, 'defendSector') and getattr(self, 'defendSector'):
            safeAppend('defenderType',
                       prettyPrint=lambda x: enumToString(DEFENDER_TYPE, x))
            safeAppend('isPatrolLeader', prettyPrint=bool)
        else:
            safeAppend(
                'strategyTargetType',
                prettyPrint=lambda x: enumToString(STRATEGY_TARGET_TYPE, x))
            safeAppend('combatMode',
                       prettyPrint=lambda x: enumToString(COMBAT_MODE, x))
            safeAppend('bombsCount')
            safeAppend('rocketsCount')
        return data