Class: TyranoDsl::Elements::World
- Inherits:
-
Object
- Object
- TyranoDsl::Elements::World
- Defined in:
- lib/tyrano_dsl/elements/world.rb
Overview
The game world
Instance Attribute Summary collapse
- #backgrounds ⇒ Hash{String => TyranoDsl::Elements::Background} readonly
- #characters ⇒ Hash{String => TyranoDsl::Elements::Character} readonly
- #jump_targets ⇒ Array<TyranoDsl::Elements::JumpTarget> readonly
- #labels ⇒ Hash{String => TyranoDsl::Elements::Label} readonly
- #scenes ⇒ Hash{String => TyranoDsl::Elements::Scene} readonly
- #title_screen ⇒ TyranoDsl::Elements::TitleScreen readonly
- #variables ⇒ Hash{String => TyranoDsl::Elements::Variable} readonly
Instance Method Summary collapse
-
#initialize ⇒ World
constructor
A new instance of World.
- #label_value(label_name) ⇒ TyranoDsl::Elements::Label
- #validate ⇒ void
Constructor Details
#initialize ⇒ World
Returns a new instance of World.
24 25 26 27 28 29 30 31 32 |
# File 'lib/tyrano_dsl/elements/world.rb', line 24 def initialize @characters = {} @backgrounds = {} @labels = {} @jump_targets = [] @scenes = {} @variables = {} @title_screen = TyranoDsl::Elements::TitleScreen.new end |
Instance Attribute Details
#backgrounds ⇒ Hash{String => TyranoDsl::Elements::Background} (readonly)
10 11 12 |
# File 'lib/tyrano_dsl/elements/world.rb', line 10 def backgrounds @backgrounds end |
#characters ⇒ Hash{String => TyranoDsl::Elements::Character} (readonly)
12 13 14 |
# File 'lib/tyrano_dsl/elements/world.rb', line 12 def characters @characters end |
#jump_targets ⇒ Array<TyranoDsl::Elements::JumpTarget> (readonly)
14 15 16 |
# File 'lib/tyrano_dsl/elements/world.rb', line 14 def jump_targets @jump_targets end |
#labels ⇒ Hash{String => TyranoDsl::Elements::Label} (readonly)
16 17 18 |
# File 'lib/tyrano_dsl/elements/world.rb', line 16 def labels @labels end |
#scenes ⇒ Hash{String => TyranoDsl::Elements::Scene} (readonly)
18 19 20 |
# File 'lib/tyrano_dsl/elements/world.rb', line 18 def scenes @scenes end |
#title_screen ⇒ TyranoDsl::Elements::TitleScreen (readonly)
20 21 22 |
# File 'lib/tyrano_dsl/elements/world.rb', line 20 def title_screen @title_screen end |
#variables ⇒ Hash{String => TyranoDsl::Elements::Variable} (readonly)
22 23 24 |
# File 'lib/tyrano_dsl/elements/world.rb', line 22 def variables @variables end |
Instance Method Details
#label_value(label_name) ⇒ TyranoDsl::Elements::Label
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tyrano_dsl/elements/world.rb', line 51 def label_value(label_name) if @labels.key? label_name @labels[label_name] else technical_name = label_name ? "label_#{@labels.length}" : nil label = TyranoDsl::Elements::Label.new(label_name, technical_name) @labels[label_name] = label label end end |
#validate ⇒ void
This method returns an undefined value.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tyrano_dsl/elements/world.rb', line 36 def validate @jump_targets.each do |jump_target| scene = @scenes[jump_target.scene] unless scene raise TyranoDsl::TyranoException, "Unknown scene [#{jump_target.scene}] declared in label" end jump_target_label = jump_target.label if jump_target_label && (!scene.labels.include?(jump_target_label.name)) raise TyranoDsl::TyranoException, "Unknown label [#{jump_target_label.name}] declared in label" end end end |