module Game.Antisplice.Monad where
import Game.Antisplice.Templates
import Game.Antisplice.Utils.AVL
import Game.Antisplice.Utils.None
import Game.Antisplice.Utils.Fail
import Game.Antisplice.Utils.Counter
import Game.Antisplice.Monad.Dungeon
import Game.Antisplice.Monad.Vocab
import Game.Antisplice.Utils.Atoms
import Game.Antisplice.Utils.BST
import Game.Antisplice.Errors
import Control.Monad
import Control.Monad.Trans.Class
import Text.Chatty.Expansion
import Text.Chatty.Expansion.Vars
import Text.Chatty.Templates
import Text.Chatty.Interactor
import Text.Chatty.Interactor.Templates
import Text.Chatty.Channel.Printer
import Text.Chatty.Channel.Broadcast
import Text.Chatty.Extended.HTML
import Text.Chatty.Extended.ANSI
import Text.Chatty.Printer
import System.IO
mkInteractor ''SplErrT mkChatty mkRoom mkDungeon mkObject mkCounter mkPlayer mkIO mkVocab mkAtoms (mkChannelPrinter ''PlayerId)
mkInteractor ''DungeonT mkPrinter mkDefCP mkExtendedPrinter mkScanner mkFinalizer mkClock mkExpanderEnv mkHistoryEnv mkRandom (mkFail ''SplErr) mkCounter mkIO mkVocab mkAtoms (mkChannelPrinter ''PlayerId)
mkInteractor ''RoomT mkChatty (mkFail ''SplErr) mkCounter mkIO mkVocab mkAtoms (mkChannelPrinter ''PlayerId)
mkInteractor ''ObjectT mkChatty (mkFail ''SplErr) mkCounter mkIO mkVocab mkAtoms (mkChannelPrinter ''PlayerId)
mkInteractor ''CounterT mkChatty (mkFail ''SplErr) mkRoom mkObject mkDungeon mkPlayer mkIO mkVocab mkAtoms (mkChannelPrinter ''PlayerId)
mkInteractor ''PlayerT mkChatty (mkFail ''SplErr) mkCounter mkIO mkVocab mkAtoms (mkChannelPrinter ''PlayerId)
mkInteractor ''VocabT mkChatty (mkFail ''SplErr) mkCounter mkDungeon mkRoom mkAtoms mkPlayer (mkChannelPrinter ''PlayerId)
mkInteractor ''AtomStoreT mkChatty (mkFail ''SplErr) mkDungeon mkRoom mkVocab mkPlayer (mkChannelPrinter ''PlayerId)
mkInteractor ''PlayerFilterT mkArchiver mkVocab mkAtoms mkCounter
liftM concat $ forM [''AnsiPrinterT,''HtmlPrinterT,''ExpanderT,''NullExpanderT,''RecorderT] $ \s ->
mkInteractor s (mkChannelPrinter ''PlayerId) mkDungeon mkPlayer mkRoom (mkFail ''SplErr)
instance ChannelPrinter PlayerId m => Broadcaster PlayerId (DungeonT m) where
bprint c str = do
s <- getDungeonState
forM_ (anyBstInorder $ playersOf s) $ \p -> do
b <- c $ indexOf p
when b $ cprint (indexOf p) str