Class: DCI::Multiplayer
Overview
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.
Class Method Summary collapse
-
.[](*args) ⇒ Object
Syntax sugar to easy the creation of Multiplayer instances.
Instance Method Summary collapse
-
#[](index) ⇒ Object
Give access to the players of this instance in a way similar to an array: multiplayer, multiplayer, multiplayer, …
- #each(&block) ⇒ Object
-
#initialize(*args) ⇒ Multiplayer
constructor
A new instance of Multiplayer.
Constructor Details
#initialize(*args) ⇒ Multiplayer
Returns a new instance of Multiplayer.
32 33 34 |
# File 'lib/drsi/dci/multiplayer.rb', line 32 def initialize(*args) @players = args end |
Class Method Details
.[](*args) ⇒ Object
Syntax sugar to easy the creation of Multiplayer instances.
18 19 20 |
# File 'lib/drsi/dci/multiplayer.rb', line 18 def self.[](*args) new(*args) end |
Instance Method Details
#[](index) ⇒ Object
Give access to the players of this instance in a way similar to an array: multiplayer, multiplayer, multiplayer, …
28 29 30 |
# File 'lib/drsi/dci/multiplayer.rb', line 28 def [](index) @players[index] end |
#each(&block) ⇒ Object
22 23 24 |
# File 'lib/drsi/dci/multiplayer.rb', line 22 def each(&block) @players.each {|player| block.call(player)} end |