fix schatz

This commit is contained in:
Raphael 2025-02-06 17:14:09 +01:00
parent e7fccdaf6c
commit e4fb08e375

View File

@ -22,15 +22,15 @@ var newmap = map.generateMap(mapWidth, mapHeight);
let schatzversteckt = false; let schatzversteckt = false;
let schatzcoords = { x: 0, y: 0 }; let schatzcoords = { x: 0, y: 0 };
while (!schatzversteckt) { while (!schatzversteckt) {
for (var line = 0; line < newmap.map.length; line++) { for (var line = 0; line < newmap.cssMap.length; line++) {
for (var column = 0; column < newmap.map[line].length; column++) { for (var column = 0; column < newmap.cssMap[line].length; column++) {
if (newmap.map[line][column] == 4 || newmap.map[line][column] == 10) { //TODO schatz nicht im Wasser Spawnen! if (newmap.cssMap[line][column] == "grass") { //TODO schatz nicht im Wasser Spawnen!
if (Math.random() < 0.1 && !schatzversteckt) { if (Math.random() < 0.1 && !schatzversteckt) {
//console.log("versteckt", line, column) //console.log("versteckt", line, column)
schatzcoords = { x: line, y: column }; schatzcoords = { x: column, y: line };
//newmap.utilMap[line][column] = "item_item_schatz"; //newmap.utilMap[line][column] = "item_item_schatz";
schatzversteckt = true 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 cssMap = newmap["cssMap"];
var map = newmap["map"]; var map = newmap["map"];
var utilMap = newmap["utilMap"]; var utilMap = newmap["utilMap"];
@ -320,7 +320,7 @@ io.on('connection', function (socket) {
playerActionTimer = setTimeout(function () { playerActionTimer = setTimeout(function () {
let randomItem = getRandomItem(0, 0); //Drop a random Item 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" randomItem = "item_item_schatz"
console.log("schatz!"); console.log("schatz!");
} }