Circular dependencies w/ static abilities
Posted: 04 Sep 2009, 23:18
I've run into an issue and I'm sure there is an easy way to deal with this. I'll try to put this in terms of MtG.
Let's say a card while in play has a static ability that says "This card is the color of all of your other in play cards" (for all I know some card like this exists). Now let's say that there are 2 of them in play. How do you handle that?
In this example I would have a hookable function called "get_colors" or something similar and in it I would do this (pseudo-code)
I'm trying to come up with a clean way to deal with this sort of thing and for some reason after a few hours of thinking about it, nothing good (read: not a hack) has popped up.
Any ideas?
~telengard
Let's say a card while in play has a static ability that says "This card is the color of all of your other in play cards" (for all I know some card like this exists). Now let's say that there are 2 of them in play. How do you handle that?
In this example I would have a hookable function called "get_colors" or something similar and in it I would do this (pseudo-code)
- Code: Select all
colors get_colors(card)
if (in_play(card) and card == this_card)
foreach (c in cards_i_have_in_play)
(if c != this_card)
colors += get_colors(c)
// for now just ignore handling duplicates etc
return colors
I'm trying to come up with a clean way to deal with this sort of thing and for some reason after a few hours of thinking about it, nothing good (read: not a hack) has popped up.
Any ideas?
~telengard