Skip to content

Commit

Permalink
Merge pull request #11376 from philcampeau/1849-fix-bond-round_state
Browse files Browse the repository at this point in the history
[1849] fix for the Bonds variant
  • Loading branch information
ollybh authored Dec 15, 2024
2 parents 4513db4 + 4d8e4d2 commit 9050a5b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/engine/game/g_1849/step/bond.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module Game
module G1849
module Step
class Bond < Engine::Step::Base
attr_reader :issued_bond, :redeemed_bond

def actions(entity)
return [] if !entity.corporation? || entity != current_entity

Expand All @@ -21,8 +19,10 @@ def actions(entity)
end

def round_state
@issued_bond = {}
@redeemed_bond = {}
{
issued_bond: false,
redeemed_bond: false,
}
end

def description
Expand All @@ -47,7 +47,7 @@ def take_loan(entity, loan)
@log << "#{entity.name} issues its bond and receives #{@game.format_currency(@game.loan_value)}"
@game.bank.spend(@game.loan_value, entity)
entity.loans << loan
@issued_bond[entity] = true
@round.issued_bond = true

initial_sp = entity.share_price.price
@game.stock_market.move_left(entity)
Expand All @@ -59,12 +59,12 @@ def can_take_loan?(entity)
@game.bonds? &&
@game.issue_bonds_enabled &&
entity.corporation? &&
!@redeemed_bond[entity] &&
!@round.redeemed_bond &&
entity.loans.size < @game.maximum_loans(entity)
end

def can_payoff_loan?(entity)
!@issued_bond[entity] &&
!@round.issued_bond &&
!entity.loans.empty? &&
entity.cash >= entity.loans.first.amount
end
Expand All @@ -86,7 +86,7 @@ def process_payoff_loan(action)

entity.loans.delete(loan)

@redeemed_bond[entity] = true
@round.redeemed_bond = true

initial_sp = entity.share_price.price
@game.stock_market.move_right(entity)
Expand Down

0 comments on commit 9050a5b

Please sign in to comment.