Show the craft-style item icon above the head when a pigeon delivers to inventory.
@@ -507,6 +507,15 @@ export class CourierService
507
507
if (toast)
508
508
{ events.push(toast); }
509
509
}
510
else
511
{
512
events.push({
513
type: "item-bubble",
514
entityId: delivered.entityId,
515
itemId: delivered.itemId,
516
quantity: delivered.quantity
517
});
518
}
510
519
}
511
520
512
521
transit.status = "delivered";
@@ -541,21 +550,25 @@ export class CourierService
541
550
cargo = this.#normalizeCargo(cargo);
542
551
const onlineId = this.simulation.characterEntities.get(characterId);
543
552
if (!onlineId)
544
{ return false; }
553
{ return null; }
545
554
if (cargo.kind === "item")
546
555
{
547
556
const bag = this.simulation.bagOf(onlineId);
548
557
if (!bag)
549
{ return false; }
558
{ return null; }
550
559
const def = itemDefinition(cargo.stack.itemId);
551
560
const result = insertStack(bag.inventory, cargo.stack, def);
552
561
if (!result.ok || result.remainder)
553
{ return false; }
562
{ return null; }
554
563
bag.inventory = result.slots;
555
564
this.#persistBag(characterId, bag);
556
return true;
565
return {
566
entityId: onlineId,
567
itemId: cargo.stack.itemId,
568
quantity: Math.max(1, cargo.stack.quantity | 0 || 1)
569
};
557
570
}
558
return false;
571
return null;
559
572
}
560
573
561
574
#creditVault (characterId, cargo, { senderCharacterId = null, recordRestNotice = true } = {})
@@ -507,6 +507,15 @@ export class CourierService507
if (toast)507
if (toast)508
{ events.push(toast); }508
{ events.push(toast); }509
}509
}510
else511
{512
events.push({513
type: "item-bubble",514
entityId: delivered.entityId,515
itemId: delivered.itemId,516
quantity: delivered.quantity517
});518
}510
}519
}511
520
512
transit.status = "delivered";521
transit.status = "delivered";@@ -541,21 +550,25 @@ export class CourierService541
cargo = this.#normalizeCargo(cargo);550
cargo = this.#normalizeCargo(cargo);542
const onlineId = this.simulation.characterEntities.get(characterId);551
const onlineId = this.simulation.characterEntities.get(characterId);543
if (!onlineId)552
if (!onlineId)544
{ return false; }553
{ return null; }545
if (cargo.kind === "item")554
if (cargo.kind === "item")546
{555
{547
const bag = this.simulation.bagOf(onlineId);556
const bag = this.simulation.bagOf(onlineId);548
if (!bag)557
if (!bag)549
{ return false; }558
{ return null; }550
const def = itemDefinition(cargo.stack.itemId);559
const def = itemDefinition(cargo.stack.itemId);551
const result = insertStack(bag.inventory, cargo.stack, def);560
const result = insertStack(bag.inventory, cargo.stack, def);552
if (!result.ok || result.remainder)561
if (!result.ok || result.remainder)553
{ return false; }562
{ return null; }554
bag.inventory = result.slots;563
bag.inventory = result.slots;555
this.#persistBag(characterId, bag);564
this.#persistBag(characterId, bag);556
return true;565
return {566
entityId: onlineId,567
itemId: cargo.stack.itemId,568
quantity: Math.max(1, cargo.stack.quantity | 0 || 1)569
};557
}570
}558
return false;571
return null;559
}572
}560
573
561
#creditVault (characterId, cargo, { senderCharacterId = null, recordRestNotice = true } = {})574
#creditVault (characterId, cargo, { senderCharacterId = null, recordRestNotice = true } = {})@@ -217,13 +217,19 @@ test("pigeon delivers an item to an online player inventory", () =>
217
217
});
218
218
assert.equal(harness.simulation.bagOf(senderId).inventory[appleSlot].quantity, senderQty - 1);
219
219
220
stepTimes(harness.simulation, 40);
220
const events = stepTimes(harness.simulation, 40);
221
221
const receiverAfter = harness.simulation.bagOf(receiverId);
222
222
const receiverApplesAfter = receiverAfter.inventory
223
223
.filter((slot) => slot?.itemId === ItemId.apple)
224
224
.reduce((sum, slot) => sum + slot.quantity, 0);
225
225
assert.equal(receiverApplesAfter, receiverApples + 1);
226
226
assert.equal(harness.stateDb.listActiveCourierTransits().length, 0);
227
assert.ok(events.some((event) =>
228
event.type === "item-bubble"
229
&& event.entityId === receiverId
230
&& event.itemId === ItemId.apple
231
&& event.quantity === 1
232
), "pigeon delivery should show the craft-style item bubble");
227
233
}
228
234
finally
229
235
{ harness.close(); }
@@ -217,13 +217,19 @@ test("pigeon delivers an item to an online player inventory", () =>217
});217
});218
assert.equal(harness.simulation.bagOf(senderId).inventory[appleSlot].quantity, senderQty - 1);218
assert.equal(harness.simulation.bagOf(senderId).inventory[appleSlot].quantity, senderQty - 1);219
219
220
stepTimes(harness.simulation, 40);220
const events = stepTimes(harness.simulation, 40);221
const receiverAfter = harness.simulation.bagOf(receiverId);221
const receiverAfter = harness.simulation.bagOf(receiverId);222
const receiverApplesAfter = receiverAfter.inventory222
const receiverApplesAfter = receiverAfter.inventory223
.filter((slot) => slot?.itemId === ItemId.apple)223
.filter((slot) => slot?.itemId === ItemId.apple)224
.reduce((sum, slot) => sum + slot.quantity, 0);224
.reduce((sum, slot) => sum + slot.quantity, 0);225
assert.equal(receiverApplesAfter, receiverApples + 1);225
assert.equal(receiverApplesAfter, receiverApples + 1);226
assert.equal(harness.stateDb.listActiveCourierTransits().length, 0);226
assert.equal(harness.stateDb.listActiveCourierTransits().length, 0);227
assert.ok(events.some((event) =>228
event.type === "item-bubble"229
&& event.entityId === receiverId230
&& event.itemId === ItemId.apple231
&& event.quantity === 1232
), "pigeon delivery should show the craft-style item bubble");227
}233
}228
finally234
finally229
{ harness.close(); }235
{ harness.close(); }@@ -177,7 +177,7 @@ test("admin gift credits bank and queues a system letter", () =>
177
177
assert.equal(active[0].destinationKind, "player");
178
178
assert.equal(active[0].cargo.stack.instance.authorDisplayName, QUESTWARD_GIFT_AUTHOR);
179
179
180
stepTimes(harness.simulation, 40);
180
const events = stepTimes(harness.simulation, 40);
181
181
182
182
const bag = harness.simulation.bagOf(entityId);
183
183
const letter = (bag.inventory ?? []).find((slot) => slot?.itemId === ItemId.letter);
@@ -185,6 +185,11 @@ test("admin gift credits bank and queues a system letter", () =>
185
185
assert.equal(letter.instance.authorDisplayName, QUESTWARD_GIFT_AUTHOR);
186
186
assert.equal(letter.instance.authorOrganization, QUESTWARD_GIFT_ORG);
187
187
assert.match(letter.instance.body, /A small thank-you/);
188
assert.ok(events.some((event) =>
189
event.type === "item-bubble"
190
&& event.entityId === entityId
191
&& event.itemId === ItemId.letter
192
));
188
193
assert.equal(
189
194
(harness.stateDb.getBag(character.character_id).vault ?? [])
190
195
.some((slot) => slot?.itemId === ItemId.letter),
@@ -177,7 +177,7 @@ test("admin gift credits bank and queues a system letter", () =>177
assert.equal(active[0].destinationKind, "player");177
assert.equal(active[0].destinationKind, "player");178
assert.equal(active[0].cargo.stack.instance.authorDisplayName, QUESTWARD_GIFT_AUTHOR);178
assert.equal(active[0].cargo.stack.instance.authorDisplayName, QUESTWARD_GIFT_AUTHOR);179
179
180
stepTimes(harness.simulation, 40);180
const events = stepTimes(harness.simulation, 40);181
181
182
const bag = harness.simulation.bagOf(entityId);182
const bag = harness.simulation.bagOf(entityId);183
const letter = (bag.inventory ?? []).find((slot) => slot?.itemId === ItemId.letter);183
const letter = (bag.inventory ?? []).find((slot) => slot?.itemId === ItemId.letter);@@ -185,6 +185,11 @@ test("admin gift credits bank and queues a system letter", () =>185
assert.equal(letter.instance.authorDisplayName, QUESTWARD_GIFT_AUTHOR);185
assert.equal(letter.instance.authorDisplayName, QUESTWARD_GIFT_AUTHOR);186
assert.equal(letter.instance.authorOrganization, QUESTWARD_GIFT_ORG);186
assert.equal(letter.instance.authorOrganization, QUESTWARD_GIFT_ORG);187
assert.match(letter.instance.body, /A small thank-you/);187
assert.match(letter.instance.body, /A small thank-you/);188
assert.ok(events.some((event) =>189
event.type === "item-bubble"190
&& event.entityId === entityId191
&& event.itemId === ItemId.letter192
));188
assert.equal(193
assert.equal(189
(harness.stateDb.getBag(character.character_id).vault ?? [])194
(harness.stateDb.getBag(character.character_id).vault ?? [])190
.some((slot) => slot?.itemId === ItemId.letter),195
.some((slot) => slot?.itemId === ItemId.letter),