Merge branch 'feature/woodworking-skill'
@@ -897,7 +897,7 @@ function completeDebark (world, handle, entityId, character, gather, events, pri
897
897
{
898
898
const result = applySkillXp(
899
899
skills,
900
SkillId.crafting,
900
SkillId.woodworking,
901
901
woodworkingXpForDebark(gather.woodTier),
902
902
world.ecs.get(handle, Component.equipment)
903
903
);
@@ -897,7 +897,7 @@ function completeDebark (world, handle, entityId, character, gather, events, pri897
{897
{898
const result = applySkillXp(898
const result = applySkillXp(899
skills,899
skills,900
SkillId.crafting,900
SkillId.woodworking,901
woodworkingXpForDebark(gather.woodTier),901
woodworkingXpForDebark(gather.woodTier),902
world.ecs.get(handle, Component.equipment)902
world.ecs.get(handle, Component.equipment)903
);903
);@@ -25,6 +25,7 @@ test("crafting stations map to the expected skills", () =>
25
25
assert.equal(craftingStationDefinition(CraftingStationId.jeweleringStation).skillId, SkillId.jewelering);
26
26
assert.equal(craftingStationDefinition(CraftingStationId.loom).skillId, SkillId.tailoring);
27
27
assert.equal(craftingStationDefinition(CraftingStationId.craftingBench).skillId, SkillId.crafting);
28
assert.equal(craftingStationDefinition(CraftingStationId.woodworkingBench).skillId, SkillId.woodworking);
28
29
assert.equal(craftingStationDefinition(CraftingStationId.oven).skillId, SkillId.cooking);
29
30
assert.equal(craftingStationDefinition(CraftingStationId.fireplace).skillId, SkillId.cooking);
30
31
});
@@ -98,7 +99,7 @@ test("crafting item stubs are registered", () =>
98
99
99
100
test("woodworking, anvil, and crafting bench expose pickaxe and axe chain recipes", () =>
100
101
{
101
assert.equal(craftingStationDefinition(CraftingStationId.woodworkingBench).skillId, SkillId.crafting);
102
assert.equal(craftingStationDefinition(CraftingStationId.woodworkingBench).skillId, SkillId.woodworking);
102
103
assert.equal(craftingStationDefinition(CraftingStationId.craftingBench).skillId, SkillId.crafting);
103
104
const handle = recipeDefinition("handle-pine");
104
105
assert.ok(handle);
@@ -25,6 +25,7 @@ test("crafting stations map to the expected skills", () =>25
assert.equal(craftingStationDefinition(CraftingStationId.jeweleringStation).skillId, SkillId.jewelering);25
assert.equal(craftingStationDefinition(CraftingStationId.jeweleringStation).skillId, SkillId.jewelering);26
assert.equal(craftingStationDefinition(CraftingStationId.loom).skillId, SkillId.tailoring);26
assert.equal(craftingStationDefinition(CraftingStationId.loom).skillId, SkillId.tailoring);27
assert.equal(craftingStationDefinition(CraftingStationId.craftingBench).skillId, SkillId.crafting);27
assert.equal(craftingStationDefinition(CraftingStationId.craftingBench).skillId, SkillId.crafting);28
assert.equal(craftingStationDefinition(CraftingStationId.woodworkingBench).skillId, SkillId.woodworking);28
assert.equal(craftingStationDefinition(CraftingStationId.oven).skillId, SkillId.cooking);29
assert.equal(craftingStationDefinition(CraftingStationId.oven).skillId, SkillId.cooking);29
assert.equal(craftingStationDefinition(CraftingStationId.fireplace).skillId, SkillId.cooking);30
assert.equal(craftingStationDefinition(CraftingStationId.fireplace).skillId, SkillId.cooking);30
});31
});@@ -98,7 +99,7 @@ test("crafting item stubs are registered", () =>98
99
99
test("woodworking, anvil, and crafting bench expose pickaxe and axe chain recipes", () =>100
test("woodworking, anvil, and crafting bench expose pickaxe and axe chain recipes", () =>100
{101
{101
assert.equal(craftingStationDefinition(CraftingStationId.woodworkingBench).skillId, SkillId.crafting);102
assert.equal(craftingStationDefinition(CraftingStationId.woodworkingBench).skillId, SkillId.woodworking);102
assert.equal(craftingStationDefinition(CraftingStationId.craftingBench).skillId, SkillId.crafting);103
assert.equal(craftingStationDefinition(CraftingStationId.craftingBench).skillId, SkillId.crafting);103
const handle = recipeDefinition("handle-pine");104
const handle = recipeDefinition("handle-pine");104
assert.ok(handle);105
assert.ok(handle);@@ -84,7 +84,7 @@ test("debarked logs keep oak itemId but change name and sprite", () =>
84
84
assert.equal(barkItemIdForWood(WoodTier.oak), WoodItemId.oakBark);
85
85
});
86
86
87
test("debark Crafting XP is half wood tier rank rounded up", () =>
87
test("debark Woodworking XP is half wood tier rank rounded up", () =>
88
88
{
89
89
assert.equal(woodworkingXpForDebark(WoodTier.pine), 1);
90
90
assert.equal(woodworkingXpForDebark(WoodTier.birch), 1);
@@ -100,7 +100,7 @@ test("debark-log on ground oak log yields bark and debarked flag", () =>
100
100
harness.simulation.reloadWorld();
101
101
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });
102
102
setSkillLevel(harness, character.character_id, SkillId.woodcutting, 20);
103
setSkillLevel(harness, character.character_id, SkillId.crafting, 1);
103
setSkillLevel(harness, character.character_id, SkillId.woodworking, 1);
104
104
const inventory = emptySlots();
105
105
inventory[0] = { itemId: ItemId.ironAxe, quantity: 1 };
106
106
harness.stateDb.saveBag(character.character_id, {
@@ -113,7 +113,7 @@ test("debark-log on ground oak log yields bark and debarked flag", () =>
113
113
const record = harness.simulation.entityRecord(entityId);
114
114
const worker = harness.simulation.workers[record.workerId];
115
115
const handle = worker.world.ecs.handleOf(entityId);
116
const craftingXpBefore = worker.world.ecs.get(handle, Component.skills).xp[SkillId.crafting] | 0;
116
const woodworkingXpBefore = worker.world.ecs.get(handle, Component.skills).xp[SkillId.woodworking] | 0;
117
117
118
118
const groundItemId = (worker.world.nextGroundItemId = (worker.world.nextGroundItemId ?? 1) + 1);
119
119
addGroundItem(worker.world, {
@@ -154,8 +154,8 @@ test("debark-log on ground oak log yields bark and debarked flag", () =>
154
154
assert.equal(bark.stack.quantity, 1);
155
155
assert.equal(worker.world.ecs.has(handle, Component.gather), false);
156
156
157
const craftingXpAfter = worker.world.ecs.get(handle, Component.skills).xp[SkillId.crafting] | 0;
158
assert.equal(craftingXpAfter - craftingXpBefore, woodworkingXpForDebark(WoodTier.oak));
157
const woodworkingXpAfter = worker.world.ecs.get(handle, Component.skills).xp[SkillId.woodworking] | 0;
158
assert.equal(woodworkingXpAfter - woodworkingXpBefore, woodworkingXpForDebark(WoodTier.oak));
159
159
}
160
160
finally
161
161
{ harness.close(); }
@@ -84,7 +84,7 @@ test("debarked logs keep oak itemId but change name and sprite", () =>84
assert.equal(barkItemIdForWood(WoodTier.oak), WoodItemId.oakBark);84
assert.equal(barkItemIdForWood(WoodTier.oak), WoodItemId.oakBark);85
});85
});86
86
87
test("debark Crafting XP is half wood tier rank rounded up", () =>87
test("debark Woodworking XP is half wood tier rank rounded up", () =>88
{88
{89
assert.equal(woodworkingXpForDebark(WoodTier.pine), 1);89
assert.equal(woodworkingXpForDebark(WoodTier.pine), 1);90
assert.equal(woodworkingXpForDebark(WoodTier.birch), 1);90
assert.equal(woodworkingXpForDebark(WoodTier.birch), 1);@@ -100,7 +100,7 @@ test("debark-log on ground oak log yields bark and debarked flag", () =>100
harness.simulation.reloadWorld();100
harness.simulation.reloadWorld();101
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });101
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });102
setSkillLevel(harness, character.character_id, SkillId.woodcutting, 20);102
setSkillLevel(harness, character.character_id, SkillId.woodcutting, 20);103
setSkillLevel(harness, character.character_id, SkillId.crafting, 1);103
setSkillLevel(harness, character.character_id, SkillId.woodworking, 1);104
const inventory = emptySlots();104
const inventory = emptySlots();105
inventory[0] = { itemId: ItemId.ironAxe, quantity: 1 };105
inventory[0] = { itemId: ItemId.ironAxe, quantity: 1 };106
harness.stateDb.saveBag(character.character_id, {106
harness.stateDb.saveBag(character.character_id, {@@ -113,7 +113,7 @@ test("debark-log on ground oak log yields bark and debarked flag", () =>113
const record = harness.simulation.entityRecord(entityId);113
const record = harness.simulation.entityRecord(entityId);114
const worker = harness.simulation.workers[record.workerId];114
const worker = harness.simulation.workers[record.workerId];115
const handle = worker.world.ecs.handleOf(entityId);115
const handle = worker.world.ecs.handleOf(entityId);116
const craftingXpBefore = worker.world.ecs.get(handle, Component.skills).xp[SkillId.crafting] | 0;116
const woodworkingXpBefore = worker.world.ecs.get(handle, Component.skills).xp[SkillId.woodworking] | 0;117
117
118
const groundItemId = (worker.world.nextGroundItemId = (worker.world.nextGroundItemId ?? 1) + 1);118
const groundItemId = (worker.world.nextGroundItemId = (worker.world.nextGroundItemId ?? 1) + 1);119
addGroundItem(worker.world, {119
addGroundItem(worker.world, {@@ -154,8 +154,8 @@ test("debark-log on ground oak log yields bark and debarked flag", () =>154
assert.equal(bark.stack.quantity, 1);154
assert.equal(bark.stack.quantity, 1);155
assert.equal(worker.world.ecs.has(handle, Component.gather), false);155
assert.equal(worker.world.ecs.has(handle, Component.gather), false);156
156
157
const craftingXpAfter = worker.world.ecs.get(handle, Component.skills).xp[SkillId.crafting] | 0;157
const woodworkingXpAfter = worker.world.ecs.get(handle, Component.skills).xp[SkillId.woodworking] | 0;158
assert.equal(craftingXpAfter - craftingXpBefore, woodworkingXpForDebark(WoodTier.oak));158
assert.equal(woodworkingXpAfter - woodworkingXpBefore, woodworkingXpForDebark(WoodTier.oak));159
}159
}160
finally160
finally161
{ harness.close(); }161
{ harness.close(); }