summaryrefslogtreecommitdiff
path: root/models/crack.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/crack.js')
-rw-r--r--models/crack.js23
1 files changed, 18 insertions, 5 deletions
diff --git a/models/crack.js b/models/crack.js
index 3f352f2..15ee833 100644
--- a/models/crack.js
+++ b/models/crack.js
@@ -18,6 +18,7 @@ module.exports = {
var accountUtils = require("utils/account");
var gameUtils = require("utils/game");
var chunkUtils = require("utils/chunk");
+let doorUtils = require("utils/tele");
var tempResource = require("models/chunk");
var BLOCK_START_TILE = tempResource.BLOCK_START_TILE;
@@ -37,16 +38,28 @@ Crack.prototype.tick = function() {
Crack.prototype.giveTileToPlayer = function() {
var tempTile = chunkUtils.getTile(this.pos);
- var isAcceptableBlock = (tempTile >= BLOCK_START_TILE && tempTile < BLOCK_START_TILE + BLOCK_TILE_AMOUNT) ||
- (tempTile >= TELEPORTER_START_TILE && tempTile < TELEPORTER_START_TILE + TELEPORTER_TILE_AMOUNT);
- if (!isAcceptableBlock)
- return;
+ var isAcceptableBlock =
+ ( tempTile >= BLOCK_START_TILE &&
+ tempTile < BLOCK_START_TILE + BLOCK_TILE_AMOUNT) ||
+ ( tempTile >= TELEPORTER_START_TILE &&
+ tempTile < TELEPORTER_START_TILE + TELEPORTER_TILE_AMOUNT) ||
+ tempTile == 0x9b;
+ if (!isAcceptableBlock) return;
var tempPlayer = gameUtils.getPlayerByUsername(this.username);
if (tempPlayer === null) {
return;
}
chunkUtils.setTile(this.pos, EMPTY_TILE);
- tempPlayer.inventory.incrementTileCount(tempTile);
+ if (tempTile == 0x9b) { // teleporter
+ const doorid = doorUtils.findDoorIdWithPos(this.pos);
+ if (doorid === null) console.error("crack.js: door doesn't exist here");
+ doorUtils.moveDoorToPlayer(
+ doorid,
+ tempPlayer.inventory,
+ tempPlayer.username);
+ } else {
+ tempPlayer.inventory.incrementTileCount(tempTile);
+ }
}
Crack.prototype.getClientInfo = function() {