|
Post by Spy on May 21, 2020 6:48:28 GMT
Hi there. I'm just a bit confused as to how the Action System resolves. In your blog you said "...I'll post an event before performing an action so that other cards can have an opportunity to react first, then you will perform the action itself and post another event to allow the opportunity for other cards to react afterward." (this is from theliquidfire.com/2017/09/11/make-a-ccg-action-system/). Where exactly does the "Perform the Action Itself" occur? It seems that "performing the action itself "is treated as another reaction that is signaled from the PerformNotification. If this is the case, how do you make sure that it's always the first one added to the reaction list? Thank you.
|
|
|
Post by Spy on May 21, 2020 7:46:36 GMT
Oh actually just one more question if you don't mind. During the main sequence of the Action System...
IEnumerator Sequence (GameAction action) { this.PostNotification (beginSequenceNotification, action);
if (action.Validate () == false) action.Cancel ();
var phase = MainPhase (action.prepare); while (phase.MoveNext ()) { yield return null; }
phase = MainPhase (action.perform); while (phase.MoveNext ()) { yield return null; }
phase = MainPhase (action.cancel); while (phase.MoveNext ()) { yield return null; }
if (rootAction == action) { phase = EventPhase (deathReaperNotification, action, true); while (phase.MoveNext ()) { yield return null; } }
this.PostNotification (endSequenceNotification, action); }
...why is the Validate check before the Prepare? Shouldn't it be after the Prepare and before the Preform?
|
|
|
Post by Admin on May 22, 2020 13:54:51 GMT
This is admittedly an advanced topic, so don't worry if it hasn't all clicked yet. Part of the confusion may be in what you understand a single action to be. For example, if you understood a single action to be "Play a spell card that damages all enemies" then you are thinking too large. That "action" would actually be carried out as a composition of actions: "Playing a card", "Casting a spell", and "Applying the effect of the spell". That particular composition was determined by the design of the game I was copying, because of the kinds of "triggers" I would like to be able to respond to. For example, I would like to be able to respond to the playing of a spell, regardless what kind it was. This level of detail might be why you are describing the performance of the action as another reaction signaled from the PerformNotification. You are right, once the first composed action of "Playing a card" is complete, the next composed action "Casting a spell" would begin, etc.
If you have only read this particular lesson, you may feel like something is "missing" and you'd be right. We set up the foundation for actions to be played with a common pattern, but the interesting bits, like actually playing a card or casting a spell, will be handled as subclasses of actions. You will see those in subsequent lessons.
For your last question, regarding the sequence of phases, (hopefully my memory is correct - it's been a while) "Prepare" is intended to be an action that will be "Performed". You may see an animation play out indicating something is about to happen. Validating an action before this point allows us to cancel an action before it has even started, so we don't need to worry about seeing that beginning part of its animation.
|
|
|
Post by Spy on May 22, 2020 18:43:49 GMT
This is admittedly an advanced topic, so don't worry if it hasn't all clicked yet. Part of the confusion may be in what you understand a single action to be. For example, if you understood a single action to be "Play a spell card that damages all enemies" then you are thinking too large. That "action" would actually be carried out as a composition of actions: "Playing a card", "Casting a spell", and "Applying the effect of the spell". That particular composition was determined by the design of the game I was copying, because of the kinds of "triggers" I would like to be able to respond to. For example, I would like to be able to respond to the playing of a spell, regardless what kind it was. This level of detail might be why you are describing the performance of the action as another reaction signaled from the PerformNotification. You are right, once the first composed action of "Playing a card" is complete, the next composed action "Casting a spell" would begin, etc. If you have only read this particular lesson, you may feel like something is "missing" and you'd be right. We set up the foundation for actions to be played with a common pattern, but the interesting bits, like actually playing a card or casting a spell, will be handled as subclasses of actions. You will see those in subsequent lessons. For your last question, regarding the sequence of phases, (hopefully my memory is correct - it's been a while) "Prepare" is intended to be an action that will be "Performed". You may see an animation play out indicating something is about to happen. Validating an action before this point allows us to cancel an action before it has even started, so we don't need to worry about seeing that beginning part of its animation. Ah alright I see. One more question if you don't mind. How exactly would you go about creating "compound effects". Basically, effects that either do multiple things (Deal 5 Damage. Heal 2) and/or effects that require information from some thing prior in order to execute properly (Deal 2 damage to all enemy minions, then Heal 1 for each hit).
|
|
|
Post by Admin on May 26, 2020 12:51:25 GMT
Note that all actions are already implemented as "compound" actions, such as how playing a spell is implemented as a reaction to playing a card. You could create another system that handles any rules specific to the way a card with compound effects would play out, if needed, but you might be able to get most of the way there simply by adding multiple reactions all at once. How you add them would depend on the type of compound effect you wanted.
|
|
|
Post by Spy on May 31, 2020 17:27:37 GMT
Note that all actions are already implemented as "compound" actions, such as how playing a spell is implemented as a reaction to playing a card. You could create another system that handles any rules specific to the way a card with compound effects would play out, if needed, but you might be able to get most of the way there simply by adding multiple reactions all at once. How you add them would depend on the type of compound effect you wanted. I see... I'm sorry I'm just struggling quite a bit when it comes to passing information from 1 Aspect to another. For example, if I wanted to so something like. "Deal Damage to a minion equal to the Health of another minion." How would I specify this interaction through the JSON?
|
|
|
Post by Admin on Jun 1, 2020 13:26:00 GMT
If you haven't already read them, make sure you read posts 9- Damage, and 17- Targeting. The Damage Action does half the job, the only "problem" is how you populate the "amount" of damage you want to do. You might try an approach that looks something like using the Damage Action (either directly or as a pattern to create a new action and system), along with also use the Targeting system to specify the amount of damage to apply by first picking the relevant minion to get the HP from.
|
|