-
Notifications
You must be signed in to change notification settings - Fork 186
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
[18Uruguay] Also add FCE shares to secondary corps #11209
base: master
Are you sure you want to change the base?
Conversation
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 is looking much better. I've suggested a couple more tweaks to the code, nothing major this time.
bundle = Engine::ShareBundle.new(@fce.shares.take(9)) if num_shares == 10 | ||
bundle = Engine::ShareBundle.new(@fce.shares.reject(&:president).take(num_shares)) unless num_shares == 10 |
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.
The if/unless modifiers are testing the same thing, so this would be clearer structured using an if/else statement.
bundle = Engine::ShareBundle.new(@fce.shares.take(9)) if num_shares == 10 | |
bundle = Engine::ShareBundle.new(@fce.shares.reject(&:president).take(num_shares)) unless num_shares == 10 | |
bundle = | |
if num_shares == 10 | |
Engine::ShareBundle.new(@fce.shares.take(9)) | |
else | |
Engine::ShareBundle.new(@fce.shares.reject(&:president).take(num_shares)) | |
end |
from_secondary = @merge_data[:secondary_corps].reduce(0) do |sum, secondary_corps| | ||
sum + (secondary_corps.president?(holder) ? 1 : 0) | ||
end |
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.
You're trying to find how many of the secondary corporations the player is president of, right? This might be simpler:
from_secondary = @merge_data[:secondary_corps].reduce(0) do |sum, secondary_corps| | |
sum + (secondary_corps.president?(holder) ? 1 : 0) | |
end | |
from_secondary = @merge_data[:secondary_corps].count { |corp| corp.president?(holder) } |
num_shares = (total_percent / 20).to_i | ||
odd_share = num_shares * 20 != total_percent |
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.
num_shares = (total_percent / 20).to_i | |
odd_share = num_shares * 20 != total_percent | |
num_shares, odd_shares = (total_percent / 10).divmod(2) |
@merge_data[:corp_share_sum] = @merge_data[:holders].reduce(0) do |sum, holder| | ||
sum + ((affected_shares(holder, @merge_data[:corps]).sum(&:percent) / 20).to_i * 10) | ||
end |
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.
Do you need to use reduce
here? Would sum
be simpler?
@merge_data[:corp_share_sum] = @merge_data[:holders].reduce(0) do |sum, holder| | |
sum + ((affected_shares(holder, @merge_data[:corps]).sum(&:percent) / 20).to_i * 10) | |
end | |
@merge_data[:corp_share_sum] = @merge_data[:holders].sum do |holder| | |
(affected_shares(holder, @merge_data[:corps]).sum(&:percent) / 20).to_i * 10 | |
end |
Fixes #11111
Fixes #11074
Fixes #[PUT_ISSUE_NUMBER_HERE]
Before clicking "Create"
master
pins
orarchive_alpha_games
label if this change will break existing gamesThis can break existing games
docker compose exec rack rubocop -a
docker compose exec rack rake
Implementation Notes
Explanation of Change
Screenshots
Any Assumptions / Hacks