summaryrefslogtreecommitdiff
path: root/utils/game.js
diff options
context:
space:
mode:
Diffstat (limited to 'utils/game.js')
-rw-r--r--utils/game.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/utils/game.js b/utils/game.js
index 4f91131..22bfa13 100644
--- a/utils/game.js
+++ b/utils/game.js
@@ -35,6 +35,7 @@ var Enemy = require("models/enemy").Enemy;
var classUtils = require("utils/class.js");
var accountUtils = require("utils/account.js");
var chunkUtils = require("utils/chunk.js");
+let doorUtils = require("utils/tele");
GameUtils.prototype.getPlayerByUsername = function(username) {
var index = 0;
@@ -205,6 +206,9 @@ GameUtils.prototype.performUpdate = function(username, commandList, done) {
if (tempCommand.commandName == "placeTile") {
performPlaceTileCommand(tempCommand, tempPlayer, tempCommandList);
}
+ if (tempCommand.commandName == "placeDoor") {
+ performPlaceDoorCommand(tempCommand, tempPlayer, tempCommandList);
+ }
if (tempCommand.commandName == "collectTile") {
performCollectTileCommand(tempCommand, tempPlayer, tempCommandList);
}
@@ -480,6 +484,18 @@ function performPlaceTileCommand(command, player, commandList) {
}
}
+function performPlaceDoorCommand(command, player, commandList) {
+ if (!isDirection(command.direction))
+ return;
+ const d = command.doorId;
+ const pos = player.getPosInWalkDirection(command.direction);
+ const curt = chunkUtils.getTile(pos);
+ if (!player.canPlaceOnTile(curt)) return;
+ if (!doorUtils.removeDoorFromInventory(player.inventory, d)) return;
+ doorUtils.placeDoor(d, pos);
+ addSetInventoryCommand(player.inventory, commandList);
+}
+
function performCollectTileCommand(command, player, commandList) {
if (isDirection(command.direction))
player.collectTile(command.direction);
@@ -534,6 +550,7 @@ GameUtils.prototype.persistEverything = function(done) {
}
this.isPersistingEverything = true;
chunkUtils.persistAllChunks();
+ doorUtils.persistAllDoors();
var self = this;
var index = 0;
function persistNextEntity() {