-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.js
More file actions
36 lines (36 loc) · 673 Bytes
/
Copy pathtest2.js
File metadata and controls
36 lines (36 loc) · 673 Bytes
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
that.setup = function() {
}
that.update = function() {
let worker = this["unit"]["worker"]
let home = this["building"][0]
let melee = this["unit"]["melee"]
let ore = context["resource"]["ore"][1]
if (worker.length < 3){
if (home.hasPlan()){
home.produce(this)
} else {
home.plan("worker")
}
} else {
if (home.hasPlan()){
home.produce(this)
} else {
home.plan("melee")
}
}
for (let i in worker){
if (worker[i].hasRoute){
worker[i].doRoute()
} else {
worker[i].createRoute(ore,home,"mine")
}
}
for (let i in melee){
let validate = 0
for (let j in worker){
validate = j
break
}
melee[i].attack(worker[validate])
}
}