-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
The set inheritance modification problem #37
Comments
I think the solution with annotations is the better one, since using inheritance could get convoluted for units with many different abilities. It's probably easier to explain, too. I would just suggest switching the symbols for the first and second operation as Using
|
Since this seems to be a syntactical problem, how about declaring the 3 possibilities like python decorators? i.e Unit(Entity):
@replacedByChild
Move(Ability):
speed = 1.0
abilities += {Move}
Villager(Unit):
VillagerMove(Unit.Move):
speed = 10.0
# this now automatically replaces `Move` with `VillagerMove`
abilities += {VillagerMove} |
(Sorry for the very delayed reply.....) Unfortunately it's not just syntactic, we are changing the set semantics here and need to configure that syntactically. Using decorators (at least to annotate the object itself) is probably not such a good choice since in a different set, the rule may not apply. So this needs to be a configuration for each set. |
@heinezen and I just found a solution for this.
Entity:
abilities : set(Ability, hierarchy_overwrite=True) = {}
Unit(Entity):
Move(Ability):
speed = 1.0
abilities += {Move}
Villager(Unit):
VillagerMove(Unit.Move):
speed = 10.0
# VillagerMove replaces Move, since the set was configured with hierarchy_overwrite!
abilities += {VillagerMove} Regarding "Where is the border", i.e. when inserting a child, up until what level should parents be purged from the set? The "maximum anchestor" is the set's member type. In the above example, this means the This would be @mic-e's "ne andere magic" from his brainstorm in 2018 :) (or actually a "keyword" in the set creation!) |
This kind of a design flaw, which we have to resolve.
The problem is that currently it is impossible that values in
set
s can be added and removed at the same time. This is required when a specialization (calledSpecial
) of a value is to be added to theset
, but the parent ofSpecial
is already in theset
.This is a problem because often entities define a preset of values, which then need to be specialized, and the old ones invalidated.
Possible idea:
set
insertion in such a way that some keyword (e.g.{@objectname, ...}
) marks it as unique, and child objects of this will replace it. We would need 3 operators:@insertion
: Any child object of this insertion will delete it+insertion
: This will delete all of its parents in the set (even if those were not annotated with@
)!insertion
: This will ignore that the insertion of a child should delete this entry (-> ignore the+
annotation effect)Example:
Solution with annotations:
Possible solution without annotations:
But this solution makes use of the inheritance, and the member names would need redundant prefixes in order to remain unique. This can be improved a bit by the member name qualifications.
Quoting @mic-e:
The text was updated successfully, but these errors were encountered: