Results 1 to 4 of 4

Thread: How do I determine what my clan stash privileges are?

  1. #1
    Senior Member
    Join Date
    Dec 2008
    Posts
    517

    Default How do I determine what my clan stash privileges are?

    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?

  2. #2
    Senior Member icon315's Avatar
    Join Date
    Nov 2009
    Location
    Kentucky
    Posts
    674

    Default

    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 Code:

        string clanStash 
    visit_url("clan_stash.php");
        
    boolean pullZero index_of(clanStash"You are authorized to withdraw zero-karma items from the stash") != -true false;
        print(
    pullZero); 
    > call scripts\test.ash

    true


    or you can check how many you can actually pull using a matcher
    PHP Code:
        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

  3. #3
    Senior Member
    Join Date
    Dec 2008
    Posts
    517

    Default

    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 by ereinion; 10-18-2017 at 11:03 PM.

  4. #4

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •