A DeafAndSilend bot
authorJoachim Breitner <mail@joachim-breitner.de>
Fri, 4 Jul 2008 23:54:48 +0000 (23:54 +0000)
committerJoachim Breitner <mail@joachim-breitner.de>
Fri, 4 Jul 2008 23:54:48 +0000 (23:54 +0000)
DeafAndSilent.hs [new file with mode: 0644]

diff --git a/DeafAndSilent.hs b/DeafAndSilent.hs
new file mode 100644 (file)
index 0000000..06d9457
--- /dev/null
@@ -0,0 +1,37 @@
+import Control.Monad.Trans
+import Control.Monad.State
+import Control.Monad.Writer
+import System.Random
+
+import Partty
+
+type UserData = Maybe Place
+
+dcb :: DayCallback UserData
+dcb DayStarts = do
+       mbp <- get
+       case mbp of
+               Nothing -> do
+                       liftIO $ putStrLn "No idea where to go, guessgin..."
+                       room <- liftIO $ randomRIO (0,9)
+                       send (Goto room)
+               Just room -> do
+                       liftIO $ putStrLn $ "Yay, I know where to go! (" ++ show room ++")"
+                       send (Goto room)
+
+
+dcb e = return ()
+
+ncb :: NightCallback UserData
+ncb (NightEnds) = put Nothing
+
+ncb (PartyHint room) = put (Just room)
+
+ncb (GotScore score) = liftIO $ putStrLn $ "Got score: " ++ show score
+
+ncb e = return ()
+
+
+main = do
+       runPartty "localhost" 1111 "me2" "passwd" dcb ncb Nothing
+