jurlaub/StarsCoreEngine — pull request #33 by mikeford1 (2014-12-28 15:42:13+00:00)
Title: changed template_tech hull slot names, started battleboard

I've also written a few functions for the battles and added a few things to the ShipDesign class that would be required for target attractiveness calculations.

I imagine that the end goal is to calculate the battle, but for each step write a line such as
"token 1 moved to (2, 2)"
"token 2 fired at token 4 doing 100 damage to shields, 150 damage to armor, destroying 1 ship"
"token 4 now has 0 shields, 3 ships with 100 armor each"
which is sent to each player in the battle
and a summary message to be displayed (unique to each player present)

My understanding is that the data will be transferred between client and engine in json format, have you got ideas as to how this should be implemented?
I was thinking that the one way to do it would be to have the player object hold a log for output, and then any time information needs to be sent to the client (object changes state, battles etc) the object itself writes something to the log. The final act of turn generation would then be to convert this log (probably made up of lists of string, one list for planet states, one list of fleets, one list of messages to be displayed etc) to a json and then encode it (PGP with different keys for each player?)

Object owned by the universe that everyone wants to know about could just be put in all logs, and any object owned by the player can already find its way back. The python functions __repr__ could be overloaded for any object to make easy to iterate over any list, just call log.fleet_records.append(repr(fleet)) to collect data from all fleets.