๐Ÿ“ฆ sleepyfran / duets

๐Ÿ“„ World.Cheats.Commands.fs ยท 44 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
44namespace Duets.Cli.Components.Commands.Cheats

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.Navigation

[<RequireQualifiedAccess>]
module WorldCommands =
    /// Command which teleports the character to a given city.
    let teleport =
        { Name = "teleport"
          Description = "Teleports you to another city instantly"
          Handler =
            (fun _ ->
                let destination =
                    Queries.World.allCities
                    |> showOptionalChoicePrompt
                        "Where to? :^)"
                        Generic.cancel
                        (fun city -> Generic.cityName city.Id)

                match destination with
                | Some city ->
                    let destinationAirport =
                        Queries.World.placeIdsByTypeInCity
                            city.Id
                            PlaceTypeIndex.Airport
                        |> List.head (* All cities must have an airport. *)

                    Navigation.travelTo
                        city.Id
                        destinationAirport
                        (State.get ())
                    |> Effect.apply

                    Scene.WorldAfterMovement
                | None -> Scene.Cheats) }