Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1849] fix for the Bonds variant #11376

Merged
merged 2 commits into from
Dec 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: nil,
redeemed_bond: nil,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're only using boolean values/tests elsewhere, so you might as well make this boolean values here.

Suggested change
issued_bond: nil,
redeemed_bond: nil,
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
Loading