Created
March 6, 2020 15:05
-
-
Save ciwolsey/059c13848820fb5a09a70e438969845e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open FSharp.Json | |
open System.IO | |
open System | |
open System.Collections.Generic | |
type Description = { | |
text: string | |
} | |
type Item = { | |
Description: Description | |
} | |
type Room = { | |
Id: Guid | |
Description: Description | |
Exits: Dictionary<string, Room> | |
Items: Item list | |
} | |
type RoomList = { | |
Rooms: Room list | |
} | |
[<EntryPoint>] | |
let main argv = | |
let rooms = { | |
Rooms = [ | |
{ | |
Id = Guid.NewGuid(); | |
Description = { text = "Room 1" }; | |
Exits = Dictionary<string, Room>(); | |
Items = []; | |
}; | |
{ | |
Id = Guid.NewGuid(); | |
Description = { text = "Room 2" }; | |
Exits = Dictionary<string, Room>(); | |
Items = []; | |
}] | |
} | |
let firstRoom = rooms.Rooms.[1]; | |
let secondRoom = rooms.Rooms.[2]; | |
firstRoom.Exits.Add ("North", secondRoom) | |
secondRoom.Exits.Add("South", firstRoom) | |
printfn "%s" firstRoom.Exits.["North"].Description.text | |
// Can't serialize right now due to recursion | |
//File.WriteAllText ("World.json", Json.serialize rooms) | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment