How do I determine what my clan stash privileges are?

ereinion

Member
To see how many clan karma I can spend per day I can search the clan stash page for the number, but how do I figure out if I can pull 0-karma items, preferably without attempting to pull one of them?
 
Not sure if mafia stores that information (I think it just tries to pull regardless) You can check clan_stash.php if it contains the phrase "You are authorized to withdraw zero-karma items from the stash."
PHP:
	string clanStash = visit_url("clan_stash.php");
	boolean pullZero = index_of(clanStash, "You are authorized to withdraw zero-karma items from the stash") != -1 ? true : false;
	print(pullZero);
> call scripts\test.ash

true


or you can check how many you can actually pull using a matcher
PHP:
	string clanStash = visit_url("clan_stash.php");
	int zeroItem = 0;
	matcher zeroKarma = create_matcher("You may withdraw ([\\d]+) such items per day", clanStash);
	while (find(zeroKarma)){
		zeroItem = zeroKarma.group(1).to_int();
	}
	print("You are allowed to pull "+zeroItem+" Zero karma items");

> call scripts\test.ash

You are allowed to pull 7 Zero karma items
 
That seems to work :) Thanks a lot.

There is one more case though, "You are exempt from your Clan's Karma requirements." This gives me all of the starting point I need to get to the what I want though :)

- edit -
I ended up with this - any comments would be appreciated:
Code:
int noOfZeroKarmaItemsAvailable() { // -1 = unlimited
    buffer clanStash = visit_url("clan_stash.php");
    matcher zeroKarma;
    int zeroItem = 0;
    
    if (index_of (clanStash, "You are exempt from your Clan's Karma requirements.") != -1) {
        return -1;
    } else if (index_of (clanStash, "You are authorized to withdraw zero-karma items from the stash") == -1) {
        return 0;
    } else {
        zeroKarma = create_matcher("You may withdraw (\\d+) such items per day", clanStash);
        while (find(zeroKarma)){
            zeroItem = to_int (zeroKarma.group(1));
        }
        return zeroItem;
    }
}
 
Last edited:
Code:
create_matcher("You may withdraw (\\d+) such items per day", clanStash);
This will fail if the number is 1 (item instead of items). Cutting the string a bit short is the easiest way to handle that.
 
Back
Top