-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add effects for permanent stat increase #75
Comments
Maybe instead of having to edit the effects in |
I'm not sure to get your point. The idea behind effect/alteration distinction is that an effect is any kind of change an entity may be affected by, because they drank a potion, an item was thrown at them, a specific spell hit them etc., and an alteration is more like a change in status, that could be temporary with a hard turn limit (duration), or we could imagine it being more resilient and requiring to consume something (like an antidote) / go somewhere (like to a "medical center") to get rid of it. An example from the code for the stun effect: # At instanciation of the effect
if self.name == "stun":
alteration_root = etree.parse("data/alterations.xml").find(name)
desc = get_localized_string(alteration_root.find("info")).strip()
abbr = alteration_root.find("abbreviated_name").text.strip()
effs_el = alteration_root.find("effects")
durable_effects = (effs_el.text.strip().split(",") if effs_el is not None else [])
self.alteration = Alteration(self.name, abbr, self.power, self.duration, desc, durable_effects) # When it's being applied to an entity
if self.name == "stun":
entity.set_alteration(self.alteration)
msg = f_ENTITY_HAS_BEEN_STUNNED_FOR_NUMBER_TURNS(entity, self.duration) Stun is a kind of effect that apply the Stun alteration for X turns to an entity. And I'm not sure if anything like the list of effects should be stored in Character entity... First because not only Characters could be affected, but also Foes, or other kind of entities. And also because I don't know, they don't look so closely related in my opinion. Effects should be kept rather close to the Effect class, so everything related to effect is around the same place. But maybe I just misunderstood your idea. |
So my point was having a hashmap containing effects and there duration and if an effect has a duration that is not 0 the effect will be applied, but if the duration is none the effect will stay forever, and then you have a the effect take the entity hit by the potion or the attack with effect, and trigger a applyEffectEvent in the entity code, then the entity's code detect that there is a change in the duration of an effect, and applies it to the stats. class Entity:
# Just a draft of the initialization process from a effects only POV
def __init__(self):
self.effects = {'stun': 0, 'speed': 0, 'health_boost': 0, 'strength': 0}
self.entityType = 'player'
self.speed = 60
self.strength = 50
self.health = 100
# Very rough, but you get the point
def applyEffectEvent(self, effect, duration):
if not effect in self.effects:
return f"Effect doesn't apply on {self.entityType}"
self.effects[effect] = duration
self.updateState()
return "Effect applied"
# I wrote my updateState function to just handle effects
# Normally it handles everything that needs to be updated
def updateState(self):
for effect in self.effects:
if self.effects[effect] == 0:
return
if self.effects[effect] == None:
match effect:
case "speed":
self.speed += 20
case "strength":
self.strength += 10
case "health_boost":
self.health += 50
case "stun":
self.speed -= 40
return
# Here you put how you usually apply your effects with a duration
# Just use self.effects[effect] to get the duration in whatever unit |
Ok to be really honest I'm still not sure to get you... It's just that I need to dig further on the subject maybe. Having an hashmap (dict in Python) is an idea I like: maps/dict is always better than a sequence of if/else statements in my opinion, it's cleaner. But I don't understand why effect logic should be in entity instead of in... Its own class. And I don't get what would be the pros of following this approach. |
OK I'll explain further: Using a Hash Map to store the effects on the entity instead of on a separate class :Pros :
Cons :
PLEASE, If you don't get something let me know. |
@IliyasDev sorry for the late answer, I was a bit busy working on other projects and needed to dig back in the code to be able to answer you correctly.
You are right, the actual effect on the entity may depends on their characteristics in a foreseeable, but it is not right now. Also, different map for every possible race and classes in game seems to be too much code duplication to me, because in most cases, entities should be affected the same way by a given effect/alteration. It's only about exceptions.
I think you are trying to explain what is polymorphism.
Not sure to get that part. Entities should not inherit from Effects.. Because they are not Effects.. Did you just mean that the application of an effect should be reversed? Like instead of having the method Anyway, I definitely agree about the different pieces needing some refactoring: the init method of Lastly, I think documentation for both Please don't hesitate to argue more if you disagree with one of my point, I'm just sharing my personal feelings about it |
Currently, only effects giving temporary stat increase as an alteration are present (such as
speed_up
,strength_up
ordefense_up
).Nothing for increasing the stats in a more "definitive" way.
It would be nice to add these kind of effects, and why not a few items making use of them.
These effects should not result in the creation of an Alteration (since it would not be temporary), but should rather directly modify the stats of the targeted entities.
Place to add implementation of the effects is
effect.py
.Place for defining displayed names is in
text.py
(effects
sub-dictionary inTRANSLATIONS
).No need to bother about translations to other languages than English right now, checking if the game is not crashing when using another language should be sufficient.
The text was updated successfully, but these errors were encountered: