Refactored chunkStore to use linvodb3, broke mapping (ofc)

This commit is contained in:
Danielv123 committed 2018-01-02 17:00:50 +01:00
1 parent cd2d00d224
commit 1b405b8701
3 files changed
+62 -104

No files matched your search

+23 -18
View File
@@ -15,28 +15,33 @@ describe("chunkStore.js", () => {
store = new chunkStore("910239"/* instanceID, use defaults for the rest */);
assert.equal(store.name, "910239");
});
it("allows you to store the locations of entities in a chunk divided database", () => {
return store.setEntity(inserterX, inserterY, {name:inserterName}).then(() => {
it("allows you to store the locations of entities", done => {
store.setEntity(inserterX, inserterY, {name:inserterName, otherData:"can be arbitrary"}).then(() => {
done();
// nothing to do here really
});
});
it("returns items located in a chunk", (done) => {
// We return the promise to mocha as it supports promises natively, works a lot better than calling done() manually.
let x = 0;
let y = -1
store.getChunk(x,y).then(chunkData => {
console.log(chunkData);
assert.equal(typeof chunkData, "object");
assert.equal(chunkData.dataObject[15][47].name, inserterName);
assert.equal(chunkData.position.x, x);
assert.equal(chunkData.position.y, y);
done();
});
it("returns entities at positions you query for", done => {
setTimeout(()=>{
store.getEntity(inserterX, inserterY).then(entities => {
entity = entities[0]
// console.log(entity)
assert.equal(entity.x, 14);
assert.equal(entity.y, -18);
assert.equal(entity.entity.name, "inserter");
assert.equal(entity.entity.otherData, "can be arbitrary");
done();
});
},500)
});
it("deletes entities when not provided with an object as 3rd arg", done => {
store.setEntity(inserterX, inserterY).then((chunk)=>{
assert(!chunk.dataObject(15, 47));
done();
store.setEntity(inserterX, inserterY).then(entity => {
assert(entity === undefined);
store.getEntity(inserterX, inserterY).then(entities => {
// console.log(entities)
assert.equal(entities.length, 0, "Why are we getting results, it should be empty?");
done();
});
});
});
});
});