Skip to content

Commit 5204c0b

Browse files
committed
Rebuild public bundle and update state tests
Rebuilt the public bundle (public/export.bundle.js) — minifier/rename changes updated font and sprite constant names and inlined styles. Updated related public assets (public/pico8-ui.woff, public/tiny-rpg-studio-sdk.css). Modified runtime state logic (src/runtime/domain/state/StateObjectManager.ts) and adjusted tests (src/__tests__/engine/PushBox.test.ts, src/__tests__/state/StateObjectManager.test.ts) to match the implementation changes. These changes appear to be a combination of a build/regeneration and a small runtime fix with corresponding test updates.
1 parent 355b0d7 commit 5204c0b

6 files changed

Lines changed: 115 additions & 21 deletions

File tree

‎public/export.bundle.js‎

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎public/pico8-ui.woff‎

0 Bytes
Binary file not shown.

‎public/tiny-rpg-studio-sdk.css‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/__tests__/engine/PushBox.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,58 @@ describe('PushBox — MovementManager', () => {
212212

213213
expect(gameState.resetPushBoxesForRoom).toHaveBeenCalledWith(0);
214214
});
215+
216+
it('resets an editor-created push-box after it is pushed, the player leaves, and then returns', () => {
217+
const game = {
218+
start: { x: 1, y: 1, roomIndex: 0 },
219+
objects: [],
220+
variables: [],
221+
};
222+
const objectManager = new StateObjectManager(game, createWorldManager(), createVariableManager());
223+
const box = objectManager.setObjectPosition(ITEM_TYPES.PUSH_BOX, 0, 4, 3);
224+
if (!box) throw new Error('push-box not created');
225+
226+
const player = { roomIndex: 0, x: 3, y: 3, lastX: 2 };
227+
const gameState = createMovementGameState({
228+
getPlayer: vi.fn(() => player),
229+
getRoomCoords: vi.fn((roomIndex: number) => ({ row: 0, col: roomIndex })),
230+
getRoomIndex: vi.fn((row: number, col: number) => (row === 0 && (col === 0 || col === 1) ? col : null)),
231+
getGame: vi.fn(() => ({
232+
rooms: [makeRoom(emptyWalls()), makeRoom(emptyWalls())],
233+
sprites: [],
234+
})),
235+
getObjectAt: vi.fn((roomIndex, x, y) => objectManager.getObjectAt(roomIndex as number, x as number, y as number)),
236+
resetPushBoxesForRoom: vi.fn((roomIndex: number) => objectManager.resetPushBoxesForRoom(roomIndex)),
237+
setPlayerPosition: vi.fn((x: number, y: number, roomIndex: number | null) => {
238+
player.x = x;
239+
player.y = y;
240+
if (roomIndex !== null) {
241+
player.roomIndex = roomIndex;
242+
}
243+
}),
244+
});
245+
const manager = makeMovementManager(gameState);
246+
247+
manager.tryMove(1, 0);
248+
249+
expect(box.x).toBe(5);
250+
expect(box.y).toBe(3);
251+
252+
player.x = 7;
253+
player.y = 3;
254+
manager.tryMove(1, 0);
255+
256+
expect(gameState.resetPushBoxesForRoom).toHaveBeenCalledWith(0);
257+
expect(player.roomIndex).toBe(1);
258+
expect(box.x).toBe(4);
259+
expect(box.y).toBe(3);
260+
261+
manager.tryMove(-1, 0);
262+
263+
expect(player.roomIndex).toBe(0);
264+
expect(box.x).toBe(4);
265+
expect(box.y).toBe(3);
266+
});
215267
});
216268

217269
describe('PushBox — InteractionManager pressure plate integration', () => {

‎src/__tests__/state/StateObjectManager.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,40 @@ describe('StateObjectManager', () => {
154154
expect(plate.activated).toBe(false);
155155
expect(chest.opened).toBe(false);
156156
});
157+
158+
it('stores the reset position when placing a push-box through the editor API', () => {
159+
const game = { start: { x: 1, y: 1, roomIndex: 0 }, objects: [], variables: [] };
160+
const manager = new StateObjectManager(game, createWorldManager(), createVariableManager());
161+
162+
const box = manager.setObjectPosition(ITEM_TYPES.PUSH_BOX, 0, 3, 4);
163+
if (!box) throw new Error('push-box not created');
164+
165+
box.x = 6;
166+
box.y = 2;
167+
manager.resetPushBoxesForRoom(0);
168+
169+
expect(box.originalX).toBe(3);
170+
expect(box.originalY).toBe(4);
171+
expect(box.x).toBe(3);
172+
expect(box.y).toBe(4);
173+
});
174+
175+
it('updates the reset position when repositioning a push-box by id', () => {
176+
const game = { start: { x: 1, y: 1, roomIndex: 0 }, objects: [], variables: [] };
177+
const manager = new StateObjectManager(game, createWorldManager(), createVariableManager());
178+
const box = manager.setObjectPosition(ITEM_TYPES.PUSH_BOX, 0, 1, 2);
179+
if (!box) throw new Error('push-box not created');
180+
181+
manager.moveObjectById(box.id, 5, 6);
182+
box.x = 7;
183+
box.y = 7;
184+
manager.resetPushBoxesForRoom(0);
185+
186+
expect(box.originalX).toBe(5);
187+
expect(box.originalY).toBe(6);
188+
expect(box.x).toBe(5);
189+
expect(box.y).toBe(6);
190+
});
157191
});
158192

159193
describe('StateObjectManager - logic gates', () => {

‎src/runtime/domain/state/StateObjectManager.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@ class StateObjectManager {
440440
entry.variableId = this.variableManager?.normalizeVariableId?.(entry.variableId) ?? fallbackVariableId;
441441
entry.activated = false;
442442
}
443+
if (normalizedType === ITEM_TYPES.PUSH_BOX) {
444+
entry.originalX = entry.x;
445+
entry.originalY = entry.y;
446+
}
443447
return this.applyObjectBehavior(entry);
444448
}
445449

@@ -463,6 +467,10 @@ class StateObjectManager {
463467
if (entry.type === StateObjectManager.PLAYER_START_TYPE) {
464468
this.syncPlayerStart(entry);
465469
}
470+
if (entry.type === ITEM_TYPES.PUSH_BOX) {
471+
entry.originalX = entry.x;
472+
entry.originalY = entry.y;
473+
}
466474
return true;
467475
}
468476

0 commit comments

Comments
 (0)