Scenario:
I am developing a text-based RPG game in Django and I am wondering what the best way would be to run an event (such as a fight between two characters) server side, and instead of simply passing the result back to the client via a template, such as who won, I want to re-run this 'fight' but in a slower speed using JavaScript. This would show each characters 'turn' and the damage they dealt, although this would be processed instantly on the server.
The methods I thought about using were as follows:
- Pass the combat log/fight through to the template via context using some dictionary or JSON and access the template variable via JavaScript
- Send this data to an API which the JavaScript code in the template will fetch and modify to show at a reduced speed
Do anyone have any better solutions? I don't think I should be posting the outcome of each fight using an API just to transfer this data to client side for use with JS, it's a waste of storage if this is the only use.
Thanks!