Class: Fable::StatePatch
- Inherits:
-
Object
- Object
- Fable::StatePatch
- Defined in:
- lib/fable/state_patch.rb
Instance Attribute Summary collapse
-
#changed_variables ⇒ Object
Returns the value of attribute changed_variables.
-
#globals ⇒ Object
Returns the value of attribute globals.
-
#turn_indicies ⇒ Object
Returns the value of attribute turn_indicies.
-
#visit_counts ⇒ Object
Returns the value of attribute visit_counts.
Instance Method Summary collapse
- #add_changed_variable(name) ⇒ Object
- #get_global(name) ⇒ Object
- #get_turn_index(container) ⇒ Object
- #get_visit_count(container) ⇒ Object
-
#initialize(state_patch_to_copy = nil) ⇒ StatePatch
constructor
A new instance of StatePatch.
- #set_global(name, value) ⇒ Object
- #set_turn_index(container, count) ⇒ Object
- #set_visit_count(container, count) ⇒ Object
Constructor Details
#initialize(state_patch_to_copy = nil) ⇒ StatePatch
Returns a new instance of StatePatch.
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fable/state_patch.rb', line 5 def initialize(state_patch_to_copy = nil) if state_patch_to_copy.nil? self.globals = {} self.changed_variables = Set.new self.visit_counts = {} self.turn_indicies = {} else self.globals = Hash[state_patch_to_copy.globals] self.changed_variables = state_patch_to_copy.changed_variables.dup self.visit_counts = Hash[state_patch_to_copy.visit_counts] self.turn_indicies = Hash[state_patch_to_copy.turn_indicies] end end |
Instance Attribute Details
#changed_variables ⇒ Object
Returns the value of attribute changed_variables.
3 4 5 |
# File 'lib/fable/state_patch.rb', line 3 def changed_variables @changed_variables end |
#globals ⇒ Object
Returns the value of attribute globals.
3 4 5 |
# File 'lib/fable/state_patch.rb', line 3 def globals @globals end |
#turn_indicies ⇒ Object
Returns the value of attribute turn_indicies.
3 4 5 |
# File 'lib/fable/state_patch.rb', line 3 def turn_indicies @turn_indicies end |
#visit_counts ⇒ Object
Returns the value of attribute visit_counts.
3 4 5 |
# File 'lib/fable/state_patch.rb', line 3 def visit_counts @visit_counts end |
Instance Method Details
#add_changed_variable(name) ⇒ Object
27 28 29 |
# File 'lib/fable/state_patch.rb', line 27 def add_changed_variable(name) self.changed_variables << name end |
#get_global(name) ⇒ Object
19 20 21 |
# File 'lib/fable/state_patch.rb', line 19 def get_global(name) return self.globals[name] end |
#get_turn_index(container) ⇒ Object
43 44 45 |
# File 'lib/fable/state_patch.rb', line 43 def get_turn_index(container) self.turn_indicies[container] end |
#get_visit_count(container) ⇒ Object
31 32 33 |
# File 'lib/fable/state_patch.rb', line 31 def get_visit_count(container) self.visit_counts[container] end |
#set_global(name, value) ⇒ Object
23 24 25 |
# File 'lib/fable/state_patch.rb', line 23 def set_global(name, value) self.globals[name] = value end |
#set_turn_index(container, count) ⇒ Object
39 40 41 |
# File 'lib/fable/state_patch.rb', line 39 def set_turn_index(container, count) self.turn_indicies[container] = count end |
#set_visit_count(container, count) ⇒ Object
35 36 37 |
# File 'lib/fable/state_patch.rb', line 35 def set_visit_count(container, count) self.visit_counts[container] = count end |