Spleen limit: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
mNo edit summary
imported>Eliteofdelete
No edit summary
Line 16: Line 16:
<p>For characters without Spleen of Steel, this value is 15. With Liver of Steel, the value is 20.|
<p>For characters without Spleen of Steel, this value is 15. With Liver of Steel, the value is 20.|


needscode=yes|
code1={{CodeSample|
title=Code Samples|
description=The following example uses proxy records of the given item to determine if you can use it for spleen.|
code=
<syntaxhighlight>
boolean can_spleen(item checkme) {
  if (checkme.spleen == 0) {
      print(checkme+" is not a valid spleen item.", "red");
      return false;
  }
  else if (checkme.levelreq > my_level()) {
      print(checkme+" level requirement is too high for you to use as a spleen item.", "red");
      return false;
  }
  else if (floor((spleen_limit() - my_spleen_use()) / checkme.spleen) > 0) {
      int amount=floor((spleen_limit() - my_spleen_use()) / checkme.spleen);
      print("You could use "+amount+" of "+checkme+".", "green");
      return true;
  }
  else print("You do not have enough spleen remaining for "+checkme, "blue");
  return false;
}
 
can_spleen($item[twinkly wad]);
can_spleen($item[epic cluster]);
can_spleen($item[astral energy drink]);
can_spleen($item[Unconscious Collective Dream Jar]);
can_spleen($item[mae west]);
 
</syntaxhighlight>|
moreinfo=More info on proxy records can be found at [http://wiki.kolmafia.us/index.php?title=Proxy_Records Proxy Records].
<br> The example gives this if you currently have 15 free spleen:
<pre>
The example gives this if you currently have 15 free spleen:
You could use 15 of twinkly wad.
You could use 15 of epic cluster.
You could use 1 of astral energy drink.
You could use 3 of Unconscious Collective Dream Jar.
Mae West is not a valid spleen item.
</pre>
}}|
 
code2={{CodeSample|
description=<br>The following example looks through all your on-hand items and tells you which spleen items would be best to use.|
code=
<syntaxhighlight>
item[int] spleen;
int[item] to_use;
float avg;
int spleen_used = my_spleen_use();
float spleen_avg (item it) {
  float realavg; 
  string[int] avgmap; 
  avgmap = split_string(it.adventures, "-");
  if (count(avgmap) == 1)
      return to_float(avgmap[0]);
  else {
      foreach it in avgmap
        realavg += to_float(avgmap[it]);
      realavg = (realavg/2.0);
  }
  return realavg;
}
 
foreach it in $items[] {
  if (it.spleen != 0 &&  it.levelreq <= my_level() && (it != $item[astral energy drink] || my_level() >= 10)) {
      avg = spleen_avg(it);
      if (avg >= 1)
        spleen[count(spleen)] = it;
  }
}
sort spleen by -spleen_avg(value);
foreach key, it in spleen {
  print(spleen[key]+": "+spleen_avg(spleen[key]));
  if (item_amount(it) > 0) {
      to_use[it] = min(item_amount(it), floor((spleen_limit() - spleen_used) / it.spleen));
      spleen_used += to_use[it] * it.spleen;
      if (spleen_used == spleen_limit()) {
        print("k");
        break;
      }
  }
}
 
print("The best spleen items you could use that you have on hand right now are:", "purple");
foreach it in to_use {
  print(to_use[it]+" "+it, "blue");
}
if (spleen_used == spleen_limit())
  print("This would fill a total of "+spleen_used+"/"+spleen_limit()+".", "green");
else print("This would only fill a total of "+spleen_used+"/"+spleen_limit()+".", "red");
</syntaxhighlight>|
moreinfo = It gave:
<pre>
The best spleen items you could use that you have on hand right now are:
1 antimatter wad
1 handful of Smithereens
12 twinkly wad
This would fill a total of 15/15.
</pre>
}}|


see_also={{SeeAlso|my_spleen_use}}|
see_also={{SeeAlso|my_spleen_use}}|

Revision as of 22:26, 21 January 2015

Function Syntax

int spleen_limit()

Returns the maximum spleen use possible for your character.

For characters without Spleen of Steel, this value is 15. With Liver of Steel, the value is 20.

Code Samples

The following example uses proxy records of the given item to determine if you can use it for spleen.

boolean can_spleen(item checkme) {
   if (checkme.spleen == 0) {
      print(checkme+" is not a valid spleen item.", "red");
      return false;
   }
   else if (checkme.levelreq > my_level()) {
      print(checkme+" level requirement is too high for you to use as a spleen item.", "red");
      return false;
   }
   else if (floor((spleen_limit() - my_spleen_use()) / checkme.spleen) > 0) {
      int amount=floor((spleen_limit() - my_spleen_use()) / checkme.spleen);
      print("You could use "+amount+" of "+checkme+".", "green");
      return true;
   }
   else print("You do not have enough spleen remaining for "+checkme, "blue");
   return false;
}

can_spleen($item[twinkly wad]);
can_spleen($item[epic cluster]);
can_spleen($item[astral energy drink]);
can_spleen($item[Unconscious Collective Dream Jar]);
can_spleen($item[mae west]);

More info on proxy records can be found at Proxy Records.


The example gives this if you currently have 15 free spleen:

The example gives this if you currently have 15 free spleen:
You could use 15 of twinkly wad.
You could use 15 of epic cluster.
You could use 1 of astral energy drink.
You could use 3 of Unconscious Collective Dream Jar.
Mae West is not a valid spleen item.


The following example looks through all your on-hand items and tells you which spleen items would be best to use.

item[int] spleen;
int[item] to_use;
float avg;
int spleen_used = my_spleen_use();
float spleen_avg (item it) {
   float realavg;   
   string[int] avgmap;   
   avgmap = split_string(it.adventures, "-");
   if (count(avgmap) == 1)
      return to_float(avgmap[0]);
   else {
      foreach it in avgmap
         realavg += to_float(avgmap[it]);
      realavg = (realavg/2.0);
   }
   return realavg;
}

foreach it in $items[] {
   if (it.spleen != 0 &&  it.levelreq <= my_level() && (it != $item[astral energy drink] || my_level() >= 10)) {
      avg = spleen_avg(it);
      if (avg >= 1) 
         spleen[count(spleen)] = it;
   }
}
sort spleen by -spleen_avg(value);
foreach key, it in spleen {
   print(spleen[key]+": "+spleen_avg(spleen[key]));
   if (item_amount(it) > 0) {
      to_use[it] = min(item_amount(it), floor((spleen_limit() - spleen_used) / it.spleen));
      spleen_used += to_use[it] * it.spleen;
      if (spleen_used == spleen_limit()) {
         print("k");
         break;
      }
   }
}

print("The best spleen items you could use that you have on hand right now are:", "purple");
foreach it in to_use {
   print(to_use[it]+" "+it, "blue");
}
if (spleen_used == spleen_limit())
   print("This would fill a total of "+spleen_used+"/"+spleen_limit()+".", "green");
else print("This would only fill a total of "+spleen_used+"/"+spleen_limit()+".", "red");

It gave:

The best spleen items you could use that you have on hand right now are:
1 antimatter wad
1 handful of Smithereens
12 twinkly wad
This would fill a total of 15/15.

See Also

my_spleen_use()