notherbase-fs 1.3.2 → 1.3.5

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.
@@ -45,7 +45,7 @@ const explorer = async function explorer(worldPath, voidPath) {
45
45
 
46
46
  let main = `${worldPath}/${req.params.region}/${req.params.area}/${req.params.poi}/views/${req.params.detail}`;
47
47
 
48
- if (fs.existsSync(main + ".js")) {
48
+ if (fs.existsSync(main + ".ejs")) {
49
49
  let context = {
50
50
  siteTitle: `NotherBase - ${req.params.detail}`,
51
51
  user: foundUser,
@@ -82,7 +82,7 @@ const explorer = async function explorer(worldPath, voidPath) {
82
82
 
83
83
  let main = `${worldPath}/${req.params.region}/${req.params.area}/${req.params.poi}/views/index`;
84
84
 
85
- if (fs.existsSync(main + ".js")) {
85
+ if (fs.existsSync(main + ".ejs")) {
86
86
  let context = {
87
87
  siteTitle: `NotherBase - ${req.params.poi}`,
88
88
  user: foundUser,
@@ -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: itemToEmpty,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "1.3.2",
3
+ "version": "1.3.5",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "main": "notherbase-fs.js",
6
6
  "scripts": {
@@ -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 (await playerInventory.change(itemIDs[0], -5)) await playerInventory.change(itemIDs[1], 1);
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;
@@ -45,7 +45,18 @@
45
45
  }
46
46
 
47
47
  try {
48
- await $.post("/inventory", change, (data, status) => {
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 (this.items[i].amount === 0) this.items.splice(i, 1);
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);