antisplice-0.17.0.0: An engine for text-based dungeons.

Safe HaskellNone

Game.Antisplice.Skills

Contents

Description

Provides utility functions for composing skills

Synopsis

Utility types

newtype Condition Source

A wrapper type for skill execution preconditions.

Constructors

Condition 

data Consumer Source

A single consumer. Build it using bareAction, bareCondition and monoid concatenation.

Constructors

Consumer !Condition !Invokable 

data Skill Source

A skill. Build it using the !+ compositor and the skill function.

data Recipe Source

A recipe. Build it using the !+ compositor and the recipe function.

class ToConsumer c whereSource

Typeclass for everything that may act as a consumer.

Methods

toConsumer :: c -> ConsumerSource

Compositors

class Extensible e whereSource

Typeclass for everything that may be extended by consumers using !+

Methods

(!+) :: ToConsumer c => e -> c -> eSource

Add a consumer to the skill.

(>!+) :: (ToConsumer c, Monad m, Extensible e) => m e -> c -> m eSource

Add a consumer to the monadic extensible

(!+>) :: (ToConsumer c, Monad m, Extensible e) => e -> m c -> m eSource

Add a monadic consumer to the extensible

(>!+>) :: (ToConsumer c, Monad m, Extensible e) => m e -> m c -> m eSource

Add a monadic consumer to the monadic extensible

Builders

skill :: String -> SkillSource

Build a bogus skill that does nothing but has a name. Use this with !+ to build powerful skills.

recipe :: RecipeMethod -> String -> RecipeSource

Build a bogus recipe that does nothing has a name and a usage method. Use this with !+ to build powerful recipes.

validConsumer :: (Append m (Cons EnsureLineEnd Nil) s, Append r Nil r, CallMask s r, Tuplify r t) => m -> (t -> Handler) -> ConsumerSource

Build a consumer using new-style input validation

validCondition :: (Append m (Cons EnsureLineEnd Nil) s, Append r Nil r, CallMask s r, Tuplify r t) => m -> (t -> Predicate) -> ConditionSource

Build a condition using new-style input validation

(#-) :: (Append m (Cons EnsureLineEnd Nil) s, Append r Nil r, CallMask s r) => m -> MaskedConsumer r -> ConsumerSource

Map a masked consumer to a call mask

(#->) :: (Append m (Cons EnsureLineEnd Nil) s, Append r Nil r, CallMask s r, Tuplify r t) => m -> (t -> Handler) -> ConsumerSource

Infix version of validConsumer

(#->>) :: (Append m (Cons EnsureLineEnd Nil) s, CallMask s Nil) => m -> Handler -> ConsumerSource

Infix version of validConsumer, swallowing the empty handler parameter

Sample consumers

focusDirectC :: ConsumerSource

Focus direct object

optionallyFocusDirectC :: ConsumerSource

Optionally ocus direct object (obligatory if none is focused yet)

callRecipe :: RecipeMethod -> ConsumerSource

Dispatch the remaining part of the line as a recipe call

Final wrappers

runConsumer :: ToConsumer c => c -> InvokableSource

Run the given consumer

wrapSkills :: [Skill] -> String -> Maybe InvokableSource

Wrap the skills into a form that is accepted by stereotypes.

wrapRecipes :: [Recipe] -> String -> Maybe (RecipeMethod -> Invokable)Source

Wrap the recipes into a form that is accepted by stereotypes.