enjine 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +91 -1
  3. data/SUPPORTED.md +34 -26
  4. data/docs/guides/card-data-format.md +143 -1
  5. data/docs/plans/dsl-gaps.md +99 -0
  6. data/docs/reference/abilities.md +46 -13
  7. data/docs/reference/costs.md +23 -6
  8. data/docs/reference/decisions.md +4 -0
  9. data/docs/reference/effects.md +118 -25
  10. data/docs/reference/filters.md +19 -2
  11. data/docs/reference/keywords.md +16 -2
  12. data/docs/reference/triggers.md +28 -7
  13. data/lib/enjine/actions/cast.rb +10 -3
  14. data/lib/enjine/actions/play_land.rb +3 -1
  15. data/lib/enjine/card_definition.rb +19 -3
  16. data/lib/enjine/cli/text.rb +10 -3
  17. data/lib/enjine/decisions/combat.rb +4 -2
  18. data/lib/enjine/decisions/damage_order.rb +18 -0
  19. data/lib/enjine/engine/ability_layers.rb +6 -1
  20. data/lib/enjine/engine/casting/alt_casting.rb +44 -4
  21. data/lib/enjine/engine/casting/cast_choices.rb +13 -1
  22. data/lib/enjine/engine/casting/casting.rb +43 -7
  23. data/lib/enjine/engine/casting/cost_options.rb +3 -1
  24. data/lib/enjine/engine/casting/permissions.rb +27 -23
  25. data/lib/enjine/engine/casting/target_counts.rb +14 -3
  26. data/lib/enjine/engine/casting/waterbend.rb +22 -2
  27. data/lib/enjine/engine/characteristics.rb +32 -14
  28. data/lib/enjine/engine/combat.rb +26 -7
  29. data/lib/enjine/engine/copies.rb +26 -12
  30. data/lib/enjine/engine/damage.rb +51 -1
  31. data/lib/enjine/engine/durations.rb +47 -0
  32. data/lib/enjine/engine/entering.rb +36 -2
  33. data/lib/enjine/engine/face_down.rb +12 -3
  34. data/lib/enjine/engine/faces.rb +16 -2
  35. data/lib/enjine/engine/follow_ups.rb +4 -1
  36. data/lib/enjine/engine/resolution.rb +46 -1
  37. data/lib/enjine/engine/rules.rb +6 -4
  38. data/lib/enjine/engine/state_based_actions.rb +8 -0
  39. data/lib/enjine/engine/triggers.rb +18 -21
  40. data/lib/enjine/engine/turn_history.rb +16 -1
  41. data/lib/enjine/engine/turn_structure.rb +1 -0
  42. data/lib/enjine/engine/zones.rb +23 -4
  43. data/lib/enjine/events.rb +6 -1
  44. data/lib/enjine/frames.rb +2 -2
  45. data/lib/enjine/mana.rb +3 -0
  46. data/lib/enjine/mechanics/abilities/chosen_values.rb +49 -6
  47. data/lib/enjine/mechanics/abilities/damage_replacements.rb +136 -64
  48. data/lib/enjine/mechanics/abilities/double_counters.rb +1 -1
  49. data/lib/enjine/mechanics/abilities/entering_choices.rb +40 -21
  50. data/lib/enjine/mechanics/abilities/play_permissions.rb +52 -19
  51. data/lib/enjine/mechanics/abilities/player_rules.rb +30 -13
  52. data/lib/enjine/mechanics/abilities/replacement_effects.rb +2 -1
  53. data/lib/enjine/mechanics/abilities/static.rb +8 -1
  54. data/lib/enjine/mechanics/card_spec.rb +99 -14
  55. data/lib/enjine/mechanics/costs/base.rb +67 -9
  56. data/lib/enjine/mechanics/costs/behold.rb +21 -5
  57. data/lib/enjine/mechanics/costs/choose_creature_type.rb +43 -0
  58. data/lib/enjine/mechanics/costs/one_of.rb +3 -0
  59. data/lib/enjine/mechanics/costs/pay_life.rb +27 -8
  60. data/lib/enjine/mechanics/costs/remove_counters.rb +8 -5
  61. data/lib/enjine/mechanics/costs/tap.rb +44 -3
  62. data/lib/enjine/mechanics/effects/base.rb +10 -2
  63. data/lib/enjine/mechanics/effects/become.rb +60 -21
  64. data/lib/enjine/mechanics/effects/copy.rb +63 -23
  65. data/lib/enjine/mechanics/effects/counters.rb +8 -2
  66. data/lib/enjine/mechanics/effects/damage.rb +11 -0
  67. data/lib/enjine/mechanics/effects/earthbend.rb +2 -1
  68. data/lib/enjine/mechanics/effects/fight.rb +11 -0
  69. data/lib/enjine/mechanics/effects/gain_control.rb +6 -3
  70. data/lib/enjine/mechanics/effects/library.rb +76 -18
  71. data/lib/enjine/mechanics/effects/pay.rb +7 -4
  72. data/lib/enjine/mechanics/effects/repeat.rb +92 -0
  73. data/lib/enjine/mechanics/effects/return_to_battlefield.rb +25 -6
  74. data/lib/enjine/mechanics/effects/search.rb +34 -6
  75. data/lib/enjine/mechanics/effects/tokens.rb +42 -10
  76. data/lib/enjine/mechanics/filters/base.rb +40 -13
  77. data/lib/enjine/mechanics/filters/exile.rb +27 -0
  78. data/lib/enjine/mechanics/filters/stack.rb +15 -9
  79. data/lib/enjine/mechanics/keywords/alternative_costs.rb +10 -6
  80. data/lib/enjine/mechanics/keywords/cards_have.rb +65 -0
  81. data/lib/enjine/mechanics/keywords/flags.rb +3 -1
  82. data/lib/enjine/mechanics/keywords/hideaway.rb +6 -5
  83. data/lib/enjine/mechanics/keywords/kicker.rb +24 -6
  84. data/lib/enjine/mechanics/keywords/protection.rb +24 -8
  85. data/lib/enjine/mechanics/keywords/riot.rb +13 -10
  86. data/lib/enjine/mechanics/linked.rb +32 -2
  87. data/lib/enjine/mechanics/selector.rb +32 -9
  88. data/lib/enjine/mechanics/triggers/base.rb +14 -3
  89. data/lib/enjine/mechanics/triggers/casting.rb +16 -10
  90. data/lib/enjine/mechanics/triggers/combat.rb +32 -12
  91. data/lib/enjine/mechanics/triggers/keyword_actions.rb +17 -0
  92. data/lib/enjine/mechanics/triggers/tap_and_counters.rb +38 -11
  93. data/lib/enjine/mechanics/triggers/zone_changes.rb +1 -1
  94. data/lib/enjine/mechanics/values.rb +20 -10
  95. data/lib/enjine/mechanics.rb +5 -0
  96. data/lib/enjine/replacements.rb +3 -2
  97. data/lib/enjine/rules_monitor.rb +17 -4
  98. data/lib/enjine/steps.rb +10 -1
  99. data/lib/enjine/version.rb +1 -1
  100. data/lib/enjine/view.rb +1 -1
  101. metadata +7 -1
@@ -53,30 +53,43 @@ module Enjine
53
53
  end
54
54
 
55
55
  # "Whenever one or more [kind] counters are put on ~" (CR 122.6): counters put on a permanent, including
56
- # the counters it enters with. Once per counter-placing event.
56
+ # the counters it enters with. Once per counter-placing event. `nth`: "when the fourth plan counter is put
57
+ # on this": only the event that takes the number of those counters from below N to N or more.
57
58
  class CountersPlaced < Trigger
58
59
  primitive :trigger, :counters_placed,
59
60
  description: "One or more counters (only `counter`, if given) are put on the subject, including the " \
60
- "counters it enters the battlefield with. Triggers once per event, however many counters.",
61
+ "counters it enters the battlefield with. Triggers once per event, however many counters. " \
62
+ "`nth` (needs `counter`): only when the Nth such counter is put on it (the event that " \
63
+ "takes it from fewer than N to N or more).",
61
64
  rules: %w[122.6 603.2 603.2c],
62
65
  params: { "subject" => "\"self\" (default) or {\"each\": filter, ...}", "counter" => "counter name",
63
66
  "first_time_this_turn" => "true: only the first time each turn such counters are put on " \
64
67
  "that permanent (an earlier placement counts even if nothing " \
65
- "could trigger then)" },
66
- example: { "counters_placed" => { "counter" => "+1/+1" } }
68
+ "could trigger then)",
69
+ "by" => "you | opponent: only counters that player puts (\"whenever you put ...\", CR 122.6a; " \
70
+ "a permanent's controller puts the counters it enters with)",
71
+ "nth" => "positive integer" },
72
+ example: { "counters_placed" => { "counter" => "+1/+1", "by" => "you" } }
67
73
 
68
- def self.keys = %w[subject counter first_time_this_turn]
74
+ def self.keys = %w[subject counter first_time_this_turn by nth]
69
75
  def watches?(event) = event.is_a?(Events::CountersChanged) || event.is_a?(Events::ZoneChanged)
70
76
 
71
77
  def setup(params, errors, path)
72
78
  @counter = params["counter"] && Counters.parse(params["counter"], errors, "#{path}.counter")
73
79
  @first_time = params["first_time_this_turn"]
74
80
  errors << "#{path}.first_time_this_turn: must be true or false" unless [nil, true, false].include?(@first_time)
81
+ @by = params["by"]
82
+ errors << "#{path}.by: must be you or opponent" unless [nil, "you", "opponent"].include?(@by)
83
+ @nth = params["nth"]
84
+ errors << "#{path}.nth: must be a positive integer" unless @nth.nil? || (@nth.is_a?(Integer) && @nth.positive?)
85
+ errors << "#{path}.nth: needs a counter" if @nth && @counter.nil?
75
86
  end
76
87
 
77
88
  def occurrences(engine, event, source)
78
- id, amount = placed(engine, event)
79
- return [] unless amount&.positive?
89
+ id, from, to = placed(engine, event)
90
+ amount = to.to_i - from.to_i
91
+ return [] unless amount.positive? && put_by_ok?(engine, event, id, source)
92
+ return [] if @nth && !(from < @nth && to >= @nth)
80
93
  return [] if @first_time && engine.counter_placements_this_turn(id, @counter) != 1
81
94
 
82
95
  obj = engine.object(id)
@@ -88,21 +101,35 @@ module Enjine
88
101
  def match?(engine, event, source) = !occurrences(engine, event, source).empty?
89
102
 
90
103
  def to_s
104
+ return "When #{@counter} counter number #{@nth} is put on #{@subject}" if @nth
105
+
91
106
  first = " for the first time each turn" if @first_time
92
- "Whenever one or more #{"#{@counter} " if @counter}counters are put on #{@subject}#{first}"
107
+ return "Whenever one or more #{"#{@counter} " if @counter}counters are put on #{@subject}#{first}" unless @by
108
+
109
+ who = @by == "you" ? "you put" : "an opponent puts"
110
+ "Whenever #{who} one or more #{"#{@counter} " if @counter}counters on #{@subject}#{first}"
93
111
  end
94
112
 
95
113
  private
96
114
 
97
- # [object id, how many matching counters were put on it] for this event, or nil.
115
+ # CR 122.6a: who put the counters, relative to the source's controller. Counters a permanent enters with are
116
+ # put by its controller.
117
+ def put_by_ok?(engine, event, id, source)
118
+ return true unless @by
119
+
120
+ putter = event.is_a?(Events::CountersChanged) ? engine.names.index(event.by) : engine.object(id).controller
121
+ (@by == "you") == (putter == source["controller"])
122
+ end
123
+
124
+ # [object id, how many matching counters it had before, how many after] for this event, or nil.
98
125
  def placed(engine, event)
99
126
  if event.is_a?(Events::CountersChanged)
100
127
  return nil if @counter && event.counter != @counter
101
128
 
102
- [event.object, event.to - event.from]
129
+ [event.object, event.from, event.to]
103
130
  elsif event.to == "battlefield" && (obj = engine.state.objects[event.new_id])
104
131
  counts = @counter ? [obj.counters.fetch(@counter, 0)] : obj.counters.values
105
- [obj.id, counts.sum]
132
+ [obj.id, 0, counts.sum]
106
133
  end
107
134
  end
108
135
  end
@@ -227,7 +227,7 @@ module Enjine
227
227
  super
228
228
  @batched = params.fetch("batched", false)
229
229
  errors << "#{path}.batched: must be true or false" unless [true, false].include?(@batched)
230
- @card = params["card"] && Mechanics.build_entry(:filter, params["card"], errors, "#{path}.card")
230
+ @card = params["card"] && Mechanics.characteristic_filter(params["card"], errors, "#{path}.card")
231
231
  end
232
232
 
233
233
  def match?(engine, event, source)
@@ -112,11 +112,14 @@ module Enjine
112
112
 
113
113
  def to_s = "the #{@kind.tr("_", " ")} of #{@selector}"
114
114
 
115
- # CR 202.3: the mana value of an object (0 without a mana cost); a spell on the stack counts its X (CR 202.3e).
116
- # Nil for an object that's gone.
115
+ # CR 202.3: the mana value of an object (0 without a mana cost); a spell on the stack counts its X (CR 202.3e);
116
+ # a melded permanent adds up its front faces (CR 713.5c, Engine::Faces). Nil for an object that's gone.
117
117
  def self.mana_value(engine, obj)
118
118
  return nil if obj.nil?
119
119
 
120
+ melded = engine.melded_mana_value(obj)
121
+ return melded if melded
122
+
120
123
  cost = engine.chars(obj).mana_cost or return 0
121
124
  (obj.zone == :stack ? cost.with_x(obj.x.to_i) : cost).mana_value
122
125
  end
@@ -354,7 +357,7 @@ module Enjine
354
357
  data = data.is_a?(Hash) ? data.transform_keys(&:to_s) : {}
355
358
  Mechanics.check_keys(data, %w[by matching from not_from], errors, path)
356
359
  casters = Selector.build(data.fetch("by", "you"), errors, "#{path}.by", **context)
357
- filter = data["matching"] && Mechanics.build_entry(:filter, data["matching"], errors, "#{path}.matching")
360
+ filter = data["matching"] && Mechanics.characteristic_filter(data["matching"], errors, "#{path}.matching")
358
361
  new(casters, filter, CastFrom.build(data, errors, path), LOGS.fetch(kind))
359
362
  end
360
363
 
@@ -401,7 +404,7 @@ module Enjine
401
404
  errors << "#{path}: must be an object {\"each\": filter, \"controller\": ...}" unless data.is_a?(Hash)
402
405
  data = data.is_a?(Hash) ? data.transform_keys(&:to_s) : {}
403
406
  Mechanics.check_keys(data, %w[each controller], errors, path)
404
- filter = data.key?("each") ? Mechanics.build_entry(:filter, data["each"], errors, "#{path}.each") : nil
407
+ filter = data.key?("each") ? Mechanics.characteristic_filter(data["each"], errors, "#{path}.each") : nil
405
408
  controller = data.fetch("controller", "any")
406
409
  errors << "#{path}.controller: must be one of you, opponent, any" unless %w[you opponent any].include?(controller)
407
410
  new(DEPARTED.fetch(kind), filter, controller)
@@ -463,6 +466,8 @@ module Enjine
463
466
  # {"share_card_type": selector | [selectors]} the referenced objects share a card type ("exiled_with": linked cards)
464
467
  # {"chosen": word} that word was chosen for this object (choose_option, CR 607.2f)
465
468
  # {"meld_with": name} you both own and control the source and a creature named so (CR 713.1a)
469
+ # {"attacking": selector} a referenced permanent is attacking, or was as it last existed ("if it was
470
+ # attacking", CR 608.2h)
466
471
  # {"not": condition}, {"all": [conditions]}, {"any": [conditions]}
467
472
  class Condition
468
473
  FLAGS = %w[your_turn was_cast attacked attacked_this_turn max_speed
@@ -472,6 +477,8 @@ module Enjine
472
477
  KEYED = { "targets" => :Targets, "triggering" => :TriggeringIs, "source" => :Source,
473
478
  "nth_resolution" => :NthResolution, "chosen" => :ChosenIs, "designation" => :Designation,
474
479
  "first_combat_phase" => :FirstCombatPhase, "meld_with" => :MeldWith }.freeze # MeldWith: effects/meld.rb
480
+ # Kinds about the objects a selector names (both in linked.rb).
481
+ SELECTED = { "share_card_type" => :ShareCardType, "attacking" => :Attacking }.freeze
475
482
 
476
483
  def self.build(data, errors, path, targets_count: 0, results_count: 0)
477
484
  unless data.is_a?(Hash)
@@ -489,7 +496,7 @@ module Enjine
489
496
  elsif data.key?("sacrificed") then Sacrificed.build(data, errors, path)
490
497
  elsif (flag = FLAGS.find { data.key?(it) }) then Flag.new(flag, data[flag] != false)
491
498
  elsif data.key?("began_extra_turn") then BeganExtraTurn.new(data["began_extra_turn"] != false) # CR 500.7
492
- elsif data.key?("share_card_type") then ShareCardType.build(data, errors, path, targets_count) # linked.rb
499
+ elsif (key = SELECTED.keys.find { data.key?(it) }) then const_get(SELECTED[key]).build(data, errors, path, **context)
493
500
  elsif (key = KEYED.keys.find { data.key?(it) }) then const_get(KEYED[key]).build(data, errors, path)
494
501
  else build_more(data, errors, path, context)
495
502
  end
@@ -697,7 +704,7 @@ module Enjine
697
704
  class TriggeringIs
698
705
  def self.build(data, errors, path)
699
706
  Mechanics.check_keys(data, %w[triggering], errors, path)
700
- new(Mechanics.build_entry(:filter, data["triggering"], errors, "#{path}.triggering"))
707
+ new(Mechanics.characteristic_filter(data["triggering"], errors, "#{path}.triggering"))
701
708
  end
702
709
 
703
710
  def initialize(filter)
@@ -705,12 +712,15 @@ module Enjine
705
712
  freeze
706
713
  end
707
714
 
715
+ # A permanent that left is matched with the card types it last had (CR 603.10a: "if it was a creature").
708
716
  def true?(engine, ctx)
709
- card = Selector.memory(engine, ctx).fetch("triggering", {})["card"]
710
- return false unless card && @filter
717
+ facts = Selector.memory(engine, ctx).fetch("triggering", {})
718
+ return false unless facts["card"] && @filter
711
719
 
712
- defn = engine.catalog.fetch(card)
713
- @filter.matches_facts?(Filters::Facts.new(chars: defn.printed_characteristics, counters: {}, token: defn.token?))
720
+ defn = engine.catalog.fetch(facts["card"])
721
+ chars = defn.printed_characteristics
722
+ chars = chars.with(types: facts["types"].map(&:to_sym)) if facts["types"]
723
+ @filter.matches_facts?(Filters::Facts.new(chars: chars, counters: {}, token: defn.token?))
714
724
  end
715
725
 
716
726
  def to_s = "it's a #{@filter.respond_to?(:primitive_name) ? @filter.primitive_name.tr("_", " ") : @filter}"
@@ -7,6 +7,11 @@ module Enjine
7
7
 
8
8
  # Builds a primitive from a data entry. An entry is either a bare name ("tap")
9
9
  # or a single-key Hash ({"mana" => {...params}}).
10
+ # A filter matched by characteristics only (Filters::Facts): `owner` can't be honoured there and is an error.
11
+ def characteristic_filter(data, errors, path)
12
+ Filters.without_owner!(build_entry(:filter, data, errors, path), errors, path)
13
+ end
14
+
10
15
  def build_entry(category, entry, errors, path, **context)
11
16
  name, params = split_entry(entry)
12
17
  unless name
@@ -23,8 +23,9 @@ module Enjine
23
23
  # several effects apply. The engine applies them in the order that player would always choose:
24
24
  # effects that let a permanent stay ("instead remove all +1/+1 counters", a shield counter) before
25
25
  # effects that send it elsewhere ("exile it instead"), "+1 counter" bonuses before doubling, and
26
- # "enters untapped" after every "enters tapped". No pair implemented so far has two orders that
27
- # each benefit that player, so no decision is asked; a frame will when one does.
26
+ # "enters untapped" after every "enters tapped". No pair of these has two orders that each benefit
27
+ # that player, so no decision is asked. Damage is where orders matter: the affected player chooses
28
+ # one before the damage is dealt (Mechanics::DamageEvents, a damage_order decision).
28
29
  module Replacements
29
30
  module_function
30
31
 
@@ -151,7 +151,7 @@ module Enjine
151
151
  return if card.instant_speed? || event.during_resolution # CR 608.2g: timing doesn't apply
152
152
 
153
153
  caster = event.player
154
- return if sneaked?(event, caster)
154
+ return if sneaked?(event, caster) || flashed_by_cost?(event, card)
155
155
 
156
156
  # The stack was empty as casting began (CR 601.2a) when the spell is at its bottom; what went on it since
157
157
  # ("whenever you cast" triggers, even one still waiting for its targets, CR 603.3d) doesn't count.
@@ -161,6 +161,12 @@ module Enjine
161
161
  end
162
162
  end
163
163
 
164
+ # CR 601.3c: "you may cast this spell as though it had flash if you [pay an optional additional cost]", paid.
165
+ def flashed_by_cost?(event, card)
166
+ paid = state.objects[event.object]&.memory&.[]("kicked_with") or return false
167
+ card.ability_instances.any? { it.ability.respond_to?(:flash?) && it.ability.flash? && it.ability.keyword == paid }
168
+ end
169
+
164
170
  # CR 702.190a: a spell cast for its sneak cost, at instant speed during its caster's declare blockers step.
165
171
  def sneaked?(event, caster)
166
172
  state.objects[event.object]&.memory&.[]("cast_with") == "sneak" && state.step == :declare_blockers &&
@@ -174,7 +180,12 @@ module Enjine
174
180
 
175
181
  defn(obj.card).keyword?(keyword) || unlocked(obj).any? { it.keywords.include?(keyword) } ||
176
182
  granted_keywords(obj.id).include?(keyword.to_sym) || static_keyword?(obj, keyword) ||
177
- (keyword.to_sym == :haste && obj.memory["haste_while_controlled_by"] == obj.controller) # cast with suspend, CR 702.62a
183
+ (keyword.to_sym == :haste && gained_haste?(obj))
184
+ end
185
+
186
+ # Haste a permanent gained as it was cast with suspend (CR 702.62a) or chose with riot (CR 702.136a).
187
+ def gained_haste?(obj)
188
+ obj.memory["haste_while_controlled_by"] == obj.controller || obj.memory["riot_haste"] == true
178
189
  end
179
190
 
180
191
  # Whether an effect or an applying static ability makes it lose all abilities (CR 613.1f).
@@ -307,9 +318,11 @@ module Enjine
307
318
  card.creature? && !card.defined_pt? && applying_statics(obj).none?(&:base_power_toughness) && !types_replaced?(obj)
308
319
  end
309
320
 
310
- # Creature types an effect replaced (layer 4): the monitor matches statics against printed types.
321
+ # Creature types or card types an effect or static replaced (layer 4, CR 205.1a): the monitor matches statics
322
+ # against printed types, and a permanent that is no longer a creature has no power or toughness.
311
323
  def types_replaced?(obj)
312
- state.effects.any? { %w[creature_types assimilate].include?(it["kind"]) && Array(it["affected"]).include?(obj.id) }
324
+ applying_statics(obj).any?(&:set_types) ||
325
+ state.effects.any? { %w[creature_types assimilate set_types].include?(it["kind"]) && Array(it["affected"]).include?(obj.id) }
313
326
  end
314
327
 
315
328
  # CR 613.4b: the latest setting effect, else as printed, or as a copy's exceptions or a token's creating
data/lib/enjine/steps.rb CHANGED
@@ -79,6 +79,7 @@ module Enjine
79
79
  # CR 514.2: remove marked damage and end "until end of turn" effects (control returns first).
80
80
  def finish(engine)
81
81
  engine.revert_temporary_control!
82
+ engine.end_next_turn_control! # Engine::Durations
82
83
  engine.cleanup_turn!
83
84
  end
84
85
 
@@ -94,6 +95,14 @@ module Enjine
94
95
  end
95
96
  end
96
97
 
98
+ # CR 513: "until your next end step" effects end as the end step begins (Engine::Durations).
99
+ class EndStep < Step
100
+ def begin(engine)
101
+ engine.expire_end_step_effects!
102
+ super
103
+ end
104
+ end
105
+
97
106
  ORDER = [
98
107
  Untap.new(:untap, :beginning),
99
108
  Step.new(:upkeep, :beginning),
@@ -105,7 +114,7 @@ module Enjine
105
114
  CombatDamage.new(:combat_damage, :combat),
106
115
  Step.new(:end_of_combat, :combat),
107
116
  Step.new(:postcombat_main, :postcombat_main),
108
- Step.new(:end, :ending),
117
+ EndStep.new(:end, :ending),
109
118
  Cleanup.new(:cleanup, :ending)
110
119
  ].freeze
111
120
  BY_NAME = ORDER.to_h { [it.name, it] }.freeze
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Enjine
4
- VERSION = "0.3.0"
4
+ VERSION = "0.5.0"
5
5
  # Comprehensive Rules document this engine follows.
6
6
  RULES_VERSION = "2026-11-06"
7
7
  end
data/lib/enjine/view.rb CHANGED
@@ -111,7 +111,7 @@ module Enjine
111
111
  return object_view(engine, id) unless engine.face_down?(obj)
112
112
 
113
113
  hidden = { "id" => id, "face_down" => true, "owner" => engine.name(obj.owner) }
114
- looks = viewer == :observer || obj.memory.fetch("may_look", []).map { engine.name(it) }.include?(viewer)
114
+ looks = viewer == :observer || ((index = engine.names.index(viewer)) && engine.may_look?(obj, index))
115
115
  looks ? object_view(engine, id).merge(hidden) : hidden
116
116
  end
117
117
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enjine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Cetin
@@ -66,6 +66,7 @@ files:
66
66
  - lib/enjine/decisions/casting.rb
67
67
  - lib/enjine/decisions/combat.rb
68
68
  - lib/enjine/decisions/commander_zone.rb
69
+ - lib/enjine/decisions/damage_order.rb
69
70
  - lib/enjine/decisions/discard.rb
70
71
  - lib/enjine/decisions/effect_choice.rb
71
72
  - lib/enjine/decisions/enter_choice.rb
@@ -98,6 +99,7 @@ files:
98
99
  - lib/enjine/engine/damage.rb
99
100
  - lib/enjine/engine/defined_power_toughness.rb
100
101
  - lib/enjine/engine/designations.rb
102
+ - lib/enjine/engine/durations.rb
101
103
  - lib/enjine/engine/emblems.rb
102
104
  - lib/enjine/engine/entering.rb
103
105
  - lib/enjine/engine/face_down.rb
@@ -149,6 +151,7 @@ files:
149
151
  - lib/enjine/mechanics/copy_except.rb
150
152
  - lib/enjine/mechanics/costs/base.rb
151
153
  - lib/enjine/mechanics/costs/behold.rb
154
+ - lib/enjine/mechanics/costs/choose_creature_type.rb
152
155
  - lib/enjine/mechanics/costs/discard.rb
153
156
  - lib/enjine/mechanics/costs/exert.rb
154
157
  - lib/enjine/mechanics/costs/exile_cards.rb
@@ -202,6 +205,7 @@ files:
202
205
  - lib/enjine/mechanics/effects/proliferate.rb
203
206
  - lib/enjine/mechanics/effects/pump.rb
204
207
  - lib/enjine/mechanics/effects/put_in_library.rb
208
+ - lib/enjine/mechanics/effects/repeat.rb
205
209
  - lib/enjine/mechanics/effects/return_choice.rb
206
210
  - lib/enjine/mechanics/effects/return_to_battlefield.rb
207
211
  - lib/enjine/mechanics/effects/return_to_hand.rb
@@ -213,6 +217,7 @@ files:
213
217
  - lib/enjine/mechanics/effects/tokens.rb
214
218
  - lib/enjine/mechanics/filters/any_target.rb
215
219
  - lib/enjine/mechanics/filters/base.rb
220
+ - lib/enjine/mechanics/filters/exile.rb
216
221
  - lib/enjine/mechanics/filters/graveyard.rb
217
222
  - lib/enjine/mechanics/filters/one_of.rb
218
223
  - lib/enjine/mechanics/filters/permanents.rb
@@ -221,6 +226,7 @@ files:
221
226
  - lib/enjine/mechanics/follow_up.rb
222
227
  - lib/enjine/mechanics/keywords/alternative_costs.rb
223
228
  - lib/enjine/mechanics/keywords/beam_me_up.rb
229
+ - lib/enjine/mechanics/keywords/cards_have.rb
224
230
  - lib/enjine/mechanics/keywords/changeling.rb
225
231
  - lib/enjine/mechanics/keywords/convoke.rb
226
232
  - lib/enjine/mechanics/keywords/crew.rb