graben auf G und Knochen

This commit is contained in:
Raphael 2024-11-10 18:07:51 +01:00
parent 71c86ecb6b
commit 1862fcd955
3 changed files with 210 additions and 156 deletions

View File

@ -295,6 +295,14 @@
margin-top: 5px;
}
.item_item_spaten3 {
background: url(../img/items.png) -59px -149px;
width: 30px;
background-size: 476px;
margin-left: 5px;
margin-top: 5px;
}
.item_weapon_stick1 {
background: url(../img/items.png) -150px -91px;
width: 30px;
@ -303,7 +311,7 @@
margin-top: 5px;
}
.item_item_bone1 {
.item_item_bone0 {
background: url(../img/items.png) -356px -29px;
width: 30px;
background-size: 476px;

View File

@ -39,7 +39,8 @@ var tooltiptexts = {
"item_weapon_sword4": "Schwert: Schaden erhöht 500",
"item_weapon_sword5": "Schwert: Schaden erhöht 600",
"item_weapon_stick1": "Stock: Schaden +20",
"item_item_bone1": "Knochen: Schaden +5",
"item_item_bone0": "Ganz toller Knochen!",
"item_item_spaten3": "Spaten: Schneller graben",
"item_consumable_fish1": "Erhöht deine Lebenspunkte um 20",
"item_consumable_fish2": "Erhöht deine Lebenspunkte um 10",
"item_item_dimond1": "Verkaufe den Diamand für 10 Siegpunkte! Bewegungsgeschwindigkeit verlangsamt!",
@ -363,13 +364,9 @@ $(document).ready(function () {
}
$(document).keydown(function (event) {
//console.log(event.which)
if (event.ctrlKey == true && (event.which == '61' || event.which == '107' || event.which == '173' || event.which == '109' || event.which == '187' || event.which == '189')) {
event.preventDefault();
}
var key = event.which;
//console.log(key);
if (key == 37 || key == 38 || key == 39 || key == 40)
if (key == 37 || key == 38 || key == 39 || key == 40 || key == 71)
event.preventDefault();
if (!keys[key]) {
@ -379,13 +376,19 @@ $(document).ready(function () {
socket.emit("keyDown", key);
}
keys[key] = true;
return;
}
//console.log(event.which)
if (event.ctrlKey == true && (event.which == '61' || event.which == '107' || event.which == '173' || event.which == '109' || event.which == '187' || event.which == '189')) {
event.preventDefault();
}
});
$(document).keyup(function (event) {
var key = event.which;
socket.emit("keyUp", key);
if (key == 69) {
if (key == 69 || key == 71) {
$("#animationDiv").remove();
}
keys[key] = false;

View File

@ -148,9 +148,11 @@ var itemAttrs = {
lvl: 1,
dmg: 20
},
"item_item_bone1": {
"item_item_bone0": {
lvl: 0,
},
"item_item_spaten3": {
lvl: 1,
dmg: 5
},
"item_consumable_fish1": {
lvl: 3,
@ -165,7 +167,7 @@ var itemAttrs = {
changeMovementSpeed: -0.5
},
"item_item_woods1": {
lvl: 0,
lvl: 1,
//changeMovementSpeed: -0.5
},
}
@ -241,7 +243,7 @@ io.on('connection', function (socket) {
socket.on('keyUp', function (key) {
allPlayers[socket.id]["keys"][key] = false;
if (key == 69) { //space
if (key == 69 || key == 71) { //space oder G
player["action"] = false;
if (playerActionTimer) {
clearTimeout(playerActionTimer);
@ -269,11 +271,50 @@ io.on('connection', function (socket) {
}, 500)
}
//}
} else if (key == 71) { // Taste G
var groundUnder = getGroundUnderPlayer(player["x"], player["y"]);
if (groundUnder == 10) { //its land
let cutTime = 6000; //6 Secs
console.log(player)
if(player["slots"] && player["slots"]["item"] && player["slots"]["item"] == "item_item_spaten3") {
cutTime = 2000;
}
if (playerActionTimer) {
clearTimeout(playerActionTimer);
playerActionTimer = null;
}
playerActionTimer = setTimeout(function () {
//Drop a random Item
let randomItem = getRandomItem(0, 0);
let nearFieldCoords = getNearEmptyField(Math.floor(player["x"] / 32), Math.floor(player["y"] / 32));
utilMap[nearFieldCoords["y"]][nearFieldCoords["x"]] = randomItem;
let newObj = {
mapY: nearFieldCoords["y"],
mapX: nearFieldCoords["x"],
newName: randomItem
}
io.sockets.emit("dropItem", newObj);
socket.emit("stopAnimation", cutTime);
allPlayers[socket.id]["action"] = false;
}, cutTime);
allPlayers[socket.id]["action"] = true;
socket.emit("animation", cutTime);
}
console.log(groundUnder)
}
});
socket.on('actionKey', function (key) {
var groundUnder = getGroundUnderPlayer(player["x"], player["y"]);
if (key == 69) {// E
if (player["mode"] == 0) { //ship
if (groundUnder >= 1) { //its nearly land
player["mode"] = 1;
@ -395,6 +436,7 @@ io.on('connection', function (socket) {
io.sockets.emit("objAction", obj);
}
}
player["action"] = true;
});
});
@ -439,6 +481,7 @@ function calcDmgAndHitPlayer(player1, player2) {
function getRandomItem(minLvl, maxLvl) {
//console.log("rnd", items.length, getRandomNumber(0, items.length), items)
// return items[32] //Spaten
// return items[32] //fish
while (1) {
let item = items[getRandomNumber(0, items.length)];