Skip to content

Instantly share code, notes, and snippets.

@dlobue
Created August 23, 2015 14:40
Show Gist options
  • Save dlobue/4b5df92567054ec203e5 to your computer and use it in GitHub Desktop.
Save dlobue/4b5df92567054ec203e5 to your computer and use it in GitHub Desktop.
clojurescript screeps config
// externs/screeps.js
var ConstructionSite = function () { };
ConstructionSite.prototype = {
id: "",
owner: null,
room: null,
pos: null,
progress: 0,
progressTotal: 0,
structureType: null,
ticksToLive: 0,
my: true,
remove: function () { }
};
var Creep = function () { };
Creep.prototype = {
id: null,
name: null,
owner: null,
room: null,
pos: null,
memory: null,
my: true,
spawning: true,
body: [ ],
carry: { energy: 0 },
carryCapacity: 0,
hits: 0,
hitsMax: 0,
ticksToLive: 0,
fatigue: 0,
attack: function (target) { },
build: function (target) { },
cancelOrder: function (methodName) { },
claimController: function (target) { },
dropEnergy: function (amount) { },
getActiveBodyparts: function (type) { },
harvest: function (target) { },
heal: function (target) { },
move: function (direction) { },
moveByPath: function(path) { },
moveTo: function (target, opts) { },
notifyWhenAttacked: function(enabled){ },
pickup: function (target) { },
rangedAttack: function (target) { },
rangedHeal: function(target) { },
rangedMassAttack: function() { },
repair: function (target) { },
say: function(message) { },
suicide: function () { },
transferEnergy: function (target, amount) { },
unclaimController: function(target) { },
upgradeController: function(target) { }
};
var Energy = function () { };
Energy.prototype = {
id: "",
room: null,
pos: null,
energy: 0
};
var Exit = function () { };
Exit.prototype = {
id: "",
room: null,
pos: null,
exit: 0
};
var Flag = function () { };
Flag.prototype = {
id: "",
color: '',
name: "",
roomName: "",
room: null,
pos: null,
memory: null,
remove: function () { },
setColor: function(color) { },
setPosition: function(x, y) { }
};
var Game = function () { };
Game.prototype = {
cpuLimit: 0,
creeps: null,
map: null,
flags: null,
rooms: null,
spawns: null,
structures: null,
time: 0,
getObjectById: function (id) { },
getRoom: function (name) { },
getUsedCpu: function(callback) { },
notify: function (message, groupInterval) { }
};
var global = function () { };
global.prototype = {
FIND_EXIT_TOP: 1,
FIND_EXIT_BOTTOM: 5,
FIND_EXIT: 10,
FIND_MY_CREEPS: 102,
FIND_SOURCES_ACTIVE: 104,
FIND_DROPPED_ENERGY: 106,
FIND_MY_STRUCTURES: 108,
FIND_FLAGS: 110,
FIND_MY_SPAWNS: 112,
TOP: 1,
RIGHT: 3,
BOTTOM: 5,
LEFT: 7,
ERR_NOT_OWNER: -1,
ERR_NAME_EXISTS: -3,
ERR_NOT_FOUND: -5,
ERR_INVALID_TARGET: -7,
ERR_NOT_IN_RANGE: -9,
ERR_TIRED: -11,
ERR_NOT_ENOUGH_EXTENSIONS: -13,
ERR_GCL_NOT_ENOUGH: -15,
COLOR_RED: "red",
COLOR_BLUE: "blue",
COLOR_GREEN: "green",
COLOR_ORANGE: "orange",
COLOR_GREY: "grey",
WORK: "work",
ATTACK: "attack",
TOUGH: "tough",
BODYPARTS_ALL: ["move", "work", "carry", "attack", "ranged_attack", "tough", "heal"],
STRUCTURE_SPAWN: "spawn",
STRUCTURE_ROAD: "road",
STRUCTURE_RAMPART: "rampart",
STRUCTURE_PORTAL: "portal",
STRUCTURE_LINK: "link",
MODE_SURVIVAL: "survival",
MODE_ARENA: "arena",
Game: null,
module: null,
exports: null,
global: this
};
var Map = function () { };
Map.prototype = {
findExit: function(fromRoom, toRoom) { },
findRoute: function(fromRoom, toRoom) { },
describeExits: function(roomName) { },
isRoomProtected: function(roomName) { }
};
var Memory = {
rooms: [],
spawns: []
};
var Owner = function() { };
Owner.prototype = {
username: ""
};
var PathStep = function() { };
PathStep.prototype = {
x: 0,
y: 0,
dx: 0,
dy: 0,
direction: null
};
var Room = function() { };
Room.prototype = {
controller: null,
storage: null,
memory: null,
mode: '',
name: "",
energyAvailable: 0,
energyCapacityAvailable: 0,
survivalInfo: null,
createFlag: function(pos, name, color) { },
createConstructionSite: function(pos, structureType) { },
find: function(type, opts) { },
findExitTo: function(room) { },
lookAt: function(target, opts) { },
lookAtArea: function(top, left, bottom, right) { },
lookForAt: function(type, target) { },
lookForAtArea: function(type, top, left, bottom, right) { },
findPath: function(fromPos, toPos, opts) { },
getPositionAt: function(x, y) { },
makeSnapshot: function(description) { }
};
var RoomPosition = function (x, y, roomName) { };
RoomPosition.prototype = {
x: 0,
y: 0,
roomName: "",
inRangeTo: function (toPos, range) { },
isNearTo: function (target) { },
getDirectionTo: function (target) { },
findPathTo: function (target, opts) { },
findNearest: function (type, opts) { },
findInRange: function (type, range, opts) { },
findClosest: function(type, opts) { },
findClosestByRange: function(type, opts) { },
getRangeTo: function(target) { },
equalsTo: function (target) { },
look: function() { },
lookFor: function(type) { },
createFlag: function(name, color) { },
createConstructionSite: function(structureType) { }
};
var Source = function () { };
Source.prototype = {
id: "",
room: null,
pos: null,
energy: 0,
energyCapacity: 0,
ticksToRegeneration: 0
};
var Spawn = function () { };
Spawn.prototype = {
id: "",
name: "",
owner: null,
room: null,
pos: null,
memory: [ ],
my: true,
structureType: 'spawn',
spawning: null,
energy: 0,
energyCapacity: 0,
hits: 0,
hitsMax: 0,
canCreateCreep: function(body, name) { },
createCreep: function (bodyParts, name, memory) { },
destroy: function() { },
notifyWhenAttacked: function(enabled) { },
transferEnergy: function (target, amount) { }
};
var Structure_Extension = function() { };
Structure_Extension.prototype = {
structureType: global.STRUCTURE_EXTENSION,
energy: 0,
energyCapacity: 0,
transferEnergy: function(target, amount) { }
};
var Structure_Link = function() { };
Structure_Link.prototype = {
structureType: global.STRUCTURE_LINK,
cooldown: 0,
energy: 0,
energyCapacity: 0,
transferEnergy: function(target, amount) { }
};
var Structure_Keeper_Lair = function() { };
Structure_Keeper_Lair.prototype = {
structureType: global.STRUCTURE_KEEPER_LAIR,
ticksToSpawn: 0
};
var Structure_Controller = function() { };
Structure_Controller.prototype = {
structureType: global.STRUCTURE_CONTROLLER,
level: 0,
progress: 0,
progressTotal: 0,
ticksToDowngrade: 0
};
var Structure_Rampart = function() {};
Structure_Rampart.prototype = {
structureType: global.STRUCTURE_RAMPART,
ticksToDecay: 0
};
var Structure_Road = function() { };
Structure_Road.prototype = {
structureType: global.STRUCTURE_ROAD,
ticksToDecay: 0
}
var Structure_Wall = function() { };
Structure_Wall.prototype = {
structureType: global.STRUCTURE_WALL,
ticksToLive: 0
};
var Structure_Storage = function() { };
Structure_Storage.prototype = {
structureType: global.STRUCTURE_STORAGE,
store: { energy: 0 },
storeCapacity: 0,
transferEnergy: function(target, amount) { }
};
var Structure = function () { };
Structure.prototype = {
id: "",
owner: null,
room: null,
pos: null,
hits: 0,
hitsMax: 0,
structureType: "",
my: true,
destroy: function() { },
notifyWhenAttacked: function(enabled) { }
};
var SurvivalInfo = function () { };
SurvivalInfo.prototype = {
score: 0,
timeToWave: 0,
wave: 0
}
(defproject screeps "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.58" :classifier "aot"
:exclusions [org.clojure/data.json]]
[org.clojure/data.json "0.2.6" :classifier "aot"]
[im.chit/purnam.native "0.5.2"]
[im.chit/purnam.core "0.5.2"]
[im.chit/purnam.common "0.5.2"]
[tailrecursion/cljs-priority-map "1.1.0"]]
:jvm-opts ^:replace ["-Xmx1g" "-server"]
:plugins [[lein-npm "0.6.1"]
[lein-cljsbuild "1.0.6" :exclusions [org.clojure/clojurescript]]]
:npm {:dependencies [[source-map-support "0.3.2"]]}
:source-paths ["src" "target/classes"]
:clean-targets ["out" "release"]
:profiles {:advanced
{:cljsbuild
{:builds
{:screeps
{:compiler
{:pretty-print false
:source-map "out/main.js.map"
;:asset-path "out"
;:source-map-path "out"
:anon-fn-naming-policy :mapped
:optimizations :advanced}}}}}
:modules
{:cljsbuild
{:builds
{:screeps
{:compiler
{:pretty-print false
:output-dir "outm"
:modules
{:screeps
{:output-to "outm/screeps.js"
:entries #{screeps.core}}}
:output-to "outm/rest.js"
:optimizations :simple}}}}}
:simple
{:cljsbuild
{:builds
{:screeps
{:compiler
{:pretty-print true
:source-map "out/main.js.map"
:anon-fn-naming-policy :mapped
:optimizations :simple}}}}}}
:cljsbuild
{:builds {:screeps
{:source-paths ["src"]
:compiler
{:main screeps.core
:verbose true
:output-to "out/main.js"
:output-dir "out"
:externs ["externs/screeps.js"]
:compiler-stats true
:pretty-print true
:language-in :ecmascript5
:language-out :ecmascript5
:optimizations :none}}}}
:target-path "target")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment