コード例 #1
0
def getShortDescr(techID, myDetail = SHORT):
    tech = client.getFullTechInfo(techID)
    techEff = Rules.techImprEff[client.getPlayer().techs.get(techID, Rules.techBaseImprovement)]
    result = []
    # specific
    if tech.subtype in descr:
        for detail, attr, text, filter, eff in descr[tech.subtype]:
            if tech.isDefault(attr):
                continue
            if detail <= myDetail:
                if not filter:
                    result.append(_(text))
                elif eff:
                    result.append(_(text) % filter(techEff * getattr(tech, attr)))
                else:
                    result.append(_(text) % filter(getattr(tech, attr)))
    # general
    for detail, attr, text, filter, eff in descr["*"]:
        if tech.isDefault(attr):
            continue
        if detail <= myDetail:
            if not filter:
                result.append(_(text))
            elif eff:
                result.append(_(text) % filter(techEff * getattr(tech, attr)))
            else:
                result.append(_(text) % filter(getattr(tech, attr)))
    if result:
        return string.join(result, ", ")
    else:
        return _("N/A")
コード例 #2
0
ファイル: SystemMapWidget.py プロジェクト: Lukc/ospace-lukc
    def getFreeSlots(self, planetID):
        planet = client.get(planetID, noUpdate=1)
        system = client.get(self.systemID, noUpdate=1)
        player = client.getPlayer()
        owner = getattr(planet, "owner", OID_NONE)
        freeSlots = 0
        if owner == player.oid and hasattr(planet, "slots") and hasattr(planet, "plSlots"):
            freeSlots = planet.plSlots - len(planet.slots)
        if hasattr(system, "planets"):
            for sPlanetID in system.planets:
                sPlanet = client.get(sPlanetID, noUpdate=1)
                if hasattr(sPlanet, "prodQueue"):
                    for task in sPlanet.prodQueue:
                        # Target Slot does not changes number of free slots
                        if (
                            not task.isShip
                            and hasattr(task, "demolishStruct")
                            and task.demolishStruct == 0
                            and task.targetID == planetID
                        ):
                            tech = client.getFullTechInfo(task.techID)
                            # constructing Habitable Surface Expansion increases planet slots
                            if tech.isProject and tech.id == 3802:
                                freeSlots += task.quantity
                            elif tech.isStructure:
                                freeSlots -= task.quantity

        return freeSlots
コード例 #3
0
    def getFreeSlots(self, planetID):
        planet = client.get(planetID, noUpdate=1)
        system = client.get(self.systemID, noUpdate=1)
        player = client.getPlayer()
        owner = getattr(planet, 'owner', Const.OID_NONE)
        freeSlots = 0
        if owner == player.oid and hasattr(planet, 'slots') and hasattr(
                planet, 'plSlots'):
            freeSlots = planet.plSlots - len(planet.slots)
        if hasattr(system, 'planets'):
            for sPlanetID in system.planets:
                sPlanet = client.get(sPlanetID, noUpdate=1)
                if hasattr(sPlanet, 'prodQueue'):
                    for task in sPlanet.prodQueue:
                        # Target Slot does not changes number of free slots
                        if not task.isShip and hasattr(
                                task, "demolishStruct"
                        ) and task.demolishStruct == 0 and task.targetID == planetID:
                            tech = client.getFullTechInfo(task.techID)
                            # constructing Habitable Surface Expansion increases planet slots
                            if tech.isProject and tech.id == 3802:
                                freeSlots += task.quantity
                            elif tech.isStructure:
                                freeSlots -= task.quantity

        return freeSlots
コード例 #4
0
def getShortDescr(techID, myDetail=SHORT):
    tech = client.getFullTechInfo(techID)
    techEff = Rules.techImprEff[client.getPlayer().techs.get(
        techID, Rules.techBaseImprovement)]
    result = []
    # specific
    if tech.subtype in descr:
        for detail, attr, text, filter, eff in descr[tech.subtype]:
            if tech.isDefault(attr):
                continue
            if detail <= myDetail:
                if not filter:
                    result.append(_(text))
                elif eff:
                    result.append(
                        _(text) % filter(techEff * getattr(tech, attr)))
                else:
                    result.append(_(text) % filter(getattr(tech, attr)))
    # general
    for detail, attr, text, filter, eff in descr["*"]:
        if tech.isDefault(attr):
            continue
        if detail <= myDetail:
            if not filter:
                result.append(_(text))
            elif eff:
                result.append(_(text) % filter(techEff * getattr(tech, attr)))
            else:
                result.append(_(text) % filter(getattr(tech, attr)))
    if result:
        return string.join(result, ", ")
    else:
        return _("N/A")