packages feed

antisplice 0.14.0.0 → 0.14.0.3

raw patch · 3 files changed

+29/−8 lines, 3 files

Files

antisplice.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.14.0.0+version:             0.14.0.3  -- A short (one-line) description of the package. synopsis:            An engine for text-based dungeons.
src/Game/Antisplice/Rooms.hs view
@@ -587,7 +587,14 @@ withObject :: MonadDungeon m => ObjectId -> ObjectT (RoomT m) a -> m a withObject i m = do   rs <- roomOfObject i+  ps <- getPlayerState   case rs of+      [] -> case avlLookup i $ playerInventoryOf ps of+              Nothing -> error "Wtf, that object does not exist. Neither in a room nor in your inventory."+              Just o -> withRoom (playerRoomOf ps) $ do+                (a,o') <- runObjectT m o+                lift $ modifyPlayerState $ \p -> p{playerInventoryOf=avlInsert o' $ playerInventoryOf p}+                return a       [r] -> withRoom r $ do         rs <- getRoomState         case anyBstLookup i $ roomObjectsOf rs of@@ -631,6 +638,9 @@  expandDun :: (MonadPrinter m,MonadDungeon m) => String -> m () expandDun [] = return ()+expandDun ('\\':'#':ss) = do+  mprint "#"+  expandDun ss expandDun ('#':'?':'{':ss) =   let nm = takeBrace 0 ss       rm = drop (length nm + 1) ss@@ -647,22 +657,32 @@         expandDun rm expandDun ('#':'{':ss) =   let (nm,rm) = (takeWhile (/='}') &&& tail.dropWhile (/='}')) ss-      replace "health" = liftM (show . joinMaybe . avlLookup Health . playerCurrenciesOf) getPlayerState >>= mprint-      replace "ohealth" = do+      prnum Nothing Nothing i = show i+      prnum (Just d) Nothing i = show (i `div` d)+      prnum Nothing (Just m) i = let exp s l = replicate (l-length s) '0' ++ s in exp (show (i `mod` m)) (length $ show (m-1))+      prnum (Just d) (Just m) i = prnum (Just d) Nothing i ++ "." ++ prnum (Just m) Nothing i+      replace :: (MonadPrinter m,MonadDungeon m) => String -> Maybe Int -> Maybe Int -> m ()+      replace "health" d m = liftM (prnum d m . joinMaybe . avlLookup Health . playerCurrenciesOf) getPlayerState >>= mprint+      replace "ohealth" d m = do         i <- liftM playerOpponentOf getPlayerState         o <- withObject i getObjectState-        mprint $ show $ objectCurHealthOf o-      replace "otitle" = do+        mprint $ prnum d m $ objectCurHealthOf o+      replace "otitle" _ _ = do         i <- liftM playerOpponentOf getPlayerState         o <- withObject i getObjectState         mprint $ unpack $ objectTitleOf o-      replace s = do+      replace s d m = do         cs <- liftM (avlInorder . currenciesOf) getDungeonState         case filter ((==s).currencyNameOf) cs of           [] -> return ()-          [c] -> liftM (show .  joinMaybe . avlLookup (currencyIdOf c) . playerCurrenciesOf) getPlayerState >>= mprint+          [c] -> liftM (prnum d m .  joinMaybe . avlLookup (currencyIdOf c) . playerCurrenciesOf) getPlayerState >>= mprint+          cs -> mprintLn $ concat $ map currencyNameOf cs+      (nm1,dm1,mm1)+        | '/' `elem` nm = (takeWhile (/='/') nm, Just $ read $ tail $ dropWhile (/='/') nm, Nothing)+        | '%' `elem` nm = (takeWhile (/='%') nm, Nothing, Just $ read $ tail $ dropWhile (/='%') nm)+        | otherwise = (nm,Nothing,Nothing)   in do-    replace nm+    replace nm1 dm1 mm1     expandDun rm expandDun ('#':ss) =   let (nm,rm) = (takeWhile isAnum &&& dropWhile isAnum) ss
src/Game/Antisplice/SingleUser.hs view
@@ -65,6 +65,7 @@       reenterCurrentRoom       roomTriggerOnAnnounceOf =<< getRoomState       roomTriggerOnLookOf =<< getRoomState+      mputv "prompt" . Literal =<< expand "$prompt> "       repl     case r :: Either SplErr ((),DungeonState) of       Left QuitError -> mprintLn "Bye bye!"