-
Notifications
You must be signed in to change notification settings - Fork 0
/
prototypes.spawn.js
222 lines (193 loc) · 5.69 KB
/
prototypes.spawn.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
// create a new function for StructureSpawn
StructureSpawn.prototype.createCustomCreep =
function(energy, roleName, target)
{
// create a balanced body as big as possible with the given energy
var numberOfParts = Math.floor(energy / 200);
var body = [];
for (let i = 0; i < numberOfParts; i++)
{
body.push(WORK);
}
for (let i = 0; i < numberOfParts; i++)
{
body.push(CARRY);
}
for (let i = 0; i < numberOfParts; i++)
{
body.push(MOVE);
}
// create creep with the created body and the given role
return this.createCreep(body, undefined, { role: roleName, working: false, targetRoom: target});
};
// Long Distance Harvester
StructureSpawn.prototype.createLongDistanceHarvester =
function (energy, target)
{
// create a body with the specified number of WORK parts and one MOVE part per non-MOVE part
var body = [];
var numberOfParts = Math.floor(energy / 250);
for (let i = 0; i < numberOfParts; i++)
{
body.push(WORK);
}
for (let i = 0; i < numberOfParts; i++)
{
body.push(CARRY);
}
for (let i = 0; i < numberOfParts * 2; i++)
{
body.push(MOVE);
}
// create creep with the created body
return this.createCreep(body, undefined,
{
role: 'longDistanceHarvester',
targetRoom: target
});
};
// CLAIMER
StructureSpawn.prototype.createClaimer =
function (target, order)
{
if (order == 1)
{
return this.createCreep([MOVE,CLAIM],undefined,
{role: 'claimer', targetRoom: target, order: order});
}
else if(order == 2)
{
return this.createCreep([MOVE,CLAIM,MOVE,CLAIM,MOVE,CLAIM,MOVE,CLAIM,MOVE,CLAIM],undefined,
{role: 'claimer', targetRoom: target, order: 1});
}
else if (order == -1)
{
return this.createCreep([MOVE,CLAIM,MOVE,CLAIM], undefined,
{role: 'claimer', targetRoom: target, order: order});
}
};
// ATTACKER
StructureSpawn.prototype.createAttacker =
function (energy, target)
{
// create a body with the specified number of ATTACK parts and one MOVE part per non-MOVE part
var body = [];
// 190 = 80 (cost of ATTACK) + 10 (cost of TOUGH) + 100 (cost of MOVE x2)
let numberOfParts = Math.floor(energy/ 190);
for (let i = 0; i < numberOfParts; i++)
{
body.push(TOUGH);
body.push(MOVE);
}
for (let i = 0; i < numberOfParts; i++)
{
body.push(ATTACK);
body.push(MOVE);
}
// create creep with the created body
return this.createCreep(body, undefined,
{
role: 'attacker',
targetRoom: target,
});
};
// RANGED ATTACKER 1100 energy
StructureSpawn.prototype.createRangedAttacker =
function (energy, target)
{
return this.createCreep([TOUGH,TOUGH,TOUGH,TOUGH,TOUGH,MOVE,MOVE,MOVE,MOVE,MOVE, RANGED_ATTACK, MOVE, RANGED_ATTACK,MOVE, RANGED_ATTACK,MOVE, RANGED_ATTACK,MOVE], undefined,
{role: 'rangedAttacker', targetRoom: target});
};
// HEALER
StructureSpawn.prototype.createHealer =
function ()
{
/* check RC level
if (this.level == )
{
}
*/
};
// Laborer
StructureSpawn.prototype.createLaborer =
function (target)
{
// create creep with the created body and the role 'laborer'
return this.createCreep(
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,
CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,
MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,
MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE], undefined,
{ role: 'laborer', working: false, targetRoom: target});
};
// Extractor
StructureSpawn.prototype.createExtractor =
function ()
{
// create creep with the created body and the role 'extractor'
return this.createCreep(
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,
CARRY,CARRY,CARRY,CARRY,
MOVE,MOVE,MOVE,MOVE,
MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE,MOVE], undefined,
{role: 'extractor', working: true});
};
// MINER
StructureSpawn.prototype.createMiner =
function (carry, sourceId)
{
if(carry)
{
return this.createCreep([WORK,WORK,WORK,WORK,WORK,CARRY,CARRY,CARRY,MOVE],undefined,
{carry: carry, role: 'miner', sourceId: sourceId});
}
else
{
return this.createCreep([WORK,WORK,WORK,WORK,WORK,MOVE],undefined,
{carry: carry, role: 'miner', sourceId: sourceId});
}
};
// Explorer
StructureSpawn.prototype.createExplorer =
function (target)
{
return this.createCreep([MOVE],'Explorer',
{role: 'explorer', targetRoom: target});
};
// LORRY
StructureSpawn.prototype.createLorry =
function (energy)
{
// create a body with twice as many CARRY as MOVE parts
var numberOfParts = Math.floor(energy / 150);
var body = [];
for (let i = 0; i < numberOfParts * 2; i++)
{
body.push(CARRY);
}
for (let i = 0; i < numberOfParts; i++)
{
body.push(MOVE);
}
// create creep with the created body and the role 'lorry'
return this.createCreep(body, undefined,
{ role: 'lorry', working: false });
};
StructureSpawn.prototype.createScientist =
function (energy)
{
// create a body with twice as many CARRY as MOVE parts
var numberOfParts = Math.floor(energy / 150);
var body = [];
for (let i = 0; i < numberOfParts * 2; i++)
{
body.push(CARRY);
}
for (let i = 0; i < numberOfParts; i++)
{
body.push(MOVE);
}
// create creep with the created body and the role 'lorry'
return this.createCreep(body, undefined,
{ role: 'scientist', working: false });
};