notherbase-fs 3.0.4 → 3.0.6

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/models/user.js CHANGED
@@ -101,16 +101,12 @@ export default class User extends Spirit {
101
101
  offsetItem = async (name, offset) => {
102
102
  let item = await Item.recallOne(name);
103
103
 
104
- if (!item) return "Item not found in database.";
104
+ if (!item) return false;
105
105
 
106
106
  let inv = this.memory.data.inventory;
107
-
108
- let holding = false;
109
-
107
+
110
108
  for (let j = 0; j < inv.length; j++) {
111
109
  if (inv[j].name === name) {
112
- holding = true;
113
-
114
110
  if (inv[j].amount >= -Math.floor(offset)) {
115
111
  inv[j].amount += Math.floor(offset);
116
112
 
@@ -118,44 +114,29 @@ export default class User extends Spirit {
118
114
  let empty = inv[j];
119
115
 
120
116
  inv.splice(j, 1);
121
-
122
- this.memory._lastUpdate = Date.now();
123
- await this.commit();
124
-
125
- return "Item emptied.";
126
- }
127
- else {
128
- this.memory._lastUpdate = Date.now();
129
- await this.commit();
130
-
131
- return inv[j];
132
117
  }
118
+
119
+ this.memory._lastUpdate = Date.now();
120
+ await this.commit();
121
+ return true;
133
122
  }
134
- else {
135
- return `Unable to remove ${-offset} ${name}
136
- from inventory because the inventory has only ${inv[j].amount}.`;
137
- }
123
+ else return false;
138
124
  }
139
125
  }
140
126
 
141
- if (!holding) {
142
- if (offset > 0) {
143
- inv.push({
144
- name: name,
145
- amount: offset
146
- });
147
-
148
- this.memory._lastUpdate = Date.now();
149
-
150
- await this.commit();
151
-
152
- return inv[inv.length - 1];
153
- }
154
- else {
155
- return `Unable to remove ${-offset} ${name}
156
- from inventory because the inventory has none.`;
157
- }
158
- };
127
+ if (offset > 0) {
128
+ inv.push({
129
+ name: name,
130
+ amount: offset
131
+ });
132
+
133
+ this.memory._lastUpdate = Date.now();
134
+
135
+ await this.commit();
136
+
137
+ return true;
138
+ }
139
+ else return false;
159
140
  }
160
141
 
161
142
  checkAttribute = async (check, against) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "notherbase-fs",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "Functions to help make developing for NotherBase easier.",
5
5
  "exports": "./notherbase-fs.js",
6
6
  "scripts": {
@@ -289,7 +289,7 @@ class Base {
289
289
  }
290
290
 
291
291
  do = async (what, data = null, route = window.location.pathname) => {
292
- let response = await Base.commune("/s/serve", {
292
+ let response = Base.commune("/s/serve", {
293
293
  script: what,
294
294
  ...data
295
295
  }, {
@@ -299,6 +299,7 @@ class Base {
299
299
  this.playerInventory.refresh();
300
300
  this.playerAttributes.refresh();
301
301
 
302
+ await response;
302
303
  return response;
303
304
  }
304
305