diff options
author | Matt Kohls <mattkohls13@gmail.com> | 2019-12-05 14:32:22 -0500 |
---|---|---|
committer | Matt Kohls <mattkohls13@gmail.com> | 2019-12-05 14:32:22 -0500 |
commit | a5c786cc8a621ae70425a7795592ecfdfb1758ac (patch) | |
tree | 4b6b7ad7a7586d799e0e0d009ed00b33e885c799 /rogue-server.js | |
parent | e4312e8008106eadd1b4d8a23630600f5952a8ca (diff) | |
download | rogue.js-a5c786cc8a621ae70425a7795592ecfdfb1758ac.tar.gz rogue.js-a5c786cc8a621ae70425a7795592ecfdfb1758ac.tar.bz2 rogue.js-a5c786cc8a621ae70425a7795592ecfdfb1758ac.zip |
Client now sent list of mobs to draw
Currently only draws them as the alt player sprite and doesn't show them
as bones if they died this turn
Diffstat (limited to 'rogue-server.js')
-rw-r--r-- | rogue-server.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/rogue-server.js b/rogue-server.js index a490d25..4978895 100644 --- a/rogue-server.js +++ b/rogue-server.js @@ -443,6 +443,10 @@ function performActions(init) { * @param character The mob the player is in charge of */ function buildPlayerMsg(character) { + return buildTurnMsg(character, ",\"mobs\":[]"); +} + +function buildTurnMsg(character, mobmsg) { var local = character.location.floor; var message = "{\"map\":\"" + floors[local] + "\","; message = message + character.stats(); @@ -451,6 +455,7 @@ function buildPlayerMsg(character) { } else { message = message + ",\"msg\":\"\""; } + message += mobmsg; return message + "}"; } @@ -458,10 +463,18 @@ function buildPlayerMsg(character) { * Send out action results to all players */ function sendResults() { + var mobmsg = ",\"mobs\":["; + for(var i = 0; i < mobs.length; i++) { + mobmsg += "{\"x\":" + mobs[i].location.x + ",\"y\":" + mobs[i].location.y + ",\"floor\":" + mobs[i].location.floor + "}"; + if(i != mobs.length - 1) { + mobmsg += ","; + } + } + mobmsg += "]"; for(var i = 0; i < mobs.length; i++) { if(players.has(mobs[i].uuid)) { console.log(new Date().toUTCString() + ' | sending turn data to ' + mobs[i].uuid); - players.get(mobs[i].uuid).send(buildPlayerMsg(mobs[i])); + players.get(mobs[i].uuid).send(buildTurnMsg(mobs[i], mobmsg)); } } } |