Compare commits

...

2 Commits

Author SHA1 Message Date
Bram van den Heuvel df918b8498 Add Bugbear names 2023-09-03 09:31:01 +02:00
Bram van den Heuvel 54bece3aea Generalize name generation 2023-09-03 09:30:12 +02:00
4 changed files with 267 additions and 57 deletions

View File

@ -9,20 +9,17 @@ For more name generators, make sure to check out <https://www.fantasynamegenerat
-}
import Names.Tools as Tools
import Random exposing (Generator)
import String.Extra
female : Generator String
female =
Random.uniform
(Random.map3 (\a b c -> a ++ b ++ c) nm1 nm2 nm3
|> Random.map String.Extra.toTitleCase
)
[ Random.map5 (\a b c d e -> a ++ b ++ c ++ d ++ e) nm1 nm2 nm3 nm4 nm5
|> Random.map String.Extra.toTitleCase
]
|> Random.andThen identity
Tools.chooseFrom2
(Tools.map3 nm1 nm2 nm3)
(Tools.map5 nm1 nm2 nm3 nm4 nm5)
|> Random.map String.Extra.toTitleCase
male : Generator String

View File

@ -9,71 +9,30 @@ For more name generators, make sure to check out <https://www.fantasynamegenerat
-}
import Names.Tools as Tools
import Random exposing (Generator)
import String.Extra
female : Generator String
female =
Random.uniform
(Random.map5
(\a b c d e -> a ++ " " ++ b ++ " " ++ c ++ " " ++ d ++ " " ++ e)
nm7
nm8
nm9
nm10
nm13
)
[ Random.map5
(\( a, b ) ( c, d ) e f g ->
a ++ " " ++ b ++ " " ++ c ++ " " ++ d ++ " " ++ e ++ " " ++ f ++ " " ++ g
)
(Random.map2 Tuple.pair nm7 nm8)
(Random.map2 Tuple.pair nm9 nm10)
nm11
nm12
nm13
]
|> Random.andThen identity
Tools.chooseFrom2
(Tools.map5 nm7 nm8 nm9 nm10 nm13)
(Tools.map7 nm7 nm8 nm9 nm10 nm11 nm12 nm13)
|> Random.map String.Extra.toTitleCase
male : Generator String
male =
Random.uniform
(Random.map5
(\a b c d e -> a ++ " " ++ b ++ " " ++ c ++ " " ++ d ++ " " ++ e)
nm1
nm2
nm3
nm4
nm6
)
[ Random.map5
(\( a, b ) ( c, d ) e f g ->
a ++ " " ++ b ++ " " ++ c ++ " " ++ d ++ " " ++ e ++ " " ++ f ++ " " ++ g
)
(Random.map2 Tuple.pair nm1 nm2)
(Random.map2 Tuple.pair nm3 nm4)
nm5
nm4
nm6
]
|> Random.andThen identity
Tools.chooseFrom2
(Tools.map5 nm1 nm2 nm3 nm4 nm6)
(Tools.map7 nm1 nm2 nm3 nm4 nm5 nm4 nm6)
|> Random.map String.Extra.toTitleCase
lastName : Generator String
lastName =
Random.map5
(\( a, b ) ( c, d ) e f g ->
a ++ " " ++ b ++ " " ++ c ++ " " ++ d ++ " " ++ e ++ " " ++ f ++ " " ++ g
)
(Random.map2 Tuple.pair nm1 nm2)
(Random.map2 Tuple.pair nm3 nm4)
nm11
nm12
nm13
Tools.map7 nm1 nm2 nm3 nm4 nm11 nm12 nm13
|> Random.map String.Extra.toTitleCase

91
src/Names/Bugbear.elm Normal file
View File

@ -0,0 +1,91 @@
module Names.Bugbear exposing (..)
{-| This module exposes a generator for Bugbear names.
For more name generators, make sure to check out <https://www.fantasynamegenerators.com/>
# Copyright (C) 2012 - 2020 FantasyNameGenerators.com.
-}
import Names.Tools as Tools
import Random exposing (Generator)
import String.Extra
female : Generator String
female =
Tools.chooseFrom2
(Tools.map5 nm1 nm2 nm3 nm4 nm5)
(Tools.map3 nm1 nm2 nm5)
|> Random.map String.Extra.toTitleCase
male : Generator String
male =
female
lastName : Generator String
lastName =
female
nm1 : Generator String
nm1 =
Random.uniform "b"
[ "br"
, "chr"
, "d"
, "g"
, "gh"
, "hr"
, "kh"
, "n"
, "r"
, "st"
, "t"
, "th"
, "v"
, "z"
, "zh"
]
nm2 : Generator String
nm2 =
Random.uniform "a" [ "e", "i", "o", "u" ]
nm3 : Generator String
nm3 =
Random.uniform "d"
[ "dd"
, "dr"
, "g"
, "gh"
, "gg"
, "gr"
, "rr"
, "rd"
, "rg"
, "rn"
, "t"
, "tt"
, "tr"
, "v"
, "vr"
, "z"
, "zz"
]
nm4 : Generator String
nm4 =
Random.uniform "a" [ "i", "o", "u" ]
nm5 : Generator String
nm5 =
Random.uniform "k" [ "lk", "mkk", "n", "nn", "nk", "r", "rk", "rr", "th" ]

163
src/Names/Tools.elm Normal file
View File

@ -0,0 +1,163 @@
module Names.Tools exposing (..)
{-| The Tools module helps with the generation of names.
-}
import Random exposing (Generator)
chooseFrom2 : Generator a -> Generator a -> Generator a
chooseFrom2 a b =
Random.uniform a [ b ]
|> Random.andThen identity
chooseFrom3 : Generator a -> Generator a -> Generator a -> Generator a
chooseFrom3 a b c =
Random.uniform a [ b, c ]
|> Random.andThen identity
chooseFrom4 :
Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
chooseFrom4 a b c d =
Random.uniform a [ b, c, d ]
|> Random.andThen identity
chooseFrom5 :
Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
chooseFrom5 a b c d e =
Random.uniform a [ b, c, d, e ]
|> Random.andThen identity
chooseFrom6 :
Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
chooseFrom6 a b c d e f =
Random.uniform a [ b, c, d, e, f ]
|> Random.andThen identity
chooseFrom7 :
Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
chooseFrom7 a b c d e f g =
Random.uniform a [ b, c, d, e, f, g ]
|> Random.andThen identity
chooseFrom8 :
Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
-> Generator a
chooseFrom8 a b c d e f g h =
Random.uniform a [ b, c, d, e, f, g, h ]
|> Random.andThen identity
map2 : Generator String -> Generator String -> Generator String
map2 =
Random.map2 (++)
map3 :
Generator String
-> Generator String
-> Generator String
-> Generator String
map3 =
Random.map3 (\a b c -> a ++ b ++ c)
map4 :
Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
map4 =
Random.map4 (\a b c d -> a ++ b ++ c ++ d)
map5 :
Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
map5 =
Random.map5 (\a b c d e -> a ++ b ++ c ++ d ++ e)
map6 :
Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
map6 nm1 nm2 =
Random.map5 (\( a, b ) c d e f -> a ++ b ++ c ++ d ++ e ++ f)
(Random.map2 Tuple.pair nm1 nm2)
map7 :
Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
map7 nm1 nm2 nm3 nm4 =
Random.map5 (\( a, b ) ( c, d ) e f g -> a ++ b ++ c ++ d ++ e ++ f ++ g)
(Random.map2 Tuple.pair nm1 nm2)
(Random.map2 Tuple.pair nm3 nm4)
map8 :
Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
-> Generator String
map8 nm1 nm2 nm3 nm4 nm5 nm6 =
Random.map5 (\( a, b ) ( c, d ) ( e, f ) g h -> a ++ b ++ c ++ d ++ e ++ f ++ g ++ h)
(Random.map2 Tuple.pair nm1 nm2)
(Random.map2 Tuple.pair nm3 nm4)
(Random.map2 Tuple.pair nm5 nm6)