From faeec383ba2448fba566707d3c1151901187b708 Mon Sep 17 00:00:00 2001 From: Renge Date: Sun, 10 Apr 2022 19:50:14 -0400 Subject: [PATCH] fix: fix some bugs in prev commit --- src/shattered_sword/Tools/RandomMapGenerator.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/shattered_sword/Tools/RandomMapGenerator.ts b/src/shattered_sword/Tools/RandomMapGenerator.ts index 4deefbb..41d229b 100644 --- a/src/shattered_sword/Tools/RandomMapGenerator.ts +++ b/src/shattered_sword/Tools/RandomMapGenerator.ts @@ -357,15 +357,17 @@ export default class RandomMapGenerator { if (old.sprites) { for (let index = 0; index < old.sprites.length; index++) { const sprite = old.sprites[index]; - if (sprite.type == 'player') { + if (sprite.type === 'player') { this.player.x = sprite.x; this.player.y = sprite.y; } else { - let tmp = new Enemy(); - tmp.type = sprite.type; - tmp.position = new Vec2(posX + sprite.x, posY + sprite.y); - room.enemies.push(tmp); + if (this.gen.random() <= sprite.possibility) { + let tmp = new Enemy(); + tmp.type = sprite.type; + tmp.position = new Vec2(posX + sprite.x, posY + sprite.y); + room.enemies.push(tmp); + } } } }