From e4fb08e375242ee54ed860ca46f9134f717b037c Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 6 Feb 2025 17:14:09 +0100 Subject: [PATCH] fix schatz --- server.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server.js b/server.js index cbced31..d246119 100644 --- a/server.js +++ b/server.js @@ -22,15 +22,15 @@ var newmap = map.generateMap(mapWidth, mapHeight); let schatzversteckt = false; let schatzcoords = { x: 0, y: 0 }; while (!schatzversteckt) { - for (var line = 0; line < newmap.map.length; line++) { - for (var column = 0; column < newmap.map[line].length; column++) { - if (newmap.map[line][column] == 4 || newmap.map[line][column] == 10) { //TODO schatz nicht im Wasser Spawnen! + for (var line = 0; line < newmap.cssMap.length; line++) { + for (var column = 0; column < newmap.cssMap[line].length; column++) { + if (newmap.cssMap[line][column] == "grass") { //TODO schatz nicht im Wasser Spawnen! if (Math.random() < 0.1 && !schatzversteckt) { //console.log("versteckt", line, column) - schatzcoords = { x: line, y: column }; + schatzcoords = { x: column, y: line }; //newmap.utilMap[line][column] = "item_item_schatz"; schatzversteckt = true - console.log(schatzcoords) + console.log(schatzcoords, newmap.cssMap[line][column]) } } @@ -38,7 +38,7 @@ while (!schatzversteckt) { } } -//console.log(newmap.map) +//console.log(newmap.cssMap) var cssMap = newmap["cssMap"]; var map = newmap["map"]; var utilMap = newmap["utilMap"]; @@ -320,7 +320,7 @@ io.on('connection', function (socket) { playerActionTimer = setTimeout(function () { let randomItem = getRandomItem(0, 0); //Drop a random Item - if(schatzcoords["y"] == x && schatzcoords["x"] == y) { + if(schatzcoords["x"] == x && schatzcoords["y"] == y) { randomItem = "item_item_schatz" console.log("schatz!"); }