The Twenty Percent

Goal

Goal

Create a small card game framework. The game logic should be processed on a graphql server, which exposes the gamestate, and the necessary message types to play. The game interface will be created with Godot Engine. Graphql server and client are Hot Chocolate and Strawberry Shake.

repo

Architecture

The actuation of the game logic takes place on the server. Only here can state be changed. Clients may read state, but are restricted to specific game actions according to the rules.

The server exposes a graphql schema, which is expressed with Hot Chocolate. The schema maps nicely to card games

  • Queries:
    • Read game state
  • Mutations:
    • Take game actions
  • Subscriptions:
    • Observe changes in the game state

The client API is generated with Strawberry Shake.

The user interface will most likely be made in Godot, with reactive components (cards visuals are altered according to subscription events).

View

Intuitively, the code here should represent what the player can see and do. It should give them enough information to take informed game actions, but can only do so by following the rules of the current context.

  • Current and observable state; Maps to Queries and Subscriptions.
  • Game Actions in the current context; Maps to Mutations.

Rules

This is the inner workings of the game. This is where state is changed and the View is updated. It should

Builder

Expresses a fluid API for writing actual cards.

    builder
        .AddSet("Alpha", _builderFactory, builder => builder
            .Card(cardBuilder => cardBuilder
                .Name("Lightning Bolt")
                .Cost(1)
                .Effect<IUnit>(context => context.Target.Attack(3)))
            .Card(cardBuilder => cardBuilder
                .Name("Ancestral Recall")
                .Cost(1)
                .Effect(context => context.Player.Draw(3)));

Bugs to come back to

  • Using NET Standard 2.1 causes errors when using some nuget packages (link)
  • Using an external http client on a server with SSL throws an exception (link)