Skip to content

Commit

Permalink
Insurance fixes (TauCetiStation#11491)
Browse files Browse the repository at this point in the history
* Update economy.dm

* Update jobs.dm
  • Loading branch information
KandreyKandrey authored Jun 1, 2023
1 parent e84edfc commit 4d0691f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
9 changes: 5 additions & 4 deletions code/controllers/subsystem/economy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SUBSYSTEM_DEF(economy)
var/list/department_dividends
var/list/stock_splits
var/list/insurance_prices = list(INSURANCE_NONE = 0, INSURANCE_STANDARD = 10, INSURANCE_PREMIUM = 40)
var/list/roundstart_insurance_prices = list(INSURANCE_NONE = 0, INSURANCE_STANDARD = 10, INSURANCE_PREMIUM = 40)
var/list/insurance_quality_decreasing = list(INSURANCE_PREMIUM, INSURANCE_STANDARD, INSURANCE_NONE)


Expand Down Expand Up @@ -171,20 +172,20 @@ SUBSYSTEM_DEF(economy)
return R.fields["insurance_type"]


/proc/get_next_insurance_type(current_insurance_type, datum/money_account/MA)
/proc/get_next_insurance_type(current_insurance_type, datum/money_account/MA, list/insurance_prices=SSeconomy.insurance_prices)
if(MA.suspended)
return INSURANCE_NONE

var/current_insurance_price = SSeconomy.insurance_prices[current_insurance_type]
var/current_insurance_price = insurance_prices[current_insurance_type]
if(current_insurance_type == MA.owner_preferred_insurance_type && MA.money >= current_insurance_price && MA.owner_max_insurance_payment >= current_insurance_price)
return current_insurance_type

var/prefprice = SSeconomy.insurance_prices[MA.owner_preferred_insurance_type]
var/prefprice = insurance_prices[MA.owner_preferred_insurance_type]
if(MA.money >= prefprice && MA.owner_max_insurance_payment >= prefprice)
return MA.owner_preferred_insurance_type

for(var/insurance_type in SSeconomy.insurance_quality_decreasing)
var/insprice = SSeconomy.insurance_prices[insurance_type]
var/insprice = insurance_prices[insurance_type]
if(MA.money >= insprice && MA.owner_max_insurance_payment >= insprice)
return insurance_type

Expand Down
8 changes: 3 additions & 5 deletions code/controllers/subsystem/jobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -588,13 +588,11 @@ SUBSYSTEM_DEF(job)
C.associated_account_number = MA.account_number
MA.set_salary(job.salary, job.salary_ratio) //set the salary equal to job
MA.owner_preferred_insurance_type = job.is_head ? SSeconomy.insurance_quality_decreasing[1] : H.roundstart_insurance
MA.owner_max_insurance_payment = SSeconomy.insurance_prices[H.roundstart_insurance]

var/insurance_type = get_next_insurance_type(H.roundstart_insurance, MA)
MA.owner_max_insurance_payment = job.is_head ? SSeconomy.roundstart_insurance_prices[MA.owner_preferred_insurance_type] : SSeconomy.roundstart_insurance_prices[H.roundstart_insurance]
var/insurance_type = get_next_insurance_type(H.roundstart_insurance, MA, SSeconomy.roundstart_insurance_prices)
H.roundstart_insurance = insurance_type

var/med_account_number = global.department_accounts["Medical"].account_number
var/insurance_price = SSeconomy.insurance_prices[insurance_type]
var/insurance_price = SSeconomy.roundstart_insurance_prices[insurance_type]
charge_to_account(med_account_number, med_account_number, "[insurance_type] Insurance payment", "NT Insurance", insurance_price)
charge_to_account(MA.account_number, "Medical", "[insurance_type] Insurance payment", "NT Insurance", -insurance_price)

Expand Down

0 comments on commit 4d0691f

Please sign in to comment.