MVP

25/04/2021 - Minimum code needed to progress in Screeps

Now that Steve has been born we can start progressing within the game. In order to progress within the game and unlock new features, Screeps provides a way to 'level-up'. To achieve this, Steve will need to harvest energy and upgrade the controller.

CreepManager

CreepManager.ts
import { Steve } from "creeps/Steve";
import { CreepRole } from "enums/CreepRole";

export class CreepManager {

    public static run() {
        for(var name in Game.creeps) {
            var creep = Game.creeps[name];
            CreepManager.runCreep(creep);
        }
    }

    private static runCreep(creep: Creep) {
        var creepRole = creep.memory.role;

        switch (creepRole) {
            case CreepRole.steve:
                Steve.run(creep);
                break;
            default:
                console.log(`unknown creep role '${creepRole}'`);
                break;
        }
    }
}

A creep manager is responsible for controlling all the creeps. It keeps track of a creep's role and delegates the behaviour to each role's class.

Creep role - Steve

A runner can be one of two states: 'harvesting' or 'upgrading'.

Harvesting

When harvesting the creep moves to the nearest energy source and starts harvesting. Once full, the creep changes its state to 'upgrading'

Upgrading

When running the creep will move to the nearest spawn structure and transfer all of its energy, after which the state will go back to 'harvesting'.

Steve harvesting and upgrading

Last updated

Was this helpful?