fidoandfido / blackswan

Blackswan Stock Game
Other
2 stars 0 forks source link

Period based news events #34

Open fidoandfido opened 13 years ago

fidoandfido commented 13 years ago

News events from the beginning of a period should be available.

This includes things like the status of the stock exchange economy, companies spawning or dissolving, major changes in company profile (ie speculative companies etc)

This should be displayed somewhere sensible.

fidoandfido commented 13 years ago

I think the most straightforward way of doing this will be to have a 'period message object' which links to a stock exchange period object (and stock exchange) and optionally a company period report (and company).

This could be done using polymorphism but that will add a layer of complexity on the DB side, with a possible performance hit (due to the cost of determining the type during object rehydration).

These messages would then be generated and saved during the period generation. Some refactoring of the code may be required to ensure that the periodGenerator knows about all the events (ie if a company modifier modifies a company by, say increasing it's debt, then whose responsibility is it to generate the event - the periodGenerator or the company modifier? It should be the period generator, hence the refactoring) Having spent the night playing around in the periodGenerator, this should not be too difficult.

After that, it is simply a matter of displaying the messages in an appropriate place.

fidoandfido commented 13 years ago

Okay, so on implementation, I think the best thing to do will be to have the messages generated by the actual modifiers themselves.

The reason for this is that they are then able to make decisions about what type of event will be generated.

For instance, it is conceivable that the company modifier may adjust the revenue and expense rates subtly and this would not generate any 'message', however a dramatic rise or drop in revenues would require a message, and so on.

This does place additional work into the modifier, so this decision may be revisited in the future.

fidoandfido commented 13 years ago

This has been done, the code to generate messages is now back in the period generator.

This required a substantial refactor of the period genertor code, and associated modifiers. Company modifiers now modify rates and debts, 'economic modifiers' now do other stuff. This makes a little more sense since the company modifiers will probably be determined on a company level (ie the profile) and the stock exchange then has control of when companies go in and out of insolvency, are dissolved etc.

All the actual code to dissolve, create companies and so on remains in the period generator, since it will be the same across all the exchanges.

fidoandfido commented 13 years ago

Last outstanding point - need to add code to render messages, probably in the stock exchange page and also on the news pages.

Will look into this shortly.

fidoandfido commented 13 years ago

A simple page to display these announcements has been added, currently grouping all announcements by stock exchange.

The logical next step to do here will be to break up the announcements into stock exchange, sector and company announcements, then add appropriate links / javascript for actions.