ereinion
Member
So I made this code-snippet in order to buff 5 random people every day, and I think it works as intended (at least it seemed to do so from todays test of it):
However I find that it seems overly complex, and wonder if any of the more experienced coders here have any suggestions on how I can make the picking of the 5 random players more efficient. Any help will be much appreciated 
Code:
void main() {
boolean[int, string] peopleToUseTheSkillOn; int index; string who;
peopleToUseTheSkillOn[0, "a"] = true;
peopleToUseTheSkillOn[1, "b"] = true;
peopleToUseTheSkillOn[2, "c"] = true;
peopleToUseTheSkillOn[3, "d"] = true;
peopleToUseTheSkillOn[4, "e"] = true;
peopleToUseTheSkillOn[5, "f"] = true;
peopleToUseTheSkillOn[6, "g"] = true;
while (have_skill($skill[The Smile of Mr. A.]) && get_property("_smilesOfMrA") < 5 && count(peopleToUseTheSkillOn) >= 5) {
repeat {
index = random(count(peopleToUseTheSkillOn));
foreach key in peopleToUseTheSkillOn[index] {
who = key;
}
} until(peopleToUseTheSkillOn[index, who]);
if (peopleToUseTheSkillOn[index, who]) {
use_skill(1, $skill[The Smile of Mr. A.], who);
peopleToUseTheSkillOn[index, who] = false;
}
}
}

Last edited: