Commit Graph

134 Commits

Author SHA1 Message Date
hyper ad2c808482 feat(sts-viewer): add effect application logging and fix command error
handling

- Log effect application details in `CombatTestScene`
- Update `tryPlayCard` to use "global" scope and handle error reasons
- Register desert triggers in `createCombatModule`
2026-04-23 16:28:10 +08:00
hyper f893ac9ff7 feat(framework): add generic types to GameHostScene
Update GameHostScene to support generic types for TResult and TModule,
allowing better type safety when interacting with the game host and
its modules.
2026-04-23 16:11:15 +08:00
hypercross dfbdaa3499 feat(sts-viewer): add spawn/despawn tweens and async interruptions
Add visual tweens for Buff and Card game objects. Update spawners to
use `GameHostScene` and `addInterruption` to ensure animations
complete before the next state change occurs.
2026-04-22 21:29:43 +08:00
hypercross c29b9a43b3 feat(framework): decouple spawner update logic
Extract the core update logic from `spawnEffect` into
`createSpawnUpdate`.
This allows manual updates of spawned objects without relying on
Preact effects, which is useful for non-reactive or imperative
update cycles.

Refactor `Buff` and `BuffSpawner` in `sts-like-viewer` to use the new
`createSpawnUpdate` API for more efficient buff rendering.
2026-04-22 20:59:35 +08:00
hypercross 447a5cfbd0 feat(sts-viewer): improve card and effect visual indicators
- Update `CardContainer` to use descriptive emojis for different target
  types
- Use emoji icons for combat unit status effects instead of keys
- Update `CardSpawner` default target type to 'player'
- Fix target type check in `CombatTestScene` to use 'enemy' instead of
  'single'
2026-04-22 19:47:37 +08:00
hypercross dda290bf9c feat(framework): add hoverEffect utility
Add a `hoverEffect` utility to `boardgame-phaser` to simplify
handling pointerover and pointerout events. Refactor
`CardContainer` in `sts-like-viewer` to use this new utility and
centralize card dimensions in `CARD_CONFIG`.
2026-04-22 15:13:33 +08:00
hypercross 5d84c42b78 style: reformat CombatUnitContainer for readability 2026-04-22 11:46:39 +08:00
hypercross a6ddafb802 build: add @types/node to sts-like-viewer 2026-04-22 11:46:24 +08:00
hypercross a181932fb3 refactor: simplify CombatTestScene instantiation in App
Remove manual instantiation of CombatTestScene in favor of passing
the class directly to PhaserScene, allowing the framework to handle
scene lifecycle.
2026-04-22 00:56:45 +08:00
hypercross 887da22baa fix(framework): check instance of Scene in PhaserScene
Ensure the scene passed to PhaserScene is an instance of Phaser.Scene
before deciding whether to instantiate it.
2026-04-22 00:55:38 +08:00
hypercross 5355afb23e feat(sts-viewer): implement card spawning and combat interaction
Add `CardContainer` and `CardSpawner` to handle visual representation
of cards in the hand. Refactor `CombatTestScene` to use `GameHostScene`
and implement card selection/targeting logic for combat simulation.
2026-04-22 00:53:57 +08:00
hypercross 3f2ba84a06 feat(sts-viewer): add CombatTestScene and unit visuals
Implement a new combat test scene to visualize Slay the Spire-like
combat states. This includes:

- `CombatUnitContainer`: A Phaser container for displaying unit HP,
  name, buffs, and enemy intents.
- `CombatUnitSpawner`: A spawner to manage the lifecycle of combat
  units based on the combat state.
- `
2026-04-21 23:50:47 +08:00
hypercross 9637312b7c feat(sts-viewer): implement combat state and fix inventory removal
- Add `createCombatState` to initialize combat using inventory and run
  state
- Implement `runContext` to bridge inventory data with combat logic
- Update inventory to use `removeItem` instead of `removeItemFromGrid`
2026-04-21 23:28:47 +08:00
hypercross 82c026628a fix(sts-like-viewer): correct y-coordinate comparison in
InventoryItemContainer

Fix a bug where the y-coordinate of an item's offset was being
compared against the target's x-coordinate instead of its y-coordinate.
2026-04-21 22:17:00 +08:00
hypercross a92b889dfa feat(sts-like-viewer): batch inventory item movement
Wrap item removal and placement in a batch to prevent multiple
reactive updates when moving items between inventories.
2026-04-21 16:50:48 +08:00
hypercross c97c2c4150 feat(sts-viewer): support multiple inventory surfaces
Refactor `InventoryTestScene` to support multiple inventory signals
simultaneously. This introduces `InventorySurface` to manage
positioning and signal mapping for multiple grids, allowing for
testing item movement between different inventory areas.
2026-04-21 16:48:45 +08:00
hypercross 422ddde200 refactor: support multiple inventory surfaces
Introduce `InventorySurface` to allow items to be moved between
different inventory grids.

- Update `InventoryItemContainer` to use surface-specific cell sizes
  and coordinate transformations.
- Update `InventoryItemSpawner` to handle multiple surfaces.
- Refactor `moveItem` to support transferring items from one
  `InventorySignal` to another.
- Add `InventorySurfaceState` to manage surface-specific metadata.
- Remove reliance on global `GRID_CONFIG` in favor of surface data.
2026-04-21 16:39:10 +08:00
hypercross 093eadbefd refactor: encapsulate InventoryItemContainer internals
Make `updateHitArea` and `renderGraphics` private to prevent external
access to internal rendering logic. Move the preview rotation reset
to ensure it always executes after a drag operation.
2026-04-21 09:51:10 +08:00
hypercross eff62bc0ed fix(sts-like-viewer): fix item movement detection and removal
- Update `InventoryItemContainer` to correctly detect rotation changes
- Use `removeItemFromGrid` in `InventoryTestScene` for item removal
2026-04-21 00:16:50 +08:00
hypercross fe0621cedf feat(sts-like-viewer): animate inventory item rotation
Introduce a tween for the item's rotation and update the hit area
calculation to account for the preview rotation. The graphics are now
centered within the container to support these transformations.
2026-04-20 22:15:05 +08:00
hypercross 30e2d9ac36 refactor: improve inventory item interaction and state
- Decouple hit area calculation from the rendering effect in
  `InventoryItemContainer`.
- Implement a dedicated `hitArea` property to track cell rectangles.
- Update `setupInteractive` to use the container itself as the hit area
  with a custom callback.
- Move drag-and-drop logic into a dedicated `setupDnDEffect` method.
- Add `addPreviewRotation` to `InventoryItemState` for cleaner rotation
  updates.
- Normalize `previewRotation` to stay within 0-360 degrees.
2026-04-20 21:59:08 +08:00
hypercross c9f573ef86 feat(sts-viewer): add item rotation support in inventory
Introduces the ability to rotate inventory items using the Alt button
during drag-and-drop.

- Updates `InventoryItemContainer` to handle rotation via
  `previewRotation`
- Adds `newRotation` parameter to `onMoveItem` callback and `moveItem`
  command
- Updates `InventoryItemState` to manage rotation state and compute
  transformed shapes
- Implements rotation logic in `renderGraphics` using `transformShape`
2026-04-20 21:40:23 +08:00
hypercross cc796d1e11 feat(framework): support multi-button drag and drop
Adds support for tracking the specific mouse button used during
drag-and-drop operations. This includes a new `ALTBUTTON` event type
to handle cases where a different button is pressed while a drag is
already in progress, and disables the browser context menu by default
in the Phaser configuration to prevent interference.
2026-04-20 20:33:56 +08:00
hypercross fd347e7a62 refactor: use InventoryItemState in InventoryItemContainer
Replace local signal-based state management with the dedicated
`InventoryItemState` class to encapsulate item properties and
logic.
2026-04-20 19:50:25 +08:00
hypercross 19dfafeb30 refactor: implement cell-based hit area for inventory items
Update `InventoryItemContainer` to use a custom hit area callback
based on individual cell rectangles instead of a single bounding
box. This allows for more precise interaction with non-rectangular
item shapes.
2026-04-20 19:45:01 +08:00
hypercross b2862e34d9 fix: improve inventory item drag-and-drop behavior
- Use `snapBack` instead of immediate coordinate reset when a drag fails
- Adjust grid snapping calculation to use center-relative coordinates
- Validate item placement by simulating removal from the grid first
2026-04-20 19:22:55 +08:00
hypercross fd41db2a89 fix(sts-like-viewer): defer interactive setup until shape is available
Delay calling `setupInteractive` in `InventoryItemContainer` until
the item shape is actually rendered to ensure the hit area matches
the visual representation.
2026-04-20 18:49:56 +08:00
hypercross f03e6c5a7b refactor: move InventoryItemSpawner and update grid drawing
- Move `InventoryItemSpawner` to `@/gameobjects`
- Wrap grid drawing in `addEffect` in `InventoryTestScene` to ensure
  reactivity
- Fix return type in `onMoveItem` callback
2026-04-20 18:44:50 +08:00
hypercross 7039938a72 refactor: delegate signal effects to DisposableBag
Introduce `addEffect` to `DisposableBag` to encapsulate Preact
signal effect creation and disposal. Update `ReactiveScene` to use
this method, simplifying effect management and ensuring proper
cleanup.
2026-04-20 18:18:26 +08:00
hypercross 45844ea800 fix(sts-viewer): use local coordinates for inventory item container
Update `InventoryItemSpawner` to draw graphics and text relative to the
container's local coordinate system instead of world coordinates.
The container is then positioned at the first cell's world position.
This also fixes drag positioning by calculating movement relative to
the initial drag start point.
2026-04-20 17:20:30 +08:00
hypercross 29b516c371 feat(sts-viewer): implement drag-and-drop for inventory items
Adds interactive drag-and-drop functionality to the inventory spawner,
allowing users to move items within the grid.

- Implements `InventoryItemSpawnerCallbacks` to handle item movement
- Adds `moveItem` utility to update inventory state via signals
- Integrates `dragDropEventEffect` for item interaction
- Updates `InventoryTestScene` to demonstrate movement
- Adjusts text colors in `GRID_CONFIG` for better visibility
2026-04-20 17:06:46 +08:00
hypercross 5884e74d8d refactor: implement inventory item spawner and config
- Add cell and text styling constants to `GRID_CONFIG`
- Replace manual item drawing in `InventoryTestScene` with
  `InventoryItemSpawner`
- Update `InventoryTestScene` to use dynamic inventory dimensions for
  grid rendering
- Register `InventoryTestScene` in the main `App` component
2026-04-20 16:45:14 +08:00
hypercross b06876ccc0 feat(sts-like-viewer): add inventory test scene
Implement `InventoryTestScene` to demonstrate reactive inventory
management using signals. Includes a grid-based visualization of items
and controls to add or remove items dynamically.
2026-04-20 16:34:03 +08:00
hypercross 368d9942d2 refactor(onitama): centralize visual constants in config
Introduce `TEXT_POSITION` and `VISUAL` objects to the configuration
to manage magic numbers for positioning, radii, stroke widths, and
alphas. Update renderers and spawners to use these constants instead
of hardcoded values or direct calculations.
2026-04-20 16:04:29 +08:00
hypercross 22817945cc fix(framework): access scene key via sys.settings in PhaserScene
Use `scene.sys.settings.key` instead of `scene.scene.key` to correctly
retrieve the scene key from the Phaser scene instance.
2026-04-20 15:47:56 +08:00
hypercross 85bc4f5400 refactor: remove unused state and widget files in sts-like-viewer 2026-04-20 15:44:09 +08:00
hypercross 033a8e4a40 refactor: clean up scenes and introduce SceneKey enum
- Remove redundant `GameFlowScene` and `PlaceholderEncounterScene`
- Introduce `SceneKey` enum for type-safe scene management
- Clean up unused imports and configuration references in existing
  scenes
- Standardize scene navigation using `SceneKey`
2026-04-20 15:36:12 +08:00
hypercross 1d803dd219 refactor(sts-like-viewer): simplify scene management and config
- Move configuration to `src/config/index.ts`
- Simplify `App.tsx` by passing scene classes directly to `PhaserScene`
- Update `GameUI` initialization to use string ID for container
- Update documentation to mention `initData` for `ReactiveScene`
- Standardize quote usage and formatting in config files
2026-04-20 15:24:07 +08:00
hypercross 2d412eedb5 refactor(framework): improve PhaserScene flexibility
Allow `PhaserScene` to accept either a scene instance or a scene
constructor. This enables more flexible scene registration within
the `PhaserBridge`. Also updates `sceneKey` to be optional,
defaulting to the scene's internal key.
2026-04-20 15:11:45 +08:00
hypercross 34a7cff964 refactor: remove inventory widget and drag controller
Removes the inventory management system and drag-and-drop
functionality from the STS-like viewer. This includes deleting the
`InventoryWidget`, `InventoryItemSpawner`, and `DragController`
classes, as well as cleaning up references in
`PlaceholderEncounterScene`.
2026-04-19 14:59:39 +08:00
hypercross 4d34f9fa78 refactor(framework): use callback instead of events in
dragDropEventEffect

Replace Phaser event emissions with a `DragDropCallback` in
`dragDropEventEffect` to provide a more explicit and type-safe API
for handling drag-and-drop interactions.
2026-04-19 13:04:53 +08:00
hypercross c25759d147 refactor(onitama): extract tweens into factory functions
Centralize Onitama animation logic by moving inline Phaser tweens
into a dedicated `tweens.ts` configuration file. This improves
reusability and cleans up spawners and renderers.

Also updated documentation to warn against adding interruptions to
looped tweens to prevent game logic hangs.
2026-04-19 12:45:05 +08:00
hypercross 3568d99e6e fix(onitama): prevent game hang by removing tween interruptions
Remove tween interruptions from the selection fade-in and pulse
animations to prevent the game state from stopping indefinitely.
2026-04-19 12:29:17 +08:00
hypercross b28da1cad3 refactor(onitama): decouple rendering logic into dedicated renderers
Introduces a centralized configuration system and extracts visual
creation logic from spawners into specialized renderer classes:
- CardRenderer
- HighlightRenderer
- PawnRenderer
- SelectionRenderer

This refactor improves separation of concerns by moving Phaser-specific
drawing and animation code out of the spawner/container logic and into
reusable renderer components.
2026-04-19 11:55:18 +08:00
hypercross c7ef992082 refactor(onitama-game): simplify GameUI initialization 2026-04-19 11:31:03 +08:00
hypercross 3afe78f54f refactor(framework): allow string ID for GameUI container
Update GameUIOptions to accept either an HTMLElement or a string ID.
If a string is provided, the class will attempt to find the element
by ID or create a new div if it does not exist. Also update the root
property to accept a JSX.Element.
2026-04-19 11:30:14 +08:00
hypercross b0e74a5257 refactor(framework): simplify spawner state management
Consolidate object and data tracking into a single Map in `spawnEffect`
to improve clarity and reduce redundant lookups. Also switch to
type-only
imports for Phaser.
2026-04-19 11:00:01 +08:00
hypercross 648e801dad Style: enforce 2-space indent and double quotes 2026-04-19 10:48:32 +08:00
hypercross e14e41461f Fix drag race condition and stale pointer events
Mark items as dragging before updating inventory state to prevent
the spawner from destroying containers mid-drag. Move inventory
removal to drop time for lost items, and add guards to ignore
stale pointer events on inactive containers.
2026-04-19 00:43:43 +08:00
hypercross 5af7140958 Refactor inventory to use Spawner pattern
Replace manual ItemRenderer with InventoryItemSpawner and
GridBackgroundRenderer. Uses spawnEffect to automatically sync item
visuals with game state changes. Separates static grid rendering and
tracks dragged items to prevent spawner conflicts.
2026-04-19 00:24:20 +08:00