class DCI::Multiplayer
This simple class lets collect together a list of any type of objects. If you pass a multiplayer collection instance as the role player when instantiating a context, every object of the collection get the role instead of the multiplayer instance itself. So this is the way for different objects to play the similar roles at the same time in a DCI
Context
.
Public Class Methods
[](*args)
click to toggle source
Syntax sugar to easy the creation of Multiplayer
instances.
# File lib/drsi/dci/multiplayer.rb, line 18 def self.[](*args) new(*args) end
new(*args)
click to toggle source
# File lib/drsi/dci/multiplayer.rb, line 32 def initialize(*args) @players = args end
Public Instance Methods
[](index)
click to toggle source
Give access to the players of this instance in a way similar to an array: multiplayer, multiplayer, multiplayer, …
# File lib/drsi/dci/multiplayer.rb, line 28 def [](index) @players[index] end
each(&block)
click to toggle source
# File lib/drsi/dci/multiplayer.rb, line 22 def each(&block) @players.each {|player| block.call(player)} end