Talking
MenuAdventures.Talking
— ModuleMenuAdventures.Talking
A sub-module that enables talking to other players.
julia> using MenuAdventures
julia> using MenuAdventures.Testing
julia> using MenuAdventures.Talking
julia> import MenuAdventures: ever_possible
julia> @universe struct Universe <: AbstractUniverse
end;
julia> @noun struct Room <: AbstractRoom
already_lit::Bool = true
end;
julia> @noun struct Person <: Noun
end;
julia> @noun struct NPC <: Noun
dialog::Dict{String, Answer} = Dict{String, Answer}()
end;
julia> ever_possible(::Say, ::Visible, ::NPC) = true;
julia> cd(joinpath(pkgdir(MenuAdventures), "test", "Talking")) do
check_choices() do interface
you = Person(
"Brandon",
grammatical_person = second_person,
indefinite_article = "",
)
friend = NPC(
"your friend",
indefinite_article = "",
dialog = Dict("Hello" => Answer("Hello", (universe, person) -> nothing))
)
room = Room("room")
universe = Universe(you, interface = interface)
universe[room, you] = Containing()
universe[room, friend] = Containing()
universe
end
end
true
MenuAdventures.Talking.Dialog
— TypeMenuAdventures.Talking.Say
— TypeSay()
Say, to someone Visible
, some Dialog
.
An Action
. Note the first argument is the addressee, and the second is the dialog. If possible(::Say, ::Dialog, addressee)
, then addressee
must have a dialog field containing a dialog dictionary. The keys of this dictionary should be text the player says, and the values should be Answer
s containing a response from the addressee
and a trigger. After a dialog option is chosen, the response trigger will be called with two arguments: universe
and addressee
. Then the dialog option will be removed.