I'd like to inquire on what I may have done wrong.
ill say what went wrong with each from what i can see
<After Eval> var heal = user.atk; var members = user.friendsUnit().aliveMembers().reduce((a, b) => a.hpRate() < b.hpRate()? a : b); for (var i = 0; i < members.length; i++) { var ally = members; if (ally.isDead()) continue; ally.gainHp(heal); ally.startDamagePopup(); ally.clearResult(); } </After Eval>
array.reduce() returns a single value, not an array. by writing it into members and trying to do array operations on it, itll produce errors. you just had to use the gainHp(), startDamagePopup(), etc. on members directly, as it would already be the allied battler with the lowest hp%
<After Eval> let lowest = 1; lowest = user.friendsUnit().aliveMembers().forEach(actor => lowest = Math.min(lowest, actor.hpRate()); let targets = user.friendsUnit().aliveMembers().filter(actor => actor.hpRate() == lowest); targets[Math.randomInt(targets.length)].gainHp(user.atk); </After Eval>
this one was given to you, but theres 2 mistakes here. theres a missing ")" for the forEach, and since forEach doesnt return a value, lowest gets rewritten to be undefined after the forEach sets it to the party's lowest hpRate. that makes the filter() return an empty array, and you get an error for trying to use gainHp() on nothing
<After Eval> var heal = user.atk; var members = user.friendsUnit().aliveMembers().forEach(actor => lowest = Math.min(lowest, actor.hpRate()); for (var i = 0; i < members.length; i++) { var ally = members; if (ally.isDead()) continue; ally.gainHp(heal); ally.startDamagePopup(); ally.clearResult(); } </After Eval>
same issues as above with the missing ")" and members being undefined because forEach() doesnt return anything, but theres another one here. I assume that you meant to declare and initialize lowest beforehand, but thats missing. because of that, the code tries to initialize lowest within the forEach, but its definition includes itself while it already isnt initialized. thatll cause an error before youd get the one for members being undefined and trying to get its length
<Post-Damage Eval> let lowest = 1; lowest = user.friendsUnit().aliveMembers().forEach(actor => lowest = Math.min(lowest, actor.hpRate()); let targets = user.friendsUnit().aliveMembers().filter(actor => actor.hpRate() == lowest); targets[Math.randomInt(targets.length)].gainHp(25); </Post-Damage Eval>
I assume this is the latest one? its the same issues as the 2nd one, but should work after those are fixed. just going to make a slight adjustment so that you can call a popup on the same random target that was healed since you tried to do it on the one before this one
Code:
<Post-Damage Eval>
let lowest = 1;
user.friendsUnit().aliveMembers().forEach(actor => lowest = Math.min(lowest, actor.hpRate()));
let targets = user.friendsUnit().aliveMembers().filter(actor => actor.hpRate() == lowest);
targets = targets[Math.randomInt(targets.length)];
targets.gainHp(25);
targets.startDamagePopup();
</Post-Damage Eval>
/*EDIT:DIdnt notice the change in tags in your last one. good call.
Post-Damage is what you want for this since After Eval still gets processed on misses**/
that should work
if you press f8 during tests itll open up the console. errors will pop up there and should give you an idea of whats failing, where, and why