Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Apply Events to Stocks Every Tick #9

Open
explodingcamera opened this issue Mar 18, 2020 · 0 comments
Open

Apply Events to Stocks Every Tick #9

explodingcamera opened this issue Mar 18, 2020 · 0 comments
Assignees

Comments

@explodingcamera
Copy link
Member

explodingcamera commented Mar 18, 2020

Right now, our game works as follows:

We have a game loop, which calls our tick function (in game/game.go) every 10 seconds to essentially update the prices for all of our stocks in our database.

Now, we need to:

  • read the events.yaml file
  • parse it with https://github.com/go-yaml/yaml and use our Event struct (defined in game/structs.go) as the type
  • get all currently running events from the database
  • mark events which shouldn't run anymore as stopped in the database
  • randomly add new events which fit the current tick (e.g their runBefore is a date before the current date)
  • apply all events that are currently running to the stocks they are supposed to effect (change the stock prices)
  • save the new stock prices to the database

For every interaction with the Database, @Alyks1 will add a new Method to the DatabaseService struct for you if it doesn't exist;P

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants