ereinion icon

best_in_slot

ereinion | PRO | 12/16/18 09:39:43 PM UTC | 0 ⭐ | 280 👁️ | Never ⏰ | []
JavaScript |

960 B

|

None

|

0 👍

/

0 👎

int get_price(item item_to_check, float acceptable_age) {
    return ((historical_age(item_to_check) <= acceptable_age)? historical_price(item_to_check) : mall_price(item_to_check));
}
 
string to_proper_case(string s) {
    return (to_upper_case(substring(s, 0, 1)) + substring(s, 1));
}
 
void main() {
    int[slot] best_in_slot_value;
    item[slot] best_in_slot_item;
    int current_value;
    slot sl;
    
    foreach it in $items[] {
        if (to_slot(it) != $slot[none]) {
            if (it.discardable && it.tradeable) {
                if (autosell_price(it) > 0) {
                    current_value = get_price(it, 0.5);
                    sl = to_slot(it);
                    if (best_in_slot_value[sl] < current_value) {
                        best_in_slot_item[sl] = it;
                        best_in_slot_value[sl] = current_value;
                    }
                }
            }
        }
    }
    
    foreach key in best_in_slot_item {
        print_html("<font color=0000FF>" + to_proper_case(key) + " - " + to_proper_case(best_in_slot_item[key]) + ", " + best_in_slot_value[key] + " meat.</font>");
    }
}

Comments