-
Notifications
You must be signed in to change notification settings - Fork 183
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
[18TS] Map and companies #11095
base: master
Are you sure you want to change the base?
[18TS] Map and companies #11095
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.
It's going to take a while to review a pull request that's this big. Here are some comments and questions on the first part of this PR.
corps = [] | ||
add_entities(corps, UNIT1_CORPORATIONS) if @units[1] | ||
add_entities(corps, UNIT2_CORPORATIONS) if @units[2] | ||
add_entities(corps, UNIT3_CORPORATIONS) if @units[3] | ||
corps |
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 add_entities
method seems like overkill. You can simply use array concatenation.
corps = [] | |
add_entities(corps, UNIT1_CORPORATIONS) if @units[1] | |
add_entities(corps, UNIT2_CORPORATIONS) if @units[2] | |
add_entities(corps, UNIT3_CORPORATIONS) if @units[3] | |
corps | |
corps = [] | |
corps += UNIT1_CORPORATIONS if @units[1] | |
corps += UNIT2_CORPORATIONS if @units[2] | |
corps += UNIT3_CORPORATIONS if @units[3] | |
corps |
comps = [] | ||
add_entities(comps, UNIT1_COMPANIES) if @units[1] | ||
add_entities(comps, UNIT3_COMPANIES.reject { |c| comps.any? { |comp| comp[:value] == c[:value] } }) if @units[3] | ||
add_entities(comps, UNIT2_COMPANIES.reject { |c| comps.any? { |comp| comp[:value] == c[:value] } }) if @units[2] | ||
comps |
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.
If the duplicate company definitions are all identical (I haven't checked the code to confirm this), you can use array addition and call uniq
to get rid of any duplicates.
comps = [] | |
add_entities(comps, UNIT1_COMPANIES) if @units[1] | |
add_entities(comps, UNIT3_COMPANIES.reject { |c| comps.any? { |comp| comp[:value] == c[:value] } }) if @units[3] | |
add_entities(comps, UNIT2_COMPANIES.reject { |c| comps.any? { |comp| comp[:value] == c[:value] } }) if @units[2] | |
comps | |
comps = [] | |
comps += UNIT1_COMPANIES if @units[1] | |
comps += UNIT3_COMPANIES if @units[3] | |
comps += UNIT2_COMPANIES if @units[2] | |
comps.uniq |
@units = {} | ||
@kits = {} | ||
@regionals = {} |
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 a bit strange. You're using a hash, but the only hash value used is true
, and you're just testing whether a hash key is present or not, which means your code wouldn't be able to tell the difference between @units[1] = true
and @units[1] = false
.
An alternative would be to use an array. Or a set if you're worried about duplicates.
@ units = ::Set[]
...
@units << 1 if @optional_rules.include?(:unit_1)
...
raise OptionError, 'Must select at least one Unit if using other options' unless @units.intersect?([1, 2, 3])
if optional_rules.include?(:unit_1) && optional_rules.include?(:unit_2) && | ||
optional_rules.include?(:unit_3) | ||
optional_rules.delete(:unit_1) | ||
optional_rules.delete(:unit_2) | ||
optional_rules.delete(:unit_3) | ||
optional_rules << :unit_123 | ||
elsif optional_rules.include?(:unit_1) && optional_rules.include?(:unit_2) | ||
optional_rules.delete(:unit_1) | ||
optional_rules.delete(:unit_2) | ||
optional_rules << :unit_12 | ||
elsif optional_rules.include?(:unit_2) && optional_rules.include?(:unit_3) | ||
optional_rules.delete(:unit_2) | ||
optional_rules.delete(:unit_3) | ||
optional_rules << :unit_23 | ||
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.
Is this needed? Isn't it just giving more conditions to check later on?
raise OptionError, 'Variant DB3 is for Unit 3' if !units[3] && optional_rules.include?(:db3) | ||
raise OptionError, 'Unit 4 requires Unit 3' if optional_rules.include?(:unit_4) && !units[3] | ||
|
||
p_range = case @units.keys.sort.map(&:to_s).join |
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.
If you have multiple units selected then @units.keys.sort.map(&:to_s).join
is going to give values like 12
, 23
or 123
which aren't matched below.
(And, fyi, the map(&:to_s)
call isn't needed, it will happen automatically when join
is called).
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 repeated in several other places.
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.
Are you trying to test how many units have been selected? That would be @units.size
.
# 119 upgrades from yellow in phase 3 | ||
return false if tile.name == '119' && !phase_color_cache.include?(:brown) | ||
|
||
# 166 upgrades from green in phase 4 | ||
return false if tile.name == '166' && !phase_color_cache.include?(:gray) |
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.
Are these needed? 119 is a green tile with brown stripes, so should automatically be available when green tiles are available. Likewise 166 is a brown tile with grey stripes, so should become available at the same time as brown tiles.
|
||
def game_location_names | ||
locations = LOCATION_NAMES.dup | ||
if optional_rules.include?(:unit_4) |
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.
Obsolete code? There isn't a unit 4 mentioned elsewhere.
# 200 upgrades from pre-printed brown tiles on Crewe, Wolverton or Swindon, doesn't upgrade | ||
return false if from.name == '200' | ||
return false if to.name == '200' && from.color != :sepia |
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.
Are the pre-printed hexes brown or sepia?
elsif a.par_price.price < b.par_price.price | ||
1 | ||
else | ||
@formed.find_index(a) < @formed.find_index(b) ? -1 : 1 |
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 can use the spaceship operator here:
@formed.find_index(a) < @formed.find_index(b) ? -1 : 1 | |
@formed.find_index(a) <=> @formed.find_index(b) |
if @depot.upcoming.first.name == '5' | ||
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.
?
module Engine | ||
module Game | ||
module G18TS | ||
class Game < Game::Base |
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.
As this is an 1825 derivative which looks like it duplicates a lot of code from the 1825 implementation, it would be better if this was a subclass of G1825::Game
instead of Game::Base
. That would give you most of 1825’s rules without all this copied code. Though you might have to refactor the 1825 code in places to allow you to override behaviour here.
@douglasfir Can you check that you haven't included more code in this pull request than you had meant to? |
Good advice, there are a lot of examples of inheriting games and it sure
seems like the way to go for this game.
1861 inherits 1867
18USA inherits 1817
1849K2S inherits 1849
18 Los Angeles and 1852 Missouri inherit 1846
(the list goes on)
…On Thu, Aug 8, 2024 at 10:35 AM Oliver Burnett-Hall < ***@***.***> wrote:
@douglasfir <https://github.com/douglasfir> Can you check that you
haven't included more code in this pull request than you had meant to?
The PR cover note says that this game has three units and no other
variants, but there is code for handling kits and regional variants. And
the PR title says this is the map and companies, but there is far more than
this included.
—
Reply to this email directly, view it on GitHub
<#11095 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AG6CEXABGHPYDVNIYRCPDRLZQOT43AVCNFSM6AAAAABL4XALWOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZWGMZTIMRSHE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Sorry for the delayed response, been away from home for the past week. My original intention with this pull request was to just post my static files (map + companies + meta information). I only realized afterwards that the rakefile requires a functioning game to accept static files, so I then included my other files since they are all necessary dependencies without removing all of the 1825 vestiges. Thanks for the advice of using a subclass; you're right, that makes much more sense. I will refactor my code accordingly, but I'm wondering if this can be releasse as an alpha quality game now to allow the designer to playtest in parallel. |
It doesn't require a functioning game, it just needs files that can be loaded without errors. If you need to include files other than ones for the all the definitions you can just include stub files for the moment – these shouldn't cause any errors and you can add the code later on:
|
We only have a production branch and a single production server, so code needs to be in a reasonable state before it is merged. If you need to be able to work with the game developer to test your code before it is merged then you've got a couple of options:
|
Map and companies for 18TS, an 1825 inspired design by site user Martin2D. My implementation rips heavily from the 1825 implementation. Unlike 1825, there are only the 3 "units", no additional variants, so the setup scripts are significantly simpler.