Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

House Rule: Happy Ending #179

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/src/elm/MassiveDecks/Card/Source.elm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Html.Attributes as HtmlA
import MassiveDecks.Card.Source.BuiltIn as BuiltIn
import MassiveDecks.Card.Source.Custom as Player
import MassiveDecks.Card.Source.Fake as Fake
import MassiveDecks.Card.Source.Generated as Generated
import MassiveDecks.Card.Source.JsonAgainstHumanity as JsonAgainstHumanity
import MassiveDecks.Card.Source.ManyDecks as ManyDecks
import MassiveDecks.Card.Source.Methods exposing (..)
Expand Down Expand Up @@ -250,6 +251,9 @@ methods source =
Custom ->
Player.methods

Generated ->
Generated.methods

Fake fakeName ->
Fake.methods fakeName

Expand Down
32 changes: 32 additions & 0 deletions client/src/elm/MassiveDecks/Card/Source/Generated.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module MassiveDecks.Card.Source.Generated exposing (..)

import MassiveDecks.Card.Source.Methods as Source
import MassiveDecks.Model exposing (Shared)
import MassiveDecks.Strings as Strings
import MassiveDecks.Strings.Languages as Lang


methods : Source.Methods msg
methods =
{ name = \() -> Strings.Generated
, logo = \() -> Nothing
, defaultDetails =
\shared ->
{ name = name shared
, url = Nothing
, translator = Nothing
, author = Nothing
, language = Nothing
}
, tooltip = \_ -> Nothing
, messages = \() -> []
}



{- Private -}


name : Shared -> String
name shared =
Strings.Generated |> Lang.string shared
4 changes: 3 additions & 1 deletion client/src/elm/MassiveDecks/Card/Source/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ type General
{-| Details on where game data came from.

- `Ex`: External sources are the main sources of cards users can add.
- `Player`: These are cards written by the given player.
- `Custom`: These are cards written by the given player.
- `Generated`: These are cards generated during a game for reasons such as house rules.
- `Fake`: These are cards used for presentation outside of a game environment.

-}
type Source
= Ex External
| Custom
| Generated
| Fake (Maybe String)


Expand Down
6 changes: 6 additions & 0 deletions client/src/elm/MassiveDecks/Game/Rules.elm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module MassiveDecks.Game.Rules exposing
( ComedyWriter
, HappyEnding
, HouseRules
, NeverHaveIEver
, PackingHeat
Expand Down Expand Up @@ -31,6 +32,7 @@ type alias HouseRules =
, reboot : Maybe Reboot
, comedyWriter : Maybe ComedyWriter
, neverHaveIEver : Maybe NeverHaveIEver
, happyEnding : Maybe HappyEnding
}


Expand Down Expand Up @@ -73,3 +75,7 @@ type alias ComedyWriter =

type alias NeverHaveIEver =
{}


type alias HappyEnding =
{}
9 changes: 9 additions & 0 deletions client/src/elm/MassiveDecks/Models/Decoders.elm
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ sourceByName name =
"Custom" ->
Json.succeed Source.Custom

"Generated" ->
Json.succeed Source.Generated

_ ->
Json.field "source" Source.generalDecoder |> Json.andThen externalSourceByGeneral |> Json.map Source.Ex

Expand Down Expand Up @@ -410,6 +413,7 @@ houseRules =
|> Json.optional "reboot" (reboot |> Json.map Just) Nothing
|> Json.optional "comedyWriter" (comedyWriter |> Json.map Just) Nothing
|> Json.optional "neverHaveIEver" (neverHaveIEver |> Json.map Just) Nothing
|> Json.optional "happyEnding" (happyEnding |> Json.map Just) Nothing


comedyWriter : Json.Decoder Rules.ComedyWriter
Expand All @@ -429,6 +433,11 @@ neverHaveIEver =
{} |> Json.succeed


happyEnding : Json.Decoder Rules.HappyEnding
happyEnding =
{} |> Json.succeed


reboot : Json.Decoder Rules.Reboot
reboot =
Json.map Rules.Reboot
Expand Down
6 changes: 6 additions & 0 deletions client/src/elm/MassiveDecks/Models/Encoders.elm
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ houseRules h =
, h.reboot |> Maybe.map (\r -> ( "reboot", reboot r ))
, h.comedyWriter |> Maybe.map (\c -> ( "comedyWriter", comedyWriter c ))
, h.neverHaveIEver |> Maybe.map (\n -> ( "neverHaveIEver", neverHaveIEver n ))
, h.happyEnding |> Maybe.map (\e -> ( "happyEnding", happyEnding e ))
]
)

Expand All @@ -141,6 +142,11 @@ neverHaveIEver _ =
Json.object []


happyEnding : Rules.HappyEnding -> Json.Value
happyEnding _ =
Json.object []


comedyWriter : Rules.ComedyWriter -> Json.Value
comedyWriter { number, exclusive } =
Json.object [ ( "number", number |> Json.int ), ( "exclusive", exclusive |> Json.bool ) ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fake =
, reboot = Nothing
, comedyWriter = Nothing
, neverHaveIEver = Nothing
, happyEnding = Nothing
}
, stages =
{ mode = Rules.Soft
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import MassiveDecks.Pages.Lobby.Configure.Configurable as Configurable
import MassiveDecks.Pages.Lobby.Configure.Configurable.Editor as Editor
import MassiveDecks.Pages.Lobby.Configure.Configurable.Model exposing (Configurable)
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.ComedyWriter as ComedyWriter
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.HappyEnding as HappyEnding
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.Model exposing (..)
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.NeverHaveIEver as NeverHaveIEver
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.PackingHeat as PackingHeat
Expand All @@ -24,5 +25,6 @@ all =
, Reboot.all |> Configurable.wrap RebootId (.reboot >> Just) (\v p -> { p | reboot = v })
, ComedyWriter.all |> Configurable.wrap ComedyWriterId (.comedyWriter >> Just) (\v p -> { p | comedyWriter = v })
, NeverHaveIEver.all |> Configurable.wrap NeverHaveIEverId (.neverHaveIEver >> Just) (\v p -> { p | neverHaveIEver = v })
, HappyEnding.all |> Configurable.wrap HappyEndingId (.happyEnding >> Just) (\v p -> { p | happyEnding = v })
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.HappyEnding exposing (all)

import MassiveDecks.Components.Form.Message as Message
import MassiveDecks.Game.Rules as Rules
import MassiveDecks.Pages.Lobby.Configure.Configurable as Configurable
import MassiveDecks.Pages.Lobby.Configure.Configurable.Editor as Editor
import MassiveDecks.Pages.Lobby.Configure.Configurable.Model exposing (Configurable)
import MassiveDecks.Pages.Lobby.Configure.Configurable.Validator as Validator
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.HappyEnding.Model exposing (..)
import MassiveDecks.Strings as Strings


all : Configurable Id (Maybe Rules.HappyEnding) model msg
all =
Configurable.group
{ id = All
, editor = Editor.group Nothing False False
, children =
[ enabled |> Configurable.wrapAsToggle {}
]
}


enabled : Configurable Id Bool model msg
enabled =
Configurable.value
{ id = Enabled
, editor = Editor.bool Strings.HouseRuleHappyEnding
, validator = Validator.none
, messages = always [ Message.info Strings.HouseRuleHappyEndingDescription ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.HappyEnding.Model exposing (Id(..))


type Id
= All
| Enabled
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.Model exposing (Id(..

import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.ComedyWriter.Model as ComedyWriter
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.NeverHaveIEver.Model as NeverHaveIEver
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.HappyEnding.Model as HappyEnding
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.PackingHeat.Model as PackingHeat
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.Rando.Model as Rando
import MassiveDecks.Pages.Lobby.Configure.Rules.HouseRules.Reboot.Model as Reboot
Expand All @@ -14,3 +15,4 @@ type Id
| ComedyWriterId ComedyWriter.Id
| RebootId Reboot.Id
| NeverHaveIEverId NeverHaveIEver.Id
| HappyEndingId HappyEnding.Id
1 change: 1 addition & 0 deletions client/src/elm/MassiveDecks/Pages/Start.elm
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ houseRules =
, ( Strings.HouseRuleRandoCardrissian, Strings.HouseRuleRandoCardrissianDescription )
, ( Strings.HouseRuleComedyWriter, Strings.HouseRuleComedyWriterDescription )
, ( Strings.HouseRuleNeverHaveIEver, Strings.HouseRuleNeverHaveIEverDescription )
, ( Strings.HouseRuleHappyEnding, Strings.HouseRuleHappyEnding )
]


Expand Down
3 changes: 3 additions & 0 deletions client/src/elm/MassiveDecks/Strings.elm
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ type MdString
| HouseRuleRandoCardrissianNumberDescription -- A description of the setting for the number of bots added to the game.
| HouseRuleNeverHaveIEver -- The name of the house rule where players can discard cards, sharing the discarded card.
| HouseRuleNeverHaveIEverDescription -- A description of the house rule where players can discard cards, sharing the discarded card.
| HouseRuleHappyEnding -- The name of the house rule where the game ends with the haiku card.
| HouseRuleHappyEndingDescription -- A description of the house rule where the game ends with the haiku card.
| MustBeMoreThanOrEqualValidationError { min : Int } -- An error when a configuration value must be more than or equal to the given value.
| MustBeLessThanOrEqualValidationError { max : Int } -- An error when a configuration value must be less than or equal to the given value.
| SetValue { value : Int } -- A description of the action of resolving a problem by setting the value to the given one.
Expand Down Expand Up @@ -254,6 +256,7 @@ type MdString
| JsonAgainstHumanityAbout -- A short description of the JSON Against Humanity source.
| BuiltIn -- A term referring to decks of cards that are provided by this instance of the game.
| APlayer -- A short description of a generic player in the game in the context of being the author of a card.
| Generated -- A short description of a card generated during the game.
| DeckAlreadyAdded -- A description of the problem of the deck already being added to the game configuration.
| ConfigureDecks -- A name for the section of the configuration screen for changing the decks for the game.
| ConfigureRules -- A name for the section of the configuration screen for changing the rules for the game.
Expand Down
12 changes: 12 additions & 0 deletions client/src/elm/MassiveDecks/Strings/Languages/De.elm
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ translate _ mdString =
, Text "eingestehen: die Karte wird öffentlich geteilt."
]

-- TODO: Translate
HouseRuleHappyEnding ->
[ Missing ]

-- TODO: Translate
HouseRuleHappyEndingDescription ->
[ Missing ]

MustBeMoreThanOrEqualValidationError { min } ->
[ Text "Der Wert muss mindestens ", Text (String.fromInt min), Text " betragen." ]

Expand Down Expand Up @@ -803,6 +811,10 @@ translate _ mdString =
APlayer ->
[ Text "Ein Spieler" ]

-- TODO: Translate
Generated ->
[ Missing ]

DeckAlreadyAdded ->
[ Text "Dieser Kartensatz ist bereits im Spiel." ]

Expand Down
12 changes: 12 additions & 0 deletions client/src/elm/MassiveDecks/Strings/Languages/DeXInformal.elm
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ translate _ mdString =
, Text "eingestehen: die Karte wird öffentlich geteilt."
]

-- TODO: Translate
HouseRuleHappyEnding ->
[ Missing ]

-- TODO: Translate
HouseRuleHappyEndingDescription ->
[ Missing ]

MustBeMoreThanOrEqualValidationError { min } ->
[ Text "Der Wert muss mindestens ", Text (String.fromInt min), Text " betragen." ]

Expand Down Expand Up @@ -802,6 +810,10 @@ translate _ mdString =
APlayer ->
[ Text "Ein Spieler" ]

-- TODO: Translate
Generated ->
[ Missing ]

DeckAlreadyAdded ->
[ Text "Dieser Kartensatz ist bereits im Spiel." ]

Expand Down
9 changes: 9 additions & 0 deletions client/src/elm/MassiveDecks/Strings/Languages/En/Internal.elm
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@ translate _ mdString =
, Text "ignorance: the card is shared publicly."
]

HouseRuleHappyEnding ->
[ Text "Happy Ending" ]

HouseRuleHappyEndingDescription ->
[ Text "When the game ends, the final round is a 'Make a Haiku' black card." ]

MustBeMoreThanOrEqualValidationError { min } ->
[ Text "The value must be at least ", Text (String.fromInt min), Text "." ]

Expand Down Expand Up @@ -758,6 +764,9 @@ translate _ mdString =
APlayer ->
[ Text "A Player" ]

Generated ->
[ Text "Generated" ]

DeckAlreadyAdded ->
[ Text "This deck is already in the game." ]

Expand Down
12 changes: 12 additions & 0 deletions client/src/elm/MassiveDecks/Strings/Languages/Id.elm
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ translate _ mdString =
, Text "ketidaktahuan: kartu dibagikan secara publik."
]

-- TODO: Translate
HouseRuleHappyEnding ->
[ Missing ]

-- TODO: Translate
HouseRuleHappyEndingDescription ->
[ Missing ]

MustBeMoreThanOrEqualValidationError { min } ->
[ Text "Nilai minimal harus ", Text (String.fromInt min), Text "." ]

Expand Down Expand Up @@ -793,6 +801,10 @@ translate _ mdString =
APlayer ->
[ Text "Seorang Player" ]

-- TODO: Translate
Generated ->
[ Missing ]

DeckAlreadyAdded ->
[ Text "Dek ini sudah ada dalam game." ]

Expand Down
12 changes: 12 additions & 0 deletions client/src/elm/MassiveDecks/Strings/Languages/It.elm
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,14 @@ translate _ mdString =
HouseRuleNeverHaveIEverDescription ->
[ Missing ]

-- TODO: Translate
HouseRuleHappyEnding ->
[ Missing ]

-- TODO: Translate
HouseRuleHappyEndingDescription ->
[ Missing ]

MustBeMoreThanOrEqualValidationError { min } ->
[ Text "Il valore deve essere almeno ", Text (String.fromInt min), Text "." ]

Expand Down Expand Up @@ -817,6 +825,10 @@ translate _ mdString =
APlayer ->
[ Text "Un giocatore" ]

-- TODO: Translate
Generated ->
[ Missing ]

DeckAlreadyAdded ->
[ Text "Questo mazzo è già nel gioco." ]

Expand Down
12 changes: 12 additions & 0 deletions client/src/elm/MassiveDecks/Strings/Languages/Pl.elm
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ translate maybeDeclCase mdString =
, Text "ignorancję: wyrzucona karta będzie publicznie widoczna."
]

-- TODO: Translate
HouseRuleHappyEnding ->
[ Missing ]

-- TODO: Translate
HouseRuleHappyEndingDescription ->
[ Missing ]

MustBeMoreThanOrEqualValidationError { min } ->
[ Text "Wartość musi być większa lub równa ", Text (String.fromInt min), Text "." ]

Expand Down Expand Up @@ -905,6 +913,10 @@ translate maybeDeclCase mdString =
APlayer ->
[ Text "Gracz" ]

-- TODO: Translate
Generated ->
[ Missing ]

DeckAlreadyAdded ->
[ Text "Ta talia jest już w grze." ]

Expand Down
Loading