laverdet / xxscreeps

Other
71 stars 16 forks source link

[Bug] ConstructionSite "progressTotal" property is missing #22

Closed NesCafe62 closed 3 years ago

NesCafe62 commented 3 years ago

made a temporary polyfil for it

Object.defineProperty(ConstructionSite.prototype, 'progressTotal', {
    get() {
        const structureType = this.structureType;
        if (structureType === STRUCTURE_CONTAINER) {
            // this is only because CONSTRUCTION_COST[STRUCTURE_CONTAINER] is missing
            return 5000;
        }
        let cost = CONSTRUCTION_COST[structureType];
        if (structureType === STRUCTURE_ROAD) {
            const terrain = new Room.Terrain(this.room.name);
            const {x, y} = this.pos;
            const cell = terrain.get(x, y);
            if (cell & TERRAIN_MASK_SWAMP) {
                cost *= CONSTRUCTION_COST_ROAD_SWAMP_RATIO;
            }
            if (cell & TERRAIN_MASK_WALL) {
                cost *= CONSTRUCTION_COST_ROAD_WALL_RATIO;
            }
        }
        return cost;
    }
});
laverdet commented 3 years ago

I think this one was resolved already