Skip to content

feat: implement server-side treasure chest loot generation and secure… - #69

Open
Darrin-Lin wants to merge 2 commits into
mainfrom
refactor/drop
Open

feat: implement server-side treasure chest loot generation and secure…#69
Darrin-Lin wants to merge 2 commits into
mainfrom
refactor/drop

Conversation

@Darrin-Lin

Copy link
Copy Markdown
Contributor

This pull request introduces a secure, server-authoritative system for generating and claiming item and gold drops from monsters and treasure chests. It adds new API endpoints and client logic to request drop data from the backend, updates the drop spawning flow to use server data when available, and ensures that gold pickups are properly claimed and reported. If the server is unavailable, local fallback logic is used to generate drops as before.

Secure Drop Generation and Claiming

  • Adds new API endpoints and client methods:

    • AuthApiClient now supports GenerateDrops and ClearDrops requests, enabling secure drop generation and cleanup via the backend. [1] [2]
    • Mock server responses are implemented for these endpoints to facilitate local testing.
  • Integrates server-driven drop generation:

    • Monster and TreasureChest now request drops from the server when possible, and only fall back to local generation if the server is unavailable or returns an error. [1] [2]
    • Drops from the server are spawned with their server-assigned instance_id and data, supporting both gold and item drops. [1] [2]
    • Local drop logic is refactored to use the provided spawn position and manager, and to match the new secure drop flow. [1] [2] [3]

Gold Drop Claiming and Profile Sync

  • Adds support for tracking and claiming gold drops:
    • CoinDrop now supports secure initialization with an instance_id and value, and notifies the main game instance when picked up. [1] [2]
    • Main tracks pending claimed drop IDs and provides methods for claiming drops and transmitting the player's profile after pickup.

Session and Cleanup Handling

  • Ensures cleanup of pending drops on logout:
    • When the player logs out, all pending drops are cleared via the ClearDrops API call.

Other Improvements

  • Adds a singleton reference to Main.Instance for easier access to global state and API clients. [1] [2]
  • Minor fixes for null checks, manager usage, and consistent item scaling in drop spawning.

These changes provide a more secure and authoritative item drop system while maintaining robust fallback behavior for offline or local play.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant