HackerTrans
TopNewTrendsCommentsPastAskShowJobs

billnreed

no profile record

comments

billnreed
·2 anni fa·discuss
I've seen this engine before and thought it was really cool!

I've been playing around with writing my own turn-based game engine with TypeScript: https://github.com/snowbillr/turn-based-game-engine

It's a WIP still, but what's really been the struggle for me is coming up with a data structure and traversal algorithm for the turn order. I wanted that to be extremely configurable by whoever uses the library.

```

engine.defineFlow((f) => {

  f.node({
    actions: f.actions(WelcomeMessage),
  })

  f.node(
    {
      actions: f.actions(RoundStart),
      cleanups: f.cleanups(RoundEnd, TestLog),
    },
    players.map(player => f.node({
      playerId: player.id,
      actions: f.actions(TurnStart),
      cleanups: f.cleanups(TurnEnd),
    })),
  )
});

```

This example shows a TicTacToe game defined like this:

```

- welcome

- round

  - player 1 turn

  - player 2 turn
```

What I ended up with was essentially a tree that's traversed depth-first to enter each node, and then goes back up the same traversal path until a sibling node is found to dive into.

That lets the user define rounds/turns/phases as children of each other in whatever shape they want.

It's been a real fun project!
billnreed
·2 anni fa·discuss
Thank you! No license or anything, just go for it if you want to use them.
billnreed
·2 anni fa·discuss
I made a few CSS-only single `div` loaders a while back, it was a fun challenge to make them interesting while only using a single div.

https://codepen.io/snowbillr/pen/QEagmW