Skip to content

Add a shared character state #9

@jon-zu

Description

@jon-zu
  • Create a shared state for each session behind a lock, which book-keeps changes
  • Expose the shared state via the Session handle
  • Upon updating the state, notify the Session via an Update message

Further thoughts:
Deadlocks and other problems should be avoided per-design. As in not exposing the lock directly and just having functions to access and update the state. For example instead of getting a mutable reference to the current stats we should allow add/sub stats:

state.sub_stats(CharStats {
 hp: 50,
 mp: 5,
 ..Default::default()
});

instead of exposing the lock and doing It by hand:

state.lock().hp -= 50;
state.lock().mp -= 5;

Which is also prone to overflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions