Skip to content
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

[1812] multiple pre-alpha updates #11540

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

philcampeau
Copy link
Collaborator

Before clicking "Create"

  • Branch is derived from the latest master
  • Add the pins or archive_alpha_games label if this change will break existing games
  • Code passes linter with docker compose exec rack rubocop -a
  • Tests pass cleanly with docker compose exec rack rake

Implementation Notes

Explanation of Change

  • Sets game to depend on 1867 code
  • add numbers to names of private companies for convenience
  • set minors to 100% float
  • moved PHASES and TRAINS back into base.rb
  • implemented loans, and penalty for not paying interest
  • implemented 2-train export
  • corrected train counts & limits
  • corrected GAME_END_CHECK
  • made p11 and p12 never close

Screenshots

Any Assumptions / Hacks

@philcampeau philcampeau added new games Issues relating to games that are not yet alpha test level 1812 labels Feb 12, 2025
Copy link
Collaborator

@ollybh ollybh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much better now that it is based on the 1867 code. But I've found a few things that I think could be improved.

module Game
module G1812
module Step
class BuyTrain < Engine::Step::BuyTrain
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this class inherit from G1867::Step::BuyTrain? You've got several methods that are cut'n'pasted from that class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100% correct. I wasn't sure how to inherit a couple of methods directly from Engine::Step::BuyTrain, but I think I got it now. I needed to inherit from Engine because the 1867 methods included code I didn't want, which prevented me from calling super. Let me know if I can improve this, it's in update fixes buy_train.rb inheritance


owed = @game.pay_interest!(entity)
if owed
@game.unpaid_loan(entity, owed)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactoring G1867::Step::LoanOperations to extract a (private) unpaid_interest method called at this point would mean that only that method would need to be redone in this class, instead of copying all of the code in this method.

Comment on lines 449 to 454
revenue += 10 if corp.assigned?(p4_company) && stops.find { |s| C18_HEX.include?(s.hex.id) }

revenue += 10 if g_train?(train) && corp.assigned?(p3_company) && stops.any? { |s| F3_PORT.include?(s.hex.id) }
revenue += 10 if g_train?(train) && corp.assigned?(p8_company) && stops.any? { |s| F3_PORT.include?(s.hex.id) }
revenue += 10 if g_train?(train) && corp.assigned?(p9_company) && stops.any? { |s| H9_PORT.include?(s.hex.id) }
revenue += 20 if g_train?(train) && corp.assigned?(p12_company) && stops.any? { |s| G6_PORT.include?(s.hex.id) }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This very repetitive. Could you make a method that encapsulates these tests?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this whole section is still a work in progress, it's not even achieving what I need. Right now my focus is on figuring out how to implement those mine stops on plain track hexes. Once I have those, I'll be able to test and correct this section. I can comment it out for now if that's better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think I got something. Let me know what you think. Tbh, I feel like it looks more cluttered. The reason I had it as separate lines was they were all clean and easily read/understood.

Comment on lines +453 to +456
{ p3_company => F3_PORT, p8_company => F3_PORT, p9_company => H9_PORT, p12_company => G6_PORT }.each do |company, port|
revenue += (company == p12_company ? 20 : 10) if g_train?(train) && corp.assigned?(company) && stops.any? do |s|
s.hex.id == port
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this isn't clearer. The HexBonus ability almost matches what you need here (and does exactly for P4), you just need some way of testing that the train is a goods train. Maybe add a trains array to that ability, then in revenue_for test both that you have a matching hex and a matching train.

include Engine::Step::AutomaticLoan

def pass!
Engine::Step::BuyTrain.instance_method(:pass!).bind_call(self)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit clunky. Could you just call super, and override nationalize! in the game class so that it does nothing?

Comment on lines +24 to +28
def buy_train_action(action, _entity = nil)
@depot_train = action.train.from_depot?

Engine::Step::BuyTrain.instance_method(:buy_train_action).bind_call(self)
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could get rid of this method entirely, by having a post_train_buy method in the game class that does nothing (but with a comment explaining why you've done this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1812 new games Issues relating to games that are not yet alpha test level
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants