Skip to content

Commit

Permalink
Merge pull request #11455 from patrikolesen/18_uruguay_interest_on_loans
Browse files Browse the repository at this point in the history
[18Uruguay] Interest should not be paid for penalty loans
  • Loading branch information
bentziaxl authored Jan 20, 2025
2 parents aa3d8d3 + 5570d40 commit a52c523
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions lib/engine/game/g_18_uruguay/loans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,30 @@ def adjust_stock_market_loan_penalty(entity)
end
end

def take_loan_if_needed_for_interest!(entity)
def pay_interest!(entity)
owed = interest_owed(entity)
return if owed.zero?
interest_paid[entity] = owed

remaining = owed - entity.cash
perform_ebuy_loans(entity, remaining + 10) if remaining.positive?
while owed > entity.cash &&
(loan = loans[0])
take_loan(entity, loan, ebuy: true)
end

if owed <= entity.cash
if owed.positive?
log_interest_payment(entity, owed)
entity.spend(owed, bank)
end
return
end
owed
end

def corps_pay_interest
corps = @round.entities.select { |entity| entity.loans.size.positive? && entity != @rptla }
corps.each do |corp|
next if corp.closed?

take_loan_if_needed_for_interest!(corp)
pay_interest!(corp)
end
end
Expand Down

0 comments on commit a52c523

Please sign in to comment.