make give/take gold/food DRY
This commit is contained in:
@@ -55,44 +55,38 @@ bool silent_GTP(short item_num) {
|
||||
cItem item = univ.scenario.get_stored_item(item_num);
|
||||
return univ.party.give_item(item,false);
|
||||
}
|
||||
|
||||
void give_gold(short amount,bool print_result) {
|
||||
if(amount < 0) return;
|
||||
univ.party.gold += amount;
|
||||
if(print_result)
|
||||
put_pc_screen();
|
||||
if(print_result) put_pc_screen();
|
||||
}
|
||||
|
||||
bool take_gold(short amount,bool print_result) {
|
||||
if(univ.party.gold < amount)
|
||||
return false;
|
||||
univ.party.gold -= amount;
|
||||
if(print_result)
|
||||
put_pc_screen();
|
||||
if(print_result) put_pc_screen();
|
||||
return true;
|
||||
}
|
||||
|
||||
void give_food(short amount,bool print_result) {
|
||||
if(amount < 0) return;
|
||||
univ.party.food = univ.party.food + amount;
|
||||
if(print_result)
|
||||
put_pc_screen();
|
||||
if(print_result) put_pc_screen();
|
||||
}
|
||||
|
||||
short take_food(short amount,bool print_result) {
|
||||
short diff;
|
||||
|
||||
diff = amount - univ.party.food;
|
||||
if(diff > 0) {
|
||||
short shortfall = amount - univ.party.food;
|
||||
if(shortfall > 0) {
|
||||
univ.party.food = 0;
|
||||
if(print_result)
|
||||
put_pc_screen();
|
||||
return diff;
|
||||
}else{
|
||||
univ.party.food -= amount;
|
||||
shortfall = 0;
|
||||
}
|
||||
|
||||
univ.party.food = univ.party.food - amount;
|
||||
if(print_result)
|
||||
put_pc_screen();
|
||||
return 0;
|
||||
if(print_result) put_pc_screen();
|
||||
return shortfall;
|
||||
}
|
||||
|
||||
void equip_item(short pc_num,short item_num) {
|
||||
|
@@ -4,10 +4,14 @@
|
||||
|
||||
bool GTP(short item_num);
|
||||
bool silent_GTP(short item_num);
|
||||
|
||||
void give_gold(short amount,bool print_result);
|
||||
bool take_gold(short amount,bool print_result);
|
||||
void give_food(short amount,bool print_result);
|
||||
// Try to take gold, but take none and return false if the party can't afford it.
|
||||
bool take_gold(short amount,bool print_result);
|
||||
// Take food until the party has 0, returning the amount of their deficiency
|
||||
short take_food(short amount,bool print_result);
|
||||
|
||||
void equip_item(short pc_num,short item_num);
|
||||
void drop_item(short pc_num,short item_num,location where_drop);
|
||||
bool place_item(cItem item,location where,bool try_contained = false);
|
||||
|
@@ -141,17 +141,6 @@ void edit_day() {
|
||||
univ.party.age = (long long) (3700) * (long long) (dialog_answer);
|
||||
}
|
||||
|
||||
void give_gold(short amount,bool /*print_result*/) {
|
||||
univ.party.gold = univ.party.gold + amount;
|
||||
}
|
||||
|
||||
bool take_gold(short amount,bool /*print_result*/) {
|
||||
if(univ.party.gold < amount)
|
||||
return false;
|
||||
univ.party.gold = univ.party.gold - amount;
|
||||
return true;
|
||||
}
|
||||
|
||||
void edit_xp(cPlayer *pc) {
|
||||
location view_loc;
|
||||
|
||||
|
@@ -1,8 +1,6 @@
|
||||
|
||||
class cDialog;
|
||||
|
||||
void give_gold(short amount,bool print_result);
|
||||
bool take_gold(short amount,bool print_result);
|
||||
void give_spec_items();
|
||||
void pick_race_abil(cPlayer *pc,short mode,cDialog* parent = nullptr);
|
||||
void reset_boats();
|
||||
|
Reference in New Issue
Block a user