Implement/improve null/un/binary logic gates
This commit is contained in:
@@ -121,6 +121,9 @@ inventoryX c = case c of
|
||||
, fuelPack
|
||||
, chemFuelPouch
|
||||
, copier ABSOLUTE
|
||||
, nulgate
|
||||
, unigate
|
||||
, bingate
|
||||
]
|
||||
'B' ->
|
||||
[ wristArmour
|
||||
|
||||
@@ -26,8 +26,9 @@ data ItemType
|
||||
| DROPPER InventoryPathing
|
||||
| CLICKER InventoryPathing
|
||||
| COPIER {_ibtPathing :: InventoryPathing}
|
||||
| UGATE
|
||||
| BGATE
|
||||
| NULGATE
|
||||
| UNIGATE
|
||||
| BINGATE
|
||||
| INTROSCAN {_ibtIntroScanType :: IntroScanType}
|
||||
| DETECTOR {_ibtDetector :: Detector}
|
||||
| ARHUD
|
||||
|
||||
@@ -8,6 +8,7 @@ module Dodge.Inventory.SelectionList (
|
||||
getItemValue,
|
||||
) where
|
||||
|
||||
import Numeric
|
||||
import Dodge.Inventory.Path
|
||||
import Control.Applicative
|
||||
import ShortShow
|
||||
@@ -86,13 +87,34 @@ itemExternalValue itm w cr
|
||||
| ITEMSCAN <- itm ^. itType
|
||||
, Just ExamineInventory <- w ^? hud . hudElement . subInventory
|
||||
= Just (Right "ON")
|
||||
-- , Just x <- itm ^? itScroll . itsInt
|
||||
-- , Just invid <- itm ^? itLocation . ilInvID
|
||||
-- , Just i <- getInventoryPath x ip invid cr
|
||||
-- , Just itm' <- cr ^? crInv . ix i
|
||||
-- = getItemValue itm' w cr
|
||||
| BINGATE <- itm ^. itType = do
|
||||
invid <- itm ^? itLocation . ilInvID
|
||||
litm <- cr ^? crInv . ix (invid -2)
|
||||
ritm <- cr ^? crInv . ix (invid -1)
|
||||
x <- itm ^? itScroll . itsRangeInt
|
||||
l <- getItemValue litm w cr ^? _Just . _Left
|
||||
r <- getItemValue ritm w cr ^? _Just . _Left
|
||||
Just . Left $ bgateCalc x l r
|
||||
| UNIGATE <- itm ^. itType = do
|
||||
invid <- itm ^? itLocation . ilInvID
|
||||
itm' <- cr ^? crInv . ix (invid -1)
|
||||
x <- itm ^? itScroll . itsRangeInt
|
||||
y <- getItemValue itm' w cr ^? _Just . _Left
|
||||
Just . Left $ ugateCalc x y
|
||||
| otherwise = mempty
|
||||
|
||||
ugateCalc :: Int -> Int -> Int
|
||||
ugateCalc x y = (x `div` ((2::Int) ^ ((f y) ::Int))::Int) `mod` 2
|
||||
where
|
||||
f i | i > 0 = 1
|
||||
| otherwise = 0
|
||||
|
||||
bgateCalc :: Int -> Int -> Int -> Int
|
||||
bgateCalc x l r = (x `div` ((2::Int) ^ ((2::Int)*f l + f r))) `mod` 2
|
||||
where
|
||||
f i | i > 0 = 1
|
||||
| otherwise = 0
|
||||
|
||||
itemScrollDisplay :: Item -> Maybe String
|
||||
itemScrollDisplay itm
|
||||
| HELD ALTERIFLE <- itm ^. itType = Just $
|
||||
@@ -100,12 +122,28 @@ itemScrollDisplay itm
|
||||
Just 0 -> "L"
|
||||
_ -> "R"
|
||||
| UseScope OpticScope{_opticZoom = x} <- itm ^. itUse = Just $ shortShow x
|
||||
| UNIGATE <- itm ^. itType = do
|
||||
i <- itm ^? itScroll . itsRangeInt
|
||||
return $ toBinary 2 i
|
||||
| BINGATE <- itm ^. itType = do
|
||||
i <- itm ^? itScroll . itsRangeInt
|
||||
return $ toBinary 4 i
|
||||
| ItemScrollInt i <- itm ^. itScroll = Just $ show i
|
||||
| ItemScrollIntRange _ i <- itm ^. itScroll = Just $ show i
|
||||
| otherwise = Nothing
|
||||
|
||||
toBinary :: Int -> Int -> String
|
||||
toBinary x = leftPad x '0' . ($ []) . showIntAtBase 2 f
|
||||
where
|
||||
f 0 = '0'
|
||||
f _ = '1'
|
||||
|
||||
getItemValue :: Item -> World -> Creature -> Maybe (Either Int String)
|
||||
getItemValue itm w cr = itemInternalValue itm <|> itemExternalValue itm w cr
|
||||
<|> itemScrollValue itm
|
||||
|
||||
itemScrollValue :: Item -> Maybe (Either Int b)
|
||||
itemScrollValue itm = Left <$> itm ^? itScroll . failing itsInt itsRangeInt
|
||||
|
||||
--itemDisplayPad :: [Char] -> String -> [Char]
|
||||
--itemDisplayPad ls rs
|
||||
|
||||
@@ -27,6 +27,8 @@ doInvEffect = \case
|
||||
ItemCopierUpdate -> copierItemUpdate
|
||||
ItemReduceWarmTime -> \itm _ -> pointerToItem itm . itUse . heldDelay . warmTime
|
||||
%~ (max 0 . subtract 1)
|
||||
-- use of pointerToItemID rather than pointerToItem because the item
|
||||
-- location is changing
|
||||
ItemSetWarmTime x -> \itm _ -> pointerToItemID (_itID itm) . itUse . heldDelay . warmTime
|
||||
.~ x
|
||||
|
||||
|
||||
+3
-2
@@ -33,8 +33,9 @@ itemFromBase = \case
|
||||
DROPPER x -> dropper x
|
||||
CLICKER x -> clicker x
|
||||
COPIER x -> copier x
|
||||
BGATE -> bgate
|
||||
UGATE -> ugate
|
||||
NULGATE -> nulgate
|
||||
UNIGATE -> unigate
|
||||
BINGATE -> bingate
|
||||
|
||||
itemFromAmmoMag :: AmmoMagType -> Item
|
||||
itemFromAmmoMag at = case at of
|
||||
|
||||
@@ -75,8 +75,9 @@ itemBaseName = \case
|
||||
DROPPER x -> "DROPPER-" ++ showInventoryPathing x
|
||||
CLICKER x -> "CLICKER-" ++ showInventoryPathing x
|
||||
COPIER x -> "COPIER-" ++ showInventoryPathing x
|
||||
BGATE -> "BGATE"
|
||||
UGATE -> "UGATE"
|
||||
BINGATE -> "BINGATE"
|
||||
UNIGATE -> "UNIGATE"
|
||||
NULGATE -> "NULGATE"
|
||||
|
||||
showInventoryPathing :: InventoryPathing -> String
|
||||
showInventoryPathing = \case
|
||||
|
||||
@@ -49,8 +49,9 @@ itemSPic it = case it ^. itType of
|
||||
DROPPER{} -> defSPic
|
||||
CLICKER{} -> defSPic
|
||||
COPIER{} -> defSPic
|
||||
BGATE -> defSPic
|
||||
UGATE -> defSPic
|
||||
BINGATE -> defSPic
|
||||
UNIGATE -> defSPic
|
||||
NULGATE -> defSPic
|
||||
|
||||
craftItemSPic :: CraftType -> Shape
|
||||
craftItemSPic = \case
|
||||
|
||||
+21
-12
@@ -20,8 +20,9 @@ module Dodge.Item.Scope (
|
||||
dropper,
|
||||
clicker,
|
||||
copier,
|
||||
bgate,
|
||||
ugate,
|
||||
nulgate,
|
||||
unigate,
|
||||
bingate,
|
||||
) where
|
||||
|
||||
import Dodge.Item.Attach
|
||||
@@ -92,19 +93,27 @@ copier x =
|
||||
& itScroll .~ ItemScrollInt 0
|
||||
& itEffect . ieInv .~ ItemCopierUpdate
|
||||
|
||||
bgate :: Item
|
||||
bgate =
|
||||
nulgate :: Item
|
||||
nulgate =
|
||||
defaultHeldItem
|
||||
& itType .~ BGATE
|
||||
& itUse .~ UseInt 0
|
||||
& itScroll .~ ItemScrollIntRange 15 0
|
||||
& itType .~ NULGATE
|
||||
& itUse .~ UseNothing
|
||||
& itScroll .~ ItemScrollIntRange 2 0
|
||||
|
||||
ugate :: Item
|
||||
ugate =
|
||||
unigate :: Item
|
||||
unigate =
|
||||
defaultHeldItem
|
||||
& itType .~ UGATE
|
||||
& itUse .~ UseInt 0
|
||||
& itScroll .~ ItemScrollIntRange 3 0
|
||||
& itType .~ UNIGATE
|
||||
& itUse .~ UseNothing
|
||||
& itScroll .~ ItemScrollIntRange 4 0
|
||||
|
||||
bingate :: Item
|
||||
bingate =
|
||||
defaultHeldItem
|
||||
& itType .~ BINGATE
|
||||
& itUse .~ UseNothing
|
||||
& itScroll .~ ItemScrollIntRange 16 0
|
||||
|
||||
|
||||
bulletModule :: BulletMod -> Item
|
||||
bulletModule bm =
|
||||
|
||||
Reference in New Issue
Block a user