readiness:function(c,t){
Effect.mkText("Ready", t);
if (t.active.cast){
t.cast = 0;
t.usedactive = false;
}
}
We need state tracking because in original you can cast SoR on something & it'll "just work"
Cast SoR on
thing before they use active -> they can then proceed to activate twice
Cast SoR on
thing after they use active -> they can then proceed to activate again
Good programming prefers to
encapsulate state, or, more relevantly, keep the book keeping logic in the active, rather than leveraging the game engine to book keep everything. So I'm going to modify the active to set a "ready" status which we will-- blah oetg-v doesn't have on-useactive proc like oetg does. So I open etg.js in oetg & remember that I reduced that file to a mere set of constants & adrenaline logic which then leads me to open Thing.js where I scout out useactive but that doesn't have what I want because that's logic for _everything_ reminding me that we have a cast method but cast is a property so /.prototype.cast & vim has scrolled to the
castSpell method. I'm going to be lazy & only bring over this.procactive("spell") after this.active.cast(this, t) for now since the nospell parameter is to deal with the fact that we don't want ricochet to ricochet itself in oetg. Now we can bind an active to the event "own spell" & it'll get triggered whenever a creature casts a spell (c will be the thing with the active, t will be the thing that's casting the active)
Quick note: proc 'death' first triggers 'owndeath' on the thing proc'ing before scanning through for anything with a 'death' activeIn oetg I renamed procactive to proc so I replace-all procactive to proc in oetg-v to continue my ever long quest to keep these two codebases in agreement. Now back to readiness. Idea is:
active cost = 0
if this.ele == time && !this.status.ready {
this.status.ready = this.usedactive ? 2 : 3
this.usedactive = false
add ownspell 'ready'
}
ownspell-ready:
if this.status.ready>1 {
this.status.ready--
this.usedactive = false
}
At first I had ready set to 2 or 1 & decremented to 0 but realized that we need to track if something's already readied to avoid SoR stacking (I don't recall the exact stacking behavior of SoR, I'm assuming it's a nop after the first cast)
Now then I've written the pseudocode so I run that through my mental pseudocode-to-javascript compiler &:
readiness:function(c,t){
Effect.mkText("Ready", t);
if (t.active.cast){
t.cast = 0;
if (t.card.element == etg.Time && !t.status.ready){
t.status.ready = t.usedactive ? 2 : 3;
t.usedactive = false;
t.addactive("ownspell", Actives.ready);
}
}
},
ready:function(c,t){
if (c.status.ready > 1){
c.status.ready--;
c.usedactive = false;
}
}
Go to test with a deck that's golden nymphs & wyrms & SoRs & .. it doesn't work. So I manually write in the above code block because yay I can't copy paste & message from the virtual terminal I'm programming in to this post I'm writing. Shit. Hopefully that'll clear my head. My test case was immediately using SoR, where it maintained previous behavior (I had forgotten to run ninja the first time). Anyways set a breakpoint in ready to see if we're even hitting it. Also testing on Wyrm worked so change test deck to nymphs & sors only. Debugger isn't working right, oh well, can see that ready status isn't decrementing. Run git diff to review changes I've made. Whoops I put proc("play") instead of proc("spell") in useactive. Now things are working better, except that I can use an active 3 times by cast & then using SoR. There's nothing in Creature to indicate the difference between cant-cast-because-new & cant-cast-because-already-cast. I'm tempted to default usedactive to 2 & make the JIT cry. So I do & test. Forgot to modify readiness with "t.usedactive == 2 ? 3 : 2". No dice. Should've been ===, not ==. This time pay attention to Ready status in tooltip. Blah need to set ready status to 2 or 1, not 3 or 2. (usedactive is only cleared when ready active's predicate is false)
Now if one uses SoR the turn after a thing is played they can only use the active once. Change to usedactive === true ? 1 : 2
Having implemented the core functionality of SoR, there's one thing left: Fate Egg. This'll be straightforward one-liner in pseudocode:
if this.status.ready then PU self after hatching. This may have some incorrect behavior for if we hatch a mutant time creature (if that's an issue someone else can add a !status.mutant to the code)
So test. Success. git diff. git co -am "Fix SoR to be like original". git push. ./pushserver. Refresh github page to get
link to commit for this sentence