rwg wrote:So to expound on my original email...
setOwner("[]") This is an empty JSON array
setOwner("['']") This is a JSON array with one entry, an empty string
The code apparently doesn't check for empty strings as player names and it should. Such player names should produce an error and will in the next build. Empty will be defined similar to, "any string which, when leading and trailing spaces and tabs are removed, results in a string with length zero."
I'm reluctant to use a String parameter with some special code, such as
"ALL", to mean that the All Players flag should be turned on. What's to stop a player from logging in as
ALL?
I'm thinking that a true/false flag should be passed that sets the All Players setting. Perhaps something like:
setOwner(jsonList, id)
setOwner(jsonList, allPlayers, id)
setOwner(jsonList, allPlayers)
If the second parameter is zero or one, it's the All Players setting. Otherwise it's a token id. If the All Players setting is not specified, it defaults to
false (zero). Setting it to
true (one) would cause the first parameter to be ignored and all owners to be turned off.
So existing code would turn off the All Players setting and only new code that knows about the second parameter would be able to turn that setting on.
Thinking about it now, it seems we have a few requirements. First, the assumption that All Players is never valid when player names are set as owners. Second, the assumption that for only the GM to have access all other information should be removed (All Players and player names).
1. Turn off All Players and remove all player names (essentially GM-only)
2. Turn off All Players and set individual players
3. Turn on All Players and remove all player names
We could use the following syntax for each one:
setOwner("[]") - obviously removes all players and somewhat-obviously removes All Players
setOwner("[...]") - obviously sets certain players as owners and somewhat-obviously removes All Players
setOwner("") - obviously removes all players and not-so-obviously turns on All Players
Any non-empty string provided as the first parameter MUST be a JSON array; anything else produces an error. This means that existing code that tries to set a single owner would be flagged as an error and would need to be changed to create a JSON array with a single element instead. This doesn't thrill me (backward compatibility and all that) and I'd be happy with a non-empty string being treated as a JSON array with one element.
Given that each of the above would be documented, are there any problems?