{-# LANGUAGE FlexibleContexts, ConstraintKinds #-}

{-
  This module is part of Ironforge.
  Copyfree (f) 2014 Marvin Cohrs

  All wrongs revoked. Sharing is an act of love, not crime.
  Please share Ironforge with everyone you like.
  
  Redistribution and use in source and binary forms, with or without modification,
  are permitted provided that the following conditions are met:

      * Redistributions of source code must retain the above copyright notice,
        this list of conditions and the following disclaimer.
      * Redistributions in binary form must reproduce the above copyright notice,
        this list of conditions and the following disclaimer in the documentation
        and/or other materials provided with the distribution.
      * Neither the name of Marvin Cohrs nor the names of other
        contributors may be used to endorse or promote products derived
        from this software without specific prior written permission.
  
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-}

module Game.Antisplice.Dungeon.Ironforge.School where

import Text.Chatty.Printer
import Text.Chatty.Scanner
import Text.Chatty.Expansion
import Text.Chatty.Expansion.Vars
import System.Chatty.Misc
import Text.Chatty.Extended.Printer
import Game.Antisplice
import Data.Chatty.Graph
import Control.Monad
import Control.Monad.Error.Class
import Data.Monoid

school :: Constructor (NodeId,NodeId)
school = do
  start <- constructRoom $ do
    ctorRoom "The Dungeon School" "Here you will learn to play this dungeon."
    addRoomObject $ do
      ctorSign
        ("This dungeon consists of multiple rooms. Whenever you enter a room you haven't seen before, the room name and a description appear:\n\n"
          ++"    %{D5;The Great Forge}\n"
          ++"    %{D2;This is the Great Forge.}\n\n"
          ++"In most cases the description will tell you something about people and objects in this room, but that's not always the case. "
          ++"Keep your eyes, ears and nose open.\nYou may now enter \"list exits\" (or short \"ex\") to get a list of ways you can take "
          ++"to leave this room. After that, type \"go west\" (or short \"w\")."
        )
        ["big","rusty"]
      addDescSeg "You see a big rusty sign on the wall. Possibly you might want to read it?"
  room2 <- constructRoom $ do
    ctorRoom "The Right Path" "In this room there are actually some things around."
    addRoomObject $ do
      ctorSign
        ("The next door is locked and opens only after you have killed Justin. So... why not give it a try?\n"
         ++"Justin is strong and at the moment you're unarmed. Take the sword lying to your feet, that will make you stronger. "
         ++"You can equip it using \"equip sword\" (after you have taken it into your inventory!). "
         ++"To see your current strength, you may just type \"list score\" (or short \"sco\"); likewise you can see your current "
         ++"equipment by entering \"list equipment\" (or short \"eq\").\n"
         ++"When you're finished with preparations, repeatedly enter \"hit justin\" and see how his health decreases. "
         ++"After that you might want to look around (\"look\" or short \"l\") and then continue with the next lesson."
        ) ["green","instructory"]
      addDescSeg "On one wall there is a green instructory sign."
  justin <- withRoom room2 $ addRoomObject $ ctorMob "%{V1;Justin}" ["justin"] "This is Justin. You know you hate him. Give him what he deserves." []
  sword <- withRoom room2 $ addRoomObject $ do
    ctorAcq "a rusty old sword" "This sword is rusty and old, but it will serve for now." ["sword","blade"] ["rusty","old"]
    addEquipSlot MainHand
    swordSte <- registerStereo $ statsStereo $
      \get k -> case k of
        Strength -> 8
        _ -> 0
    addFeature $ Stereo Worn swordSte
  bipath start room2 West
  end <- constructRoom $ ctorRoom "Exit of the Dungeon School" "To be continued. Type \"ascend\" to return to the ordinary world :)"
  guardedPath room2 end West $ do
    rs <- roomOfObject justin
    case rs of
      [] -> return True
      _ -> return False
  return (start,end)