Skip to content
Merged
Show file tree
Hide file tree
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
51 changes: 22 additions & 29 deletions lib/engine/game/g_18_pa/entities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,10 @@ def company_header(_company)
color: '#000000',
},
{
float_percent: 50,
float_percent: 40,
sym: 'B&O',
name: 'Baltimore & Ohio Railroad',
logo: '18_chesapeake/BO',
simple_logo: '1830/BO.alt',
logo: '18_pa/b&o',
tokens: [0, 40],
shares: [40, 20, 20, 20],
type: 'five_share',
Expand All @@ -242,81 +241,75 @@ def company_header(_company)
color: '#025aaa',
},
{
float_percent: 20,
name: 'Boston and Albany Railroad',
float_percent: 40,
sym: 'B&A',
logo: '18_ny/ba',
simple_logo: '18_ny/ba.alt',
name: 'Boston and Albany Railroad',
logo: '18_pa/b&a',
tokens: [0, 40],
shares: [40, 20, 20, 20],
type: 'five_share',
coordinates: 'D27',
city: 0,
abilities: [{ type: 'assign_hexes', hexes: ['D17'], count: 1 }],
color: '#E21F27',
},
{
float_percent: 50,
float_percent: 40,
sym: 'CNJ',
name: 'Central Railroad of New Jersey',
logo: '',
simple_logo: '',
logo: '18_pa/cnj',
tokens: [0, 40],
shares: [40, 20, 20, 20],
type: 'five_share',
coordinates: 'H17',
city: 0,
color: :'#ADD8E6',
color: '#ADD8E6',
text_color: 'black',
},
{
float_percent: 50,
float_percent: 40,
sym: 'ERIE',
name: 'Erie Railroad',
logo: '1846/ERIE',
simple_logo: '1830/ERIE.alt',
logo: '18_pa/erie',
tokens: [0, 40],
shares: [40, 20, 20, 20],
type: 'five_share',
coordinates: 'H17',
city: 1,
abilities: [{ type: 'assign_hexes', hexes: ['C2'], count: 1 }],
color: :'#FFF500',
text_color: 'black',
color: '#FFA500',
},
{
float_percent: 50,
float_percent: 40,
name: 'New York, New Haven, & Hartford Railroad',
sym: 'NH',
logo: '18_ny/nynh',
simple_logo: '18_ny/nynh.alt',
logo: '18_pa/nynh',
tokens: [0, 40],
shares: [40, 20, 20, 20],
type: 'five_share',
coordinates: 'G22',
color: '#E96B21',
color: '#32763f',
},
{
float_percent: 50,
float_percent: 40,
sym: 'PRR',
name: 'Pennsylvania Railroad',
logo: '18_chesapeake/PRR',
simple_logo: '1830/PRR.alt',
logo: '18_pa/prr',
tokens: [0, 40],
shares: [40, 20, 20, 20],
type: 'five_share',
coordinates: 'I8',
abilities: [{ type: 'assign_hexes', hexes: ['I2'], count: 1 }],
color: '#32763f',
color: '#7b352a',
},
{
float_percent: 50,
float_percent: 40,
sym: 'NYC',
name: 'New York Central System',
logo: '1830/NYC',
simple_logo: '1830/NYC.alt',
tokens: [100, 100, 100],
logo: '18_pa/nyc',
tokens: [0, 0, 0, 100, 100, 100],
shares: [20, 10, 10, 10, 10, 10, 10, 10, 10],
color: :'#474548',
color: '#000000',
},
].freeze
end
Expand Down
83 changes: 72 additions & 11 deletions lib/engine/game/g_18_pa/game.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,11 @@ class Game < Game::Base
CURRENCY_FORMAT_STR = '$%s'

MUST_BUY_TRAIN = :always
EBUY_DEPOT_TRAIN_MUST_BE_CHEAPEST = true
EBUY_DEPOT_TRAIN_MUST_BE_CHEAPEST = false
SELL_AFTER = :operate
SOLD_SHARES_DESTINATION = :corporation
MARKET_SHARE_LIMIT = 80 # percent
EBUY_FROM_OTHERS = :never
TILE_LAYS = [{ lay: true, upgrade: true }, { lay: :not_if_upgraded, upgrade: false }].freeze

BANK_CASH = 8_000

Expand Down Expand Up @@ -66,15 +65,13 @@ class Game < Game::Base
train_limit: 3,
tiles: %i[yellow green],
operating_rounds: 2,
status: %i['may_convert_acquire'],
},
{
name: '5',
on: '5',
train_limit: 2,
tiles: %i[yellow green brown],
operating_rounds: 2,
status: %i['may_convert_acquire'],
},
{
name: '3D',
Expand Down Expand Up @@ -125,6 +122,7 @@ class Game < Game::Base
{ 'nodes' => ['town'], 'pay' => 99, 'visit' => 99 }],
price: 500,
num: 99,
# events: [{ 'type' => 'convert_2r_trains' }],
},
# The 2R trains are reserved for corps which buy in Minors 4-9
{
Expand All @@ -145,23 +143,86 @@ class Game < Game::Base
},
].freeze

SCRANTON_HEX = 'G12'
SCRANTON_MARKER_ICON = 'coal'
SCRANTON_MARKER_COST = 40
DOUBLING_TOKEN_CORPS = %w[B&A ERIE PRR].freeze
MINOR_UPGRADES = %w[yellow green].freeze

def new_auction_round
Engine::Round::Auction.new(self, [
Engine::Step::SelectionAuction,
])
end

def stock_round
Engine::Round::Stock.new(self, [
Engine::Step::DiscardTrain,
Engine::Step::Exchange,
Engine::Step::SpecialTrack,
Engine::Step::BuySellParShares,
])
end

def operating_round(round_num)
Round::Operating.new(self, [
Engine::Step::Bankrupt,
Engine::Step::Exchange,
Engine::Step::SpecialTrack,
Engine::Step::SpecialToken,
Engine::Step::BuyCompany,
Engine::Step::HomeToken,
Engine::Step::Track,
G18PA::Step::Track,
Engine::Step::Token,
Engine::Step::Route,
Engine::Step::Dividend,
G18PA::Step::Dividend,
Engine::Step::DiscardTrain,
Engine::Step::BuyTrain,
[Engine::Step::BuyCompany, { blocks: true }],
], round_num: round_num)
end

def setup
@scranton_marker_ability = Engine::Ability::Description.new(type: 'description', description: 'Scranton Token')

@corporations.each do |corporation|
tile = hex_by_id(corporation.coordinates)&.tile
tile.cities[corporation.city || 0].place_token(corporation, corporation.tokens.first, free: true) unless tile.nil?
end
end

def scranton_marker_available?
hex_by_id(SCRANTON_HEX).tile.icons.any? { |icon| icon.name == SCRANTON_MARKER_ICON }
end

def scranton_marker?(entity)
return false if !entity.corporation? || entity.type == :minor

scranton_markers(entity).any?
end

def scranton_markers(entity)
entity.all_abilities.select { |ability| ability.description == @scranton_marker_ability.description }
end

def connected_to_scranton?(entity)
graph.reachable_hexes(entity).include?(hex_by_id(SCRANTON_HEX))
end

def can_buy_scranton_marker?(entity)
return false if !entity.corporation? || entity.type == :minor

scranton_marker_available? &&
!scranton_marker?(entity) &&
buying_power(entity) >= SCRANTON_MARKER_COST &&
connected_to_coalfields?(entity)
end

def buy_scranton_marker(entity)
return unless can_buy_scranton_marker?(entity)

entity.spend(SCRANTON_MARKER_COST, @bank)
entity.add_ability(@scranton_marker_ability.dup)
@log << "#{entity.name} buys a Scranton bonus token for $#{SCRANTON_MARKER_COST}."

tile_icons = hex_by_id(SCRANTON_HEX).tile.icons
tile_icons.delete_at(tile_icons.find_index { |icon| icon.name == SCRANTON_MARKER_ICON })
end
end
end
end
Expand Down
Loading