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.
4 stars 2 forks source link

Split transitions map from actual transition functions #114

Closed johnameyer closed 5 months ago

johnameyer commented 5 months ago

Today the various transition functions exist on the same class as the function that returns the mapping.

https://github.com/johnameyer/cards-ts/blob/68a31c74ec2b4799078e894c156a9c5ed6b3ba20/packages/war/src/game-state-transitions.ts#L9-L28

Now that all the functions have the same signature, we can likely just have the class/object be that mapping i.e.

class Transitions {
  [GameState.START_GAME]() {
     ...
  }
}

Likely an object to prevent use of this and encourage use of controllers.