robinheghan / elm-warrior / Warrior.Map.Builder

You can use this module to build your own maps!


type Template

A map in progress.

Map layout


type alias Size =
{ rows : Basics.Int
, columns : Basics.Int 
}

Describes how large a map should be in rows and columns.

init : Size -> Template

Initialize an empty map of a given size where every tile is empty. Use the the following with functions to make the map more interesting.

withDescription : String -> Template -> Template

Sets a description for the map which will be displayed above the map when the game is played.

withSpawnPoint : Warrior.Coordinate.Coordinate -> Template -> Template

Marks a coordinate on the map where a playable warrior will spawn.

withExitPoint : Warrior.Coordinate.Coordinate -> Template -> Template

Marks a coordinate on the map where the player needs to go to advance to the next map.

withWalledArea : Warrior.Coordinate.Coordinate -> Warrior.Coordinate.Coordinate -> Template -> Template

Turns every tile between two coordinates into wall tiles.

Non-playable characters (Npc's) and Items

withNpc : String -> Warrior.Coordinate.Coordinate -> (Warrior -> Warrior.Internal.Map.Map -> Warrior.History.History -> Warrior.Action) -> Template -> Template

Places a villain on the specific coordinate of the map, using the supplied function to know what to do each turn. You can find pre-made turn functions in the Warrior.Npc module.

armLastNpc : Warrior.Item.Item -> Template -> Template

Places an item into the inventory of the last villain added with the withNpc function.

withItem : Warrior.Coordinate.Coordinate -> Warrior.Item.Item -> Template -> Template

Places an item on the map which can be picked up by warriors.

Queries

spawnPoints : Template -> List Warrior.Coordinate.Coordinate

A list of points where warriors can spawn.

npcs : Template -> List ( Warrior, Warrior -> Warrior.Internal.Map.Map -> Warrior.History.History -> Warrior.Action )

Return a list of all non-playable characters along with their turn functions.

Finally

build : Template -> Warrior.Internal.Map.Map

Turn this template into a map