notherbase-fs 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/controllers/inventory.js
CHANGED
|
@@ -51,18 +51,18 @@ router.post("/", async function(req, res) {
|
|
|
51
51
|
await foundInventory.save();
|
|
52
52
|
|
|
53
53
|
res.status(200).send({
|
|
54
|
-
item:
|
|
54
|
+
item: {
|
|
55
|
+
_id: itemToEmpty
|
|
56
|
+
},
|
|
55
57
|
amount: 0
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
60
|
else {
|
|
59
61
|
await foundInventory.save();
|
|
60
|
-
|
|
61
62
|
res.status(200).send(foundInventory.items[j]);
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
else {
|
|
65
|
-
console.log("subtract from too few", req.change);
|
|
66
66
|
res.status(304).send(
|
|
67
67
|
`Unable to remove ${req.body.amount} ${req.body.item}
|
|
68
68
|
from inventory because the inventory has only ${foundInventory.items[j].amount}.`
|
|
@@ -87,7 +87,6 @@ router.post("/", async function(req, res) {
|
|
|
87
87
|
res.status(200).send(foundInventory.items[foundInventory.items.length - 1]);
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
|
-
console.log("subtract from none", req.body);
|
|
91
90
|
res.status(304).send(
|
|
92
91
|
`Unable to remove ${req.body.amount} ${req.body.item}
|
|
93
92
|
from inventory because the inventory has none.`
|
|
@@ -96,12 +95,10 @@ router.post("/", async function(req, res) {
|
|
|
96
95
|
};
|
|
97
96
|
}
|
|
98
97
|
else {
|
|
99
|
-
console.log(`${req.body.item} doesn't exist!`);
|
|
100
98
|
res.status(400).send(`${req.body.item} doesn't exist!`);
|
|
101
99
|
}
|
|
102
100
|
}
|
|
103
101
|
else {
|
|
104
|
-
console.log(`${req.body.item} ${req.body.amount} Check Input!`);
|
|
105
102
|
res.status(400).send(`${req.body.item} ${req.body.amount} Check Input!`);
|
|
106
103
|
}
|
|
107
104
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
<hr>
|
|
13
13
|
|
|
14
|
-
<button onclick="tradeForDoll()">Trade 5g for a doll</button>
|
|
14
|
+
<button onclick="tradeForDoll()" id="trade">Trade 5g for a doll</button>
|
|
15
15
|
|
|
16
16
|
<hr>
|
|
17
17
|
|
|
@@ -68,8 +68,22 @@
|
|
|
68
68
|
</a>
|
|
69
69
|
|
|
70
70
|
<script>
|
|
71
|
+
let bought = false;
|
|
72
|
+
|
|
71
73
|
let tradeForDoll = async function tradeForDoll() {
|
|
72
|
-
if (
|
|
74
|
+
if (!bought) {
|
|
75
|
+
$("#trade").addClass("invisible");
|
|
76
|
+
|
|
77
|
+
let paid = await playerInventory.change("Gold Coin", -5);
|
|
78
|
+
|
|
79
|
+
if (paid) {
|
|
80
|
+
bought = true;
|
|
81
|
+
await playerInventory.change("Rag Doll", 1);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
$("#trade").removeClass("invisible");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
73
87
|
}
|
|
74
88
|
|
|
75
89
|
let time = 0;
|
package/views/inventory.ejs
CHANGED
|
@@ -45,7 +45,18 @@
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
try {
|
|
48
|
-
|
|
48
|
+
let data = null;
|
|
49
|
+
let status = null;
|
|
50
|
+
|
|
51
|
+
await $.post("/inventory", change, (d, s) => {
|
|
52
|
+
data = d;
|
|
53
|
+
status = s;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (status === "notmodified") {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
49
60
|
let holding = false;
|
|
50
61
|
|
|
51
62
|
for (let i = 0; i < this.items.length; i++) {
|
|
@@ -53,7 +64,7 @@
|
|
|
53
64
|
this.items[i].amount = data.amount;
|
|
54
65
|
holding = true;
|
|
55
66
|
|
|
56
|
-
if (
|
|
67
|
+
if (data.amount <= 0) this.items.splice(i, 1);
|
|
57
68
|
}
|
|
58
69
|
}
|
|
59
70
|
|
|
@@ -62,9 +73,8 @@
|
|
|
62
73
|
}
|
|
63
74
|
|
|
64
75
|
this.render();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
return true;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
68
78
|
}
|
|
69
79
|
catch(err) {
|
|
70
80
|
console.log(err);
|
|
@@ -86,6 +96,7 @@
|
|
|
86
96
|
}
|
|
87
97
|
|
|
88
98
|
render() {
|
|
99
|
+
console.log(this.items);
|
|
89
100
|
this.$list.empty();
|
|
90
101
|
|
|
91
102
|
for (let i = 0; i < this.items.length; i++) {
|