johnameyer / cards-ts

A card game framework and various games in Typescript. The framework allows for bot development and playing card games in the terminal or in a browser.
6 stars 2 forks source link

State componentization #60

Closed johnameyer closed 3 years ago

johnameyer commented 3 years ago

Rather than having a flat state for each game, refactor common functionality into separate components that can be chosen arbitrarily by games. Consumers should be able to expect a subset of the state (e.g. only {messages: MessagesState}). As well, use controllers to wrap each component so that only expected operations are performed and the state remains consistent.

johnameyer commented 3 years ago

With #63, ownership of modules no longer necessitates deserialization, just initialization, transformation, and validation. Still trying to figure out how modules can be built out of smaller modules without duplicating state across module children or exposing children modules to consumers.

johnameyer commented 3 years ago

New thoughts:

johnameyer commented 3 years ago

Still up in the air in the implementation: