fix dropping so dropped at player location, fix limit to hold items to 10
This commit is contained in:
parent
acacbf2fa1
commit
ea1e906121
|
@ -155,7 +155,7 @@ function checkKeys(key){
|
||||||
function pickup(){
|
function pickup(){
|
||||||
for (let i = 0; i < roomItems.length; i++){
|
for (let i = 0; i < roomItems.length; i++){
|
||||||
if ((player.position.x == roomItems[i].position.x) && (player.position.y == roomItems[i].position.y)){
|
if ((player.position.x == roomItems[i].position.x) && (player.position.y == roomItems[i].position.y)){
|
||||||
if (roomItems.length>10){
|
if (roomItems.length<10){
|
||||||
console.log("You take "+roomItems[i].name);
|
console.log("You take "+roomItems[i].name);
|
||||||
|
|
||||||
//add to player inventory
|
//add to player inventory
|
||||||
|
@ -164,6 +164,7 @@ function pickup(){
|
||||||
//now remove from room since owned by player now
|
//now remove from room since owned by player now
|
||||||
roomItems.splice(i, 1);
|
roomItems.splice(i, 1);
|
||||||
} else {
|
} else {
|
||||||
|
console.log(roomItems);
|
||||||
console.log("Your backpack is already full");
|
console.log("Your backpack is already full");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,8 +246,8 @@ function eatOrDrop(key){
|
||||||
"description": inventory[key.full].description,
|
"description": inventory[key.full].description,
|
||||||
"position":
|
"position":
|
||||||
{
|
{
|
||||||
"x": inventory[key.full].position.x,
|
"x": player.position.x,
|
||||||
"y": inventory[key.full].position.y
|
"y": player.position.y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user