Skip to content

Commit

Permalink
Merge branch 'master' into testpr
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrodogg committed Jun 30, 2020
2 parents 191cc7b + d3fa50c commit 3204ee1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,13 @@ class World {
Taken from https://github.com/screeps/backend-local/blob/master/lib/cli/bots.js#L37.
*/
genRandomBadge() {
var badge = {};
badge.type = Math.floor(Math.random()*24)+1;
badge.color1 = '#'+Math.floor(Math.random()*0xffffff).toString(16);
badge.color2 = '#'+Math.floor(Math.random()*0xffffff).toString(16);
badge.color3 = '#'+Math.floor(Math.random()*0xffffff).toString(16);
const badge = {};
badge.type = Math.floor(Math.random() * 24) + 1;
badge.color1 = `#${Math.floor(Math.random() * 0xffffff).toString(16)}`;
badge.color2 = `#${Math.floor(Math.random() * 0xffffff).toString(16)}`;
badge.color3 = `#${Math.floor(Math.random() * 0xffffff).toString(16)}`;
badge.flip = Math.random() > 0.5;
badge.param = Math.floor(Math.random()*200) - 100;
badge.param = Math.floor(Math.random() * 200) - 100;
return badge;
}

Expand All @@ -182,7 +182,9 @@ class World {
throw new Error(`cannot add user in ${room}: room does not have any controller`);
}
// Insert user and update data
const user = await db.users.insert({ username, cpu, cpuAvailable, gcl, active, badge: this.genRandomBadge()});
const user = await db.users.insert(
{ username, cpu, cpuAvailable, gcl, active, badge: this.genRandomBadge() }
);
await Promise.all([
env.set(env.keys.MEMORY + user._id, '{}'),
env.sadd(env.keys.ACTIVE_ROOMS, room),
Expand Down

0 comments on commit 3204ee1

Please sign in to comment.