Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace DM //Digital Manbaby
- open System
- [<CLIMutable>]
- type GlobalState = {
- manbabyName : string;
- happiness : int;
- mentalHealth : int;
- physicalHealth : int;
- statusList : string array;
- GBP : int;
- playerName : string;
- inventory : string array;
- isDead : bool;
- }
- module FileIO =
- open System.Xml.Serialization
- open System.IO
- let filename = "save.dm"
- let chkfile () =
- if not (File.Exists(filename)) then
- use file = File.Create(filename)
- file.Close()
- true
- else false
- type Write = GlobalState -> unit
- let write : Write = fun gs ->
- use file = new FileStream(filename, FileMode.Create, FileAccess.Write)
- let ser = new XmlSerializer(typeof<GlobalState>)
- ser.Serialize(file, gs)
- file.Close()
- type Read = unit -> GlobalState
- let read : Read = fun () ->
- use file = new FileStream(filename, FileMode.Open, FileAccess.Read)
- let ser = new XmlSerializer(typeof<GlobalState>)
- let result = ser.Deserialize(file) :?> GlobalState
- file.Close()
- result
- module Logic =
- let uppercase (n : string) =
- match n with
- | n when n.Length > 0 ->
- string(n.[0]).ToUpper() + n.Substring(1)
- | _ -> n
- let chkItem gs item =
- let result = Array.tryFind (fun n -> n = item) gs.inventory
- match result with
- | Some x -> true
- | None -> false
- let remItem gs item =
- let result =
- match Array.tryFindIndex ((=) item) gs.inventory with
- | Some 0 -> gs.inventory.[1..]
- | Some i -> Array.append gs.inventory.[..i-1] gs.inventory.[i+1..]
- | None -> gs.inventory
- { gs with inventory = result }
- let remStat gs stat =
- let result =
- match Array.tryFindIndex ((=) stat) gs.statusList with
- | Some 0 -> gs.statusList.[1..]
- | Some i -> Array.append gs.statusList.[..i-1] gs.statusList.[i+1..]
- | None -> gs.statusList
- { gs with statusList = result }
- let hasStat gs st =
- let m x = if x = st then true else false
- let c = Array.tryFind m gs.statusList
- match c with
- | Some x -> true
- | None -> false
- let getInv gs =
- let result = Array.rev (Array.sort gs.inventory)
- let l = result.Length - 1
- printfn "%s" "Inventory:"
- if l < 0 then printfn "You have no items!"
- for i in 0 .. l do
- printfn " %i: %s" (i + 1) (uppercase result.[i])
- module Stats =
- let SeederState : GlobalState = {
- manbabyName = "DM";
- happiness = 100;
- mentalHealth = 100;
- physicalHealth = 100;
- statusList = [| |];
- GBP = 50;
- playerName = "Player";
- inventory = [| |];
- isDead = false;
- }
- let happiness gs n =
- let t = gs.happiness + n
- match t with
- | t when t > 100 -> { gs with happiness = 100 }
- | t when t < 0 -> { gs with happiness = 0 }
- | _ -> { gs with happiness = t }
- let mentalHealth gs n =
- let t = gs.mentalHealth + n
- match t with
- | t when t > 100 -> { gs with mentalHealth = 100 }
- | t when t < 0 -> { gs with mentalHealth = 0 }
- | _ -> { gs with mentalHealth = t }
- let physicalHealth gs n =
- let t = gs.physicalHealth + n
- match t with
- | t when t > 100 -> { gs with physicalHealth = 100 }
- | t when t < 0 -> { gs with physicalHealth = 0 }
- | _ -> { gs with physicalHealth = t }
- let private statuses = [
- "Hungry";
- "Sick";
- "Brain Damaged";
- "Angry";
- ]
- let randomStatus gs =
- let randNum = new Random()
- randNum.Next() |> ignore
- let seed = 2000
- let r = randNum.Next(seed)
- if r > seed/3 then
- let b = List.nth statuses (randNum.Next(List.length statuses))
- let d = Logic.hasStat gs b
- if d then gs else
- let t = Array.append gs.statusList [| b |]
- { gs with statusList = t }
- else gs
- let private updateOneStat gs num =
- if gs.statusList.Length = 0 then
- gs
- else
- match gs.statusList.[num] with
- | "Hungry" | "Sick" ->
- let gsb = physicalHealth gs -5
- if gsb.physicalHealth = 0 then
- printfn "%s is dead. You won! You are finally free." gsb.manbabyName
- { gsb with isDead = true }
- else
- printfn "%s isn't feeling well!" gsb.manbabyName
- gsb
- | "Brain Damaged" ->
- let gsb = mentalHealth gs -5
- if gsb.mentalHealth = 0 then
- printfn "%s is braindead. You are now stuck with a vegitable." gsb.manbabyName
- { gsb with isDead = true }
- else
- printfn "%s's brain is manfunctioning!" gsb.manbabyName
- gsb
- | "Angry" ->
- printfn "%s is angry. This doesn't really matter." gs.manbabyName
- gs
- | _ -> gs
- let rec private updateStatsHelper gs num =
- if num >= gs.statusList.Length then
- gs
- else
- let ggs = updateOneStat gs num
- updateStatsHelper ggs (num + 1)
- let updateStats gs =
- let ggs = randomStatus gs
- updateStatsHelper ggs 0
- module Manbabies =
- let private quotes = [
- "MUMMY I WANT BOOBIES";
- "BABOOO";
- "FLUTTERSHY IS BEST PONY";
- "SO EPIC!!!! UPBOAT!!!";
- "DON'T MAKE ME GET MY KATANA";
- "* (screams incoherently)";
- "I HAVE TO TELL PEOPLE ON THE INERNET THEY'RE WRONG";
- "I'M GETTING TRIGGERED";
- "I do not talk to any MEN other than my father and Santa.";
- "CWC gives us REAL autistics like me a BAD NAME"; //10
- "MOMMY VOTE FOR RON PAUL";
- "* (drools and shits himself)";
- "99999999- *INTERNAL ERROR; REBOOTING*";
- "OMG TWAINS! MUMMY I WANT A CHOO-CHOO TWAIN";
- "MUMMY IT'S ALMOST MY 30TH BIRTHDAY!";
- "*sigh* so lonesome";
- "All I want for Christmas is a pretty girlfriend.";
- "MUMMY I NEED $100 TO JOIN THIS MINECRAFT SERVER";
- "MOM I NEED CREDIT CARD NOOOOOW";
- "TENDIES!?!?!?!?"; //20
- ]
- let play gs =
- if gs.happiness = 0 then
- printfn "%s isn't happy enough to play!" gs.manbabyName
- gs
- else
- let randNum = new Random()
- randNum.Next() |> ignore
- let r = randNum.Next(20)
- printfn "You jangled some keys in front of %s" gs.manbabyName
- printfn "He was amused by this! You got %i GBP!" r
- { gs with GBP = gs.GBP + r }
- let printManbaby mb st =
- if st = "" then
- let randNum = new Random()
- randNum.Next() |> ignore
- printfn "\n %s" (List.nth quotes (randNum.Next(List.length quotes)))
- else printfn "\n %s" st
- for i in mb do
- printfn "%s" i
- let okaySmallArt = [|
- " ";
- " ";
- " __^ ";
- " /, ,\\; ";
- " / . \\ ";
- " \\_____/ ";
- " ";
- |]
- let okaySmall st =
- printManbaby okaySmallArt st
- let deadSmallArt = [|
- " ";
- " . * ";
- " __^ . ";
- " . /x x\\; ";
- " / _ \\ * ";
- " \\_____/ ";
- " ";
- |]
- let deadSmall st =
- printManbaby deadSmallArt st
- module Items =
- let tendies gs =
- let name = "tendies"
- if (Logic.chkItem gs name) then
- printfn "%s enjoyed the %s" gs.manbabyName (Logic.uppercase name)
- let result = Stats.happiness gs 20
- let bgs = Logic.remItem result name
- Logic.remStat bgs "Hungry"
- else gs
- let fedora gs =
- let name = "fedora"
- if (Logic.chkItem gs name) then
- printfn "%s loves his %s!" gs.manbabyName (Logic.uppercase name)
- let ggs = Stats.happiness gs 5
- Logic.remStat ggs "Angry"
- else gs
- let girlfriend gs =
- let name = "girlfriend"
- if (Logic.chkItem gs name) then
- printfn "Congratulations! %s finally has a %s" gs.manbabyName (Logic.uppercase name)
- printfn "But she murdered him and took all his GBP."
- { gs with isDead = true; GBP = 0; }
- else gs
- let medicine gs =
- let name = "medicine"
- if (Logic.chkItem gs name) then
- printfn "%s hates %s, but it's for the best." gs.manbabyName (Logic.uppercase name)
- let bgs = Stats.physicalHealth gs 10
- let ags = Logic.remStat bgs "Sick"
- let ggs = Logic.remStat ags "Brain Damaged"
- if Logic.hasStat ggs "Angry" then ggs else
- { ggs with statusList = Array.append ggs.statusList [| "Angry" |] }
- else gs
- module Store =
- let prices = [
- ("tendies" , 5 );
- ("medicine" , 0 );
- ("fedora" , 20);
- ("girlfriend", 999999999);
- ]
- let private ifItemExists item =
- let m x = if (fst x) = item then true else false
- match List.tryFindIndex m prices with
- | Some d -> (true , d)
- | None -> (false, 0)
- let giveItem gs item =
- let t, i = ifItemExists item
- if t then
- let r = gs.GBP - (snd prices.[i])
- if r < 0 then
- printfn "You don't have enough GBP for that."
- gs
- else
- { gs with
- inventory = ( Array.append gs.inventory [| (fst prices.[i]) |] )
- GBP = r
- }
- else
- printfn "Item \"%s\" not found in Store." (fst prices.[i])
- gs
- let private slogans = [
- "The only store where the diapers come pre-defecated.";
- "Buy two Officer Nasty dolls, get the third half-price!";
- "You stick your dick in it, you buy it.";
- "Please be quiet, autistic manchildren scare easily.";
- "* The faint smell of fecal matter fills the air.";
- "You see a couple, and can't tell which is the motherly\nold hag and which is the cross-dressing manchild.";
- "Don't ask where the bathrooms are. You don't want to use them.";
- "Just because we sell a brand you don't like doesn't mean\nwe're going to burn every item we have in stock.";
- "Psst. Don't get them a real laptop, just get a Spiderman\nLearning Laptop and they'll never tell the difference.";
- "Our security officers have to dress like clowns\nor the customers get triggered.";
- "No, we don't sell Team Fortress 2 furry mods.";
- ]
- let shop gs =
- for i in prices do
- if (fst i).Length > 7 then
- printfn "%s\t%i" (Logic.uppercase (fst i)) (snd i)
- else
- printfn "%s\t\t%i" (Logic.uppercase (fst i)) (snd i)
- printf "\n>"
- let input = Console.ReadLine().ToLower()
- if input = "leave" || input = "l" then
- gs
- elif input = "inventory" || input = "i" then
- Logic.getInv gs
- gs
- else
- let result, _ = ifItemExists input
- if result then
- giveItem gs input
- else gs
- let rec keepShopping gs =
- printfn "Continue shopping? (Y/N):"
- printf ">"
- let input = Console.ReadLine().ToLower()
- if input = "y" then
- let ggs = shop gs
- keepShopping ggs
- elif input = "n" then
- printfn "Have an ABSOLUTELY beautiful day.\n\n"
- gs
- else
- printfn "I didn't quite get that."
- keepShopping gs
- let storeInterface gs =
- let randNum = new Random()
- printfn "\nWelcome to We Luv Manchildren!"
- printfn "%s\n" (List.nth slogans (randNum.Next(List.length slogans)))
- printfn "What would you like to buy today?"
- printfn "(Type '[L]eave' to exit the store.)"
- printfn "(Or '[I]nventory' to see what you have.)\n"
- let ggs = shop gs
- keepShopping ggs
- module Input =
- let useItemPrompt gs =
- printfn "\nUse what item?"
- printf ">"
- let input = Console.ReadLine().ToLower()
- if (Logic.chkItem gs input) || input = "rich" then
- printfn "Used the %s!" (input |> Logic.uppercase)
- match input with
- | "tendies" -> Items.tendies gs
- | "fedora" -> Items.fedora gs
- | "medicine" -> Items.medicine gs
- | "girlfriend" -> Items.girlfriend gs
- | "rich" -> { gs with GBP = 999999999 } //cheat code
- | _ -> printfn "I don't know that item."; gs
- else
- printfn "You don't have that!"
- gs
- let rec mainInput gs =
- printfn "\n[S]hop - [C]heck - [I]nventory - [U]se - [P]lay - [Q]uit:"
- printf ">"
- let input = Console.ReadLine().ToLower()
- match input with
- | "shop" | "s" ->
- Store.storeInterface gs
- | "quit" | "q" ->
- FileIO.write gs
- printfn "\"%s\" was automatically saved." gs.manbabyName
- printfn "Press any key to continue."
- printfn "Goodbye!\n"
- Console.ReadKey() |> ignore
- exit 0; gs
- | "check" | "c" ->
- Manbabies.okaySmall ""
- printfn "Name: %s" gs.manbabyName
- printfn "Happiness: %i, Mental: %i, Physical: %i" gs.happiness gs.mentalHealth gs.physicalHealth
- printf "Status: "
- if gs.statusList.Length = 0 then
- printf "None"
- else
- for i in 0 .. gs.statusList.Length - 1 do
- if i = gs.statusList.Length - 1 then
- printf "%s" gs.statusList.[i]
- else printf "%s, " gs.statusList.[i]
- printf "\n"
- gs
- | "inventory" | "i" ->
- Logic.getInv gs
- printfn "\nGBP: %i" gs.GBP
- gs
- | "use" | "u" ->
- useItemPrompt gs
- | "play" | "p" ->
- Manbabies.play gs
- | "" | " " | " " | " " ->
- gs
- | _ ->
- printfn "I didn't quite get that."
- gs
- let rec update gs =
- let ggs = Stats.updateStats gs
- if ggs.isDead then
- printfn " G A M E O V E R"
- FileIO.write ggs
- Console.ReadKey() |> ignore
- ggs
- else
- update (mainInput ggs)
- let rec private getName question =
- printfn "What is %s?" question
- printf ">"
- let name = Console.ReadLine().ToLower() |> Logic.uppercase
- printfn "Is \"%s\" correct? (Y/N):" name
- let ans = Console.ReadLine().ToLower()
- match ans with
- | "yes" | "y" -> name
- | "no" | "n" | _ -> getName question
- let beginFirstGame gs =
- printfn "Thank you for adopting your first Manchild!"
- let getplayerName = getName "YOUR NAME"
- let getmanbabyName = getName "YOUR MANCHILD'S NAME"
- printfn "Great! Lets get started...\n"
- { gs with playerName = getplayerName; manbabyName = getmanbabyName }
- module Main =
- [<EntryPoint>]
- let main args =
- let c = FileIO.chkfile ()
- if c then
- FileIO.write Stats.SeederState
- let gs1 = Input.beginFirstGame Stats.SeederState
- FileIO.write gs1
- Manbabies.okaySmall ""
- Input.update gs1 |> ignore
- else
- let gs1 = FileIO.read ()
- if gs1.isDead then
- Manbabies.deadSmall "Mummy I only wanted to live."
- printfn "%s is dead. You murdered him, remember?" gs1.manbabyName
- printfn "Delete save.dm and try again, you heartless criminal.\n"
- printfn "Press any key to continue being a murderer..."
- Console.ReadKey() |> ignore
- printf "\n"
- else
- Manbabies.okaySmall ""
- printfn "Welcome back! %s missed you sortof." gs1.manbabyName
- Input.update gs1 |> ignore
- 0
- //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement