Skip to content

Commit

Permalink
Log when a corporation acquired a mine/port token
Browse files Browse the repository at this point in the history
  • Loading branch information
ollybh committed Sep 11, 2023
1 parent cf56a2d commit ecc38e7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
10 changes: 10 additions & 0 deletions lib/engine/game/g_18_ardennes/map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ def dummy_corp(sym, logo, coords)
hex.place_token(token)
end
end

corp
end

def dummy_token_type(token)
case token.corporation
when @mine_corp then :mine
when @port_corp then :port
else raise GameError, 'Not a dummy token'
end
end

def hexes_by_id(coordinates)
Expand Down
6 changes: 5 additions & 1 deletion lib/engine/game/g_18_ardennes/step/home_hex_tile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,12 @@ def process_lay_tile(action)
hex = action.hex
return if hex.tokens.empty?

action.entity.assign!(hex.coordinates)
corporation = action.entity
corporation.assign!(hex.coordinates)
token_type = @game.dummy_token_type(hex.tokens.first)
hex.tokens.first.remove!
@game.log << "#{corporation.id} collects a #{token_type} token " \
"from hex #{hex.coordinates} (#{hex.location_name})"
end
end
end
Expand Down
9 changes: 7 additions & 2 deletions lib/engine/game/g_18_ardennes/step/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,16 @@ def can_replace_token?(entity, token)
def process_remove_token(action)
corp = action.entity
city = action.city
check_connected(corp, city, city.hex)
hex = city.hex
check_connected(corp, city, hex)

city.tokens[action.slot].remove!
old_token = city.tokens[action.slot]
token_type = @game.dummy_token_type(old_token)
old_token.remove!
place_token(corp, city, available_tokens(corp).first)
corp.assign!(city.hex.coordinates)
@game.log << "#{corp.id} collects a #{token_type} token from " \
"hex #{hex.coordinates} (#{hex.location_name})"
pass!
end
end
Expand Down

0 comments on commit ecc38e7

Please sign in to comment.