ivan1993spb / snake-server

Snake-Server is a pure Go implementation of the famous arcade game 🐍
https://snakeonline.xyz
MIT License
33 stars 3 forks source link

Refactor ExperimentalPlayground #96

Closed ivan1993spb closed 3 years ago

ivan1993spb commented 4 years ago

ExperimentalPlayground is designed to receive *engine.Object and pass it through to engine.Map. *engine.Object contains an actual game object. Therefore, there is a necessity to manage *engine.Object somewhere on the layers above ExperimentalPlayground which turned out to be a quite complicated and awkward situation.

Rewrite ExperimentalPlayground to manage *engine.Object inside of ExperimentalPlayground:

  1. Rename *engine.Object to *engine.Container with regards to the purpose it serves
  2. Define engine.Object interface as an empty interface interface{}
  3. Make all methods of ExperimentalPlayground receive actual game objects engine.Object and wrap them into engine.Container before passing to engine.Map
  4. Store the mapping of game objects and their containers in ExperimentalPlayground: map[engine.Object]*engine.Container
  5. Add sync.RWMutex to regulate access to the map
  6. Rewrite tests for ExperimentalPlayground and add some if necessary
  7. Conduct a benchmark test to estimate the gains and loses of the new solution
  8. Add comments to ExperimentalPlayground
  9. Accept empty locations as valid when registering objects