int getfixitems(int fix, item it, string type)
{
if(type == "auto")
retrieve_item( fix , it );
else if (type == "mall")
buy( fix , it );
else if (type == "inventory")
{
if ( item_amount( it ) < fix )
fix = item_amount( it );
if ( item_amount( it ) == 0 )
print ("Currently out of: " + it + " switch type to auto or continue without buff","red");
}
else
{
print ("Type: " + type + " does not conform to standards (auto|mall|inventory), going to auto","red");
fix = getfixitems(fix, it, "auto");
}
return fix;
}
boolean is_item (effect e)
{
int index = 0;
foreach i in $items[]
if(string_modifier(i, "Effect")!="")
{
string test = item_type( i );
if (test == "")
{
string f = string_modifier(i, "Effect");
f = replace_string(f, "™", "");
effect g = f.to_effect();
if (g == e)
{
index += 1;
}
}
}
if (index > 0)
return true;
return false;
}
void ef_toitem (effect e, float amount, string type)
{
int[effect, item] effect_to_item;
foreach i in $items[]
if(string_modifier(i, "Effect")!="")
{
string test = item_type( i );
if (test == "")
{
string f = string_modifier(i, "Effect");
f = replace_string(f, "™", "");
effect g = f.to_effect();
if (g == e)
{
effect_to_item[g, i] = numeric_modifier(i, "Effect Duration");
}
}
}
int cost;
int value = 999999999;
int stop = 50000; //Mall price cap
int turns;
item it;
foreach a,b in effect_to_item
{
cost = mall_price(b);
if (cost < stop)
{
int it2 = effect_to_item[a,b];
if ((it2!=0)&&(cost!=0))
{
int test = cost / it2;
if (test < value)
{
it = b;
value = test;
turns = it2;
}
}
}
}
if (value != 999999999)
{
int current = have_effect(e);
if (current !=0 )
{
float left = amount - current;
if (left > 0)
{
float get = left/turns;
int fix = ceil( get );
use( getfixitems(fix, it, type), it );
}
else
print ("Currently have minimum turns of: " + e,"red");
}
else
{
float get = amount/turns;
int fix = ceil( get );
use( getfixitems(fix, it, type), it );
}
}
else
print("Error with " + e + " could not find suitable item under " + stop,"red");
}
void main()
{
ef_toitem($effect[polka face], 20, "auto");
}