Skip to content

Commit

Permalink
[1844] Consider lowest cost variant for buy_train step actions
Browse files Browse the repository at this point in the history
  • Loading branch information
crericha committed Oct 17, 2024
1 parent b9fd70a commit f229cc9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/engine/train.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ def id
# if set ability must be a :train_discount ability
def min_price(ability: nil)
return 1 unless from_depot?
return @price unless ability

Array(ability).map { |a| a.discounted_price(self, @price) }.min
variants.keys.map do |v|
variant = clone
variant.variant = v
Array(ability).map { |a| a.discounted_price(variant, variant.price) }.min || variant.price
end.min
end

def from_depot?
Expand Down
2 changes: 1 addition & 1 deletion public/fixtures/1844/160062.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/fixtures/1844/164302.json

Large diffs are not rendered by default.

0 comments on commit f229cc9

Please sign in to comment.