Hello, I'm confused about implementing an "end_day" method that will update all the statuses of my game characters.
To elaborate, I have two classes: Character and Time. In my Character class I have a method called attend_class. To summarize, in that method, the character updates its class quota by +1 until the requirements for passing the class is reached. For example: math class requires 20 quotas to pass, thus the characters must attend that class 20 times. But in my case the Character updates its quota instantly.
I'm looking to implement an end_day method in my Time class that updates that quota only if the day is passed.
So instead of:
attend_class -> +quota -> check if meets required quotas -> pass class
I'm trying to achieve:
attend_class -> end_day -> +quota -> check if meets required quotas -> pass class
Any suggestions? Thanks a lot!
Doing updates in turn based games?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Re: Doing updates in turn based games?
I am not sure if I got you right. You can add a variable that would store changes that you apply later: For example:
Code: Select all
def attend_class(...):
self.quota_plus += 1
Code: Select all
def end_day(...):
for c in characters:
c.quota += c.quota_plus
c.quota_plus = 0
# check if meets required quotas -> pass class
Code: Select all
# check if meets required quotas
if requirements_are_met:
c.pass_class = True
Code: Select all
#save the value and name of variable to update
self.update.append(["quota", 1])
Code: Select all
def end_day(...):
for c in characters:
for stat_name, change in c.update
setattr(c, stat_name, getattr(c,stat_name) + change)
c.update = []
Re: Doing updates in turn based games?
Thank you for your advice. I think I kind of get the idea. Before updating, I store the updates in a temporary variable that acts as potential to be added after the day has ended. And when the end_day method is called, all the potential gets updated into each of its own real values. If I'm not mistaken._ticlock_ wrote: ↑Fri Dec 09, 2022 12:51 pm I am not sure if I got you right. You can add a variable that would store changes that you apply later: For example:Code: Select all
def attend_class(...): self.quota_plus += 1
Code: Select all
def end_day(...): for c in characters: c.quota += c.quota_plus c.quota_plus = 0 # check if meets required quotas -> pass class
Re: Doing updates in turn based games?
The concept is correct. The way you do it can be different.Deimos96 wrote: ↑Fri Dec 09, 2022 9:06 pm Thank you for your advice. I think I kind of get the idea. Before updating, I store the updates in a temporary variable that acts as potential to be added after the day has ended. And when the end_day method is called, all the potential gets updated into each of its own real values. If I'm not mistaken.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot]