Jun-11-2018, 06:04 AM
Hello everyone,
I am developing a text-based RPG game in Django for learning purposes 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:
Does 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 Javascript, it's a waste of storage if this is the only use. I am wanted to do the first option - accessing it via a template variable using JavaScript which would be a dictionary
Thanks!
I am developing a text-based RPG game in Django for learning purposes 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 a context variable using some dictionary or JSON and access the template variable via JavaScript (if this is possible to even do, is it best avoided?)
- Send this data to an API which the JavaScript code in the template will fetch and modify to show at a reduced speed
Does 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 Javascript, it's a waste of storage if this is the only use. I am wanted to do the first option - accessing it via a template variable using JavaScript which would be a dictionary
Thanks!