Thread: Random Quest
View Single Post
  #5  
Old 04-23-2019, 03:47 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

Quote:
Originally Posted by Sturm View Post
You would have to define each possible turn-in combination.

What? No.

Code:
# list of 10 possible item ids
my @find = (
    0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
    8,
    9
);

# items found
my @found;

# items turned in (automatically exported in API)
# (item id => count)
my %itemcount = (
    1 => 1,
    3 => 1,
    7 => 2,
    a => 1
);

foreach my $item (keys %itemcount) {
    # validate item and make sure it is unique
    if ((grep /$item/, @find) && (!grep /$item/, @found)) {
        push @found, $item;
     }
    # only required if count will be less than 4 (max item ids that can be turned in)
    last if (@found == 4);
  }

print "found " . scalar @found . " of 4 required items ";

# minimum number of validated items
if (@found == 4) {
    print "(PASS)\n";
    # to accept only one of each validated item handed in - UNTESTED
    # plugin::check_handin(\%itemcount, map { $_ => 1 } @found);
} else {
    print "(FAIL)\n";
}
note: the above example assumes 4 unique item ids are required for success
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;
Reply With Quote