Class: Gamefic::Subplot

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic/subplot.rb

Defined Under Namespace

Modules: Element, Feature, Host

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(plot, feature: nil) {|_self| ... } ⇒ Subplot

Returns a new instance of Subplot.

Yields:

  • (_self)

Yield Parameters:



42
43
44
45
46
47
48
49
50
# File 'lib/gamefic/subplot.rb', line 42

def initialize plot, feature:nil
  @plot = plot
  @entities = []
  @players = []
  @concluded = false
  post_initialize
  yield(self) if block_given?
  introduce feature unless feature.nil?
end

Instance Attribute Details

#entitiesObject (readonly)

Returns the value of attribute entities.



40
41
42
# File 'lib/gamefic/subplot.rb', line 40

def entities
  @entities
end

#playersObject (readonly)

Returns the value of attribute players.



40
41
42
# File 'lib/gamefic/subplot.rb', line 40

def players
  @players
end

#plotObject (readonly)

Returns the value of attribute plot.



40
41
42
# File 'lib/gamefic/subplot.rb', line 40

def plot
  @plot
end

Instance Method Details

#concludeObject



68
69
70
71
72
73
74
75
76
# File 'lib/gamefic/subplot.rb', line 68

def conclude
  concluded = true
  entities.each { |e|
    e.destroy
  }
  players.each { |p|
    exeunt p
  }
end

#concluded?Boolean



77
78
79
# File 'lib/gamefic/subplot.rb', line 77

def concluded?
  @concluded
end

#exeunt(player) ⇒ Object



64
65
66
67
# File 'lib/gamefic/subplot.rb', line 64

def exeunt player
  player.send(:p_subplots).delete self
  players.delete player
end

#introduce(player) ⇒ Object



60
61
62
63
# File 'lib/gamefic/subplot.rb', line 60

def introduce player
  player.send(:p_subplots).push self
  players.push player
end

#make(*args) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/gamefic/subplot.rb', line 53

def make *args
  e = plot.make(*args)
  e.extend Gamefic::Subplot::Element
  e.instance_variable_set(:@subplot, self)
  entities.push e
  e
end

#post_initializeObject



51
52
# File 'lib/gamefic/subplot.rb', line 51

def post_initialize
end