Closed brettbeatty closed 4 years ago
Hmm I almost wonder if it would make more sense if we made Game
a genserver instead of an agent. I think agent is a nice abstraction, but maybe if we make it a genserver so that we're passing messages to it instead of running functions on it, it will make more sense. And then Games
would be the only place we pass it messages from
I would probably tend to keep it to agents if it's just a wrapper around a Game struct
Our agent calls could just look like this
# where `game` is the code
def do_something(game, some_arg) do
game
|> game_name()
|> Agent.get_and_update(Game, :do_something, [some_arg])
# or `|> Agent.get_and_update(&Game.do_something(&1, some_arg))`
end
And our game functions would look something like this
# where `game` is the game struct
def do_something(game, some_arg) do
# do something
end
OK I'm on board with that.
Here's just getting the agents up and running.
I don't know how I feel about combining struct & agent logic now. Part of me wants to have the entire public API be agent calls to private update functions, but I'm wondering if all of the struct-updating calls should be in
Game
andGames
just has agent calls to the functions inGame
.Opinion?