Beispiel #1
0
    def repairZone(self, base):

        assert isZoneCenter(base)

        powerOn = self.city.isTilePowered(self.x, self.y)

        bi = tiles.get(base).getBuildingInfo()
        assert bi is not None
        assert len(bi.members) == bi.width * bi.height

        xOrg = self.x - 1
        yOrg = self.y - 1
        i = 0
        for y in xrange(bi.height):
            for x in xrange(bi.width):
                x2 = xOrg + x
                y2 = yOrg + y

                ts = tiles.get(bi.members[i])
                if powerOn and ts.onPower is not None:
                    ts = ts.onPower

                if self.city.testBounds(x2, y2):
                    thCh = self.city.getTile(x2, y2)
                    if not (isIndestructible(thCh)
                            or isAnimated(thCh)
                            or isRubble(thCh)
                            or isZoneCenter(thCh)):
                        self.city.setTile(x2, y2, ts.tileNum)
                    i += 1
Beispiel #2
0
    def repairZone(self, base):

        assert isZoneCenter(base)

        powerOn = self.city.isTilePowered(self.x, self.y)

        bi = tiles.get(base).getBuildingInfo()
        assert bi is not None
        assert len(bi.members) == bi.width * bi.height

        xOrg = self.x - 1
        yOrg = self.y - 1
        i = 0
        for y in xrange(bi.height):
            for x in xrange(bi.width):
                x2 = xOrg + x
                y2 = yOrg + y

                ts = tiles.get(bi.members[i])
                if powerOn and ts.onPower is not None:
                    ts = ts.onPower

                if self.city.testBounds(x2, y2):
                    thCh = self.city.getTile(x2, y2)
                    if not (isIndestructible(thCh) or isAnimated(thCh) or isRubble(thCh) or isZoneCenter(thCh)):
                        self.city.setTile(x2, y2, ts.tileNum)
                    i += 1
Beispiel #3
0
    def zonePlop(self, base):
        assert isZoneCenter(base)

        bi = tiles.get(base).getBuildingInfo()
        assert bi is not None

        xOrg = self.x - 1
        yOrg = self.y - 1

        for y in xrange(yOrg, yOrg + bi.height):
            for x in xrange(xOrg, xOrg + bi.width):
                if not self.city.testBounds(x, y):
                    return False
                if isIndestructible(self.city.getTile(x, y)):
                    return False

        assert len(bi.members) == bi.width * bi.height
        i = 0
        for y in xrange(yOrg, yOrg + bi.height):
            for x in xrange(xOrg, xOrg + bi.width):
                self.city.setTile(x, y, bi.members[i])
                i += 1

        # refresh own tile property
        self.tile = self.city.getTile(self.x, self.y)

        self.setZonePower()
        return True
Beispiel #4
0
    def applyZone(self, eff, base):
        assert isZoneCenter(base)

        bi = tiles.get(base).getBuildingInfo()
        if bi is None:
            # TODO throw error
            print("error. cannot applyzone to #" + str(base))
            return False

        cost = self.tool.getToolCost()
        for rowNum in xrange(bi.height):
            for columnNum in xrange(bi.width):
                tileValue = eff.getTile(columnNum, rowNum)
                tileValue = tileValue & LOMASK

                if tileValue != DIRT:
                    if canAutoBulldozeZ(tileValue) and self.engine.autoBulldoze:
                        cost += 1
                    else:
                        # TODO if tile water set tool result to NONE

                        eff.toolResult(ToolResult.UH_OH)
                        return False

        eff.spend(cost)

        i = 0
        # TODO optimize this by storing full zones and just copying that here?
        for rowNum in xrange(bi.height):
            for columnNum in xrange(bi.width):
                eff.setTile(columnNum, rowNum, bi.members[i])
                i += 1

        self.fixBorder(eff, bi.width, bi.height)
        return True
Beispiel #5
0
    def zonePlop(self, base):
        assert isZoneCenter(base)

        bi = tiles.get(base).getBuildingInfo()
        assert bi is not None

        xOrg = self.x - 1
        yOrg = self.y - 1

        for y in xrange(yOrg, yOrg + bi.height):
            for x in xrange(xOrg, xOrg + bi.width):
                if not self.city.testBounds(x, y):
                    return False
                if isIndestructible(self.city.getTile(x, y)):
                    return False

        assert len(bi.members) == bi.width * bi.height
        i = 0
        for y in xrange(yOrg, yOrg + bi.height):
            for x in xrange(xOrg, xOrg + bi.width):
                self.city.setTile(x, y, bi.members[i])
                i += 1

        # refresh own tile property
        self.tile = self.city.getTile(self.x, self.y)

        self.setZonePower()
        return True
Beispiel #6
0
    def applyZone(self, eff, base):
        assert isZoneCenter(base)

        bi = tiles.get(base).getBuildingInfo()
        if bi is None:
            # TODO throw error
            print("error. cannot applyzone to #" + str(base))
            return False

        cost = self.tool.getToolCost()
        for rowNum in xrange(bi.height):
            for columnNum in xrange(bi.width):
                tileValue = eff.getTile(columnNum, rowNum)
                tileValue = tileValue & LOMASK

                if tileValue != DIRT:
                    if canAutoBulldozeZ(
                            tileValue) and self.engine.autoBulldoze:
                        cost += 1
                    else:
                        # TODO if tile water set tool result to NONE

                        eff.toolResult(ToolResult.UH_OH)
                        return False

        eff.spend(cost)

        i = 0
        # TODO optimize this by storing full zones and just copying that here?
        for rowNum in xrange(bi.height):
            for columnNum in xrange(bi.width):
                eff.setTile(columnNum, rowNum, bi.members[i])
                i += 1

        self.fixBorder(eff, bi.width, bi.height)
        return True