ExtraActions
MenuAdventures.ExtraActionsMenuAdventures.ExtraActions.AttackMenuAdventures.ExtraActions.EatMenuAdventures.ExtraActions.GiveMenuAdventures.ExtraActions.PushBetweenRoomsMenuAdventures.ExtraActions.TurnOnOrOff
MenuAdventures.ExtraActions — ModuleMenuAdventures.ExtraActionsA sub-module with miscellaneous extra actions.
julia> using MenuAdventures
julia> using MenuAdventures.Testing
julia> using MenuAdventures.ExtraActions
julia> import MenuAdventures: ever_possible, is_shining
julia> @universe struct Universe <: AbstractUniverse
end;
julia> @noun struct Room <: AbstractRoom
already_lit::Bool = true
end;
julia> @noun struct Person <: Noun
end;
julia> ever_possible(::Give, ::Reachable, ::Person) = true;
julia> @noun struct Food <: Noun
end;
julia> ever_possible(::Eat, ::Reachable, ::Food) = true;
julia> @noun mutable struct Lamp <: Noun
on::Bool = false
end;
julia> ever_possible(::Take, ::Reachable, ::Lamp) = true;
julia> ever_possible(::TurnOnOrOff, ::Reachable, ::Lamp) = true;
julia> is_shining(thing::Lamp) = thing.on;
julia> @noun struct Anvil <: Noun
end;
julia> ever_possible(::PushBetweenRooms, ::Immediate, ::Anvil) = true;
julia> cd(joinpath(pkgdir(MenuAdventures), "test", "ExtraActions")) do
check_choices() do interface
you = Person(
"Brandon",
grammatical_person = second_person,
indefinite_article = "",
)
light_room = Room("light room")
dark_room = Room("dark room", already_lit = false)
universe = Universe(you, interface = interface)
universe[light_room, dark_room] = North()
universe[light_room, you] = Containing()
universe[light_room, Person("your friend", indefinite_article = "")] = Containing()
universe[light_room, Lamp("lamp")] = Containing()
universe[light_room, Lamp("other lamp")] = Containing()
universe[light_room, Food("food", indefinite_article = "some")] = Containing()
universe[light_room, Anvil("anvil")] = Containing()
universe
end
end
trueMenuAdventures.ExtraActions.Attack — TypeMenuAdventures.ExtraActions.Eat — TypeMenuAdventures.ExtraActions.Give — TypeGive()Give something from your Inventory to someone Reachable.
An Action. By default, ever_possible(::Give, ::Inventory, _) = true, that is, you can give someone anything in your inventory.
MenuAdventures.ExtraActions.PushBetweenRooms — TypeMenuAdventures.ExtraActions.TurnOnOrOff — Type