Add more modules
This commit is contained in:
parent
0c63cb075b
commit
504f5fcc0c
18 changed files with 1448 additions and 11 deletions
|
@ -105,10 +105,16 @@ function randomEntity(x, y) {
|
|||
if (Math.random() > 0.3) {
|
||||
entity = new Entity(x, y, 'fuelcan');
|
||||
} else {
|
||||
let arr = Object.entries(modules);
|
||||
[type, arr] = arr[Math.random() * arr.length | 0];
|
||||
arr = Object.keys(arr);
|
||||
entity = new Entity(x, y, type, arr[Math.random() * arr.length | 0]);
|
||||
let type, id;
|
||||
while (true) {
|
||||
let arr = Object.entries(modules);
|
||||
[type, arr] = arr[Math.random() * arr.length | 0];
|
||||
arr = Object.keys(arr);
|
||||
id = arr[Math.random() * arr.length | 0];
|
||||
let value = modules[type][id].value;
|
||||
if (Math.random() < (1 / value)) break;
|
||||
}
|
||||
entity = new Entity(x, y, type, id);
|
||||
}
|
||||
|
||||
world.entities.add(entity);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue