Module: TyranoDsl::ParsingWords::DeclareCharacter
- Includes:
- ParsingWordsModule
- Defined in:
- lib/tyrano_dsl/parsing_words/declare_character.rb
Instance Method Summary collapse
Instance Method Details
#declare_character(character_name, stances) ⇒ void
This method returns an undefined value.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tyrano_dsl/parsing_words/declare_character.rb', line 13 def declare_character(character_name, stances) symbolized_stances = symbolize_keys(stances) symbolized_stances.each_pair do |name, path| symbolized_stances[name] = file_full_path(path) end default_stance = symbolized_stances[:default] unless default_stance raise TyranoDsl::TyranoException, 'A default stance is required' end if context.world.characters.key? character_name raise TyranoDsl::TyranoException, "Duplicated character [#{character_name}]" end context.world.characters[character_name] = TyranoDsl::Elements::Character.new( character_name, symbolized_stances, context.world.characters.length + 1 ) add_parsed_word( TyranoDsl::Vocabulary::DECLARE_CHARACTER, name: character_name, stances: symbolized_stances, default_stance: default_stance ) end |