-
Notifications
You must be signed in to change notification settings - Fork 231
[1862 USA & Canada] PR 04: SR mechanics — GHU discount, NYH par lock, private close triggers #12736
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
Open
neutronc
wants to merge
3
commits into
tobymao:master
Choose a base branch
from
neutronc:1862_usa_canada_pB_sr_mechanics_v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
lib/engine/game/g_1862_usa_canada/step/buy_sell_par_shares.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative '../../../step/buy_sell_par_shares' | ||
|
|
||
| module Engine | ||
| module Game | ||
| module G1862UsaCanada | ||
| module Step | ||
| class BuySellParShares < Engine::Step::BuySellParShares | ||
| # NHSC gives the buyer NYH's director cert; NYH must be parred at | ||
| # exactly $100. Restrict available par prices to that single value. | ||
| def get_par_prices(entity, corporation) | ||
| return nyh_par_prices if corporation.id == 'NYH' | ||
|
|
||
| super | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def nyh_par_prices | ||
| [@game.stock_market.par_prices.find { |p| p.price == 100 }].compact | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative '../../../step/dividend' | ||
|
|
||
| module Engine | ||
| module Game | ||
| module G1862UsaCanada | ||
| module Step | ||
| class Dividend < Engine::Step::Dividend | ||
| def process_dividend(action) | ||
| entity = action.entity | ||
| first_time = entity.operating_history.none? { |_, info| info.dividend.kind.to_sym == :payout } | ||
| super | ||
| @game.on_first_payout!(entity) if first_time && action.kind.to_sym == :payout | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative '../../../step/token' | ||
|
|
||
| module Engine | ||
| module Game | ||
| module G1862UsaCanada | ||
| module Step | ||
| class Token < Engine::Step::Token | ||
| # GHU (Bahnhoflizenz) gives the director's corporation an $80 discount | ||
| # on station token placement (minimum $0). The discount is auto-applied | ||
| # whenever the operating corporation's director holds GHU. | ||
| def process_place_token(action) | ||
| apply_ghu_discount!(action.entity, action.token) | ||
| super | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def ghu_company | ||
| @game.companies.find { |c| c.sym == 'GHU' && !c.closed? } | ||
| end | ||
|
|
||
| def apply_ghu_discount!(corporation, token) | ||
| ghu = ghu_company | ||
| return unless ghu&.owner == corporation.owner | ||
|
|
||
| discount = ghu.abilities.find { |a| a.type == :token }&.discount.to_i | ||
| token.price = [token.price - discount, 0].max | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.