enjine 0.6.1 → 0.6.3

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.
data/lib/enjine/state.rb CHANGED
@@ -88,15 +88,15 @@ module Enjine
88
88
  # The rules the game was set up with (Enjine::Format), and each player's commander card id or nil (CR 903.3).
89
89
  # Like `decklists`, a restart begins from these again.
90
90
  attr_accessor :format, :commanders
91
+ # The most permanents the battlefield may hold before the game is drawn, or nil (Setup's `permanent_limit:`).
92
+ attr_accessor :permanent_limit
91
93
  # Object ids of commanders put into a graveyard, exile, hand or library since state-based actions were last
92
94
  # checked, whose owner may still send them to the command zone (CR 903.9, Engine::Commander).
93
95
  attr_accessor :commander_returns
94
96
 
95
- def self.initial(names:, decklists:, seed:, outside: nil, format: Format::CONSTRUCTED, commanders: nil)
97
+ def self.initial(names:, decklists:, seed:, outside: nil, format: Format::CONSTRUCTED, commanders: nil, permanent_limit: nil)
96
98
  state = new
97
- state.format = format
98
- state.commanders = (commanders || names.map { nil }).freeze
99
- state.commander_returns = []
99
+ assign_rules(state, format, commanders || names.map { nil }, permanent_limit)
100
100
  state.seed = seed
101
101
  state.rng = Rng.from_seed(seed)
102
102
  state.decklists = decklists.map { |l| l.dup.freeze }.freeze
@@ -122,6 +122,14 @@ module Enjine
122
122
  state
123
123
  end
124
124
 
125
+ def self.assign_rules(state, format, commanders, permanent_limit)
126
+ state.format = format
127
+ state.commanders = commanders.freeze
128
+ state.commander_returns = []
129
+ state.permanent_limit = permanent_limit
130
+ end
131
+ private_class_method :assign_rules
132
+
125
133
  # Phases added this turn (CR 500.8): "pending" [{"after": phase, "phases": ["combat", "main"]}] wait for
126
134
  # their phase to end, "queue" lists added phases still to come and "resume" the step the turn goes on
127
135
  # with after them (Engine::TurnStructure); "combats" counts combat phases begun this turn.
@@ -158,6 +166,7 @@ module Enjine
158
166
  **DEEP_FIELDS.to_h { [it, deep_dup(public_send(it))] },
159
167
  "repeat_cleanup" => repeat_cleanup, "combat_damage_pass" => combat_damage_pass,
160
168
  "attacks_declared" => attacks_declared }.merge("outside_lists" => (outside_lists || []).map(&:dup)).merge(format_h)
169
+ .merge({ "permanent_limit" => permanent_limit }.compact)
161
170
  end
162
171
 
163
172
  # What a Commander game adds to a snapshot; a constructed game's is unchanged.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Enjine
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.3"
5
5
  # Comprehensive Rules document this engine follows.
6
6
  RULES_VERSION = "2026-11-06"
7
7
  end
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.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mehmet Cetin