Yo1k / tic-tac-toe

A multiplayer turn-based game
MIT License
0 stars 0 forks source link

Consider exposing attributes of `World` in order to reduce the number of things we have to pass around #23

Open stIncMale opened 2 years ago

stIncMale commented 2 years ago

I did this in Rust: World exposes World.advance() and World.state. This way World and, maybe, ActionQueues are the only things the UI needs to depend on.

What's especially cool in Rust, is that World.state is exposed via a shared reference, which makes it impossible for the UI to modify it directly, i.e., World.state is read-only data from the perspective of the UI, while being mutable via World.advance(). Doing the same in Java/Python requires wrapping State in a different type, that exposes only reading methods, while in Rust &State fields are all exposed and are still read-only.