Last night I was predominantly working on the Pack commands. Well, one really. Sometimes something sounds really simple but can turn out to be quite complex, and that is how it turned out with the pack invite/pack accept command.
Firstly, we had to check if they were on the invite list already. So get the data from that field, loop through each value and see if they are there*. If so, fail. Also had to check and make sure it is an alpha doing the inviting, if not, fail. A few more checks and finally can invite. Need to grab the data from the invite list, add this new person to it, then resave it back there. Do appropriate echoes and that’s the first half done.
Secondly, the person who has been invited needs to accept (or decline but we’ll get to that another night). To accept, we need to check they have been invited*. If not, fail. If everything has the green light, then we first remove them from the invite list** and save it back. Then we loop through all 10 positions in the pack and put them in the first free slot (working from top to bottom). This, new members tend to be added at the lowest rank of the pack. Of course the Alpha can promote or demote as necessary.
* This involves pulling the list of names, which is basically “nameA nameB nameC” and splitting the list at the spaces. Each word between spaces is checked against the character name.
** This involves pulling the list of names, doing as above, loop through looking for a match. For each non-match, we put it into a new list of names, and exclude the match. The final result is saved back.