-
Notifications
You must be signed in to change notification settings - Fork 189
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
[18CO] Specific Mine Implementation #2022
Conversation
i think normally this was done with the assign ability. could that be used instead for consistency? |
I've looked through all the games using assign and I'm having a difficult time visualizing how to use the Assign ability here. I guess I should first try to clarify whether you meant the assign_hexes Ability or whether you meant Assignable ? Where I see assign_hexes Ability being used is when one corporation places tokens on hexes to gain a bonus. This is the exact opposite - all corporations are removing tokens from the map to gain their respective bonuses. Additionally, once the mine is collected, the hex it came from is no longer relevant. If Mine was its own object, using Assignable on said class would make sense, but I haven't seen a pattern of games defining their own object types. |
it's not an ability, it's an action. an entity can assign a target |
lib/engine/step/g_18_co/track.rb
Outdated
# TODO: Implement Mine Collection | ||
@log << 'TODO: implement mine token collection' | ||
# Mine Token Collection | ||
unless action.hex.tile.icons.select { |icon| icon.name == 'mine' }.empty? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless action.hex.tile.icons.select { |icon| icon.name == 'mine' }.empty? | |
if action.hex.tile.icons.map(&:name).include?('mine') |
@tobymao @ryandriskel I took a crack at doing this via assignment; it does use the assignment hash a little differently than we have elsewhere in that the value really matters and can be something other than I did a bit of local testing and this works for at least a couple mines and with the Idarado Mining Company (I didn't keep going up till phase 6 to test closing of the mines). |
Thanks @michaeljb - That does look a lot cleaner. I really appreciate you giving it a shot. I'll load it up on my computer tomorrow and run through everything. Moving this to Draft for now. |
d54bb86
to
180fa31
Compare
I've got the basic code working following Michael's lead. It is cleaner, but I feel this trades misusing Ability count_per_or for misusing Assignment active. The one thing lost by not using the Abilities section is the number of mines owned by the corp. Also, the corporation never places a mine on the board, so it might be misleading having the mine show up in the token list. One possibility I see is to extend the assignment data to allow an object rather than just an active flag. I'm going to play around with that and see if there's a clean solution. |
84b58cc
to
5393a53
Compare
9a7ab23
to
66422b9
Compare
lib/engine/game/g_18_co.rb
Outdated
setup_corporations | ||
end | ||
|
||
def setup_companies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This became unnecessary with @michaeljb 's imc.owner check in mine_multiplier
|
||
case action | ||
when Action::BuyCompany | ||
mine_update_text(action.entity) if action.company == imc && action.entity.corporation? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the IMC is bought in, the text on the Ability needs to be updated to reflect the change in mine value and total.
# Only pay mines if a train produce revenue regardless of withhold or pay | ||
if tfm.positive? && (payout[:corporation].positive? || payout[:per_share].positive?) | ||
@game.bank.spend(tfm, entity) | ||
def process_dividend(action) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled this from @michaeljb 's suggestions as it is a much more appropriate place to execute the action.
@log << "#{action.entity.name} collects a mine token from | ||
#{action.hex.name} for a total of | ||
#{@game.format_currency(@game.mines_total(action.entity))} from mines" | ||
@log << "#{action.entity.name} collects a mine token from #{action.hex.name}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I shortened the log message to avoid redundancy since the payout is shown on the corporation now
38dd09f
to
bb2f2c7
Compare
conflict |
bb2f2c7
to
6f82a12
Compare
Rebased |
This change only impacts 18CO files.
Background
From #1836
Results
Mines show up as a corporation ability
![Screen Shot 2020-10-25 at 10 13 18 AM](https://user-images.githubusercontent.com/15675400/97115618-40662c80-16bd-11eb-9067-37778b7f35b6.png)
Log is written to when a corporation picks up a mine as well as when mine money is awarded
![Screen Shot 2020-10-25 at 10 18 04 AM](https://user-images.githubusercontent.com/15675400/97115628-4fe57580-16bd-11eb-88ca-65146ca88b8f.png)
Implementation Notes
Rather than define new Ability classes I am working with the Base class. I don't know any other games that use tokens like this. One downside is the need to build a New object when adding a mine as the attributes are read only.
Piggybacking on change_share_price isn't the most ideal place to do this, but the timing is right and the data needed to determine if mines should pay is available.