Skinney/elm-warrior/1.2.0

NOTE: the latest version is 4.0.5

Renamed to robinheghan/elm-warrior. It is published under that name, and new versions come out there.

Versions published as Skinney/elm-warrior still install under that name. 15 versions of 15 come from the new location (see their notes).

Rerouted (renamed, verified). The GitHub user or repository was renamed. The tag is still there, at the new name. The Lamdera package server serves a copy recovered from https://github.com/robinheghan/elm-warrior.

What we checked: The repo moved to github.com/robinheghan/elm-warrior. Rebuilt with git archive from commit aa214487d0a8 of https://github.com/robinheghan/elm-warrior (zip prefix Skinney-elm-warrior-aa21448/, America/Los_Angeles times): the zip is byte-identical to the one package.elm-lang.org recorded, SHA-1 bb8957c51e680c2555d2905e1e8ea66d31e88915.

The Lamdera compiler uses this copy and prints a one-line notice saying so. elm itself fails to download this version.

Details · package.elm-lang.org's zip: https://github.com/Skinney/elm-warrior/zipball/1.2.0/

Warrior.Map

The functions in this module allows you to create your own maps, or simply ask questions about the map currently being played.

type Map

A map, or level.

type alias Config =
{ rows : Int
, columns : Int
}

Describes how large a map should be in rows and columns. Use this when creating your own maps.

type Tile
= Wall
| Empty
| SpawnPoint
| Player
| Item Item
| Exit

Describes what is on a specific coordinate of a map.

Player API

canMoveOnto : Coordinate -> Map -> Bool

Checks if a Move action can be performed.

Checks if a Move action can be formed onto the given tile.

isExitPoint : Map -> Coordinate -> Bool

Checks to see if a specific coordinate on the map is an exit point.

look : Direction -> Coordinate -> Map -> List Tile

Provides a list of everything the player can see in a specific direction. The first item of the list will be the one tile away from the player. The second item will be two tiles away, etc.

Creation API

init : Config -> Map

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.

withExitPoint : Coordinate -> Map -> Map

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

withItem : Coordinate -> Item -> Map -> Map

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

withNPC : Coordinate -> (Player -> Map -> Action) -> Map -> Map

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.

withSpawnPoint : Coordinate -> Map -> Map

Marks a coordinate on the map where the player will spawn.

withWalledArea : Coordinate -> Coordinate -> Map -> Map

Turns every tile between two coordinates into walls.

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

setNpcs : List ( Player, Player -> Map -> Action ) -> Map -> Map

Replace all villains with the provided list. Might be less code than using multiple withNPC calls.

withDescription : String -> Map -> Map

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

Internals

coordinateFrom : Direction -> Coordinate -> Coordinate

Ignore this function.

npcs : Map -> List ( Player, Player -> Map -> Action )

Framework function

removeItem : Coordinate -> Map -> Maybe ( Item, Map )

Removes an item from the map. This function can be ignored as it will be called by the framework.

spawnPoints : Map -> List Coordinate

A list of all points where players can spawn.

view : List Coordinate -> Map -> Element a

Framework function