class ComplexMove
A complex move is any move that has its own state. Moves that span multiple ticks are complex, because the server may have to tell the client how much of the complex move has been completed by a player.
Attributes
actor_id[R]
Public Class Methods
new(actor=nil)
click to toggle source
# File lib/game_2d/complex_move.rb, line 13 def initialize(actor=nil) self.actor_id = actor.nullsafe_registry_id end
Public Instance Methods
actor_id=(id)
click to toggle source
# File lib/game_2d/complex_move.rb, line 17 def actor_id=(id) @actor_id = id.try(:to_sym) end
all_state()
click to toggle source
# File lib/game_2d/complex_move.rb, line 32 def all_state [actor_id] end
as_json()
click to toggle source
# File lib/game_2d/complex_move.rb, line 35 def as_json Serializable.as_json(self).merge!(:actor_id => actor_id) end
on_completion(actor)
click to toggle source
Take a final action after the complex move is done
# File lib/game_2d/complex_move.rb, line 30 def on_completion(actor); end
to_s()
click to toggle source
# File lib/game_2d/complex_move.rb, line 42 def to_s self.class.name end
update(actor)
click to toggle source
Execute one tick of the move. Return true if there is more work to do, false if the move has completed.
# File lib/game_2d/complex_move.rb, line 24 def update(actor) false end
update_from_json(json)
click to toggle source
# File lib/game_2d/complex_move.rb, line 38 def update_from_json(json) self.actor_id = json[:actor_id] if json[:actor_id] self end