๐Ÿ“ฆ sleepyfran / duets

๐Ÿ“„ Life.Cheats.Commands.fs ยท 115 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115namespace Duets.Cli.Components.Commands.Cheats

open System
open Duets.Agents
open Duets.Cli
open Duets.Cli.Components
open Duets.Cli.Components.Commands
open Duets.Cli.SceneIndex
open Duets.Cli.Text
open Duets.Entities
open Duets.Simulation
open Duets.Simulation.Time.AdvanceTime

[<RequireQualifiedAccess>]
module LifeCommands =
    let private makeHappy () =
        let character = Queries.Characters.playableCharacter (State.get ())

        [ CharacterAttribute.Energy
          CharacterAttribute.Health
          CharacterAttribute.Hunger
          CharacterAttribute.Mood ]
        |> List.iter (fun attr ->
            Character.Attribute.add character attr 100 |> Effect.applyMultiple)

    /// Command which gives 100 to all needs of the character.
    let happy =
        { Name = "happy"
          Description = "Sets energy, health, hunger and mood to 100%"
          Handler =
            (fun _ ->
                makeHappy ()

                Scene.Cheats) }

    /// Command which sets the player in free roam.
    let roaming =
        { Name = "roaming"
          Description =
            "Allows you to change the current situation to free roam"
          Handler =
            (fun _ ->
                Situations.freeRoam |> Effect.apply
                Scene.Cheats) }

    /// Command which removes all moodlets of the character.
    let notMoody =
        { Name = "not moody"
          Description = "Removes all your current moodlets"
          Handler =
            (fun _ ->
                let character =
                    Queries.Characters.playableCharacter (State.get ())

                let moodlets = Queries.Characters.moodlets character

                CharacterMoodletsChanged(
                    character.Id,
                    Diff(moodlets, Set.empty)
                )
                |> Effect.apply

                Scene.Cheats) }

    /// Command which lets the player modify their fame freely.
    let spotlight =
        { Name = "spotlight"
          Description =
            "Lets you modify your fame without actually having to put up any work for it!"
          Handler =
            (fun _ ->
                let selectedFame =
                    showRangedNumberPrompt
                        0
                        100
                        "What fame level do you want to have?"

                let state = State.get ()

                Character.Attribute.setToPlayable
                    CharacterAttribute.Fame
                    selectedFame
                    state
                |> Effect.applyMultiple

                Scene.Cheats) }

    /// Command which lets the user advance in time.
    let timeTravel =
        { Name = "time travel"
          Description =
            "Advances the time by the number of day moments specified in the argument, keeping your character happy"
          Handler =
            (fun times ->
                "Travelling in time..." |> Styles.information |> showMessage

                let joinedArgs = String.Join("", times)

                match Int32.TryParse joinedArgs with
                | true, n ->
                    [ 1..n ]
                    |> List.iter (fun _ ->
                        makeHappy ()

                        advanceDayMoment' (State.get ()) 1<dayMoments>
                        |> Effect.applyMultiple)

                    let currentTime = Queries.Calendar.today (State.get ())

                    $"You have travelled in time and it's now {Styles.time currentTime}"
                    |> showMessage

                    Scene.Cheats
                | false, _ -> Scene.Cheats) }