├── src ├── Screeps │ ├── Game.js │ ├── Creep.js │ ├── Memory.js │ ├── Market.purs │ ├── RoomPosition.js │ ├── RoomObject.purs │ ├── Extractor.purs │ ├── Resource.purs │ ├── Road.purs │ ├── Wall.purs │ ├── Nuke.purs │ ├── Source.purs │ ├── OwnedStructure.purs │ ├── Mineral.purs │ ├── Effects.purs │ ├── KeeperLair.purs │ ├── Room.js │ ├── Portal.purs │ ├── PowerBank.purs │ ├── Extension.purs │ ├── Observer.purs │ ├── Storage.purs │ ├── Container.purs │ ├── Rampart.purs │ ├── ConstructionSite.purs │ ├── Link.purs │ ├── Nuker.purs │ ├── Controller.purs │ ├── PowerSpawn.purs │ ├── Flag.purs │ ├── Spawn.js │ ├── Terminal.purs │ ├── Tower.purs │ ├── Structure.purs │ ├── Lab.purs │ ├── Map.purs │ ├── Game.purs │ ├── Memory.purs │ ├── Spawn.purs │ ├── FFI.purs │ ├── FFI.js │ ├── Types.purs │ ├── Room.purs │ ├── RoomPosition.purs │ ├── Creep.purs │ ├── Constants.js │ └── Constants.purs └── Screeps.purs ├── .gitignore ├── docs └── Screeps │ ├── Market.md │ ├── Extractor.md │ ├── Wall.md │ ├── Road.md │ ├── RoomObject.md │ ├── KeeperLair.md │ ├── OwnedStructure.md │ ├── Observer.md │ ├── Resource.md │ ├── Portal.md │ ├── PowerBank.md │ ├── Extension.md │ ├── Nuke.md │ ├── Source.md │ ├── Mineral.md │ ├── Rampart.md │ ├── Storage.md │ ├── Container.md │ ├── Effects.md │ ├── Link.md │ ├── Nuker.md │ ├── ConstructionSite.md │ ├── Terminal.md │ ├── PowerSpawn.md │ ├── Controller.md │ ├── Flag.md │ ├── Tower.md │ ├── Lab.md │ ├── Structure.md │ ├── Map.md │ ├── Memory.md │ ├── Game.md │ ├── Spawn.md │ ├── Room.md │ ├── FFI.md │ ├── RoomPosition.md │ ├── Creep.md │ ├── Types.md │ └── Constants.md ├── test └── Main.purs ├── bower.json ├── LICENSE └── README.md /src/Screeps/Game.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | exports.getGameGlobal = function(){ return Game; } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bower_components/ 2 | /node_modules/ 3 | /.pulp-cache/ 4 | /output/ 5 | /.psci* 6 | /src/.webpack.js 7 | -------------------------------------------------------------------------------- /src/Screeps/Creep.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | exports.totalAmtCarrying = function(creep){ 4 | return _.sum(creep.carry); 5 | } 6 | -------------------------------------------------------------------------------- /src/Screeps/Memory.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | exports.getMemoryGlobal = function(){ return Memory; } 4 | exports.getRawMemoryGlobal = function(){ return RawMemory; } 5 | -------------------------------------------------------------------------------- /docs/Screeps/Market.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Market 2 | 3 | Corresponds to the Screeps API [Market](http://support.screeps.com/hc/en-us/articles/203079191-Map) 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Screeps/Market.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Market](http://support.screeps.com/hc/en-us/articles/203079191-Map) 2 | module Screeps.Market where 3 | 4 | -- TODO: Implement 5 | -------------------------------------------------------------------------------- /test/Main.purs: -------------------------------------------------------------------------------- 1 | module Test.Main where 2 | 3 | import Prelude 4 | import Control.Monad.Eff (Eff) 5 | import Control.Monad.Eff.Console (CONSOLE, log) 6 | 7 | main :: forall e. Eff (console :: CONSOLE | e) Unit 8 | main = do 9 | log "You should add some tests." 10 | -------------------------------------------------------------------------------- /src/Screeps/RoomPosition.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // module Screeps.RoomPosition 4 | 5 | exports.mkRoomPosition = function(x){ 6 | return function(y){ 7 | return function(roomName){ 8 | return new RoomPosition(x, y, roomName); 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /docs/Screeps/Extractor.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Extractor 2 | 3 | Corresponds to the Screeps API [StructureExtractor](http://support.screeps.com/hc/en-us/articles/207715739-StructureExtractor) 4 | 5 | #### `toExtractor` 6 | 7 | ``` purescript 8 | toExtractor :: forall a. Structure a -> Maybe Extractor 9 | ``` 10 | 11 | 12 | -------------------------------------------------------------------------------- /docs/Screeps/Wall.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Wall 2 | 3 | Corresponds to the Screeps API [StructureWall](http://support.screeps.com/hc/en-us/articles/208437125-StructureWall) 4 | 5 | #### `ticksToLive` 6 | 7 | ``` purescript 8 | ticksToLive :: Wall -> Int 9 | ``` 10 | 11 | #### `toWall` 12 | 13 | ``` purescript 14 | toWall :: forall a. Structure a -> Maybe Wall 15 | ``` 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/Screeps/Road.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Road 2 | 3 | Corresponds to the Screeps API [StructureRoad](http://support.screeps.com/hc/en-us/articles/207713089-StructureRoad) 4 | 5 | #### `ticksToDecay` 6 | 7 | ``` purescript 8 | ticksToDecay :: Road -> Int 9 | ``` 10 | 11 | #### `toRoad` 12 | 13 | ``` purescript 14 | toRoad :: forall a. Structure a -> Maybe Road 15 | ``` 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/Screeps/RoomObject.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.RoomObject 2 | 3 | Corresponds to the Screeps API [RoomObject](http://support.screeps.com/hc/en-us/articles/208435305-RoomObject) 4 | 5 | #### `room` 6 | 7 | ``` purescript 8 | room :: forall a. RoomObject a -> Room 9 | ``` 10 | 11 | #### `pos` 12 | 13 | ``` purescript 14 | pos :: forall a. RoomObject a -> RoomPosition 15 | ``` 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Screeps.purs: -------------------------------------------------------------------------------- 1 | -- | This helper module re-exports almost all of the types and constants used in the library. 2 | -- | Functions for using particular types are defined in their own modules. 3 | module Screeps 4 | ( module Screeps.Constants 5 | , module Screeps.Effects 6 | , module Screeps.Types 7 | ) where 8 | 9 | import Screeps.Constants 10 | import Screeps.Effects 11 | import Screeps.Types 12 | -------------------------------------------------------------------------------- /docs/Screeps/KeeperLair.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.KeeperLair 2 | 3 | Corresponds to the Screeps API [StructureKeeperLair](http://support.screeps.com/hc/en-us/articles/207712119-StructureKeeperLair) 4 | 5 | #### `ticksToSpawn` 6 | 7 | ``` purescript 8 | ticksToSpawn :: KeeperLair -> Int 9 | ``` 10 | 11 | #### `toKeeperLair` 12 | 13 | ``` purescript 14 | toKeeperLair :: forall a. Structure a -> Maybe KeeperLair 15 | ``` 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/Screeps/OwnedStructure.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.OwnedStructure 2 | 3 | Corresponds to the Screeps API [OwnedStructure](http://support.screeps.com/hc/en-us/articles/207710979-OwnedStructure) 4 | 5 | #### `my` 6 | 7 | ``` purescript 8 | my :: forall a. OwnedStructure a -> Boolean 9 | ``` 10 | 11 | #### `owner` 12 | 13 | ``` purescript 14 | owner :: forall a. OwnedStructure a -> Maybe { username :: String } 15 | ``` 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Screeps/RoomObject.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [RoomObject](http://support.screeps.com/hc/en-us/articles/208435305-RoomObject) 2 | module Screeps.RoomObject where 3 | 4 | import Screeps.Types (Room, RoomObject, RoomPosition) 5 | import Screeps.FFI (unsafeField) 6 | 7 | room :: forall a. RoomObject a -> Room 8 | room = unsafeField "room" 9 | 10 | pos :: forall a. RoomObject a -> RoomPosition 11 | pos = unsafeField "pos" 12 | -------------------------------------------------------------------------------- /docs/Screeps/Observer.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Observer 2 | 3 | Corresponds to the Screeps API [StructureObserver](http://support.screeps.com/hc/en-us/articles/208436365-StructureObserver) 4 | 5 | #### `observeRoom` 6 | 7 | ``` purescript 8 | observeRoom :: forall e. Observer -> String -> Eff (cmd :: CMD | e) ReturnCode 9 | ``` 10 | 11 | #### `toObserver` 12 | 13 | ``` purescript 14 | toObserver :: forall a. Structure a -> Maybe Observer 15 | ``` 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/Screeps/Resource.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Resource 2 | 3 | Corresponds to the Screeps API [Resource](http://support.screeps.com/hc/en-us/articles/203016362-Resource) 4 | 5 | #### `amount` 6 | 7 | ``` purescript 8 | amount :: Resource -> Int 9 | ``` 10 | 11 | #### `id` 12 | 13 | ``` purescript 14 | id :: Resource -> Id Resource 15 | ``` 16 | 17 | #### `resourceType` 18 | 19 | ``` purescript 20 | resourceType :: Resource -> ResourceType 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/Screeps/Extractor.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureExtractor](http://support.screeps.com/hc/en-us/articles/207715739-StructureExtractor) 2 | module Screeps.Extractor where 3 | 4 | import Data.Maybe (Maybe) 5 | 6 | import Screeps.Constants (structure_extractor) 7 | import Screeps.Structure (unsafeCast) 8 | import Screeps.Types (Extractor, Structure) 9 | 10 | toExtractor :: forall a. Structure a -> Maybe Extractor 11 | toExtractor = unsafeCast structure_extractor 12 | -------------------------------------------------------------------------------- /src/Screeps/Resource.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Resource](http://support.screeps.com/hc/en-us/articles/203016362-Resource) 2 | module Screeps.Resource where 3 | 4 | import Screeps.Types (Id, Resource, ResourceType) 5 | import Screeps.FFI (unsafeField) 6 | 7 | amount :: Resource -> Int 8 | amount = unsafeField "amount" 9 | 10 | id :: Resource -> Id Resource 11 | id = unsafeField "id" 12 | 13 | resourceType :: Resource -> ResourceType 14 | resourceType = unsafeField "id" 15 | -------------------------------------------------------------------------------- /docs/Screeps/Portal.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Portal 2 | 3 | Corresponds to the Screeps API [StructurePortal](http://support.screeps.com/hc/en-us/articles/208647345-StructurePortal) 4 | 5 | #### `destination` 6 | 7 | ``` purescript 8 | destination :: Portal -> RoomPosition 9 | ``` 10 | 11 | #### `ticksToDecay` 12 | 13 | ``` purescript 14 | ticksToDecay :: Portal -> Int 15 | ``` 16 | 17 | #### `toPortal` 18 | 19 | ``` purescript 20 | toPortal :: forall a. Structure a -> Maybe Portal 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/Screeps/PowerBank.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.PowerBank 2 | 3 | Corresponds to the Screeps API [StructurePowerBank](http://support.screeps.com/hc/en-us/articles/207712729-StructurePowerBank) 4 | 5 | #### `power` 6 | 7 | ``` purescript 8 | power :: PowerBank -> Int 9 | ``` 10 | 11 | #### `ticksToDecay` 12 | 13 | ``` purescript 14 | ticksToDecay :: PowerBank -> Int 15 | ``` 16 | 17 | #### `toPowerBank` 18 | 19 | ``` purescript 20 | toPowerBank :: forall a. Structure a -> Maybe PowerBank 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/Screeps/Extension.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Extension 2 | 3 | Corresponds to the Screeps API [StructureExtension](http://support.screeps.com/hc/en-us/articles/207711949-StructureExtension) 4 | 5 | #### `energy` 6 | 7 | ``` purescript 8 | energy :: Extension -> Int 9 | ``` 10 | 11 | #### `energyCapacity` 12 | 13 | ``` purescript 14 | energyCapacity :: Extension -> Int 15 | ``` 16 | 17 | #### `toExtension` 18 | 19 | ``` purescript 20 | toExtension :: forall a. Structure a -> Maybe Extension 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/Screeps/Nuke.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Nuke 2 | 3 | Corresponds to the Screeps API [Nuke](http://support.screeps.com/hc/en-us/articles/208488525-Nuke) 4 | 5 | #### `id` 6 | 7 | ``` purescript 8 | id :: Nuke -> Id Nuke 9 | ``` 10 | 11 | #### `launchRoomName` 12 | 13 | ``` purescript 14 | launchRoomName :: Nuke -> String 15 | ``` 16 | 17 | #### `timeToLand` 18 | 19 | ``` purescript 20 | timeToLand :: Nuke -> Int 21 | ``` 22 | 23 | #### `ticksToRegeneration` 24 | 25 | ``` purescript 26 | ticksToRegeneration :: Nuke -> Int 27 | ``` 28 | 29 | 30 | -------------------------------------------------------------------------------- /docs/Screeps/Source.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Source 2 | 3 | Corresponds to the Screeps API [Source](http://support.screeps.com/hc/en-us/articles/203079211-Source) 4 | 5 | #### `energy` 6 | 7 | ``` purescript 8 | energy :: Source -> Int 9 | ``` 10 | 11 | #### `energyCapacity` 12 | 13 | ``` purescript 14 | energyCapacity :: Source -> Int 15 | ``` 16 | 17 | #### `id` 18 | 19 | ``` purescript 20 | id :: Source -> Id Source 21 | ``` 22 | 23 | #### `ticksToRegeneration` 24 | 25 | ``` purescript 26 | ticksToRegeneration :: Source -> Int 27 | ``` 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Screeps/Road.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureRoad](http://support.screeps.com/hc/en-us/articles/207713089-StructureRoad) 2 | module Screeps.Road where 3 | 4 | import Data.Maybe (Maybe) 5 | 6 | import Screeps.Constants (structure_road) 7 | import Screeps.FFI (unsafeField) 8 | import Screeps.Structure (unsafeCast) 9 | import Screeps.Types (Road, Structure) 10 | 11 | ticksToDecay :: Road -> Int 12 | ticksToDecay = unsafeField "ticksToDecay" 13 | 14 | toRoad :: forall a. Structure a -> Maybe Road 15 | toRoad = unsafeCast structure_road 16 | -------------------------------------------------------------------------------- /src/Screeps/Wall.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureWall](http://support.screeps.com/hc/en-us/articles/208437125-StructureWall) 2 | module Screeps.Wall where 3 | 4 | import Data.Maybe (Maybe) 5 | 6 | import Screeps.Constants (structure_wall) 7 | import Screeps.FFI (unsafeField) 8 | import Screeps.Structure (unsafeCast) 9 | import Screeps.Types (Structure, Wall) 10 | 11 | ticksToLive :: Wall -> Int 12 | ticksToLive = unsafeField "ticksToLive" 13 | 14 | toWall :: forall a. Structure a -> Maybe Wall 15 | toWall = unsafeCast structure_wall 16 | -------------------------------------------------------------------------------- /src/Screeps/Nuke.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Nuke](http://support.screeps.com/hc/en-us/articles/208488525-Nuke) 2 | module Screeps.Nuke where 3 | 4 | import Screeps.Types (Id, Nuke) 5 | import Screeps.FFI (unsafeField) 6 | 7 | id :: Nuke -> Id Nuke 8 | id = unsafeField "id" 9 | 10 | launchRoomName :: Nuke -> String 11 | launchRoomName = unsafeField "launchRoomName" 12 | 13 | timeToLand :: Nuke -> Int 14 | timeToLand = unsafeField "timeToLand" 15 | 16 | ticksToRegeneration :: Nuke -> Int 17 | ticksToRegeneration = unsafeField "ticksToRegeneration" 18 | -------------------------------------------------------------------------------- /src/Screeps/Source.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Source](http://support.screeps.com/hc/en-us/articles/203079211-Source) 2 | module Screeps.Source where 3 | 4 | import Screeps.Types (Id, Source) 5 | import Screeps.FFI (unsafeField) 6 | 7 | energy :: Source -> Int 8 | energy = unsafeField "energy" 9 | 10 | energyCapacity :: Source -> Int 11 | energyCapacity = unsafeField "energyCapacity" 12 | 13 | id :: Source -> Id Source 14 | id = unsafeField "id" 15 | 16 | ticksToRegeneration :: Source -> Int 17 | ticksToRegeneration = unsafeField "ticksToRegeneration" 18 | -------------------------------------------------------------------------------- /docs/Screeps/Mineral.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Mineral 2 | 3 | Corresponds to the Screeps API [Mineral](http://support.screeps.com/hc/en-us/articles/207218579-Mineral) 4 | 5 | #### `mineralAmount` 6 | 7 | ``` purescript 8 | mineralAmount :: Mineral -> Int 9 | ``` 10 | 11 | #### `mineralType` 12 | 13 | ``` purescript 14 | mineralType :: Mineral -> ResourceType 15 | ``` 16 | 17 | #### `id` 18 | 19 | ``` purescript 20 | id :: Mineral -> Id Mineral 21 | ``` 22 | 23 | #### `ticksToRegeneration` 24 | 25 | ``` purescript 26 | ticksToRegeneration :: Mineral -> Int 27 | ``` 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Screeps/OwnedStructure.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [OwnedStructure](http://support.screeps.com/hc/en-us/articles/207710979-OwnedStructure) 2 | module Screeps.OwnedStructure where 3 | 4 | import Prelude 5 | import Data.Maybe (Maybe, fromMaybe) 6 | 7 | import Screeps.Types (OwnedStructure) 8 | import Screeps.FFI (toMaybe, unsafeField) 9 | 10 | my :: forall a. OwnedStructure a -> Boolean 11 | my struc = fromMaybe false $ toMaybe $ unsafeField "my" struc 12 | 13 | owner :: forall a. OwnedStructure a -> Maybe { username :: String } 14 | owner struc = toMaybe $ unsafeField "owner" struc 15 | -------------------------------------------------------------------------------- /src/Screeps/Mineral.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Mineral](http://support.screeps.com/hc/en-us/articles/207218579-Mineral) 2 | module Screeps.Mineral where 3 | 4 | import Screeps.Types (Id, Mineral, ResourceType) 5 | import Screeps.FFI (unsafeField) 6 | 7 | mineralAmount :: Mineral -> Int 8 | mineralAmount = unsafeField "mineralAmount" 9 | 10 | mineralType :: Mineral -> ResourceType 11 | mineralType = unsafeField "mineralType" 12 | 13 | id :: Mineral -> Id Mineral 14 | id = unsafeField "id" 15 | 16 | ticksToRegeneration :: Mineral -> Int 17 | ticksToRegeneration = unsafeField "ticksToRegeneration" 18 | -------------------------------------------------------------------------------- /src/Screeps/Effects.purs: -------------------------------------------------------------------------------- 1 | module Screeps.Effects where 2 | 3 | -- | Tag for functions which execute a Screeps command as a side effect e.g. to move a creep. 4 | foreign import data CMD :: ! 5 | 6 | -- | Memory accesses are tagged with this effect. 7 | foreign import data MEMORY :: ! 8 | 9 | -- | Global scope is cleared periodically, so values depending on global variables like Game and Memory need to be fetched dynamically. This effect enforces this. 10 | foreign import data TICK :: ! 11 | 12 | -- | For time-dependent functions where the output changes depending on when it is called. 13 | foreign import data TIME :: ! 14 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "purescript-screeps", 3 | "ignore": [ 4 | "**/.*", 5 | "node_modules", 6 | "bower_components", 7 | "output" 8 | ], 9 | "dependencies": { 10 | "purescript-console": "^1.0.0", 11 | "purescript-functions": "^1.0.0", 12 | "purescript-maybe": "^1.0.0", 13 | "purescript-argonaut-core": "^1.0.0", 14 | "purescript-argonaut-codecs": "^1.1.0", 15 | "purescript-unsafe-coerce": "^1.0.0", 16 | "purescript-partial": "^1.1.2", 17 | "purescript-exceptions": "~1.0.0" 18 | }, 19 | "devDependencies": { 20 | "purescript-psci-support": "^1.0.0" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Screeps/KeeperLair.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureKeeperLair](http://support.screeps.com/hc/en-us/articles/207712119-StructureKeeperLair) 2 | module Screeps.KeeperLair where 3 | 4 | import Data.Maybe (Maybe) 5 | 6 | import Screeps.Constants (structure_keeper_lair) 7 | import Screeps.FFI (unsafeField) 8 | import Screeps.Structure (unsafeCast) 9 | import Screeps.Types (KeeperLair, Structure) 10 | 11 | ticksToSpawn :: KeeperLair -> Int 12 | ticksToSpawn = unsafeField "ticksToSpawn" 13 | 14 | toKeeperLair :: forall a. Structure a -> Maybe KeeperLair 15 | toKeeperLair = unsafeCast structure_keeper_lair 16 | -------------------------------------------------------------------------------- /docs/Screeps/Rampart.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Rampart 2 | 3 | Corresponds to the Screeps API [StructureRampart](http://support.screeps.com/hc/en-us/articles/207712959-StructureRampart) 4 | 5 | #### `isPublic` 6 | 7 | ``` purescript 8 | isPublic :: Rampart -> Boolean 9 | ``` 10 | 11 | #### `ticksToDecay` 12 | 13 | ``` purescript 14 | ticksToDecay :: Rampart -> Int 15 | ``` 16 | 17 | #### `setPublic` 18 | 19 | ``` purescript 20 | setPublic :: forall e. Rampart -> Boolean -> Eff (cmd :: CMD | e) ReturnCode 21 | ``` 22 | 23 | #### `toRampart` 24 | 25 | ``` purescript 26 | toRampart :: forall a. Structure a -> Maybe Rampart 27 | ``` 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Screeps/Room.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // module Screeps.Room 4 | 5 | exports.getRoomGlobal = function(){ return Room; } 6 | 7 | exports.findExitToImpl = function(room){ 8 | return function(otherRoom){ 9 | return function(left){ 10 | return function(right){ 11 | var result = room.findExitTo(otherRoom); 12 | if(result == FIND_EXIT_TOP || 13 | result == FIND_EXIT_RIGHT || 14 | result == FIND_EXIT_BOTTOM || 15 | result == FIND_EXIT_LEFT){ 16 | return right(result); 17 | } else { 18 | return left(result); 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /docs/Screeps/Storage.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Storage 2 | 3 | Corresponds to the Screeps API [StructureStorage](http://support.screeps.com/hc/en-us/articles/208436805-StructureStorage) 4 | 5 | #### `Store` 6 | 7 | ``` purescript 8 | data Store :: * 9 | ``` 10 | 11 | #### `store` 12 | 13 | ``` purescript 14 | store :: Storage -> Store 15 | ``` 16 | 17 | #### `storeGet` 18 | 19 | ``` purescript 20 | storeGet :: Storage -> ResourceType -> Int 21 | ``` 22 | 23 | #### `storeCapacity` 24 | 25 | ``` purescript 26 | storeCapacity :: Storage -> Int 27 | ``` 28 | 29 | #### `toStorage` 30 | 31 | ``` purescript 32 | toStorage :: forall a. Structure a -> Maybe Storage 33 | ``` 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/Screeps/Portal.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructurePortal](http://support.screeps.com/hc/en-us/articles/208647345-StructurePortal) 2 | module Screeps.Portal where 3 | 4 | import Data.Maybe (Maybe) 5 | 6 | import Screeps.Constants (structure_portal) 7 | import Screeps.FFI (unsafeField) 8 | import Screeps.Structure (unsafeCast) 9 | import Screeps.Types (Portal, RoomPosition, Structure) 10 | 11 | destination :: Portal -> RoomPosition 12 | destination = unsafeField "destination" 13 | 14 | ticksToDecay :: Portal -> Int 15 | ticksToDecay = unsafeField "ticksToDecay" 16 | 17 | toPortal :: forall a. Structure a -> Maybe Portal 18 | toPortal = unsafeCast structure_portal 19 | -------------------------------------------------------------------------------- /src/Screeps/PowerBank.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructurePowerBank](http://support.screeps.com/hc/en-us/articles/207712729-StructurePowerBank) 2 | module Screeps.PowerBank where 3 | 4 | import Data.Maybe (Maybe) 5 | 6 | import Screeps.Constants (structure_power_bank) 7 | import Screeps.FFI (unsafeField) 8 | import Screeps.Structure (unsafeCast) 9 | import Screeps.Types (PowerBank, Structure) 10 | 11 | power :: PowerBank -> Int 12 | power = unsafeField "power" 13 | 14 | ticksToDecay :: PowerBank -> Int 15 | ticksToDecay = unsafeField "ticksToDecay" 16 | 17 | toPowerBank :: forall a. Structure a -> Maybe PowerBank 18 | toPowerBank = unsafeCast structure_power_bank 19 | -------------------------------------------------------------------------------- /src/Screeps/Extension.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureExtension](http://support.screeps.com/hc/en-us/articles/207711949-StructureExtension) 2 | module Screeps.Extension where 3 | 4 | import Data.Maybe (Maybe) 5 | 6 | import Screeps.Constants (structure_extension) 7 | import Screeps.FFI (unsafeField) 8 | import Screeps.Structure (unsafeCast) 9 | import Screeps.Types (Extension, Structure) 10 | 11 | energy :: Extension -> Int 12 | energy = unsafeField "energy" 13 | 14 | energyCapacity :: Extension -> Int 15 | energyCapacity = unsafeField "energyCapacity" 16 | 17 | toExtension :: forall a. Structure a -> Maybe Extension 18 | toExtension = unsafeCast structure_extension 19 | -------------------------------------------------------------------------------- /docs/Screeps/Container.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Container 2 | 3 | Corresponds to the Screeps API [StructureContainer](http://support.screeps.com/hc/en-us/articles/208435885-StructureContainer) 4 | 5 | #### `Store` 6 | 7 | ``` purescript 8 | data Store :: * 9 | ``` 10 | 11 | #### `store` 12 | 13 | ``` purescript 14 | store :: Container -> Store 15 | ``` 16 | 17 | #### `storeGet` 18 | 19 | ``` purescript 20 | storeGet :: Container -> ResourceType -> Int 21 | ``` 22 | 23 | #### `storeCapacity` 24 | 25 | ``` purescript 26 | storeCapacity :: Container -> Int 27 | ``` 28 | 29 | #### `toContainer` 30 | 31 | ``` purescript 32 | toContainer :: forall a. Structure a -> Maybe Container 33 | ``` 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/Screeps/Observer.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureObserver](http://support.screeps.com/hc/en-us/articles/208436365-StructureObserver) 2 | module Screeps.Observer where 3 | 4 | import Control.Monad.Eff (Eff) 5 | import Data.Maybe (Maybe) 6 | 7 | import Screeps.Constants (structure_observer) 8 | import Screeps.Effects (CMD) 9 | import Screeps.FFI (runThisEffFn1) 10 | import Screeps.Structure (unsafeCast) 11 | import Screeps.Types (Observer, ReturnCode, Structure) 12 | 13 | observeRoom :: forall e. Observer -> String -> Eff (cmd :: CMD | e) ReturnCode 14 | observeRoom obs roomName = runThisEffFn1 "observeRoom" obs roomName 15 | 16 | toObserver :: forall a. Structure a -> Maybe Observer 17 | toObserver = unsafeCast structure_observer 18 | -------------------------------------------------------------------------------- /docs/Screeps/Effects.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Effects 2 | 3 | #### `CMD` 4 | 5 | ``` purescript 6 | data CMD :: ! 7 | ``` 8 | 9 | Tag for functions which execute a Screeps command as a side effect e.g. to move a creep. 10 | 11 | #### `MEMORY` 12 | 13 | ``` purescript 14 | data MEMORY :: ! 15 | ``` 16 | 17 | Memory accesses are tagged with this effect. 18 | 19 | #### `TICK` 20 | 21 | ``` purescript 22 | data TICK :: ! 23 | ``` 24 | 25 | Global scope is cleared periodically, so values depending on global variables like Game and Memory need to be fetched dynamically. This effect enforces this. 26 | 27 | #### `TIME` 28 | 29 | ``` purescript 30 | data TIME :: ! 31 | ``` 32 | 33 | For time-dependent functions where the output changes depending on when it is called. 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/Screeps/Storage.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureStorage](http://support.screeps.com/hc/en-us/articles/208436805-StructureStorage) 2 | module Screeps.Storage where 3 | 4 | import Data.Maybe (Maybe) 5 | 6 | import Screeps.Constants (structure_storage) 7 | import Screeps.FFI (unsafeField) 8 | import Screeps.Structure (unsafeCast) 9 | import Screeps.Types (ResourceType(ResourceType), Storage, Structure) 10 | 11 | foreign import data Store :: * 12 | 13 | store :: Storage -> Store 14 | store = unsafeField "store" 15 | 16 | storeGet :: Storage -> ResourceType -> Int 17 | storeGet s (ResourceType res) = unsafeField res (store s) 18 | 19 | storeCapacity :: Storage -> Int 20 | storeCapacity = unsafeField "storeCapacity" 21 | 22 | toStorage :: forall a. Structure a -> Maybe Storage 23 | toStorage = unsafeCast structure_storage 24 | -------------------------------------------------------------------------------- /docs/Screeps/Link.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Link 2 | 3 | Corresponds to the Screeps API [StructureLink](http://support.screeps.com/hc/en-us/articles/208436275-StructureLink) 4 | 5 | #### `cooldown` 6 | 7 | ``` purescript 8 | cooldown :: Link -> Int 9 | ``` 10 | 11 | #### `energy` 12 | 13 | ``` purescript 14 | energy :: Link -> Int 15 | ``` 16 | 17 | #### `energyCapacity` 18 | 19 | ``` purescript 20 | energyCapacity :: Link -> Int 21 | ``` 22 | 23 | #### `transferEnergy` 24 | 25 | ``` purescript 26 | transferEnergy :: forall e. Link -> Link -> Eff (cmd :: CMD | e) ReturnCode 27 | ``` 28 | 29 | #### `transferEnergyAmt` 30 | 31 | ``` purescript 32 | transferEnergyAmt :: forall e. Link -> Link -> Int -> Eff (cmd :: CMD | e) ReturnCode 33 | ``` 34 | 35 | #### `toLink` 36 | 37 | ``` purescript 38 | toLink :: forall a. Structure a -> Maybe Link 39 | ``` 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/Screeps/Container.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureContainer](http://support.screeps.com/hc/en-us/articles/208435885-StructureContainer) 2 | module Screeps.Container where 3 | 4 | import Data.Maybe (Maybe) 5 | 6 | import Screeps.Structure (unsafeCast) 7 | import Screeps.Constants (structure_container) 8 | import Screeps.Types (Container, ResourceType(ResourceType), Structure) 9 | import Screeps.FFI (unsafeField) 10 | 11 | foreign import data Store :: * 12 | 13 | store :: Container -> Store 14 | store = unsafeField "store" 15 | 16 | storeGet :: Container -> ResourceType -> Int 17 | storeGet s (ResourceType res) = unsafeField res (store s) 18 | 19 | storeCapacity :: Container -> Int 20 | storeCapacity = unsafeField "storeCapacity" 21 | 22 | toContainer :: forall a. Structure a -> Maybe Container 23 | toContainer = unsafeCast structure_container 24 | -------------------------------------------------------------------------------- /src/Screeps/Rampart.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureRampart](http://support.screeps.com/hc/en-us/articles/207712959-StructureRampart) 2 | module Screeps.Rampart where 3 | 4 | import Control.Monad.Eff (Eff) 5 | import Data.Maybe (Maybe) 6 | 7 | import Screeps.Constants (structure_rampart) 8 | import Screeps.Effects (CMD) 9 | import Screeps.FFI (unsafeField) 10 | import Screeps.Structure (unsafeCast) 11 | import Screeps.Types (Rampart, ReturnCode, Structure) 12 | 13 | isPublic :: Rampart -> Boolean 14 | isPublic = unsafeField "isPublic" 15 | 16 | ticksToDecay :: Rampart -> Int 17 | ticksToDecay = unsafeField "ticksToDecay" 18 | 19 | setPublic :: forall e. Rampart -> Boolean -> Eff (cmd :: CMD | e) ReturnCode 20 | setPublic = unsafeField "setPublic" 21 | 22 | toRampart :: forall a. Structure a -> Maybe Rampart 23 | toRampart = unsafeCast structure_rampart 24 | -------------------------------------------------------------------------------- /docs/Screeps/Nuker.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Nuker 2 | 3 | Corresponds to the Screeps API [StructureNuker](http://support.screeps.com/hc/en-us/articles/208488255-StructureNuker) 4 | 5 | #### `energy` 6 | 7 | ``` purescript 8 | energy :: Nuker -> Int 9 | ``` 10 | 11 | #### `energyCapacity` 12 | 13 | ``` purescript 14 | energyCapacity :: Nuker -> Int 15 | ``` 16 | 17 | #### `ghodium` 18 | 19 | ``` purescript 20 | ghodium :: Nuker -> Int 21 | ``` 22 | 23 | #### `ghodiumCapacity` 24 | 25 | ``` purescript 26 | ghodiumCapacity :: Nuker -> Int 27 | ``` 28 | 29 | #### `cooldown` 30 | 31 | ``` purescript 32 | cooldown :: Nuker -> Int 33 | ``` 34 | 35 | #### `launchNuke` 36 | 37 | ``` purescript 38 | launchNuke :: forall e. Nuker -> RoomPosition -> Eff (cmd :: CMD | e) ReturnCode 39 | ``` 40 | 41 | #### `toNuker` 42 | 43 | ``` purescript 44 | toNuker :: forall a. Structure a -> Maybe Nuker 45 | ``` 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/Screeps/ConstructionSite.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.ConstructionSite 2 | 3 | Corresponds to the Screeps API [ConstructionSite](http://support.screeps.com/hc/en-us/articles/203016342-ConstructionSite) 4 | 5 | #### `id` 6 | 7 | ``` purescript 8 | id :: ConstructionSite -> Id ConstructionSite 9 | ``` 10 | 11 | #### `my` 12 | 13 | ``` purescript 14 | my :: ConstructionSite -> Boolean 15 | ``` 16 | 17 | #### `owner` 18 | 19 | ``` purescript 20 | owner :: ConstructionSite -> { username :: String } 21 | ``` 22 | 23 | #### `progress` 24 | 25 | ``` purescript 26 | progress :: ConstructionSite -> Int 27 | ``` 28 | 29 | #### `progressTotal` 30 | 31 | ``` purescript 32 | progressTotal :: ConstructionSite -> Int 33 | ``` 34 | 35 | #### `structureType` 36 | 37 | ``` purescript 38 | structureType :: ConstructionSite -> StructureType 39 | ``` 40 | 41 | #### `remove` 42 | 43 | ``` purescript 44 | remove :: forall e. ConstructionSite -> Eff (cmd :: CMD | e) ReturnCode 45 | ``` 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/Screeps/Terminal.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Terminal 2 | 3 | Corresponds to the Screeps API [StructureTerminal](http://support.screeps.com/hc/en-us/articles/207713399-StructureTerminal) 4 | 5 | #### `Store` 6 | 7 | ``` purescript 8 | data Store :: * 9 | ``` 10 | 11 | #### `store` 12 | 13 | ``` purescript 14 | store :: Terminal -> Store 15 | ``` 16 | 17 | #### `storeGet` 18 | 19 | ``` purescript 20 | storeGet :: Store -> ResourceType -> Int 21 | ``` 22 | 23 | #### `storeCapacity` 24 | 25 | ``` purescript 26 | storeCapacity :: Terminal -> Int 27 | ``` 28 | 29 | #### `send` 30 | 31 | ``` purescript 32 | send :: forall e. Terminal -> ResourceType -> Int -> String -> Eff (cmd :: CMD | e) ReturnCode 33 | ``` 34 | 35 | #### `send'` 36 | 37 | ``` purescript 38 | send' :: forall e. Terminal -> ResourceType -> Int -> String -> String -> Eff (cmd :: CMD | e) ReturnCode 39 | ``` 40 | 41 | #### `toTerminal` 42 | 43 | ``` purescript 44 | toTerminal :: forall a. Structure a -> Maybe Terminal 45 | ``` 46 | 47 | 48 | -------------------------------------------------------------------------------- /docs/Screeps/PowerSpawn.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.PowerSpawn 2 | 3 | Corresponds to the Screeps API [StructurePowerSpawn](http://support.screeps.com/hc/en-us/articles/208436585-StructurePowerSpawn) 4 | 5 | #### `energy` 6 | 7 | ``` purescript 8 | energy :: PowerSpawn -> Int 9 | ``` 10 | 11 | #### `energyCapacity` 12 | 13 | ``` purescript 14 | energyCapacity :: PowerSpawn -> Int 15 | ``` 16 | 17 | #### `power` 18 | 19 | ``` purescript 20 | power :: PowerSpawn -> Int 21 | ``` 22 | 23 | #### `powerCapacity` 24 | 25 | ``` purescript 26 | powerCapacity :: PowerSpawn -> Int 27 | ``` 28 | 29 | #### `createPowerCreep` 30 | 31 | ``` purescript 32 | createPowerCreep :: forall e. PowerSpawn -> String -> Eff (cmd :: CMD | e) ReturnCode 33 | ``` 34 | 35 | #### `processPower` 36 | 37 | ``` purescript 38 | processPower :: forall e. PowerSpawn -> Eff (cmd :: CMD | e) ReturnCode 39 | ``` 40 | 41 | #### `toPowerSpawn` 42 | 43 | ``` purescript 44 | toPowerSpawn :: forall a. Structure a -> Maybe PowerSpawn 45 | ``` 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/Screeps/ConstructionSite.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [ConstructionSite](http://support.screeps.com/hc/en-us/articles/203016342-ConstructionSite) 2 | module Screeps.ConstructionSite where 3 | 4 | import Control.Monad.Eff (Eff) 5 | 6 | import Screeps.Effects (CMD) 7 | import Screeps.Types (ConstructionSite, Id, ReturnCode, StructureType) 8 | import Screeps.FFI (runThisEffFn0, unsafeField) 9 | 10 | id :: ConstructionSite -> Id ConstructionSite 11 | id = unsafeField "id" 12 | 13 | my :: ConstructionSite -> Boolean 14 | my = unsafeField "my" 15 | 16 | owner :: ConstructionSite -> { username :: String } 17 | owner = unsafeField "owner" 18 | 19 | progress :: ConstructionSite -> Int 20 | progress = unsafeField "progress" 21 | 22 | progressTotal :: ConstructionSite -> Int 23 | progressTotal = unsafeField "progressTotal" 24 | 25 | structureType :: ConstructionSite -> StructureType 26 | structureType = unsafeField "structureType" 27 | 28 | remove :: forall e. ConstructionSite -> Eff (cmd :: CMD | e) ReturnCode 29 | remove = runThisEffFn0 "remove" 30 | -------------------------------------------------------------------------------- /docs/Screeps/Controller.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Controller 2 | 3 | Corresponds to the Screeps API [StructureController](http://support.screeps.com/hc/en-us/articles/207711889-StructureController) 4 | 5 | #### `level` 6 | 7 | ``` purescript 8 | level :: Controller -> Int 9 | ``` 10 | 11 | #### `progress` 12 | 13 | ``` purescript 14 | progress :: Controller -> Int 15 | ``` 16 | 17 | #### `progressTotal` 18 | 19 | ``` purescript 20 | progressTotal :: Controller -> Int 21 | ``` 22 | 23 | #### `reservation` 24 | 25 | ``` purescript 26 | reservation :: Controller -> Int 27 | ``` 28 | 29 | #### `ticksToDowngrade` 30 | 31 | ``` purescript 32 | ticksToDowngrade :: Controller -> Int 33 | ``` 34 | 35 | #### `upgradeBlocked` 36 | 37 | ``` purescript 38 | upgradeBlocked :: Controller -> Int 39 | ``` 40 | 41 | #### `unclaim` 42 | 43 | ``` purescript 44 | unclaim :: forall e. Controller -> Eff (cmd :: CMD | e) ReturnCode 45 | ``` 46 | 47 | #### `toController` 48 | 49 | ``` purescript 50 | toController :: forall a. Structure a -> Maybe Controller 51 | ``` 52 | 53 | 54 | -------------------------------------------------------------------------------- /docs/Screeps/Flag.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Flag 2 | 3 | Corresponds to the Screeps API [Flag](http://support.screeps.com/hc/en-us/articles/203079181-Flag) 4 | 5 | #### `color` 6 | 7 | ``` purescript 8 | color :: Flag -> Color 9 | ``` 10 | 11 | #### `memory` 12 | 13 | ``` purescript 14 | memory :: forall a. Flag -> a 15 | ``` 16 | 17 | #### `name` 18 | 19 | ``` purescript 20 | name :: Flag -> String 21 | ``` 22 | 23 | #### `secondaryColor` 24 | 25 | ``` purescript 26 | secondaryColor :: Flag -> Color 27 | ``` 28 | 29 | #### `remove` 30 | 31 | ``` purescript 32 | remove :: forall e. Flag -> Eff (cmd :: CMD | e) ReturnCode 33 | ``` 34 | 35 | #### `setColor` 36 | 37 | ``` purescript 38 | setColor :: forall e. Flag -> Color -> Eff (cmd :: CMD | e) ReturnCode 39 | ``` 40 | 41 | #### `setColors` 42 | 43 | ``` purescript 44 | setColors :: forall e. Flag -> Color -> Color -> Eff (cmd :: CMD | e) ReturnCode 45 | ``` 46 | 47 | #### `setPosition` 48 | 49 | ``` purescript 50 | setPosition :: forall a e. Flag -> TargetPosition a -> Eff (cmd :: CMD | e) ReturnCode 51 | ``` 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/Screeps/Link.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureLink](http://support.screeps.com/hc/en-us/articles/208436275-StructureLink) 2 | module Screeps.Link where 3 | 4 | import Control.Monad.Eff (Eff) 5 | import Data.Maybe (Maybe) 6 | 7 | import Screeps.Constants (structure_link) 8 | import Screeps.Effects (CMD) 9 | import Screeps.FFI (runThisEffFn1, runThisEffFn2, unsafeField) 10 | import Screeps.Structure (unsafeCast) 11 | import Screeps.Types (Link, ReturnCode, Structure) 12 | 13 | cooldown :: Link -> Int 14 | cooldown = unsafeField "cooldown" 15 | 16 | energy :: Link -> Int 17 | energy = unsafeField "energy" 18 | 19 | energyCapacity :: Link -> Int 20 | energyCapacity = unsafeField "energyCapacity" 21 | 22 | transferEnergy :: forall e. Link -> Link -> Eff (cmd :: CMD | e) ReturnCode 23 | transferEnergy = runThisEffFn1 "transferEnergy" 24 | 25 | transferEnergyAmt :: forall e. Link -> Link -> Int -> Eff (cmd :: CMD | e) ReturnCode 26 | transferEnergyAmt = runThisEffFn2 "transferEnergy" 27 | 28 | toLink :: forall a. Structure a -> Maybe Link 29 | toLink = unsafeCast structure_link 30 | -------------------------------------------------------------------------------- /src/Screeps/Nuker.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureNuker](http://support.screeps.com/hc/en-us/articles/208488255-StructureNuker) 2 | module Screeps.Nuker where 3 | 4 | import Control.Monad.Eff (Eff) 5 | import Data.Maybe (Maybe) 6 | 7 | import Screeps.Constants (structure_nuker) 8 | import Screeps.Effects (CMD) 9 | import Screeps.FFI (runThisEffFn1, unsafeField) 10 | import Screeps.Structure (unsafeCast) 11 | import Screeps.Types (Nuker, ReturnCode, RoomPosition, Structure) 12 | 13 | energy :: Nuker -> Int 14 | energy = unsafeField "energy" 15 | 16 | energyCapacity :: Nuker -> Int 17 | energyCapacity = unsafeField "energyCapacity" 18 | 19 | ghodium :: Nuker -> Int 20 | ghodium = unsafeField "ghodium" 21 | 22 | ghodiumCapacity :: Nuker -> Int 23 | ghodiumCapacity = unsafeField "ghodiumCapacity" 24 | 25 | cooldown :: Nuker -> Int 26 | cooldown = unsafeField "cooldown" 27 | 28 | launchNuke :: forall e. Nuker -> RoomPosition -> Eff (cmd :: CMD | e) ReturnCode 29 | launchNuke = runThisEffFn1 "launchNuke" 30 | 31 | toNuker :: forall a. Structure a -> Maybe Nuker 32 | toNuker = unsafeCast structure_nuker 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Nicholas Kariniemi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docs/Screeps/Tower.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Tower 2 | 3 | Corresponds to the Screeps API [StructureTower](http://support.screeps.com/hc/en-us/articles/208437105-StructureTower) 4 | 5 | #### `energy` 6 | 7 | ``` purescript 8 | energy :: Tower -> Int 9 | ``` 10 | 11 | #### `energyCapacity` 12 | 13 | ``` purescript 14 | energyCapacity :: Tower -> Int 15 | ``` 16 | 17 | #### `attack` 18 | 19 | ``` purescript 20 | attack :: forall e. Tower -> Creep -> Eff (cmd :: CMD | e) ReturnCode 21 | ``` 22 | 23 | #### `heal` 24 | 25 | ``` purescript 26 | heal :: forall e. Tower -> Creep -> Eff (cmd :: CMD | e) ReturnCode 27 | ``` 28 | 29 | #### `repair` 30 | 31 | ``` purescript 32 | repair :: forall a e. Tower -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 33 | ``` 34 | 35 | #### `transferEnergy` 36 | 37 | ``` purescript 38 | transferEnergy :: forall e. Tower -> Creep -> Eff (cmd :: CMD | e) ReturnCode 39 | ``` 40 | 41 | #### `transferEnergyAmt` 42 | 43 | ``` purescript 44 | transferEnergyAmt :: forall e. Tower -> Creep -> Int -> Eff (cmd :: CMD | e) ReturnCode 45 | ``` 46 | 47 | #### `toTower` 48 | 49 | ``` purescript 50 | toTower :: forall a. Structure a -> Maybe Tower 51 | ``` 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/Screeps/Controller.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureController](http://support.screeps.com/hc/en-us/articles/207711889-StructureController) 2 | module Screeps.Controller where 3 | 4 | import Data.Maybe (Maybe) 5 | import Control.Monad.Eff (Eff) 6 | 7 | import Screeps.Constants (structure_controller) 8 | import Screeps.Effects (CMD) 9 | import Screeps.FFI (runThisEffFn0, unsafeField) 10 | import Screeps.Structure (unsafeCast) 11 | import Screeps.Types (Controller, ReturnCode, Structure) 12 | 13 | level :: Controller -> Int 14 | level = unsafeField "level" 15 | 16 | progress :: Controller -> Int 17 | progress = unsafeField "progress" 18 | 19 | progressTotal :: Controller -> Int 20 | progressTotal = unsafeField "progressTotal" 21 | 22 | reservation :: Controller -> Int 23 | reservation = unsafeField "reservation" 24 | 25 | ticksToDowngrade :: Controller -> Int 26 | ticksToDowngrade = unsafeField "ticksToDowngrade" 27 | 28 | upgradeBlocked :: Controller -> Int 29 | upgradeBlocked = unsafeField "upgradeBlocked" 30 | 31 | unclaim :: forall e. Controller -> Eff (cmd :: CMD | e) ReturnCode 32 | unclaim = runThisEffFn0 "unclaim" 33 | 34 | toController :: forall a. Structure a -> Maybe Controller 35 | toController = unsafeCast structure_controller 36 | -------------------------------------------------------------------------------- /docs/Screeps/Lab.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Lab 2 | 3 | Corresponds to the Screeps API [StructureLab](http://support.screeps.com/hc/en-us/articles/208436195-StructureLab) 4 | 5 | #### `cooldown` 6 | 7 | ``` purescript 8 | cooldown :: Lab -> Int 9 | ``` 10 | 11 | #### `energy` 12 | 13 | ``` purescript 14 | energy :: Lab -> Int 15 | ``` 16 | 17 | #### `energyCapacity` 18 | 19 | ``` purescript 20 | energyCapacity :: Lab -> Int 21 | ``` 22 | 23 | #### `mineralAmount` 24 | 25 | ``` purescript 26 | mineralAmount :: Lab -> Int 27 | ``` 28 | 29 | #### `mineralType` 30 | 31 | ``` purescript 32 | mineralType :: Lab -> String 33 | ``` 34 | 35 | #### `mineralCapacity` 36 | 37 | ``` purescript 38 | mineralCapacity :: Lab -> Int 39 | ``` 40 | 41 | #### `boostCreep` 42 | 43 | ``` purescript 44 | boostCreep :: forall e. Lab -> Creep -> Eff (cmd :: CMD | e) ReturnCode 45 | ``` 46 | 47 | #### `boostCreep'` 48 | 49 | ``` purescript 50 | boostCreep' :: forall e. Lab -> Creep -> Int -> Eff (cmd :: CMD | e) ReturnCode 51 | ``` 52 | 53 | #### `runReaction` 54 | 55 | ``` purescript 56 | runReaction :: forall e. Lab -> Lab -> Lab -> Eff (cmd :: CMD | e) ReturnCode 57 | ``` 58 | 59 | #### `toLab` 60 | 61 | ``` purescript 62 | toLab :: forall a. Structure a -> Maybe Lab 63 | ``` 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/Screeps/PowerSpawn.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructurePowerSpawn](http://support.screeps.com/hc/en-us/articles/208436585-StructurePowerSpawn) 2 | module Screeps.PowerSpawn where 3 | 4 | import Control.Monad.Eff (Eff) 5 | import Data.Maybe (Maybe) 6 | 7 | import Screeps.Constants (structure_power_spawn) 8 | import Screeps.Effects (CMD) 9 | import Screeps.FFI (runThisEffFn0, runThisEffFn1, unsafeField) 10 | import Screeps.Structure (unsafeCast) 11 | import Screeps.Types (PowerSpawn, ReturnCode, Structure) 12 | 13 | energy :: PowerSpawn -> Int 14 | energy = unsafeField "energy" 15 | 16 | energyCapacity :: PowerSpawn -> Int 17 | energyCapacity = unsafeField "energyCapacity" 18 | 19 | power :: PowerSpawn -> Int 20 | power = unsafeField "power" 21 | 22 | powerCapacity :: PowerSpawn -> Int 23 | powerCapacity = unsafeField "powerCapacity" 24 | 25 | createPowerCreep :: forall e. PowerSpawn -> String -> Eff (cmd :: CMD | e) ReturnCode 26 | createPowerCreep spawn name = runThisEffFn1 "createPowerCreep" spawn name 27 | 28 | processPower :: forall e. PowerSpawn -> Eff (cmd :: CMD | e) ReturnCode 29 | processPower = runThisEffFn0 "processPower" 30 | 31 | toPowerSpawn :: forall a. Structure a -> Maybe PowerSpawn 32 | toPowerSpawn = unsafeCast structure_power_spawn 33 | -------------------------------------------------------------------------------- /docs/Screeps/Structure.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Structure 2 | 3 | Corresponds to the Screeps API [Structure](http://support.screeps.com/hc/en-us/articles/203079221-Structure) 4 | 5 | #### `hits` 6 | 7 | ``` purescript 8 | hits :: forall a. Structure a -> Int 9 | ``` 10 | 11 | #### `hitsMax` 12 | 13 | ``` purescript 14 | hitsMax :: forall a. Structure a -> Int 15 | ``` 16 | 17 | #### `id` 18 | 19 | ``` purescript 20 | id :: forall a. Structure a -> Id (Structure a) 21 | ``` 22 | 23 | #### `structureType` 24 | 25 | ``` purescript 26 | structureType :: forall a. Structure a -> StructureType 27 | ``` 28 | 29 | #### `destroy` 30 | 31 | ``` purescript 32 | destroy :: forall a e. Structure a -> Eff (cmd :: CMD | e) ReturnCode 33 | ``` 34 | 35 | #### `isActive` 36 | 37 | ``` purescript 38 | isActive :: forall a e. Structure a -> Eff (cmd :: CMD | e) Boolean 39 | ``` 40 | 41 | #### `notifyWhenAttacked` 42 | 43 | ``` purescript 44 | notifyWhenAttacked :: forall a e. Structure a -> Boolean -> Eff (cmd :: CMD | e) ReturnCode 45 | ``` 46 | 47 | #### `unsafeCast` 48 | 49 | ``` purescript 50 | unsafeCast :: forall a b. StructureType -> Structure a -> Maybe b 51 | ``` 52 | 53 | #### `asStructure` 54 | 55 | ``` purescript 56 | asStructure :: forall a. Structure a -> Structure Unit 57 | ``` 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/Screeps/Flag.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Flag](http://support.screeps.com/hc/en-us/articles/203079181-Flag) 2 | module Screeps.Flag where 3 | 4 | import Control.Monad.Eff (Eff) 5 | 6 | import Screeps.Effects (CMD) 7 | import Screeps.Types (Color, Flag, ReturnCode, RoomPosition, TargetPosition(..)) 8 | import Screeps.FFI (runThisEffFn0, runThisEffFn1, runThisEffFn2, unsafeField) 9 | 10 | color :: Flag -> Color 11 | color = unsafeField "color" 12 | 13 | memory :: forall a. Flag -> a 14 | memory = unsafeField "memory" 15 | 16 | name :: Flag -> String 17 | name = unsafeField "name" 18 | 19 | secondaryColor :: Flag -> Color 20 | secondaryColor = unsafeField "secondaryColor" 21 | 22 | remove :: forall e. Flag -> Eff (cmd :: CMD | e) ReturnCode 23 | remove = runThisEffFn0 "remove" 24 | 25 | setColor :: forall e. Flag -> Color -> Eff (cmd :: CMD | e) ReturnCode 26 | setColor = runThisEffFn1 "setColor" 27 | 28 | setColors :: forall e. Flag -> Color -> Color -> Eff (cmd :: CMD | e) ReturnCode 29 | setColors = runThisEffFn2 "setColor" 30 | 31 | setPosition :: forall a e. Flag -> TargetPosition a -> Eff (cmd :: CMD | e) ReturnCode 32 | setPosition flag (TargetPt x y) = runThisEffFn2 "setPosition" flag x y 33 | setPosition flag (TargetObj obj) = runThisEffFn1 "setPosition" flag obj 34 | setPosition flag (TargetPos pos) = runThisEffFn1 "setPosition" flag pos 35 | -------------------------------------------------------------------------------- /src/Screeps/Spawn.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | exports.createCreepImpl = function(structure){ 4 | return function(parts){ 5 | return function(left){ 6 | return function(right){ 7 | return function(){ 8 | var result = structure.createCreep(parts); 9 | if(typeof result === "string"){ 10 | return right(result); 11 | } else { 12 | return left(result); 13 | } 14 | } 15 | } 16 | } 17 | } 18 | } 19 | 20 | exports.createCreepPrimeImpl = function(structure){ 21 | return function(parts){ 22 | return function(name){ 23 | return function(memory){ 24 | return function(left){ 25 | return function(right){ 26 | return function(){ 27 | var result = structure.createCreep(parts, name, memory); 28 | if(typeof result === "string"){ 29 | return right(result); 30 | } else { 31 | return left(result); 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Screeps/Terminal.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureTerminal](http://support.screeps.com/hc/en-us/articles/207713399-StructureTerminal) 2 | module Screeps.Terminal where 3 | 4 | import Control.Monad.Eff (Eff) 5 | import Data.Maybe (Maybe) 6 | 7 | import Screeps.Constants (structure_terminal) 8 | import Screeps.Effects (CMD) 9 | import Screeps.FFI (runThisEffFn3, runThisEffFn4, unsafeField) 10 | import Screeps.Structure (unsafeCast) 11 | import Screeps.Types (ResourceType(ResourceType), ReturnCode, Structure, Terminal) 12 | 13 | foreign import data Store :: * 14 | 15 | store :: Terminal -> Store 16 | store = unsafeField "store" 17 | 18 | storeGet :: Store -> ResourceType -> Int 19 | storeGet s (ResourceType res) = unsafeField res s 20 | 21 | storeCapacity :: Terminal -> Int 22 | storeCapacity = unsafeField "storeCapacity" 23 | 24 | send :: forall e. Terminal -> ResourceType -> Int -> String -> Eff ( cmd :: CMD | e) ReturnCode 25 | send term res amount destRoomName = runThisEffFn3 "send" term res amount destRoomName 26 | 27 | send' :: forall e. Terminal -> ResourceType -> Int -> String -> String -> Eff ( cmd :: CMD | e) ReturnCode 28 | send' term res amount destRoomName description = runThisEffFn4 "send" term res amount destRoomName description 29 | 30 | toTerminal :: forall a. Structure a -> Maybe Terminal 31 | toTerminal = unsafeCast structure_terminal 32 | -------------------------------------------------------------------------------- /src/Screeps/Tower.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureTower](http://support.screeps.com/hc/en-us/articles/208437105-StructureTower) 2 | module Screeps.Tower where 3 | 4 | import Control.Monad.Eff (Eff) 5 | import Data.Maybe (Maybe) 6 | 7 | import Screeps.Constants (structure_tower) 8 | import Screeps.Effects (CMD) 9 | import Screeps.Structure (unsafeCast) 10 | import Screeps.Types (Creep, ReturnCode, Structure, Tower) 11 | import Screeps.FFI (runThisEffFn1, runThisEffFn2, unsafeField) 12 | 13 | energy :: Tower -> Int 14 | energy = unsafeField "energy" 15 | 16 | energyCapacity :: Tower -> Int 17 | energyCapacity = unsafeField "energyCapacity" 18 | 19 | attack :: forall e. Tower -> Creep -> Eff ( cmd :: CMD | e) ReturnCode 20 | attack = runThisEffFn1 "attack" 21 | 22 | heal :: forall e. Tower -> Creep -> Eff (cmd :: CMD | e) ReturnCode 23 | heal = runThisEffFn1 "heal" 24 | 25 | repair :: forall a e. Tower -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 26 | repair = runThisEffFn1 "repair" 27 | 28 | transferEnergy :: forall e. Tower -> Creep -> Eff (cmd :: CMD | e) ReturnCode 29 | transferEnergy = runThisEffFn1 "transferEnergy" 30 | 31 | transferEnergyAmt :: forall e. Tower -> Creep -> Int -> Eff (cmd :: CMD | e) ReturnCode 32 | transferEnergyAmt = runThisEffFn2 "transferEnergy" 33 | 34 | toTower :: forall a. Structure a -> Maybe Tower 35 | toTower = unsafeCast structure_tower 36 | -------------------------------------------------------------------------------- /docs/Screeps/Map.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Map 2 | 3 | Corresponds to the Screeps API [Map](http://support.screeps.com/hc/en-us/articles/203079191-Map) 4 | 5 | #### `ExitsInfo` 6 | 7 | ``` purescript 8 | type ExitsInfo = { 1 :: String, 3 :: String, 5 :: String, 7 :: String } 9 | ``` 10 | 11 | #### `RoomRoute` 12 | 13 | ``` purescript 14 | type RoomRoute = Array ExitToRoom 15 | ``` 16 | 17 | #### `ExitToRoom` 18 | 19 | ``` purescript 20 | type ExitToRoom = { exit :: FindType Unit, room :: String } 21 | ``` 22 | 23 | #### `describeExits` 24 | 25 | ``` purescript 26 | describeExits :: String -> Maybe ExitsInfo 27 | ``` 28 | 29 | #### `findExit` 30 | 31 | ``` purescript 32 | findExit :: Room -> Room -> ReturnCode 33 | ``` 34 | 35 | #### `findExit'` 36 | 37 | ``` purescript 38 | findExit' :: String -> String -> ReturnCode 39 | ``` 40 | 41 | #### `findRoute` 42 | 43 | ``` purescript 44 | findRoute :: Room -> Room -> RoomRoute 45 | ``` 46 | 47 | #### `findRoute'` 48 | 49 | ``` purescript 50 | findRoute' :: String -> String -> RoomRoute 51 | ``` 52 | 53 | #### `getRoomLinearDistance` 54 | 55 | ``` purescript 56 | getRoomLinearDistance :: String -> String -> Int 57 | ``` 58 | 59 | #### `getTerrainAt` 60 | 61 | ``` purescript 62 | getTerrainAt :: forall a. TargetPosition a -> String -> Terrain 63 | ``` 64 | 65 | #### `isRoomProtected` 66 | 67 | ``` purescript 68 | isRoomProtected :: String -> Boolean 69 | ``` 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/Screeps/Structure.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Structure](http://support.screeps.com/hc/en-us/articles/203079221-Structure) 2 | module Screeps.Structure where 3 | 4 | import Prelude 5 | import Control.Monad.Eff (Eff) 6 | import Data.Maybe (Maybe(Just, Nothing)) 7 | import Unsafe.Coerce (unsafeCoerce) 8 | 9 | import Screeps.Effects (CMD) 10 | import Screeps.Types (Id, ReturnCode, Structure, StructureType) 11 | import Screeps.FFI (runThisEffFn0, runThisEffFn1, unsafeField) 12 | 13 | hits :: forall a. Structure a -> Int 14 | hits = unsafeField "hits" 15 | 16 | hitsMax :: forall a. Structure a -> Int 17 | hitsMax = unsafeField "hitsMax" 18 | 19 | id :: forall a. Structure a -> Id (Structure a) 20 | id = unsafeField "id" 21 | 22 | structureType :: forall a. Structure a -> StructureType 23 | structureType = unsafeField "structureType" 24 | 25 | destroy :: forall a e. Structure a -> Eff (cmd :: CMD | e) ReturnCode 26 | destroy = runThisEffFn0 "destroy" 27 | 28 | isActive :: forall a e. Structure a -> Eff (cmd :: CMD | e) Boolean 29 | isActive = runThisEffFn0 "isActive" 30 | 31 | notifyWhenAttacked :: forall a e. Structure a -> Boolean -> Eff (cmd :: CMD | e) ReturnCode 32 | notifyWhenAttacked = runThisEffFn1 "notifyWhenAttacked" 33 | 34 | unsafeCast :: forall a b. StructureType -> Structure a -> Maybe b 35 | unsafeCast t struc 36 | | structureType struc == t = Just $ unsafeCoerce struc 37 | | otherwise = Nothing 38 | 39 | asStructure :: forall a. Structure a -> Structure Unit 40 | asStructure = unsafeCoerce 41 | -------------------------------------------------------------------------------- /src/Screeps/Lab.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureLab](http://support.screeps.com/hc/en-us/articles/208436195-StructureLab) 2 | module Screeps.Lab where 3 | 4 | import Control.Monad.Eff (Eff) 5 | import Data.Maybe (Maybe) 6 | 7 | import Screeps.Constants (structure_lab) 8 | import Screeps.Effects (CMD) 9 | import Screeps.FFI (runThisEffFn1, runThisEffFn2, unsafeField) 10 | import Screeps.Structure (unsafeCast) 11 | import Screeps.Types (Creep, Lab, ReturnCode, Structure) 12 | 13 | cooldown :: Lab -> Int 14 | cooldown = unsafeField "cooldown" 15 | 16 | energy :: Lab -> Int 17 | energy = unsafeField "energy" 18 | 19 | energyCapacity :: Lab -> Int 20 | energyCapacity = unsafeField "energyCapacity" 21 | 22 | mineralAmount :: Lab -> Int 23 | mineralAmount = unsafeField "mineralAmount" 24 | 25 | mineralType :: Lab -> String 26 | mineralType = unsafeField "mineralType" 27 | 28 | mineralCapacity :: Lab -> Int 29 | mineralCapacity = unsafeField "mineralCapacity" 30 | 31 | boostCreep :: forall e. Lab -> Creep -> Eff (cmd :: CMD | e) ReturnCode 32 | boostCreep = runThisEffFn1 "boostCreep" 33 | 34 | boostCreep' :: forall e. Lab -> Creep -> Int -> Eff (cmd :: CMD | e) ReturnCode 35 | boostCreep' lab creep bodyPartsCount = runThisEffFn2 "boostCreep" lab creep bodyPartsCount 36 | 37 | runReaction :: forall e. Lab -> Lab -> Lab -> Eff (cmd :: CMD | e) ReturnCode 38 | runReaction lab lab1 lab2 = runThisEffFn2 "runReaction" lab lab1 lab2 39 | 40 | toLab :: forall a. Structure a -> Maybe Lab 41 | toLab = unsafeCast structure_lab 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # purescript-screeps 2 | 3 | PureScript bindings for the [Screeps API](http://support.screeps.com/hc/en-us/articles/203084991-API-Reference). 4 | 5 | 6 | ## Installation 7 | 8 | Install: 9 | 10 | ``` 11 | bower install --save purescript-screeps 12 | ``` 13 | 14 | To deploy your code you need to expose it to Screeps from the exported CommonJS "loop" function and push it to the Screeps servers. If you are using NodeJS and pulp and running the Screeps game from Steam locally, deployment can be done automatically on changes by running `npm run watch:deploy` with the following scripts in your `package.json`: 15 | 16 | ``` 17 | # package.json 18 | { 19 | # ... 20 | "scripts": { 21 | "deploy": "cp output/screepsMain.js ~/.config/Screeps/scripts/screeps.com/default/main.js", 22 | "watch:deploy": "npm run clean && pulp --watch --then \"npm run wrapMain && npm run deploy\" build --to output/main.js", 23 | "wrapMain": "echo 'module.exports.loop = function(){' > output/screepsMain.js && cat output/main.js >> output/screepsMain.js && echo '}' >> output/screepsMain.js" 24 | } 25 | } 26 | ``` 27 | 28 | ## Usage 29 | 30 | Module documentation is [here](https://github.com/nicholaskariniemi/purescript-screeps/tree/master/docs). 31 | 32 | In most cases you will import `Screeps`, which contains all of the major types, and then one or more of the other modules. Most modules correspond directly to a Screeps API class/object. 33 | 34 | ## Status 35 | 36 | * PathFinder API not implemented 37 | * Market API not implemented 38 | * More advanced options and parsing of error types in certain cases not implemented 39 | -------------------------------------------------------------------------------- /src/Screeps/Map.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Map](http://support.screeps.com/hc/en-us/articles/203079191-Map) 2 | module Screeps.Map where 3 | 4 | import Prelude 5 | import Data.Maybe (Maybe) 6 | 7 | import Screeps.Effects (CMD) 8 | import Screeps.Types (FindType, ReturnCode, Room, RoomPosition, TargetPosition(..), Terrain(Terrain)) 9 | import Screeps.FFI (toMaybe, runThisFn1, runThisFn2, runThisFn3) 10 | import Screeps.Game as Game 11 | 12 | type ExitsInfo = 13 | { "1" :: String 14 | , "3" :: String 15 | , "5" :: String 16 | , "7" :: String } 17 | 18 | type RoomRoute = Array ExitToRoom 19 | 20 | type ExitToRoom = 21 | { exit :: FindType Unit 22 | , room :: String } 23 | 24 | describeExits :: String -> Maybe ExitsInfo 25 | describeExits name = toMaybe $ runThisFn1 "describeExits" Game.map name 26 | 27 | -- TODO: options 28 | findExit :: Room -> Room -> ReturnCode 29 | findExit from to = runThisFn2 "findExit" Game.map from to 30 | 31 | findExit' :: String -> String -> ReturnCode 32 | findExit' from to = runThisFn2 "findExit" Game.map from to 33 | 34 | -- TODO: options 35 | -- TODO: handle returning errors 36 | findRoute :: Room -> Room -> RoomRoute 37 | findRoute from to = runThisFn2 "findRoute" Game.map from to 38 | 39 | findRoute' :: String -> String -> RoomRoute 40 | findRoute' from to = runThisFn2 "findRoute" Game.map from to 41 | 42 | getRoomLinearDistance :: String -> String -> Int 43 | getRoomLinearDistance name1 name2 = runThisFn2 "getRoomLinearDistance" Game.map name1 name2 44 | 45 | getTerrainAt :: forall a. TargetPosition a -> String -> Terrain 46 | getTerrainAt (TargetPt x y) roomName = runThisFn3 "getTerrainAt" Game.map x y roomName 47 | getTerrainAt (TargetPos pos) roomName = runThisFn2 "getTerrainAt" Game.map pos roomName 48 | getTerrainAt (TargetObj obj) roomName = runThisFn2 "getTerrainAt" Game.map obj roomName 49 | 50 | isRoomProtected :: String -> Boolean 51 | isRoomProtected roomName = runThisFn1 "isRoomProtected" Game.map roomName 52 | -------------------------------------------------------------------------------- /docs/Screeps/Memory.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Memory 2 | 3 | Corresponds to the Screeps APIs [Memory](http://support.screeps.com/hc/en-us/articles/203084991-API-Reference) and [RawMemory](http://support.screeps.com/hc/en-us/articles/205619121-RawMemory) 4 | 5 | #### `MemoryGlobal` 6 | 7 | ``` purescript 8 | data MemoryGlobal :: * 9 | ``` 10 | 11 | #### `getMemoryGlobal` 12 | 13 | ``` purescript 14 | getMemoryGlobal :: forall e. Eff (tick :: TICK | e) MemoryGlobal 15 | ``` 16 | 17 | #### `RawMemoryGlobal` 18 | 19 | ``` purescript 20 | data RawMemoryGlobal :: * 21 | ``` 22 | 23 | #### `getRawMemoryGlobal` 24 | 25 | ``` purescript 26 | getRawMemoryGlobal :: forall e. Eff (tick :: TICK | e) RawMemoryGlobal 27 | ``` 28 | 29 | #### `get` 30 | 31 | ``` purescript 32 | get :: forall a e. DecodeJson a => MemoryGlobal -> String -> Eff (memory :: MEMORY | e) (Either String a) 33 | ``` 34 | 35 | #### `set` 36 | 37 | ``` purescript 38 | set :: forall a e. EncodeJson a => MemoryGlobal -> String -> a -> Eff (memory :: MEMORY | e) Unit 39 | ``` 40 | 41 | #### `delete` 42 | 43 | ``` purescript 44 | delete :: forall e. MemoryGlobal -> String -> Eff (memory :: MEMORY | e) Unit 45 | ``` 46 | 47 | #### `getRaw` 48 | 49 | ``` purescript 50 | getRaw :: forall a e. DecodeJson a => RawMemoryGlobal -> Eff (memory :: MEMORY | e) (Either String a) 51 | ``` 52 | 53 | #### `getRaw'` 54 | 55 | ``` purescript 56 | getRaw' :: forall e. RawMemoryGlobal -> Eff (memory :: MEMORY | e) String 57 | ``` 58 | 59 | #### `setRaw` 60 | 61 | ``` purescript 62 | setRaw :: forall a e. EncodeJson a => RawMemoryGlobal -> a -> Eff (memory :: MEMORY | e) Unit 63 | ``` 64 | 65 | #### `setRaw'` 66 | 67 | ``` purescript 68 | setRaw' :: forall e. RawMemoryGlobal -> String -> Eff (memory :: MEMORY | e) Unit 69 | ``` 70 | 71 | #### `fromJson` 72 | 73 | ``` purescript 74 | fromJson :: forall a. DecodeJson a => String -> (Either String a) 75 | ``` 76 | 77 | #### `toJson` 78 | 79 | ``` purescript 80 | toJson :: forall a. EncodeJson a => a -> String 81 | ``` 82 | 83 | 84 | -------------------------------------------------------------------------------- /docs/Screeps/Game.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Game 2 | 3 | Corresponds to the Screeps API [Game](http://support.screeps.com/hc/en-us/articles/203016382-Game) 4 | 5 | #### `getGameGlobal` 6 | 7 | ``` purescript 8 | getGameGlobal :: forall e. Eff (tick :: TICK | e) GameGlobal 9 | ``` 10 | 11 | #### `Gcl` 12 | 13 | ``` purescript 14 | type Gcl = { level :: Int, progress :: Int, progressTotal :: Int } 15 | ``` 16 | 17 | #### `Cpu` 18 | 19 | ``` purescript 20 | type Cpu = { limit :: Int, tickLimit :: Int, bucket :: Int } 21 | ``` 22 | 23 | #### `constructionSites` 24 | 25 | ``` purescript 26 | constructionSites :: GameGlobal -> StrMap ConstructionSite 27 | ``` 28 | 29 | #### `cpu` 30 | 31 | ``` purescript 32 | cpu :: GameGlobal -> Cpu 33 | ``` 34 | 35 | #### `creeps` 36 | 37 | ``` purescript 38 | creeps :: GameGlobal -> StrMap Creep 39 | ``` 40 | 41 | #### `flags` 42 | 43 | ``` purescript 44 | flags :: GameGlobal -> StrMap Flag 45 | ``` 46 | 47 | #### `gcl` 48 | 49 | ``` purescript 50 | gcl :: GameGlobal -> Gcl 51 | ``` 52 | 53 | #### `map` 54 | 55 | ``` purescript 56 | map :: GameGlobal -> WorldMap 57 | ``` 58 | 59 | #### `market` 60 | 61 | ``` purescript 62 | market :: GameGlobal -> Market 63 | ``` 64 | 65 | #### `rooms` 66 | 67 | ``` purescript 68 | rooms :: GameGlobal -> StrMap Room 69 | ``` 70 | 71 | #### `spawns` 72 | 73 | ``` purescript 74 | spawns :: GameGlobal -> StrMap Spawn 75 | ``` 76 | 77 | #### `structures` 78 | 79 | ``` purescript 80 | structures :: GameGlobal -> StrMap (Structure Unit) 81 | ``` 82 | 83 | #### `time` 84 | 85 | ``` purescript 86 | time :: GameGlobal -> Int 87 | ``` 88 | 89 | #### `getUsed` 90 | 91 | ``` purescript 92 | getUsed :: forall e. GameGlobal -> Eff (time :: TIME | e) Number 93 | ``` 94 | 95 | #### `getObjectById` 96 | 97 | ``` purescript 98 | getObjectById :: forall a. GameGlobal -> Id a -> Maybe a 99 | ``` 100 | 101 | #### `notify` 102 | 103 | ``` purescript 104 | notify :: forall e. GameGlobal -> String -> Eff (cmd :: CMD | e) Unit 105 | ``` 106 | 107 | #### `notify'` 108 | 109 | ``` purescript 110 | notify' :: forall e. GameGlobal -> String -> Int -> Eff (cmd :: CMD | e) Unit 111 | ``` 112 | 113 | 114 | -------------------------------------------------------------------------------- /src/Screeps/Game.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Game](http://support.screeps.com/hc/en-us/articles/203016382-Game) 2 | module Screeps.Game where 3 | 4 | import Prelude 5 | import Control.Monad.Eff (Eff) 6 | import Data.Maybe (Maybe) 7 | import Data.StrMap as StrMap 8 | 9 | import Screeps.Effects (CMD, TICK, TIME) 10 | import Screeps.Types (ConstructionSite, Creep, Flag, GameGlobal, Id, Market, ReturnCode, Room, Spawn, Structure, WorldMap) 11 | import Screeps.FFI (toMaybe, runThisEffFn0, runThisEffFn1, runThisEffFn2, runThisFn0, runThisFn1, unsafeField) 12 | 13 | foreign import getGameGlobal :: forall e. Eff (tick :: TICK | e) GameGlobal 14 | 15 | type Gcl = 16 | { level :: Int 17 | , progress :: Int 18 | , progressTotal :: Int } 19 | 20 | type Cpu = 21 | { limit :: Int 22 | , tickLimit :: Int 23 | , bucket :: Int } 24 | 25 | constructionSites :: GameGlobal -> StrMap.StrMap ConstructionSite 26 | constructionSites = unsafeField "constructionSites" 27 | 28 | cpu :: GameGlobal -> Cpu 29 | cpu = unsafeField "cpu" 30 | 31 | creeps :: GameGlobal -> StrMap.StrMap Creep 32 | creeps = unsafeField "creeps" 33 | 34 | flags :: GameGlobal -> StrMap.StrMap Flag 35 | flags = unsafeField "flags" 36 | 37 | gcl :: GameGlobal -> Gcl 38 | gcl = unsafeField "gcl" 39 | 40 | map :: GameGlobal -> WorldMap 41 | map = unsafeField "map" 42 | 43 | market :: GameGlobal -> Market 44 | market = unsafeField "market" 45 | 46 | rooms :: GameGlobal -> StrMap.StrMap Room 47 | rooms = unsafeField "rooms" 48 | 49 | spawns :: GameGlobal -> StrMap.StrMap Spawn 50 | spawns = unsafeField "spawns" 51 | 52 | structures :: GameGlobal -> StrMap.StrMap (Structure Unit) 53 | structures = unsafeField "structures" 54 | 55 | time :: GameGlobal -> Int 56 | time = unsafeField "time" 57 | 58 | getUsed :: forall e. GameGlobal -> Eff (time :: TIME | e) Number 59 | getUsed game = runThisEffFn0 "getUsed" (cpu game) 60 | 61 | getObjectById :: forall a. GameGlobal -> Id a -> Maybe a 62 | getObjectById game id = toMaybe $ runThisFn1 "getObjectById" game id 63 | 64 | notify :: forall e. GameGlobal -> String -> Eff (cmd :: CMD | e) Unit 65 | notify game msg = runThisEffFn1 "notify" game msg 66 | 67 | notify' :: forall e. GameGlobal -> String -> Int -> Eff (cmd :: CMD | e) Unit 68 | notify' game msg groupInterval = runThisEffFn2 "notify" game msg groupInterval 69 | -------------------------------------------------------------------------------- /src/Screeps/Memory.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps APIs [Memory](http://support.screeps.com/hc/en-us/articles/203084991-API-Reference) and [RawMemory](http://support.screeps.com/hc/en-us/articles/205619121-RawMemory) 2 | module Screeps.Memory where 3 | 4 | import Prelude 5 | import Data.Argonaut.Decode (class DecodeJson, decodeJson) 6 | import Data.Argonaut.Encode (class EncodeJson, encodeJson) 7 | import Data.Argonaut.Parser (jsonParser) 8 | import Data.Argonaut.Printer (printJson) 9 | import Data.Either (Either) 10 | import Control.Monad.Eff (Eff) 11 | 12 | import Screeps.Effects (MEMORY, TICK) 13 | import Screeps.FFI (runThisEffFn0, runThisEffFn1, unsafeGetFieldEff, unsafeSetFieldEff, unsafeDeleteFieldEff) 14 | 15 | foreign import data MemoryGlobal :: * 16 | foreign import getMemoryGlobal :: forall e. Eff (tick :: TICK | e) MemoryGlobal 17 | 18 | foreign import data RawMemoryGlobal :: * 19 | foreign import getRawMemoryGlobal :: forall e. Eff (tick :: TICK | e) RawMemoryGlobal 20 | 21 | get :: forall a e. (DecodeJson a) => MemoryGlobal -> String -> Eff ( memory :: MEMORY | e ) (Either String a) 22 | get memoryGlobal key = decodeJson <$> unsafeGetFieldEff key memoryGlobal 23 | 24 | set :: forall a e. (EncodeJson a) => MemoryGlobal -> String -> a -> Eff ( memory :: MEMORY | e ) Unit 25 | set memoryGlobal key val = unsafeSetFieldEff key memoryGlobal (encodeJson val) 26 | 27 | delete :: forall e. MemoryGlobal -> String -> Eff ( memory :: MEMORY | e ) Unit 28 | delete memoryGlobal key = unsafeDeleteFieldEff key memoryGlobal 29 | 30 | getRaw :: forall a e. (DecodeJson a) => RawMemoryGlobal -> Eff ( memory :: MEMORY | e) (Either String a) 31 | getRaw rawMemoryGlobal = fromJson <$> runThisEffFn0 "get" rawMemoryGlobal 32 | 33 | getRaw' :: forall e. RawMemoryGlobal -> Eff ( memory :: MEMORY | e) String 34 | getRaw' rawMemoryGlobal = runThisEffFn0 "get" rawMemoryGlobal 35 | 36 | setRaw :: forall a e. (EncodeJson a) => RawMemoryGlobal -> a -> Eff ( memory :: MEMORY | e) Unit 37 | setRaw rawMemoryGlobal memory = runThisEffFn1 "set" rawMemoryGlobal (toJson memory) 38 | 39 | setRaw' :: forall e. RawMemoryGlobal -> String -> Eff ( memory :: MEMORY | e) Unit 40 | setRaw' = runThisEffFn1 "set" 41 | 42 | fromJson :: forall a. (DecodeJson a) => String -> (Either String a) 43 | fromJson jsonStr = jsonParser jsonStr >>= decodeJson 44 | 45 | toJson :: forall a. (EncodeJson a) => a -> String 46 | toJson = printJson <<< encodeJson 47 | -------------------------------------------------------------------------------- /docs/Screeps/Spawn.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Spawn 2 | 3 | Corresponds to the Screeps API [StructureSpawn](http://support.screeps.com/hc/en-us/articles/205990342-StructureSpawn) 4 | 5 | #### `CreepInfo` 6 | 7 | ``` purescript 8 | type CreepInfo = { name :: String, needTime :: Int, remainingTime :: Int } 9 | ``` 10 | 11 | #### `energy` 12 | 13 | ``` purescript 14 | energy :: Spawn -> Int 15 | ``` 16 | 17 | #### `energyCapacity` 18 | 19 | ``` purescript 20 | energyCapacity :: Spawn -> Int 21 | ``` 22 | 23 | #### `memory` 24 | 25 | ``` purescript 26 | memory :: forall props. Spawn -> { | props } 27 | ``` 28 | 29 | #### `name` 30 | 31 | ``` purescript 32 | name :: Spawn -> String 33 | ``` 34 | 35 | #### `spawning` 36 | 37 | ``` purescript 38 | spawning :: Spawn -> Maybe CreepInfo 39 | ``` 40 | 41 | #### `canCreateCreep` 42 | 43 | ``` purescript 44 | canCreateCreep :: Spawn -> Array BodyPartType -> ReturnCode 45 | ``` 46 | 47 | #### `canCreateCreep'` 48 | 49 | ``` purescript 50 | canCreateCreep' :: forall e. Spawn -> Array BodyPartType -> String -> Eff (cmd :: CMD | e) ReturnCode 51 | ``` 52 | 53 | #### `createCreepImpl` 54 | 55 | ``` purescript 56 | createCreepImpl :: forall e. Spawn -> Array BodyPartType -> (ReturnCode -> Either ReturnCode String) -> (String -> Either ReturnCode String) -> Eff (cmd :: CMD | e) (Either ReturnCode String) 57 | ``` 58 | 59 | #### `createCreepPrimeImpl` 60 | 61 | ``` purescript 62 | createCreepPrimeImpl :: forall e mem. Spawn -> Array BodyPartType -> NullOrUndefined String -> mem -> (ReturnCode -> Either ReturnCode String) -> (String -> Either ReturnCode String) -> Eff (cmd :: CMD | e) (Either ReturnCode String) 63 | ``` 64 | 65 | #### `createCreep` 66 | 67 | ``` purescript 68 | createCreep :: forall e. Spawn -> Array BodyPartType -> Eff (cmd :: CMD | e) (Either ReturnCode String) 69 | ``` 70 | 71 | #### `createCreep'` 72 | 73 | ``` purescript 74 | createCreep' :: forall mem e. EncodeJson mem => Spawn -> Array BodyPartType -> Maybe String -> mem -> Eff (cmd :: CMD | e) (Either ReturnCode String) 75 | ``` 76 | 77 | #### `recycleCreep` 78 | 79 | ``` purescript 80 | recycleCreep :: forall e. Spawn -> Creep -> Eff (cmd :: CMD | e) ReturnCode 81 | ``` 82 | 83 | #### `renewCreep` 84 | 85 | ``` purescript 86 | renewCreep :: forall e. Spawn -> Creep -> Eff (cmd :: CMD | e) ReturnCode 87 | ``` 88 | 89 | #### `toSpawn` 90 | 91 | ``` purescript 92 | toSpawn :: forall a. Structure a -> Maybe Spawn 93 | ``` 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/Screeps/Spawn.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [StructureSpawn](http://support.screeps.com/hc/en-us/articles/205990342-StructureSpawn) 2 | module Screeps.Spawn where 3 | 4 | import Prelude 5 | import Control.Monad.Eff (Eff) 6 | import Data.Argonaut.Encode (class EncodeJson, encodeJson) 7 | import Data.Either (Either(Left, Right)) 8 | import Data.Maybe (Maybe) 9 | 10 | import Screeps.Constants (structure_spawn) 11 | import Screeps.Effects (CMD) 12 | import Screeps.Structure (unsafeCast) 13 | import Screeps.Types (BodyPartType, Creep, ReturnCode, Spawn, Structure) 14 | import Screeps.FFI (NullOrUndefined, runThisEffFn1, runThisEffFn2, runThisFn1, toMaybe, toNullable, unsafeField) 15 | 16 | type CreepInfo = 17 | { name :: String 18 | , needTime :: Int 19 | , remainingTime :: Int } 20 | 21 | energy :: Spawn -> Int 22 | energy = unsafeField "energy" 23 | 24 | energyCapacity :: Spawn -> Int 25 | energyCapacity = unsafeField "energyCapacity" 26 | 27 | memory :: forall props. Spawn -> { | props } 28 | memory = unsafeField "memory" 29 | 30 | name :: Spawn -> String 31 | name = unsafeField "name" 32 | 33 | spawning :: Spawn -> Maybe CreepInfo 34 | spawning spawn = toMaybe $ unsafeField "spawning" spawn 35 | 36 | canCreateCreep :: Spawn -> Array BodyPartType -> ReturnCode 37 | canCreateCreep spawn parts = runThisFn1 "canCreateCreep" spawn parts 38 | 39 | canCreateCreep' :: forall e. Spawn -> Array BodyPartType -> String -> Eff (cmd :: CMD | e) ReturnCode 40 | canCreateCreep' spawn parts name' = runThisEffFn2 "canCreateCreep" spawn parts name' 41 | 42 | foreign import createCreepImpl :: forall e. 43 | Spawn -> 44 | Array BodyPartType -> 45 | (ReturnCode -> Either ReturnCode String) -> 46 | (String -> Either ReturnCode String) -> 47 | Eff (cmd :: CMD | e) (Either ReturnCode String) 48 | foreign import createCreepPrimeImpl :: forall e mem. 49 | Spawn -> 50 | Array BodyPartType -> 51 | NullOrUndefined String -> 52 | mem -> 53 | (ReturnCode -> Either ReturnCode String) -> 54 | (String -> Either ReturnCode String) -> 55 | Eff (cmd :: CMD | e) (Either ReturnCode String) 56 | 57 | createCreep :: forall e. Spawn -> Array BodyPartType -> Eff (cmd :: CMD | e) (Either ReturnCode String) 58 | createCreep spawn parts = createCreepImpl spawn parts Left Right 59 | 60 | createCreep' :: forall mem e. (EncodeJson mem) => Spawn -> Array BodyPartType -> Maybe String -> mem -> Eff (cmd :: CMD | e) (Either ReturnCode String) 61 | createCreep' spawn parts name' mem = createCreepPrimeImpl spawn parts (toNullable name') (encodeJson mem) Left Right 62 | 63 | recycleCreep :: forall e. Spawn -> Creep -> Eff (cmd :: CMD | e) ReturnCode 64 | recycleCreep = runThisEffFn1 "recycleCreep" 65 | 66 | renewCreep :: forall e. Spawn -> Creep -> Eff (cmd :: CMD | e) ReturnCode 67 | renewCreep = runThisEffFn1 "renewCreep" 68 | 69 | toSpawn :: forall a. Structure a -> Maybe Spawn 70 | toSpawn = unsafeCast structure_spawn 71 | -------------------------------------------------------------------------------- /src/Screeps/FFI.purs: -------------------------------------------------------------------------------- 1 | -- | Internal helper module for JavaScript FFI 2 | module Screeps.FFI where 3 | 4 | import Prelude 5 | import Control.Monad.Eff (Eff) 6 | import Data.Maybe (Maybe(Just, Nothing), isJust, fromJust, maybe) 7 | import Data.Function.Uncurried (Fn3, runFn3) 8 | import Partial.Unsafe (unsafePartial) 9 | 10 | foreign import unsafeField :: forall obj val. String -> obj -> val 11 | foreign import unsafeGetFieldEff :: forall obj val eff. String -> obj -> Eff eff val 12 | foreign import unsafeSetFieldEff :: forall obj val eff. String -> obj -> val -> Eff eff Unit 13 | foreign import unsafeDeleteFieldEff :: forall obj eff. String -> obj -> Eff eff Unit 14 | foreign import runThisEffFn0 :: forall eff this a. String -> this -> Eff eff a 15 | foreign import runThisEffFn1 :: forall eff this a b. String -> this -> a -> Eff eff b 16 | foreign import runThisEffFn2 :: forall eff this a b c. String -> this -> a -> b -> Eff eff c 17 | foreign import runThisEffFn3 :: forall eff this a b c d. String -> this -> a -> b -> c -> Eff eff d 18 | foreign import runThisEffFn4 :: forall eff this a b c d e. String -> this -> a -> b -> c -> d -> Eff eff e 19 | foreign import runThisEffFn5 :: forall eff this a b c d e f. String -> this -> a -> b -> c -> d -> e -> Eff eff f 20 | foreign import runThisEffFn6 :: forall eff this a b c d e f g. String -> this -> a -> b -> c -> d -> e -> f -> Eff eff g 21 | foreign import runThisFn0 :: forall this a. String -> this -> a 22 | foreign import runThisFn1 :: forall this a b. String -> this -> a -> b 23 | foreign import runThisFn2 :: forall this a b c. String -> this -> a -> b -> c 24 | foreign import runThisFn3 :: forall this a b c d. String -> this -> a -> b -> c -> d 25 | foreign import runThisFn4 :: forall this a b c d e. String -> this -> a -> b -> c -> d -> e 26 | foreign import runThisFn5 :: forall this a b c d e f. String -> this -> a -> b -> c -> d -> e -> f 27 | foreign import runThisFn6 :: forall this a b c d e f g. String -> this -> a -> b -> c -> d -> e -> f -> g 28 | 29 | foreign import data NullOrUndefined :: * -> * 30 | foreign import null :: forall a. NullOrUndefined a 31 | foreign import undefined :: forall a. NullOrUndefined a 32 | foreign import notNullOrUndefined :: forall a. a -> NullOrUndefined a 33 | foreign import isNull :: forall a. NullOrUndefined a -> Boolean 34 | foreign import isUndefined :: forall a. NullOrUndefined a -> Boolean 35 | foreign import toMaybeImpl :: forall a m. Fn3 (NullOrUndefined a) m (a -> m) m 36 | 37 | toMaybe :: forall a. NullOrUndefined a -> Maybe a 38 | toMaybe n = runFn3 toMaybeImpl n Nothing Just 39 | 40 | toNullable :: forall a. Maybe a -> NullOrUndefined a 41 | toNullable = maybe null notNullOrUndefined 42 | 43 | toUndefinable :: forall a. Maybe a -> NullOrUndefined a 44 | toUndefinable = maybe undefined notNullOrUndefined 45 | 46 | foreign import data JsObject :: * 47 | foreign import selectMaybesImpl :: forall a. (Maybe a -> Boolean) -> (Maybe a -> a) -> a -> JsObject 48 | 49 | selectMaybes :: forall a. a -> JsObject 50 | selectMaybes obj = unsafePartial $ selectMaybesImpl isJust fromJust obj 51 | -------------------------------------------------------------------------------- /docs/Screeps/Room.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Room 2 | 3 | Corresponds to the Screeps API [Room](http://support.screeps.com/hc/en-us/articles/203079011-Room) 4 | 5 | #### `RoomGlobal` 6 | 7 | ``` purescript 8 | data RoomGlobal :: * 9 | ``` 10 | 11 | #### `getRoomGlobal` 12 | 13 | ``` purescript 14 | getRoomGlobal :: forall e. Eff (tick :: TICK | e) RoomGlobal 15 | ``` 16 | 17 | #### `PathOptions` 18 | 19 | ``` purescript 20 | type PathOptions o = { ignoreCreeps :: Maybe Boolean, ignoreDestructibleStructures :: Maybe Boolean, ignoreRoads :: Maybe Boolean, ignore :: Maybe (Array RoomPosition), avoid :: Maybe (Array RoomPosition), maxOps :: Maybe Int, heuristicWeight :: Maybe Number, serialize :: Maybe Boolean, maxRooms :: Maybe Int | o } 21 | ``` 22 | 23 | #### `pathOpts` 24 | 25 | ``` purescript 26 | pathOpts :: PathOptions () 27 | ``` 28 | 29 | #### `controller` 30 | 31 | ``` purescript 32 | controller :: Room -> Maybe Controller 33 | ``` 34 | 35 | #### `energyAvailable` 36 | 37 | ``` purescript 38 | energyAvailable :: Room -> Int 39 | ``` 40 | 41 | #### `energyCapacityAvailable` 42 | 43 | ``` purescript 44 | energyCapacityAvailable :: Room -> Int 45 | ``` 46 | 47 | #### `memory` 48 | 49 | ``` purescript 50 | memory :: forall props. Room -> { | props } 51 | ``` 52 | 53 | #### `mode` 54 | 55 | ``` purescript 56 | mode :: Room -> Mode 57 | ``` 58 | 59 | #### `name` 60 | 61 | ``` purescript 62 | name :: Room -> String 63 | ``` 64 | 65 | #### `storage` 66 | 67 | ``` purescript 68 | storage :: Room -> Maybe Storage 69 | ``` 70 | 71 | #### `terminal` 72 | 73 | ``` purescript 74 | terminal :: Room -> Maybe Terminal 75 | ``` 76 | 77 | #### `serializePath` 78 | 79 | ``` purescript 80 | serializePath :: RoomGlobal -> Path -> String 81 | ``` 82 | 83 | #### `deserializePath` 84 | 85 | ``` purescript 86 | deserializePath :: RoomGlobal -> String -> Path 87 | ``` 88 | 89 | #### `createConstructionSite` 90 | 91 | ``` purescript 92 | createConstructionSite :: forall a e. Room -> TargetPosition a -> StructureType -> Eff (cmd :: CMD | e) ReturnCode 93 | ``` 94 | 95 | #### `createFlag` 96 | 97 | ``` purescript 98 | createFlag :: forall a e. Room -> TargetPosition a -> Eff (cmd :: CMD | e) ReturnCode 99 | ``` 100 | 101 | #### `createFlagWithName` 102 | 103 | ``` purescript 104 | createFlagWithName :: forall a e. Room -> TargetPosition a -> String -> Eff (cmd :: CMD | e) ReturnCode 105 | ``` 106 | 107 | #### `createFlagWithColor` 108 | 109 | ``` purescript 110 | createFlagWithColor :: forall a e. Room -> TargetPosition a -> String -> Color -> Eff (cmd :: CMD | e) ReturnCode 111 | ``` 112 | 113 | #### `createFlagWithColors` 114 | 115 | ``` purescript 116 | createFlagWithColors :: forall a e. Room -> TargetPosition a -> String -> Color -> Color -> Eff (cmd :: CMD | e) ReturnCode 117 | ``` 118 | 119 | #### `find` 120 | 121 | ``` purescript 122 | find :: forall a. Room -> FindType a -> Array a 123 | ``` 124 | 125 | #### `find'` 126 | 127 | ``` purescript 128 | find' :: forall a. Room -> FindType a -> FilterFn a -> Array a 129 | ``` 130 | 131 | #### `RoomIdentifier` 132 | 133 | ``` purescript 134 | data RoomIdentifier 135 | = RoomName String 136 | | RoomObj Room 137 | ``` 138 | 139 | #### `findExitToImpl` 140 | 141 | ``` purescript 142 | findExitToImpl :: forall a. Room -> a -> (ReturnCode -> Either ReturnCode (FindType RoomPosition)) -> (FindType RoomPosition -> Either ReturnCode (FindType RoomPosition)) -> Either ReturnCode (FindType RoomPosition) 143 | ``` 144 | 145 | #### `findExitTo` 146 | 147 | ``` purescript 148 | findExitTo :: Room -> RoomIdentifier -> Either ReturnCode (FindType RoomPosition) 149 | ``` 150 | 151 | #### `findPath` 152 | 153 | ``` purescript 154 | findPath :: Room -> RoomPosition -> RoomPosition -> Path 155 | ``` 156 | 157 | #### `findPath'` 158 | 159 | ``` purescript 160 | findPath' :: forall o. Room -> RoomPosition -> RoomPosition -> PathOptions o -> Path 161 | ``` 162 | 163 | #### `getPositionAt` 164 | 165 | ``` purescript 166 | getPositionAt :: Room -> Int -> Int -> RoomPosition 167 | ``` 168 | 169 | #### `lookForAt` 170 | 171 | ``` purescript 172 | lookForAt :: forall a. Room -> LookType a -> TargetPosition a -> Array a 173 | ``` 174 | 175 | 176 | -------------------------------------------------------------------------------- /docs/Screeps/FFI.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.FFI 2 | 3 | Internal helper module for JavaScript FFI 4 | 5 | #### `unsafeField` 6 | 7 | ``` purescript 8 | unsafeField :: forall obj val. String -> obj -> val 9 | ``` 10 | 11 | #### `unsafeGetFieldEff` 12 | 13 | ``` purescript 14 | unsafeGetFieldEff :: forall obj val eff. String -> obj -> Eff eff val 15 | ``` 16 | 17 | #### `unsafeSetFieldEff` 18 | 19 | ``` purescript 20 | unsafeSetFieldEff :: forall obj val eff. String -> obj -> val -> Eff eff Unit 21 | ``` 22 | 23 | #### `unsafeDeleteFieldEff` 24 | 25 | ``` purescript 26 | unsafeDeleteFieldEff :: forall obj eff. String -> obj -> Eff eff Unit 27 | ``` 28 | 29 | #### `runThisEffFn0` 30 | 31 | ``` purescript 32 | runThisEffFn0 :: forall eff this a. String -> this -> Eff eff a 33 | ``` 34 | 35 | #### `runThisEffFn1` 36 | 37 | ``` purescript 38 | runThisEffFn1 :: forall eff this a b. String -> this -> a -> Eff eff b 39 | ``` 40 | 41 | #### `runThisEffFn2` 42 | 43 | ``` purescript 44 | runThisEffFn2 :: forall eff this a b c. String -> this -> a -> b -> Eff eff c 45 | ``` 46 | 47 | #### `runThisEffFn3` 48 | 49 | ``` purescript 50 | runThisEffFn3 :: forall eff this a b c d. String -> this -> a -> b -> c -> Eff eff d 51 | ``` 52 | 53 | #### `runThisEffFn4` 54 | 55 | ``` purescript 56 | runThisEffFn4 :: forall eff this a b c d e. String -> this -> a -> b -> c -> d -> Eff eff e 57 | ``` 58 | 59 | #### `runThisEffFn5` 60 | 61 | ``` purescript 62 | runThisEffFn5 :: forall eff this a b c d e f. String -> this -> a -> b -> c -> d -> e -> Eff eff f 63 | ``` 64 | 65 | #### `runThisEffFn6` 66 | 67 | ``` purescript 68 | runThisEffFn6 :: forall eff this a b c d e f g. String -> this -> a -> b -> c -> d -> e -> f -> Eff eff g 69 | ``` 70 | 71 | #### `runThisFn0` 72 | 73 | ``` purescript 74 | runThisFn0 :: forall this a. String -> this -> a 75 | ``` 76 | 77 | #### `runThisFn1` 78 | 79 | ``` purescript 80 | runThisFn1 :: forall this a b. String -> this -> a -> b 81 | ``` 82 | 83 | #### `runThisFn2` 84 | 85 | ``` purescript 86 | runThisFn2 :: forall this a b c. String -> this -> a -> b -> c 87 | ``` 88 | 89 | #### `runThisFn3` 90 | 91 | ``` purescript 92 | runThisFn3 :: forall this a b c d. String -> this -> a -> b -> c -> d 93 | ``` 94 | 95 | #### `runThisFn4` 96 | 97 | ``` purescript 98 | runThisFn4 :: forall this a b c d e. String -> this -> a -> b -> c -> d -> e 99 | ``` 100 | 101 | #### `runThisFn5` 102 | 103 | ``` purescript 104 | runThisFn5 :: forall this a b c d e f. String -> this -> a -> b -> c -> d -> e -> f 105 | ``` 106 | 107 | #### `runThisFn6` 108 | 109 | ``` purescript 110 | runThisFn6 :: forall this a b c d e f g. String -> this -> a -> b -> c -> d -> e -> f -> g 111 | ``` 112 | 113 | #### `NullOrUndefined` 114 | 115 | ``` purescript 116 | data NullOrUndefined :: * -> * 117 | ``` 118 | 119 | #### `null` 120 | 121 | ``` purescript 122 | null :: forall a. NullOrUndefined a 123 | ``` 124 | 125 | #### `undefined` 126 | 127 | ``` purescript 128 | undefined :: forall a. NullOrUndefined a 129 | ``` 130 | 131 | #### `notNullOrUndefined` 132 | 133 | ``` purescript 134 | notNullOrUndefined :: forall a. a -> NullOrUndefined a 135 | ``` 136 | 137 | #### `isNull` 138 | 139 | ``` purescript 140 | isNull :: forall a. NullOrUndefined a -> Boolean 141 | ``` 142 | 143 | #### `isUndefined` 144 | 145 | ``` purescript 146 | isUndefined :: forall a. NullOrUndefined a -> Boolean 147 | ``` 148 | 149 | #### `toMaybeImpl` 150 | 151 | ``` purescript 152 | toMaybeImpl :: forall a m. Fn3 (NullOrUndefined a) m (a -> m) m 153 | ``` 154 | 155 | #### `toMaybe` 156 | 157 | ``` purescript 158 | toMaybe :: forall a. NullOrUndefined a -> Maybe a 159 | ``` 160 | 161 | #### `toNullable` 162 | 163 | ``` purescript 164 | toNullable :: forall a. Maybe a -> NullOrUndefined a 165 | ``` 166 | 167 | #### `toUndefinable` 168 | 169 | ``` purescript 170 | toUndefinable :: forall a. Maybe a -> NullOrUndefined a 171 | ``` 172 | 173 | #### `JsObject` 174 | 175 | ``` purescript 176 | data JsObject :: * 177 | ``` 178 | 179 | #### `selectMaybesImpl` 180 | 181 | ``` purescript 182 | selectMaybesImpl :: forall a. (Maybe a -> Boolean) -> (Maybe a -> a) -> a -> JsObject 183 | ``` 184 | 185 | #### `selectMaybes` 186 | 187 | ``` purescript 188 | selectMaybes :: forall a. a -> JsObject 189 | ``` 190 | 191 | 192 | -------------------------------------------------------------------------------- /docs/Screeps/RoomPosition.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.RoomPosition 2 | 3 | Corresponds to the Screeps API [RoomPosition](http://support.screeps.com/hc/en-us/articles/203079201-RoomPosition) 4 | 5 | #### `mkRoomPosition` 6 | 7 | ``` purescript 8 | mkRoomPosition :: Int -> Int -> String -> RoomPosition 9 | ``` 10 | 11 | #### `tryPure` 12 | 13 | ``` purescript 14 | tryPure :: forall a. Eff (err :: EXCEPTION) a -> Either Error a 15 | ``` 16 | 17 | #### `ClosestPathOptions` 18 | 19 | ``` purescript 20 | type ClosestPathOptions = PathOptions (filter :: Maybe (forall a. a -> Boolean), algorithm :: Maybe FindAlgorithm) 21 | ``` 22 | 23 | #### `FindAlgorithm` 24 | 25 | ``` purescript 26 | newtype FindAlgorithm 27 | = FindAlgorithm String 28 | ``` 29 | 30 | #### `algorithmAstar` 31 | 32 | ``` purescript 33 | algorithmAstar :: FindAlgorithm 34 | ``` 35 | 36 | #### `algorithmDijkstra` 37 | 38 | ``` purescript 39 | algorithmDijkstra :: FindAlgorithm 40 | ``` 41 | 42 | #### `closestPathOpts` 43 | 44 | ``` purescript 45 | closestPathOpts :: ClosestPathOptions 46 | ``` 47 | 48 | #### `unwrapContext` 49 | 50 | ``` purescript 51 | unwrapContext :: forall a b. FindContext a -> b 52 | ``` 53 | 54 | #### `roomName` 55 | 56 | ``` purescript 57 | roomName :: RoomPosition -> String 58 | ``` 59 | 60 | #### `x` 61 | 62 | ``` purescript 63 | x :: RoomPosition -> Int 64 | ``` 65 | 66 | #### `y` 67 | 68 | ``` purescript 69 | y :: RoomPosition -> Int 70 | ``` 71 | 72 | #### `createConstructionSite` 73 | 74 | ``` purescript 75 | createConstructionSite :: forall e. RoomPosition -> StructureType -> Eff (cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 76 | ``` 77 | 78 | #### `createFlag` 79 | 80 | ``` purescript 81 | createFlag :: forall e. RoomPosition -> Eff (cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 82 | ``` 83 | 84 | #### `createFlagWithName` 85 | 86 | ``` purescript 87 | createFlagWithName :: forall e. RoomPosition -> String -> Eff (cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 88 | ``` 89 | 90 | #### `createFlagWithColor` 91 | 92 | ``` purescript 93 | createFlagWithColor :: forall e. RoomPosition -> String -> Color -> Eff (cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 94 | ``` 95 | 96 | #### `createFlagWithColors` 97 | 98 | ``` purescript 99 | createFlagWithColors :: forall e. RoomPosition -> String -> Color -> Color -> Eff (cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 100 | ``` 101 | 102 | #### `findClosestByPath` 103 | 104 | ``` purescript 105 | findClosestByPath :: forall a. RoomPosition -> FindContext a -> Either Error (Maybe a) 106 | ``` 107 | 108 | #### `findClosestByPath'` 109 | 110 | ``` purescript 111 | findClosestByPath' :: forall a. RoomPosition -> FindContext a -> ClosestPathOptions -> Either Error (Maybe a) 112 | ``` 113 | 114 | #### `findClosestByRange` 115 | 116 | ``` purescript 117 | findClosestByRange :: forall a. RoomPosition -> FindContext a -> Either Error (Maybe a) 118 | ``` 119 | 120 | #### `findClosestByRange'` 121 | 122 | ``` purescript 123 | findClosestByRange' :: forall a. RoomPosition -> FindContext a -> FilterFn a -> Either Error (Maybe a) 124 | ``` 125 | 126 | #### `findInRange` 127 | 128 | ``` purescript 129 | findInRange :: forall a. RoomPosition -> FindContext a -> Int -> Either Error (Array a) 130 | ``` 131 | 132 | #### `findInRange'` 133 | 134 | ``` purescript 135 | findInRange' :: forall a. RoomPosition -> FindContext a -> Int -> FilterFn a -> Either Error (Array a) 136 | ``` 137 | 138 | #### `findPathTo` 139 | 140 | ``` purescript 141 | findPathTo :: forall a. RoomPosition -> TargetPosition a -> Either Error Path 142 | ``` 143 | 144 | #### `findPathTo'` 145 | 146 | ``` purescript 147 | findPathTo' :: forall a. RoomPosition -> TargetPosition a -> PathOptions () -> Either Error Path 148 | ``` 149 | 150 | #### `getDirectionTo` 151 | 152 | ``` purescript 153 | getDirectionTo :: forall a. RoomPosition -> TargetPosition a -> Direction 154 | ``` 155 | 156 | #### `getRangeTo` 157 | 158 | ``` purescript 159 | getRangeTo :: forall a. RoomPosition -> TargetPosition a -> Int 160 | ``` 161 | 162 | May return Infinity 163 | 164 | #### `inRangeTo` 165 | 166 | ``` purescript 167 | inRangeTo :: forall a. RoomPosition -> TargetPosition a -> Int -> Boolean 168 | ``` 169 | 170 | #### `isEqualTo` 171 | 172 | ``` purescript 173 | isEqualTo :: forall a. RoomPosition -> TargetPosition a -> Boolean 174 | ``` 175 | 176 | #### `isNearTo` 177 | 178 | ``` purescript 179 | isNearTo :: forall a. RoomPosition -> TargetPosition a -> Boolean 180 | ``` 181 | 182 | #### `lookFor` 183 | 184 | ``` purescript 185 | lookFor :: forall a. RoomPosition -> LookType a -> Either Error (Array a) 186 | ``` 187 | 188 | 189 | -------------------------------------------------------------------------------- /src/Screeps/FFI.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // module Screeps.FFI 4 | 5 | exports.unsafeField = function(key){ 6 | return function(obj){ 7 | return obj[key]; 8 | } 9 | } 10 | 11 | exports.unsafeGetFieldEff = function(key){ 12 | return function(obj){ 13 | return function(){ 14 | return obj[key]; 15 | } 16 | } 17 | } 18 | 19 | exports.unsafeSetFieldEff = function(key){ 20 | return function(obj){ 21 | return function(val){ 22 | return function(){ 23 | obj[key] = val; 24 | } 25 | } 26 | } 27 | } 28 | 29 | exports.unsafeDeleteFieldEff = function(key){ 30 | return function(obj){ 31 | return function(){ 32 | delete obj[key]; 33 | } 34 | } 35 | } 36 | 37 | exports.runThisEffFn0 = function(key){ 38 | return function(self){ 39 | return function(){ 40 | return self[key](); 41 | } 42 | } 43 | } 44 | 45 | exports.runThisEffFn1 = function(key){ 46 | return function(self){ 47 | return function(a){ 48 | return function(){ 49 | return self[key](a); 50 | } 51 | } 52 | } 53 | } 54 | 55 | exports.runThisEffFn2 = function(key){ 56 | return function(self){ 57 | return function(a){ 58 | return function(b){ 59 | return function(){ 60 | return self[key](a, b); 61 | } 62 | } 63 | } 64 | } 65 | } 66 | 67 | exports.runThisEffFn3 = function(key){ 68 | return function(self){ 69 | return function(a){ 70 | return function(b){ 71 | return function(c){ 72 | return function(){ 73 | return self[key](a, b, c); 74 | } 75 | } 76 | } 77 | } 78 | } 79 | } 80 | 81 | exports.runThisEffFn4 = function(key){ 82 | return function(self){ 83 | return function(a){ 84 | return function(b){ 85 | return function(c){ 86 | return function(d){ 87 | return function(){ 88 | return self[key](a, b, c, d); 89 | } 90 | } 91 | } 92 | } 93 | } 94 | } 95 | } 96 | 97 | exports.runThisEffFn5 = function(key){ 98 | return function(self){ 99 | return function(a){ 100 | return function(b){ 101 | return function(c){ 102 | return function(d){ 103 | return function(e){ 104 | return function(){ 105 | return self[key](a, b, c, d, e); 106 | } 107 | } 108 | } 109 | } 110 | } 111 | } 112 | } 113 | } 114 | 115 | exports.runThisEffFn6 = function(key){ 116 | return function(self){ 117 | return function(a){ 118 | return function(b){ 119 | return function(c){ 120 | return function(d){ 121 | return function(e){ 122 | return function(f){ 123 | return function(){ 124 | return self[key](a, b, c, d, e, f); 125 | } 126 | } 127 | } 128 | } 129 | } 130 | } 131 | } 132 | } 133 | } 134 | 135 | exports.runThisFn0 = function(key){ 136 | return function(self){ 137 | return self[key](); 138 | } 139 | } 140 | 141 | exports.runThisFn1 = function(key){ 142 | return function(self){ 143 | return function(a){ 144 | return self[key](a); 145 | } 146 | } 147 | } 148 | 149 | exports.runThisFn2 = function(key){ 150 | return function(self){ 151 | return function(a){ 152 | return function(b){ 153 | return self[key](a, b); 154 | } 155 | } 156 | } 157 | } 158 | 159 | exports.runThisFn3 = function(key){ 160 | return function(self){ 161 | return function(a){ 162 | return function(b){ 163 | return function(c){ 164 | return self[key](a, b, c); 165 | } 166 | } 167 | } 168 | } 169 | } 170 | 171 | exports.runThisFn4 = function(key){ 172 | return function(self){ 173 | return function(a){ 174 | return function(b){ 175 | return function(c){ 176 | return function(d){ 177 | return self[key](a, b, c, d); 178 | } 179 | } 180 | } 181 | } 182 | } 183 | } 184 | 185 | exports.runThisFn5 = function(key){ 186 | return function(self){ 187 | return function(a){ 188 | return function(b){ 189 | return function(c){ 190 | return function(d){ 191 | return function(e){ 192 | return self[key](a, b, c, d, e); 193 | } 194 | } 195 | } 196 | } 197 | } 198 | } 199 | } 200 | 201 | exports.runThisFn6 = function(key){ 202 | return function(self){ 203 | return function(a){ 204 | return function(b){ 205 | return function(c){ 206 | return function(d){ 207 | return function(e){ 208 | return function(f){ 209 | return self[key](a, b, c, d, e, f); 210 | } 211 | } 212 | } 213 | } 214 | } 215 | } 216 | } 217 | } 218 | 219 | exports.null = null; 220 | exports.undefined = undefined; 221 | 222 | exports.notNullOrUndefined = function(x){ 223 | return x; 224 | } 225 | 226 | exports.isNull = function(x){ 227 | return x === null; 228 | } 229 | 230 | exports.isUndefined = function(x){ 231 | return x === undefined; 232 | } 233 | 234 | exports.toMaybeImpl = function(val, nothing, just){ 235 | if(val === null || val === undefined){ 236 | return nothing; 237 | } else { 238 | return just(val); 239 | } 240 | } 241 | 242 | exports.selectMaybesImpl = function(isJust){ 243 | return function(fromJust){ 244 | return function(obj){ 245 | var newObj = {}; 246 | for(var key in obj){ 247 | if(!obj.hasOwnProperty(key)){ 248 | continue; 249 | } 250 | if(isJust(obj[key])){ 251 | newObj[key] = fromJust(obj[key]); 252 | } 253 | } 254 | return newObj; 255 | } 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /src/Screeps/Types.purs: -------------------------------------------------------------------------------- 1 | -- | Defines the main types used in the library and the relationships between them. 2 | module Screeps.Types where 3 | 4 | import Prelude 5 | import Data.Argonaut.Decode (class DecodeJson, decodeJson, gDecodeJson) 6 | import Data.Argonaut.Encode (class EncodeJson, encodeJson, gEncodeJson) 7 | import Data.Generic (class Generic, gEq, gShow) 8 | import Data.Maybe (Maybe) 9 | import Data.StrMap as StrMap 10 | 11 | foreign import data GameGlobal :: * 12 | 13 | foreign import data Market :: * 14 | foreign import data Room :: * 15 | foreign import data RoomPosition :: * 16 | foreign import data WorldMap :: * 17 | 18 | type RoomObject a = RawRoomObject a 19 | type Structure a = RoomObject (RawStructure a) 20 | type OwnedStructure a = Structure (RawOwnedStructure a) 21 | 22 | type Container = Structure RawContainer 23 | type Controller = OwnedStructure RawController 24 | type Extension = OwnedStructure RawExtension 25 | type Extractor = OwnedStructure RawExtractor 26 | type KeeperLair = OwnedStructure RawKeeperLair 27 | type Lab = OwnedStructure RawLab 28 | type Link = OwnedStructure RawLink 29 | type Nuker = OwnedStructure RawNuker 30 | type Observer = OwnedStructure RawObserver 31 | type Portal = OwnedStructure RawPortal 32 | type PowerBank = OwnedStructure RawPowerBank 33 | type PowerSpawn = OwnedStructure RawPowerSpawn 34 | type Rampart = OwnedStructure RawRampart 35 | type Road = OwnedStructure RawRoad 36 | type Spawn = OwnedStructure RawSpawn 37 | type Storage = OwnedStructure RawStorage 38 | type Terminal = OwnedStructure RawTerminal 39 | type Tower = OwnedStructure RawTower 40 | type Wall = OwnedStructure RawWall 41 | 42 | type ConstructionSite = RoomObject RawConstructionSite 43 | type Creep = RoomObject RawCreep 44 | type Flag = RoomObject RawFlag 45 | type Mineral = RoomObject RawMineral 46 | type Nuke = RoomObject RawNuke 47 | type Resource = RoomObject RawResource 48 | type Source = RoomObject RawSource 49 | 50 | foreign import data RawOwnedStructure :: * -> * 51 | foreign import data RawRoomObject :: * -> * 52 | foreign import data RawStructure :: * -> * 53 | 54 | foreign import data RawContainer :: * 55 | foreign import data RawController :: * 56 | foreign import data RawExtension :: * 57 | foreign import data RawExtractor :: * 58 | foreign import data RawKeeperLair :: * 59 | foreign import data RawLab :: * 60 | foreign import data RawLink :: * 61 | foreign import data RawNuker :: * 62 | foreign import data RawObserver :: * 63 | foreign import data RawPortal :: * 64 | foreign import data RawPowerBank :: * 65 | foreign import data RawPowerSpawn :: * 66 | foreign import data RawRampart :: * 67 | foreign import data RawRoad :: * 68 | foreign import data RawSpawn :: * 69 | foreign import data RawStorage :: * 70 | foreign import data RawTerminal :: * 71 | foreign import data RawTower :: * 72 | foreign import data RawWall :: * 73 | 74 | foreign import data RawConstructionSite :: * 75 | foreign import data RawCreep :: * 76 | foreign import data RawFlag :: * 77 | foreign import data RawMineral :: * 78 | foreign import data RawNuke :: * 79 | foreign import data RawResource :: * 80 | foreign import data RawSource :: * 81 | 82 | type Path = Array PathStep -- or String? 83 | 84 | type PathStep = 85 | { x :: Int 86 | , y :: Int 87 | , dx :: Number 88 | , dy :: Number 89 | , direction :: Direction } 90 | 91 | newtype ReturnCode = ReturnCode Int 92 | derive instance genericReturnCode :: Generic ReturnCode 93 | instance eqReturnCode :: Eq ReturnCode where eq = gEq 94 | instance showReturnCode :: Show ReturnCode where 95 | show (ReturnCode n) = show n 96 | 97 | newtype ResourceType = ResourceType String 98 | derive instance genericResourceType :: Generic ResourceType 99 | instance eqResourceType :: Eq ResourceType where eq = gEq 100 | instance showResourceType :: Show ResourceType where 101 | show (ResourceType s) = s 102 | 103 | newtype StructureType = StructureType String 104 | derive instance genericStructureType :: Generic StructureType 105 | instance eqStructureType :: Eq StructureType where eq = gEq 106 | instance showStructureType :: Show StructureType where show = gShow 107 | 108 | newtype TerrainMask = TerrainMask Int 109 | derive instance genericTerrainMask :: Generic TerrainMask 110 | instance eqTerrainMask :: Eq TerrainMask where eq = gEq 111 | instance showTerrainMask :: Show TerrainMask where show = gShow 112 | 113 | newtype Terrain = Terrain String 114 | derive instance genericTerrain :: Generic Terrain 115 | instance eqTerrain :: Eq Terrain where eq = gEq 116 | instance showTerrain :: Show Terrain 117 | where show (Terrain s) = s 118 | 119 | newtype Mode = Mode String 120 | derive instance genericMode :: Generic Mode 121 | instance eqMode :: Eq Mode where eq = gEq 122 | instance showMode :: Show Mode where show = gShow 123 | 124 | newtype Id a = Id String 125 | derive instance genericId :: Generic (Id a) 126 | instance eqId :: Eq (Id a) where eq = gEq 127 | instance showId :: Show (Id a) where show = gShow 128 | instance decodeJsonId :: DecodeJson (Id a) where decodeJson = gDecodeJson 129 | instance encodeJsonId :: EncodeJson (Id a) where encodeJson = gEncodeJson 130 | 131 | newtype Direction = Direction Int 132 | derive instance genericDirection :: Generic Direction 133 | instance eqDirection :: Eq Direction where eq = gEq 134 | instance showDirection :: Show Direction where show = gShow 135 | 136 | newtype BodyPartType = BodyPartType String 137 | derive instance genericBodyPartType :: Generic BodyPartType 138 | instance eqBodyPartType :: Eq BodyPartType where eq = gEq 139 | instance showBodyPartType :: Show BodyPartType where show = gShow 140 | 141 | newtype Color = Color Int 142 | derive instance genericColor :: Generic Color 143 | instance eqColor :: Eq Color where eq = gEq 144 | instance showColor :: Show Color where show = gShow 145 | 146 | newtype LookType a = LookType String 147 | newtype FindType a = FindType Int 148 | 149 | type StructureInfo = StrMap.StrMap Int 150 | 151 | ----------------- 152 | -- Helper types and functions 153 | ----------------- 154 | 155 | type FilterFn a = a -> Boolean 156 | 157 | data TargetPosition a = 158 | TargetPt Int Int | 159 | TargetObj (RoomObject a) | 160 | TargetPos RoomPosition 161 | 162 | data FindContext a = 163 | OfType (FindType a) | 164 | OfObj (Array a) | -- should be RoomObject a 165 | OfPos (Array RoomPosition) 166 | -------------------------------------------------------------------------------- /src/Screeps/Room.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Room](http://support.screeps.com/hc/en-us/articles/203079011-Room) 2 | module Screeps.Room where 3 | 4 | import Prelude 5 | import Control.Monad.Eff (Eff) 6 | import Data.Array as Array 7 | import Data.Either (Either(Left,Right)) 8 | import Data.Maybe (Maybe(Just, Nothing)) 9 | import Data.StrMap as StrMap 10 | import Data.Tuple (Tuple(Tuple)) 11 | 12 | import Screeps.Effects (CMD, TICK) 13 | import Screeps.Types (Controller, Color, FilterFn, FindType, LookType, Mode, Path, ReturnCode, Room, RoomPosition, Storage, StructureType, TargetPosition(..), Terminal) 14 | import Screeps.FFI (runThisEffFn1, runThisEffFn2, runThisEffFn3, runThisEffFn4, runThisEffFn5, runThisFn1, runThisFn2, runThisFn3, selectMaybes, toMaybe, unsafeField) 15 | 16 | foreign import data RoomGlobal :: * 17 | foreign import getRoomGlobal :: forall e. Eff (tick :: TICK | e) RoomGlobal 18 | 19 | -- TODO: costCallback option 20 | type PathOptions o = 21 | { ignoreCreeps :: Maybe Boolean 22 | , ignoreDestructibleStructures :: Maybe Boolean 23 | , ignoreRoads :: Maybe Boolean 24 | , ignore :: Maybe (Array RoomPosition) 25 | , avoid :: Maybe (Array RoomPosition) 26 | , maxOps :: Maybe Int 27 | , heuristicWeight :: Maybe Number 28 | , serialize :: Maybe Boolean 29 | , maxRooms :: Maybe Int 30 | | o } 31 | 32 | pathOpts :: PathOptions () 33 | pathOpts = 34 | { ignoreCreeps: Nothing 35 | , ignoreDestructibleStructures: Nothing 36 | , ignoreRoads: Nothing 37 | , ignore: Nothing 38 | , avoid: Nothing 39 | , maxOps: Nothing 40 | , heuristicWeight: Nothing 41 | , serialize: Nothing 42 | , maxRooms: Nothing } 43 | 44 | controller :: Room -> Maybe Controller 45 | controller room = toMaybe $ unsafeField "controller" room 46 | 47 | energyAvailable :: Room -> Int 48 | energyAvailable = unsafeField "energyAvailable" 49 | 50 | energyCapacityAvailable :: Room -> Int 51 | energyCapacityAvailable = unsafeField "energyCapacityAvailable" 52 | 53 | memory :: forall props. Room -> { | props } 54 | memory = unsafeField "energyAvailable" 55 | 56 | mode :: Room -> Mode 57 | mode = unsafeField "mode" 58 | 59 | name :: Room -> String 60 | name = unsafeField "name" 61 | 62 | storage :: Room -> Maybe Storage 63 | storage room = toMaybe $ unsafeField "storage" room 64 | 65 | terminal :: Room -> Maybe Terminal 66 | terminal room = toMaybe $ unsafeField "terminal" room 67 | 68 | serializePath :: RoomGlobal -> Path -> String 69 | serializePath = runThisFn1 "serializePath" 70 | 71 | deserializePath :: RoomGlobal -> String -> Path 72 | deserializePath = runThisFn1 "deserializePath" 73 | 74 | createConstructionSite :: forall a e. Room -> TargetPosition a -> StructureType -> Eff (cmd :: CMD | e) ReturnCode 75 | createConstructionSite room (TargetPt x' y') strucType = runThisEffFn3 "createConstructionSite" room x' y' strucType 76 | createConstructionSite room (TargetPos pos) strucType = runThisEffFn2 "createConstructionSite" room pos strucType 77 | createConstructionSite room (TargetObj obj) strucType = runThisEffFn2 "createConstructionSite" room obj strucType 78 | 79 | createFlag :: forall a e. Room -> TargetPosition a -> Eff (cmd :: CMD | e) ReturnCode 80 | createFlag room (TargetPt x' y') = runThisEffFn2 "createFlag" room x' y' 81 | createFlag room (TargetPos pos) = runThisEffFn1 "createFlag" room pos 82 | createFlag room (TargetObj obj) = runThisEffFn1 "createFlag" room obj 83 | 84 | createFlagWithName :: forall a e. Room -> TargetPosition a -> String -> Eff (cmd :: CMD | e) ReturnCode 85 | createFlagWithName room (TargetPt x' y') name' = runThisEffFn3 "createFlag" room x' y' name' 86 | createFlagWithName room (TargetPos pos) name' = runThisEffFn2 "createFlag" room pos name' 87 | createFlagWithName room (TargetObj obj) name' = runThisEffFn2 "createFlag" room obj name' 88 | 89 | createFlagWithColor :: forall a e. Room -> TargetPosition a -> String -> Color -> Eff (cmd :: CMD | e) ReturnCode 90 | createFlagWithColor room (TargetPt x' y') name' color = runThisEffFn4 "createFlag" room x' y' name' color 91 | createFlagWithColor room (TargetPos pos) name' color = runThisEffFn3 "createFlag" room pos name' color 92 | createFlagWithColor room (TargetObj obj) name' color = runThisEffFn3 "createFlag" room obj name' color 93 | 94 | createFlagWithColors :: forall a e. Room -> TargetPosition a -> String -> Color -> Color -> Eff (cmd :: CMD | e) ReturnCode 95 | createFlagWithColors room (TargetPt x' y') name' color color2 = 96 | runThisEffFn5 "createFlag" room x' y' name' color color2 97 | createFlagWithColors room (TargetPos pos) name' color color2 = 98 | runThisEffFn4 "createFlag" room pos name' color color2 99 | createFlagWithColors room (TargetObj obj) name' color color2 = 100 | runThisEffFn4 "createFlag" room obj name' color color2 101 | 102 | find :: forall a. Room -> FindType a -> Array a 103 | find = runThisFn1 "find" 104 | 105 | find' :: forall a. Room -> FindType a -> FilterFn a -> Array a 106 | find' room findType filter = runThisFn2 "find" room findType { filter } 107 | 108 | data RoomIdentifier = RoomName String | RoomObj Room 109 | 110 | foreign import findExitToImpl :: forall a. 111 | Room -> 112 | a -> 113 | (ReturnCode -> Either ReturnCode (FindType RoomPosition)) -> 114 | (FindType RoomPosition -> Either ReturnCode (FindType RoomPosition)) -> 115 | Either ReturnCode (FindType RoomPosition) 116 | 117 | findExitTo :: Room -> RoomIdentifier -> Either ReturnCode (FindType RoomPosition) 118 | findExitTo room (RoomName otherRoomName) = findExitToImpl room otherRoomName Left Right 119 | findExitTo room (RoomObj otherRoom) = findExitToImpl room otherRoom Left Right 120 | 121 | findPath :: Room -> RoomPosition -> RoomPosition -> Path 122 | findPath = runThisFn2 "findPath" 123 | 124 | findPath' :: forall o. Room -> RoomPosition -> RoomPosition -> PathOptions o -> Path 125 | findPath' room pos1 pos2 opts = runThisFn3 "findPath" room pos1 pos2 (selectMaybes opts) 126 | 127 | getPositionAt :: Room -> Int -> Int -> RoomPosition 128 | getPositionAt = runThisFn2 "getPositionAt" 129 | 130 | -- lookAt omitted - use lookForAt 131 | -- lookAtArea omitted - use lookForAtArea 132 | 133 | lookForAt :: forall a. Room -> LookType a -> TargetPosition a -> Array a 134 | lookForAt room lookType (TargetPt x' y') = runThisFn3 "lookForAt" room lookType x' y' 135 | lookForAt room lookType (TargetPos pos) = runThisFn2 "lookForAt" room lookType pos 136 | lookForAt room lookType (TargetObj obj) = runThisFn2 "lookForAt" room lookType obj 137 | 138 | -- TODO: implement this 139 | -- lookForAtArea :: forall a. Room -> LookType a -> Int -> Int -> Int -> Int -> Boolean -> Array a 140 | -- lookForAtArea r t top left bot right asArray = runThisFn6 "lookForAt" r t top left bot right asArray 141 | -------------------------------------------------------------------------------- /src/Screeps/RoomPosition.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [RoomPosition](http://support.screeps.com/hc/en-us/articles/203079201-RoomPosition) 2 | module Screeps.RoomPosition where 3 | 4 | import Prelude 5 | import Control.Monad.Eff (Eff, runPure) 6 | import Control.Monad.Eff.Exception (EXCEPTION, Error, error, try) 7 | import Data.Either (Either(Left, Right)) 8 | import Data.Maybe (Maybe(Nothing), maybe) 9 | import Unsafe.Coerce (unsafeCoerce) 10 | 11 | import Screeps.Effects (CMD) 12 | import Screeps.Types (Color, Direction, FilterFn, FindContext(..), FindType, LookType, Path, ReturnCode, RoomObject, RoomPosition, TargetPosition(..), StructureType) 13 | import Screeps.FFI (runThisEffFn0, runThisEffFn1, runThisEffFn2, runThisEffFn3, runThisFn0, runThisFn1, runThisFn2, runThisFn3, selectMaybes, toMaybe, unsafeField) 14 | import Screeps.Room (PathOptions) 15 | 16 | foreign import mkRoomPosition :: Int -> Int -> String -> RoomPosition 17 | 18 | tryPure :: forall a. Eff (err :: EXCEPTION) a -> Either Error a 19 | tryPure = runPure <<< try 20 | 21 | type ClosestPathOptions = PathOptions 22 | ( filter :: Maybe (forall a. a -> Boolean) 23 | , algorithm :: Maybe FindAlgorithm ) 24 | 25 | newtype FindAlgorithm = FindAlgorithm String 26 | 27 | algorithmAstar :: FindAlgorithm 28 | algorithmAstar = FindAlgorithm "astar" 29 | 30 | algorithmDijkstra :: FindAlgorithm 31 | algorithmDijkstra = FindAlgorithm "dijkstra" 32 | 33 | closestPathOpts :: ClosestPathOptions 34 | closestPathOpts = 35 | { ignoreCreeps: Nothing 36 | , ignoreDestructibleStructures: Nothing 37 | , ignoreRoads: Nothing 38 | , ignore: Nothing 39 | , avoid: Nothing 40 | , maxOps: Nothing 41 | , heuristicWeight: Nothing 42 | , serialize: Nothing 43 | , maxRooms: Nothing 44 | , filter: Nothing 45 | , algorithm: Nothing 46 | } 47 | 48 | unwrapContext :: forall a b. FindContext a -> b 49 | unwrapContext (OfType findType) = unsafeCoerce findType 50 | unwrapContext (OfObj objects) = unsafeCoerce objects 51 | unwrapContext (OfPos positions) = unsafeCoerce positions 52 | 53 | roomName :: RoomPosition -> String 54 | roomName = unsafeField "roomName" 55 | 56 | x :: RoomPosition -> Int 57 | x = unsafeField "x" 58 | 59 | y :: RoomPosition -> Int 60 | y = unsafeField "y" 61 | 62 | createConstructionSite :: forall e. RoomPosition -> StructureType -> Eff ( cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 63 | createConstructionSite = runThisEffFn1 "createConstructionSite" 64 | 65 | createFlag :: forall e. RoomPosition -> Eff ( cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 66 | createFlag = runThisEffFn0 "createFlag" 67 | 68 | createFlagWithName :: forall e. RoomPosition -> String -> Eff ( cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 69 | createFlagWithName pos name = runThisEffFn1 "createFlag" pos name 70 | 71 | createFlagWithColor :: forall e. RoomPosition -> String -> Color -> Eff ( cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 72 | createFlagWithColor pos name color = runThisEffFn2 "createFlag" pos name color 73 | 74 | createFlagWithColors :: forall e. RoomPosition -> String -> Color -> Color -> Eff ( cmd :: CMD, exception :: EXCEPTION | e) ReturnCode 75 | createFlagWithColors pos name color secondaryColor = runThisEffFn3 "createFlag" pos name color secondaryColor 76 | 77 | findClosestByPath :: forall a. RoomPosition -> FindContext a -> Either Error (Maybe a) 78 | findClosestByPath pos ctx = tryPure (toMaybe <$> runThisEffFn1 "findClosestByPath" pos (unwrapContext ctx)) 79 | 80 | findClosestByPath' :: forall a. RoomPosition -> FindContext a -> ClosestPathOptions -> Either Error (Maybe a) 81 | findClosestByPath' pos ctx opts = tryPure (toMaybe <$> runThisEffFn2 "findClosestByPath" pos ctx' options) 82 | where ctx' = unwrapContext ctx 83 | options = selectMaybes opts 84 | 85 | findClosestByRange :: forall a. RoomPosition -> FindContext a -> Either Error (Maybe a) 86 | findClosestByRange pos ctx = tryPure (toMaybe <$> runThisEffFn1 "findClosestByRange" pos (unwrapContext ctx)) 87 | 88 | findClosestByRange' :: forall a. RoomPosition -> FindContext a -> FilterFn a -> Either Error (Maybe a) 89 | findClosestByRange' pos ctx filter = tryPure (toMaybe <$> runThisEffFn2 "findClosestByRange" pos (unwrapContext ctx) { filter }) 90 | 91 | findInRange :: forall a. RoomPosition -> FindContext a -> Int -> Either Error (Array a) 92 | findInRange pos ctx range = tryPure (runThisEffFn2 "findInRange" pos (unwrapContext ctx) range) 93 | 94 | findInRange' :: forall a. RoomPosition -> FindContext a -> Int -> FilterFn a -> Either Error (Array a) 95 | findInRange' pos ctx range filter = tryPure (runThisEffFn3 "findInRange" pos (unwrapContext ctx) range { filter }) 96 | 97 | findPathTo :: forall a. RoomPosition -> TargetPosition a -> Either Error Path 98 | findPathTo pos (TargetPt x' y') = tryPure (runThisEffFn2 "findPathTo" pos x' y') 99 | findPathTo pos (TargetPos destPos) = tryPure (runThisEffFn1 "findPathTo" pos destPos) 100 | findPathTo pos (TargetObj obj) = tryPure (runThisEffFn1 "findPathTo" pos obj) 101 | 102 | findPathTo' :: forall a. RoomPosition -> TargetPosition a -> PathOptions () -> Either Error Path 103 | findPathTo' pos (TargetPt x' y') opts = tryPure (runThisEffFn3 "findPathTo" pos x' y' (selectMaybes opts)) 104 | findPathTo' pos (TargetPos destPos) opts = tryPure (runThisEffFn2 "findPathTo" pos destPos (selectMaybes opts)) 105 | findPathTo' pos (TargetObj obj) opts = tryPure (runThisEffFn2 "findPathTo" pos obj (selectMaybes opts)) 106 | 107 | getDirectionTo :: forall a. RoomPosition -> TargetPosition a -> Direction 108 | getDirectionTo pos (TargetPt x' y') = runThisFn2 "getDirectionTo" pos x' y' 109 | getDirectionTo pos (TargetPos otherPos) = runThisFn1 "getDirectionTo" pos otherPos 110 | getDirectionTo pos (TargetObj obj) = runThisFn1 "getDirectionTo" pos obj 111 | 112 | -- | May return Infinity 113 | getRangeTo :: forall a. RoomPosition -> TargetPosition a -> Int 114 | getRangeTo pos (TargetPt x' y') = runThisFn2 "getRangeTo" pos x' y' 115 | getRangeTo pos (TargetPos destPos) = runThisFn1 "getRangeTo" pos destPos 116 | getRangeTo pos (TargetObj obj) = runThisFn1 "getRangeTo" pos obj 117 | 118 | inRangeTo :: forall a. RoomPosition -> TargetPosition a -> Int -> Boolean 119 | inRangeTo pos (TargetPt x' y') range = runThisFn3 "inRangeTo" pos x' y' range 120 | inRangeTo pos (TargetPos destPos) range = runThisFn2 "inRangeTo" pos destPos range 121 | inRangeTo pos (TargetObj obj) range = runThisFn2 "inRangeTo" pos obj range 122 | 123 | isEqualTo :: forall a. RoomPosition -> TargetPosition a -> Boolean 124 | isEqualTo pos (TargetPt x' y') = runThisFn2 "isEqualTo" pos x' y' 125 | isEqualTo pos (TargetPos otherPos) = runThisFn1 "isEqualTo" pos otherPos 126 | isEqualTo pos (TargetObj obj) = runThisFn1 "isEqualTo" pos obj 127 | 128 | isNearTo :: forall a. RoomPosition -> TargetPosition a -> Boolean 129 | isNearTo pos (TargetPt x' y') = runThisFn2 "isNearTo" pos x' y' 130 | isNearTo pos (TargetPos otherPos) = runThisFn1 "isNearTo" pos otherPos 131 | isNearTo pos (TargetObj obj) = runThisFn1 "isNearTo" pos obj 132 | 133 | -- look function omitted - use lookFor 134 | 135 | lookFor :: forall a. RoomPosition -> LookType a -> Either Error (Array a) 136 | lookFor pos lookType = tryPure (runThisEffFn1 "lookFor" pos lookType) 137 | -------------------------------------------------------------------------------- /docs/Screeps/Creep.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Creep 2 | 3 | Corresponds to the Screeps API [Creep](http://support.screeps.com/hc/en-us/articles/203013212-Creep) 4 | 5 | #### `CreepCargo` 6 | 7 | ``` purescript 8 | data CreepCargo :: * 9 | ``` 10 | 11 | #### `BodyPart` 12 | 13 | ``` purescript 14 | type BodyPart = { boost :: Maybe String, type :: BodyPartType, hits :: Int } 15 | ``` 16 | 17 | #### `MoveOptions` 18 | 19 | ``` purescript 20 | type MoveOptions = PathOptions (reusePath :: Maybe Int, serializeMemory :: Maybe Boolean, noPathFinding :: Maybe Boolean) 21 | ``` 22 | 23 | #### `moveOpts` 24 | 25 | ``` purescript 26 | moveOpts :: MoveOptions 27 | ``` 28 | 29 | #### `body` 30 | 31 | ``` purescript 32 | body :: Creep -> Array BodyPart 33 | ``` 34 | 35 | #### `carry` 36 | 37 | ``` purescript 38 | carry :: Creep -> CreepCargo 39 | ``` 40 | 41 | #### `amtCarrying` 42 | 43 | ``` purescript 44 | amtCarrying :: Creep -> ResourceType -> Int 45 | ``` 46 | 47 | #### `totalAmtCarrying` 48 | 49 | ``` purescript 50 | totalAmtCarrying :: Creep -> Int 51 | ``` 52 | 53 | #### `carryCapacity` 54 | 55 | ``` purescript 56 | carryCapacity :: Creep -> Int 57 | ``` 58 | 59 | #### `fatigue` 60 | 61 | ``` purescript 62 | fatigue :: Creep -> Int 63 | ``` 64 | 65 | #### `hits` 66 | 67 | ``` purescript 68 | hits :: Creep -> Int 69 | ``` 70 | 71 | #### `hitsMax` 72 | 73 | ``` purescript 74 | hitsMax :: Creep -> Int 75 | ``` 76 | 77 | #### `getId` 78 | 79 | ``` purescript 80 | getId :: Creep -> Id Creep 81 | ``` 82 | 83 | #### `getIdAsStr` 84 | 85 | ``` purescript 86 | getIdAsStr :: Creep -> String 87 | ``` 88 | 89 | #### `my` 90 | 91 | ``` purescript 92 | my :: Creep -> Boolean 93 | ``` 94 | 95 | #### `name` 96 | 97 | ``` purescript 98 | name :: Creep -> String 99 | ``` 100 | 101 | #### `owner` 102 | 103 | ``` purescript 104 | owner :: Creep -> { username :: String } 105 | ``` 106 | 107 | #### `saying` 108 | 109 | ``` purescript 110 | saying :: Creep -> Maybe String 111 | ``` 112 | 113 | #### `spawning` 114 | 115 | ``` purescript 116 | spawning :: Creep -> Boolean 117 | ``` 118 | 119 | #### `ticksToLive` 120 | 121 | ``` purescript 122 | ticksToLive :: Creep -> Int 123 | ``` 124 | 125 | #### `attackCreep` 126 | 127 | ``` purescript 128 | attackCreep :: forall e. Creep -> Creep -> Eff (cmd :: CMD | e) ReturnCode 129 | ``` 130 | 131 | #### `attackStructure` 132 | 133 | ``` purescript 134 | attackStructure :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 135 | ``` 136 | 137 | #### `attackController` 138 | 139 | ``` purescript 140 | attackController :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 141 | ``` 142 | 143 | #### `build` 144 | 145 | ``` purescript 146 | build :: forall e. Creep -> ConstructionSite -> Eff (cmd :: CMD | e) ReturnCode 147 | ``` 148 | 149 | #### `cancelOrder` 150 | 151 | ``` purescript 152 | cancelOrder :: forall e. Creep -> String -> Eff (cmd :: CMD | e) ReturnCode 153 | ``` 154 | 155 | #### `claimController` 156 | 157 | ``` purescript 158 | claimController :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 159 | ``` 160 | 161 | #### `dismantle` 162 | 163 | ``` purescript 164 | dismantle :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 165 | ``` 166 | 167 | #### `drop` 168 | 169 | ``` purescript 170 | drop :: forall e. Creep -> ResourceType -> Eff (cmd :: CMD | e) ReturnCode 171 | ``` 172 | 173 | #### `dropAmt` 174 | 175 | ``` purescript 176 | dropAmt :: forall e. Creep -> ResourceType -> Int -> Eff (cmd :: CMD | e) ReturnCode 177 | ``` 178 | 179 | #### `getActiveBodyparts` 180 | 181 | ``` purescript 182 | getActiveBodyparts :: Creep -> BodyPartType -> Int 183 | ``` 184 | 185 | #### `harvestSource` 186 | 187 | ``` purescript 188 | harvestSource :: forall e. Creep -> Source -> Eff (cmd :: CMD | e) ReturnCode 189 | ``` 190 | 191 | #### `harvestMineral` 192 | 193 | ``` purescript 194 | harvestMineral :: forall e. Creep -> Mineral -> Eff (cmd :: CMD | e) ReturnCode 195 | ``` 196 | 197 | #### `heal` 198 | 199 | ``` purescript 200 | heal :: forall e. Creep -> Creep -> Eff (cmd :: CMD | e) ReturnCode 201 | ``` 202 | 203 | #### `getMemory` 204 | 205 | ``` purescript 206 | getMemory :: forall a e. DecodeJson a => Creep -> String -> Eff (memory :: MEMORY | e) (Either String a) 207 | ``` 208 | 209 | #### `setMemory` 210 | 211 | ``` purescript 212 | setMemory :: forall a e. EncodeJson a => Creep -> String -> a -> Eff (memory :: MEMORY | e) Unit 213 | ``` 214 | 215 | #### `move` 216 | 217 | ``` purescript 218 | move :: forall e. Creep -> Direction -> Eff (cmd :: CMD | e) ReturnCode 219 | ``` 220 | 221 | #### `moveByPath` 222 | 223 | ``` purescript 224 | moveByPath :: forall e. Creep -> Path -> Eff (cmd :: CMD | e) ReturnCode 225 | ``` 226 | 227 | #### `moveTo` 228 | 229 | ``` purescript 230 | moveTo :: forall a e. Creep -> TargetPosition a -> Eff (cmd :: CMD, memory :: MEMORY | e) ReturnCode 231 | ``` 232 | 233 | #### `moveTo'` 234 | 235 | ``` purescript 236 | moveTo' :: forall a e. Creep -> TargetPosition a -> MoveOptions -> Eff (cmd :: CMD, memory :: MEMORY | e) ReturnCode 237 | ``` 238 | 239 | #### `notifyWhenAttacked` 240 | 241 | ``` purescript 242 | notifyWhenAttacked :: forall e. Creep -> Boolean -> Eff (cmd :: CMD | e) ReturnCode 243 | ``` 244 | 245 | #### `pickup` 246 | 247 | ``` purescript 248 | pickup :: forall e. Creep -> Resource -> Eff (cmd :: CMD | e) ReturnCode 249 | ``` 250 | 251 | #### `rangedAttackCreep` 252 | 253 | ``` purescript 254 | rangedAttackCreep :: forall e. Creep -> Creep -> Eff (cmd :: CMD | e) ReturnCode 255 | ``` 256 | 257 | #### `rangedAttackStructure` 258 | 259 | ``` purescript 260 | rangedAttackStructure :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 261 | ``` 262 | 263 | #### `rangedHeal` 264 | 265 | ``` purescript 266 | rangedHeal :: forall e. Creep -> Creep -> Eff (cmd :: CMD | e) ReturnCode 267 | ``` 268 | 269 | #### `rangedMassAttack` 270 | 271 | ``` purescript 272 | rangedMassAttack :: forall e. Creep -> Eff (cmd :: CMD | e) ReturnCode 273 | ``` 274 | 275 | #### `repair` 276 | 277 | ``` purescript 278 | repair :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 279 | ``` 280 | 281 | #### `reserveController` 282 | 283 | ``` purescript 284 | reserveController :: forall e. Creep -> Controller -> Eff (cmd :: CMD | e) ReturnCode 285 | ``` 286 | 287 | #### `say` 288 | 289 | ``` purescript 290 | say :: forall e. Creep -> String -> Eff (cmd :: CMD | e) ReturnCode 291 | ``` 292 | 293 | #### `sayPublic` 294 | 295 | ``` purescript 296 | sayPublic :: forall e. Creep -> String -> Eff (cmd :: CMD | e) ReturnCode 297 | ``` 298 | 299 | #### `suicide` 300 | 301 | ``` purescript 302 | suicide :: forall e. Creep -> Eff (cmd :: CMD | e) ReturnCode 303 | ``` 304 | 305 | #### `transferToCreep` 306 | 307 | ``` purescript 308 | transferToCreep :: forall e. Creep -> Creep -> ResourceType -> Int -> Eff (cmd :: CMD | e) ReturnCode 309 | ``` 310 | 311 | #### `transferToStructure` 312 | 313 | ``` purescript 314 | transferToStructure :: forall a e. Creep -> Structure a -> ResourceType -> Eff (cmd :: CMD | e) ReturnCode 315 | ``` 316 | 317 | #### `transferAmtToStructure` 318 | 319 | ``` purescript 320 | transferAmtToStructure :: forall a e. Creep -> Structure a -> ResourceType -> Int -> Eff (cmd :: CMD | e) ReturnCode 321 | ``` 322 | 323 | #### `upgradeController` 324 | 325 | ``` purescript 326 | upgradeController :: forall e. Creep -> Controller -> Eff (cmd :: CMD | e) ReturnCode 327 | ``` 328 | 329 | #### `withdraw` 330 | 331 | ``` purescript 332 | withdraw :: forall a e. Creep -> Structure a -> ResourceType -> Eff (cmd :: CMD | e) ReturnCode 333 | ``` 334 | 335 | #### `withdrawAmt` 336 | 337 | ``` purescript 338 | withdrawAmt :: forall a e. Creep -> Structure a -> ResourceType -> Int -> Eff (cmd :: CMD | e) ReturnCode 339 | ``` 340 | 341 | 342 | -------------------------------------------------------------------------------- /src/Screeps/Creep.purs: -------------------------------------------------------------------------------- 1 | -- | Corresponds to the Screeps API [Creep](http://support.screeps.com/hc/en-us/articles/203013212-Creep) 2 | module Screeps.Creep where 3 | 4 | import Prelude 5 | import Control.Monad.Eff (Eff) 6 | import Data.Argonaut.Decode (class DecodeJson) 7 | import Data.Argonaut.Encode (class EncodeJson) 8 | import Data.Either (Either) 9 | import Data.Maybe (Maybe(Nothing)) 10 | 11 | import Screeps.Effects (CMD, MEMORY) 12 | import Screeps.Types (BodyPartType, ConstructionSite, Controller, Creep, Direction, Id, Mineral, Path, Resource, ResourceType, ReturnCode, Source, Structure, TargetPosition(..)) 13 | import Screeps.FFI (runThisEffFn0, runThisEffFn1, runThisEffFn2, runThisEffFn3, runThisFn1, selectMaybes, toMaybe, unsafeGetFieldEff, unsafeField, unsafeSetFieldEff) 14 | import Screeps.Memory (fromJson, toJson) 15 | import Screeps.Room (PathOptions) 16 | 17 | foreign import data CreepCargo :: * 18 | 19 | type BodyPart = 20 | { boost :: Maybe String 21 | , type :: BodyPartType 22 | , hits :: Int } 23 | 24 | type MoveOptions = PathOptions 25 | ( reusePath :: Maybe Int 26 | , serializeMemory :: Maybe Boolean 27 | , noPathFinding :: Maybe Boolean ) 28 | 29 | moveOpts :: MoveOptions 30 | moveOpts = 31 | { ignoreCreeps: Nothing 32 | , ignoreDestructibleStructures: Nothing 33 | , ignoreRoads: Nothing 34 | , ignore: Nothing 35 | , avoid: Nothing 36 | , maxOps: Nothing 37 | , heuristicWeight: Nothing 38 | , serialize: Nothing 39 | , maxRooms: Nothing 40 | , reusePath: Nothing 41 | , serializeMemory: Nothing 42 | , noPathFinding: Nothing } 43 | 44 | body :: Creep -> Array BodyPart 45 | body creep = unsafeField "body" creep 46 | 47 | carry :: Creep -> CreepCargo 48 | carry = unsafeField "carry" 49 | 50 | amtCarrying :: Creep -> ResourceType -> Int 51 | amtCarrying creep res = unsafeField (show res) $ carry creep 52 | 53 | foreign import totalAmtCarrying :: Creep -> Int 54 | 55 | carryCapacity :: Creep -> Int 56 | carryCapacity = unsafeField "carryCapacity" 57 | 58 | fatigue :: Creep -> Int 59 | fatigue = unsafeField "fatigue" 60 | 61 | hits :: Creep -> Int 62 | hits = unsafeField "hits" 63 | 64 | hitsMax :: Creep -> Int 65 | hitsMax = unsafeField "hitsMax" 66 | 67 | getId :: Creep -> Id Creep 68 | getId = unsafeField "id" 69 | 70 | getIdAsStr :: Creep -> String 71 | getIdAsStr = unsafeField "id" 72 | 73 | my :: Creep -> Boolean 74 | my = unsafeField "my" 75 | 76 | name :: Creep -> String 77 | name = unsafeField "name" 78 | 79 | owner :: Creep -> { username :: String } 80 | owner = unsafeField "owner" 81 | 82 | saying :: Creep -> Maybe String 83 | saying c = toMaybe $ unsafeField "saying" c 84 | 85 | spawning :: Creep -> Boolean 86 | spawning = unsafeField "spawning" 87 | 88 | ticksToLive :: Creep -> Int 89 | ticksToLive = unsafeField "ticksToLive" 90 | 91 | attackCreep :: forall e. Creep -> Creep -> Eff ( cmd :: CMD | e) ReturnCode 92 | attackCreep = runThisEffFn1 "attack" 93 | 94 | attackStructure :: forall a e. Creep -> Structure a -> Eff ( cmd :: CMD | e) ReturnCode 95 | attackStructure = runThisEffFn1 "attack" 96 | 97 | attackController :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 98 | attackController = runThisEffFn1 "attackController" 99 | 100 | build :: forall e. Creep -> ConstructionSite -> Eff (cmd :: CMD | e) ReturnCode 101 | build = runThisEffFn1 "build" 102 | 103 | cancelOrder :: forall e. Creep -> String -> Eff (cmd :: CMD | e) ReturnCode 104 | cancelOrder = runThisEffFn1 "cancelOrder" 105 | 106 | claimController :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 107 | claimController = runThisEffFn1 "claimController" 108 | 109 | dismantle :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 110 | dismantle = runThisEffFn1 "dismantle" 111 | 112 | drop :: forall e. Creep -> ResourceType -> Eff (cmd :: CMD | e) ReturnCode 113 | drop = runThisEffFn1 "drop" 114 | 115 | dropAmt :: forall e. Creep -> ResourceType -> Int -> Eff (cmd :: CMD | e) ReturnCode 116 | dropAmt = runThisEffFn2 "drop" 117 | 118 | getActiveBodyparts :: Creep -> BodyPartType -> Int 119 | getActiveBodyparts = runThisFn1 "getActiveBodyparts" 120 | 121 | harvestSource :: forall e. Creep -> Source -> Eff (cmd :: CMD | e) ReturnCode 122 | harvestSource = runThisEffFn1 "harvest" 123 | 124 | harvestMineral :: forall e. Creep -> Mineral -> Eff (cmd :: CMD | e) ReturnCode 125 | harvestMineral = runThisEffFn1 "harvest" 126 | 127 | heal :: forall e. Creep -> Creep -> Eff (cmd :: CMD | e) ReturnCode 128 | heal = runThisEffFn1 "heal" 129 | 130 | getMemory :: forall a e. (DecodeJson a) => Creep -> String -> Eff ( memory :: MEMORY | e ) (Either String a) 131 | getMemory creep key = fromJson <$> unsafeGetFieldEff key creepMemory 132 | where creepMemory = unsafeField "memory" creep 133 | 134 | setMemory :: forall a e. (EncodeJson a) => Creep -> String -> a -> Eff ( memory :: MEMORY | e ) Unit 135 | setMemory creep key val = unsafeSetFieldEff key creepMemory (toJson val) 136 | where creepMemory = unsafeField "memory" creep 137 | 138 | move :: forall e. Creep -> Direction -> Eff (cmd :: CMD | e) ReturnCode 139 | move = runThisEffFn1 "move" 140 | 141 | moveByPath :: forall e. Creep -> Path -> Eff (cmd :: CMD | e) ReturnCode 142 | moveByPath = runThisEffFn1 "moveByPath" 143 | 144 | moveTo :: forall a e. Creep -> TargetPosition a -> Eff (cmd :: CMD, memory :: MEMORY | e) ReturnCode 145 | moveTo creep (TargetPt x y) = runThisEffFn2 "moveTo" creep x y 146 | moveTo creep (TargetPos pos) = runThisEffFn1 "moveTo" creep pos 147 | moveTo creep (TargetObj obj) = runThisEffFn1 "moveTo" creep obj 148 | 149 | moveTo' :: forall a e. Creep -> TargetPosition a -> MoveOptions -> Eff (cmd :: CMD, memory :: MEMORY | e) ReturnCode 150 | moveTo' creep (TargetPt x y) opts = runThisEffFn3 "moveTo" creep x y (selectMaybes opts) 151 | moveTo' creep (TargetPos pos) opts = runThisEffFn2 "moveTo" creep pos (selectMaybes opts) 152 | moveTo' creep (TargetObj obj) opts = runThisEffFn2 "moveTo" creep obj (selectMaybes opts) 153 | 154 | notifyWhenAttacked :: forall e. Creep -> Boolean -> Eff (cmd :: CMD | e) ReturnCode 155 | notifyWhenAttacked = runThisEffFn1 "notifyWhenAttacked" 156 | 157 | pickup :: forall e. Creep -> Resource -> Eff (cmd :: CMD | e) ReturnCode 158 | pickup = runThisEffFn1 "pickup" 159 | 160 | rangedAttackCreep :: forall e. Creep -> Creep -> Eff (cmd :: CMD | e) ReturnCode 161 | rangedAttackCreep = runThisEffFn1 "rangedAttack" 162 | 163 | rangedAttackStructure :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 164 | rangedAttackStructure = runThisEffFn1 "rangedAttack" 165 | 166 | rangedHeal :: forall e. Creep -> Creep -> Eff (cmd :: CMD | e) ReturnCode 167 | rangedHeal = runThisEffFn1 "rangedHeal" 168 | 169 | rangedMassAttack :: forall e. Creep -> Eff (cmd :: CMD | e) ReturnCode 170 | rangedMassAttack = runThisEffFn0 "rangedMassAttack" 171 | 172 | repair :: forall a e. Creep -> Structure a -> Eff (cmd :: CMD | e) ReturnCode 173 | repair = runThisEffFn1 "repair" 174 | 175 | reserveController :: forall e. Creep -> Controller -> Eff (cmd :: CMD | e) ReturnCode 176 | reserveController = runThisEffFn1 "reserveController" 177 | 178 | say :: forall e. Creep -> String -> Eff (cmd :: CMD | e) ReturnCode 179 | say creep msg = runThisEffFn1 "say" creep msg 180 | 181 | sayPublic :: forall e. Creep -> String -> Eff (cmd :: CMD | e) ReturnCode 182 | sayPublic creep msg = runThisEffFn2 "say" creep msg true 183 | 184 | suicide :: forall e. Creep -> Eff (cmd :: CMD | e) ReturnCode 185 | suicide = runThisEffFn0 "suicide" 186 | 187 | transferToCreep :: forall e. Creep -> Creep -> ResourceType -> Int -> Eff (cmd :: CMD | e) ReturnCode 188 | transferToCreep = runThisEffFn3 "transfer" 189 | 190 | transferToStructure :: forall a e. Creep -> Structure a -> ResourceType -> Eff (cmd :: CMD | e) ReturnCode 191 | transferToStructure = runThisEffFn2 "transfer" 192 | 193 | transferAmtToStructure :: forall a e. Creep -> Structure a -> ResourceType -> Int -> Eff (cmd :: CMD | e) ReturnCode 194 | transferAmtToStructure = runThisEffFn3 "transfer" 195 | 196 | upgradeController :: forall e. Creep -> Controller -> Eff (cmd :: CMD | e) ReturnCode 197 | upgradeController = runThisEffFn1 "upgradeController" 198 | 199 | withdraw :: forall a e. Creep -> Structure a -> ResourceType -> Eff (cmd :: CMD | e) ReturnCode 200 | withdraw = runThisEffFn2 "withdraw" 201 | 202 | withdrawAmt :: forall a e. Creep -> Structure a -> ResourceType -> Int -> Eff (cmd :: CMD | e) ReturnCode 203 | withdrawAmt = runThisEffFn3 "withdraw" 204 | -------------------------------------------------------------------------------- /docs/Screeps/Types.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Types 2 | 3 | Defines the main types used in the library and the relationships between them. 4 | 5 | #### `GameGlobal` 6 | 7 | ``` purescript 8 | data GameGlobal :: * 9 | ``` 10 | 11 | #### `Market` 12 | 13 | ``` purescript 14 | data Market :: * 15 | ``` 16 | 17 | #### `Room` 18 | 19 | ``` purescript 20 | data Room :: * 21 | ``` 22 | 23 | #### `RoomPosition` 24 | 25 | ``` purescript 26 | data RoomPosition :: * 27 | ``` 28 | 29 | #### `WorldMap` 30 | 31 | ``` purescript 32 | data WorldMap :: * 33 | ``` 34 | 35 | #### `RoomObject` 36 | 37 | ``` purescript 38 | type RoomObject a = RawRoomObject a 39 | ``` 40 | 41 | #### `Structure` 42 | 43 | ``` purescript 44 | type Structure a = RoomObject (RawStructure a) 45 | ``` 46 | 47 | #### `OwnedStructure` 48 | 49 | ``` purescript 50 | type OwnedStructure a = Structure (RawOwnedStructure a) 51 | ``` 52 | 53 | #### `Container` 54 | 55 | ``` purescript 56 | type Container = Structure RawContainer 57 | ``` 58 | 59 | #### `Controller` 60 | 61 | ``` purescript 62 | type Controller = OwnedStructure RawController 63 | ``` 64 | 65 | #### `Extension` 66 | 67 | ``` purescript 68 | type Extension = OwnedStructure RawExtension 69 | ``` 70 | 71 | #### `Extractor` 72 | 73 | ``` purescript 74 | type Extractor = OwnedStructure RawExtractor 75 | ``` 76 | 77 | #### `KeeperLair` 78 | 79 | ``` purescript 80 | type KeeperLair = OwnedStructure RawKeeperLair 81 | ``` 82 | 83 | #### `Lab` 84 | 85 | ``` purescript 86 | type Lab = OwnedStructure RawLab 87 | ``` 88 | 89 | #### `Link` 90 | 91 | ``` purescript 92 | type Link = OwnedStructure RawLink 93 | ``` 94 | 95 | #### `Nuker` 96 | 97 | ``` purescript 98 | type Nuker = OwnedStructure RawNuker 99 | ``` 100 | 101 | #### `Observer` 102 | 103 | ``` purescript 104 | type Observer = OwnedStructure RawObserver 105 | ``` 106 | 107 | #### `Portal` 108 | 109 | ``` purescript 110 | type Portal = OwnedStructure RawPortal 111 | ``` 112 | 113 | #### `PowerBank` 114 | 115 | ``` purescript 116 | type PowerBank = OwnedStructure RawPowerBank 117 | ``` 118 | 119 | #### `PowerSpawn` 120 | 121 | ``` purescript 122 | type PowerSpawn = OwnedStructure RawPowerSpawn 123 | ``` 124 | 125 | #### `Rampart` 126 | 127 | ``` purescript 128 | type Rampart = OwnedStructure RawRampart 129 | ``` 130 | 131 | #### `Road` 132 | 133 | ``` purescript 134 | type Road = OwnedStructure RawRoad 135 | ``` 136 | 137 | #### `Spawn` 138 | 139 | ``` purescript 140 | type Spawn = OwnedStructure RawSpawn 141 | ``` 142 | 143 | #### `Storage` 144 | 145 | ``` purescript 146 | type Storage = OwnedStructure RawStorage 147 | ``` 148 | 149 | #### `Terminal` 150 | 151 | ``` purescript 152 | type Terminal = OwnedStructure RawTerminal 153 | ``` 154 | 155 | #### `Tower` 156 | 157 | ``` purescript 158 | type Tower = OwnedStructure RawTower 159 | ``` 160 | 161 | #### `Wall` 162 | 163 | ``` purescript 164 | type Wall = OwnedStructure RawWall 165 | ``` 166 | 167 | #### `ConstructionSite` 168 | 169 | ``` purescript 170 | type ConstructionSite = RoomObject RawConstructionSite 171 | ``` 172 | 173 | #### `Creep` 174 | 175 | ``` purescript 176 | type Creep = RoomObject RawCreep 177 | ``` 178 | 179 | #### `Flag` 180 | 181 | ``` purescript 182 | type Flag = RoomObject RawFlag 183 | ``` 184 | 185 | #### `Mineral` 186 | 187 | ``` purescript 188 | type Mineral = RoomObject RawMineral 189 | ``` 190 | 191 | #### `Nuke` 192 | 193 | ``` purescript 194 | type Nuke = RoomObject RawNuke 195 | ``` 196 | 197 | #### `Resource` 198 | 199 | ``` purescript 200 | type Resource = RoomObject RawResource 201 | ``` 202 | 203 | #### `Source` 204 | 205 | ``` purescript 206 | type Source = RoomObject RawSource 207 | ``` 208 | 209 | #### `RawOwnedStructure` 210 | 211 | ``` purescript 212 | data RawOwnedStructure :: * -> * 213 | ``` 214 | 215 | #### `RawRoomObject` 216 | 217 | ``` purescript 218 | data RawRoomObject :: * -> * 219 | ``` 220 | 221 | #### `RawStructure` 222 | 223 | ``` purescript 224 | data RawStructure :: * -> * 225 | ``` 226 | 227 | #### `RawContainer` 228 | 229 | ``` purescript 230 | data RawContainer :: * 231 | ``` 232 | 233 | #### `RawController` 234 | 235 | ``` purescript 236 | data RawController :: * 237 | ``` 238 | 239 | #### `RawExtension` 240 | 241 | ``` purescript 242 | data RawExtension :: * 243 | ``` 244 | 245 | #### `RawExtractor` 246 | 247 | ``` purescript 248 | data RawExtractor :: * 249 | ``` 250 | 251 | #### `RawKeeperLair` 252 | 253 | ``` purescript 254 | data RawKeeperLair :: * 255 | ``` 256 | 257 | #### `RawLab` 258 | 259 | ``` purescript 260 | data RawLab :: * 261 | ``` 262 | 263 | #### `RawLink` 264 | 265 | ``` purescript 266 | data RawLink :: * 267 | ``` 268 | 269 | #### `RawNuker` 270 | 271 | ``` purescript 272 | data RawNuker :: * 273 | ``` 274 | 275 | #### `RawObserver` 276 | 277 | ``` purescript 278 | data RawObserver :: * 279 | ``` 280 | 281 | #### `RawPortal` 282 | 283 | ``` purescript 284 | data RawPortal :: * 285 | ``` 286 | 287 | #### `RawPowerBank` 288 | 289 | ``` purescript 290 | data RawPowerBank :: * 291 | ``` 292 | 293 | #### `RawPowerSpawn` 294 | 295 | ``` purescript 296 | data RawPowerSpawn :: * 297 | ``` 298 | 299 | #### `RawRampart` 300 | 301 | ``` purescript 302 | data RawRampart :: * 303 | ``` 304 | 305 | #### `RawRoad` 306 | 307 | ``` purescript 308 | data RawRoad :: * 309 | ``` 310 | 311 | #### `RawSpawn` 312 | 313 | ``` purescript 314 | data RawSpawn :: * 315 | ``` 316 | 317 | #### `RawStorage` 318 | 319 | ``` purescript 320 | data RawStorage :: * 321 | ``` 322 | 323 | #### `RawTerminal` 324 | 325 | ``` purescript 326 | data RawTerminal :: * 327 | ``` 328 | 329 | #### `RawTower` 330 | 331 | ``` purescript 332 | data RawTower :: * 333 | ``` 334 | 335 | #### `RawWall` 336 | 337 | ``` purescript 338 | data RawWall :: * 339 | ``` 340 | 341 | #### `RawConstructionSite` 342 | 343 | ``` purescript 344 | data RawConstructionSite :: * 345 | ``` 346 | 347 | #### `RawCreep` 348 | 349 | ``` purescript 350 | data RawCreep :: * 351 | ``` 352 | 353 | #### `RawFlag` 354 | 355 | ``` purescript 356 | data RawFlag :: * 357 | ``` 358 | 359 | #### `RawMineral` 360 | 361 | ``` purescript 362 | data RawMineral :: * 363 | ``` 364 | 365 | #### `RawNuke` 366 | 367 | ``` purescript 368 | data RawNuke :: * 369 | ``` 370 | 371 | #### `RawResource` 372 | 373 | ``` purescript 374 | data RawResource :: * 375 | ``` 376 | 377 | #### `RawSource` 378 | 379 | ``` purescript 380 | data RawSource :: * 381 | ``` 382 | 383 | #### `Path` 384 | 385 | ``` purescript 386 | type Path = Array PathStep 387 | ``` 388 | 389 | #### `PathStep` 390 | 391 | ``` purescript 392 | type PathStep = { x :: Int, y :: Int, dx :: Number, dy :: Number, direction :: Direction } 393 | ``` 394 | 395 | #### `ReturnCode` 396 | 397 | ``` purescript 398 | newtype ReturnCode 399 | = ReturnCode Int 400 | ``` 401 | 402 | ##### Instances 403 | ``` purescript 404 | Generic ReturnCode 405 | Eq ReturnCode 406 | Show ReturnCode 407 | ``` 408 | 409 | #### `ResourceType` 410 | 411 | ``` purescript 412 | newtype ResourceType 413 | = ResourceType String 414 | ``` 415 | 416 | ##### Instances 417 | ``` purescript 418 | Generic ResourceType 419 | Eq ResourceType 420 | Show ResourceType 421 | ``` 422 | 423 | #### `StructureType` 424 | 425 | ``` purescript 426 | newtype StructureType 427 | = StructureType String 428 | ``` 429 | 430 | ##### Instances 431 | ``` purescript 432 | Generic StructureType 433 | Eq StructureType 434 | Show StructureType 435 | ``` 436 | 437 | #### `TerrainMask` 438 | 439 | ``` purescript 440 | newtype TerrainMask 441 | = TerrainMask Int 442 | ``` 443 | 444 | ##### Instances 445 | ``` purescript 446 | Generic TerrainMask 447 | Eq TerrainMask 448 | Show TerrainMask 449 | ``` 450 | 451 | #### `Terrain` 452 | 453 | ``` purescript 454 | newtype Terrain 455 | = Terrain String 456 | ``` 457 | 458 | ##### Instances 459 | ``` purescript 460 | Generic Terrain 461 | Eq Terrain 462 | Show Terrain 463 | ``` 464 | 465 | #### `Mode` 466 | 467 | ``` purescript 468 | newtype Mode 469 | = Mode String 470 | ``` 471 | 472 | ##### Instances 473 | ``` purescript 474 | Generic Mode 475 | Eq Mode 476 | Show Mode 477 | ``` 478 | 479 | #### `Id` 480 | 481 | ``` purescript 482 | newtype Id a 483 | = Id String 484 | ``` 485 | 486 | ##### Instances 487 | ``` purescript 488 | Generic (Id a) 489 | Eq (Id a) 490 | Show (Id a) 491 | DecodeJson (Id a) 492 | EncodeJson (Id a) 493 | ``` 494 | 495 | #### `Direction` 496 | 497 | ``` purescript 498 | newtype Direction 499 | = Direction Int 500 | ``` 501 | 502 | ##### Instances 503 | ``` purescript 504 | Generic Direction 505 | Eq Direction 506 | Show Direction 507 | ``` 508 | 509 | #### `BodyPartType` 510 | 511 | ``` purescript 512 | newtype BodyPartType 513 | = BodyPartType String 514 | ``` 515 | 516 | ##### Instances 517 | ``` purescript 518 | Generic BodyPartType 519 | Eq BodyPartType 520 | Show BodyPartType 521 | ``` 522 | 523 | #### `Color` 524 | 525 | ``` purescript 526 | newtype Color 527 | = Color Int 528 | ``` 529 | 530 | ##### Instances 531 | ``` purescript 532 | Generic Color 533 | Eq Color 534 | Show Color 535 | ``` 536 | 537 | #### `LookType` 538 | 539 | ``` purescript 540 | newtype LookType a 541 | = LookType String 542 | ``` 543 | 544 | #### `FindType` 545 | 546 | ``` purescript 547 | newtype FindType a 548 | = FindType Int 549 | ``` 550 | 551 | #### `StructureInfo` 552 | 553 | ``` purescript 554 | type StructureInfo = StrMap Int 555 | ``` 556 | 557 | #### `FilterFn` 558 | 559 | ``` purescript 560 | type FilterFn a = a -> Boolean 561 | ``` 562 | 563 | #### `TargetPosition` 564 | 565 | ``` purescript 566 | data TargetPosition a 567 | = TargetPt Int Int 568 | | TargetObj (RoomObject a) 569 | | TargetPos RoomPosition 570 | ``` 571 | 572 | #### `FindContext` 573 | 574 | ``` purescript 575 | data FindContext a 576 | = OfType (FindType a) 577 | | OfObj (Array a) 578 | | OfPos (Array RoomPosition) 579 | ``` 580 | 581 | 582 | -------------------------------------------------------------------------------- /src/Screeps/Constants.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | exports.ok = OK; 4 | exports.err_not_owner = ERR_NOT_OWNER; 5 | exports.err_no_path = ERR_NO_PATH; 6 | exports.err_name_exists = ERR_NAME_EXISTS; 7 | exports.err_busy = ERR_BUSY; 8 | exports.err_not_found = ERR_NOT_FOUND; 9 | exports.err_not_enough_energy = ERR_NOT_ENOUGH_ENERGY; 10 | exports.err_not_enough_resources = ERR_NOT_ENOUGH_RESOURCES; 11 | exports.err_invalid_target = ERR_INVALID_TARGET; 12 | exports.err_full = ERR_FULL; 13 | exports.err_not_in_range = ERR_NOT_IN_RANGE; 14 | exports.err_invalid_args = ERR_INVALID_ARGS; 15 | exports.err_tired = ERR_TIRED; 16 | exports.err_no_bodypart = ERR_NO_BODYPART; 17 | exports.err_not_enough_extensions = ERR_NOT_ENOUGH_EXTENSIONS; 18 | exports.err_rcl_not_enough = ERR_RCL_NOT_ENOUGH; 19 | exports.err_gcl_not_enough = ERR_GCL_NOT_ENOUGH; 20 | 21 | exports.find_exit_top = FIND_EXIT_TOP; 22 | exports.find_exit_right = FIND_EXIT_RIGHT; 23 | exports.find_exit_bottom = FIND_EXIT_BOTTOM; 24 | exports.find_exit_left = FIND_EXIT_LEFT; 25 | exports.find_exit = FIND_EXIT; 26 | exports.find_creeps = FIND_CREEPS; 27 | exports.find_my_creeps = FIND_MY_CREEPS; 28 | exports.find_hostile_creeps = FIND_HOSTILE_CREEPS; 29 | exports.find_sources_active = FIND_SOURCES_ACTIVE; 30 | exports.find_sources = FIND_SOURCES; 31 | exports.find_dropped_energy = FIND_DROPPED_ENERGY; 32 | exports.find_dropped_resources = FIND_DROPPED_RESOURCES; 33 | exports.find_structures = FIND_STRUCTURES; 34 | exports.find_structures0 = FIND_STRUCTURES; 35 | exports.find_my_structures = FIND_MY_STRUCTURES; 36 | exports.find_hostile_structures = FIND_HOSTILE_STRUCTURES; 37 | exports.find_flags = FIND_FLAGS; 38 | exports.find_construction_sites = FIND_CONSTRUCTION_SITES; 39 | exports.find_my_spawns = FIND_MY_SPAWNS; 40 | exports.find_hostile_spawns = FIND_HOSTILE_SPAWNS; 41 | exports.find_my_construction_sites = FIND_MY_CONSTRUCTION_SITES; 42 | exports.find_hostile_construction_sites = FIND_HOSTILE_CONSTRUCTION_SITES; 43 | exports.find_minerals = FIND_MINERALS; 44 | exports.find_nukes = FIND_NUKES; 45 | 46 | exports.top = TOP; 47 | exports.top_right = TOP_RIGHT; 48 | exports.right = RIGHT; 49 | exports.bottom_right = BOTTOM_RIGHT; 50 | exports.bottom = BOTTOM; 51 | exports.bottom_left = BOTTOM_LEFT; 52 | exports.left = LEFT; 53 | exports.top_left = TOP_LEFT; 54 | 55 | exports.color_red = COLOR_RED; 56 | exports.color_purple = COLOR_PURPLE; 57 | exports.color_blue = COLOR_BLUE; 58 | exports.color_cyan = COLOR_CYAN; 59 | exports.color_green = COLOR_GREEN; 60 | exports.color_yellow = COLOR_YELLOW; 61 | exports.color_orange = COLOR_ORANGE; 62 | exports.color_brown = COLOR_BROWN; 63 | exports.color_grey = COLOR_GREY; 64 | exports.color_white = COLOR_WHITE; 65 | 66 | exports.look_creeps = LOOK_CREEPS; 67 | exports.look_energy = LOOK_ENERGY; 68 | exports.look_resources = LOOK_RESOURCES; 69 | exports.look_sources = LOOK_SOURCES; 70 | exports.look_minerals = LOOK_MINERALS; 71 | exports.look_structures = LOOK_STRUCTURES; 72 | exports.look_flags = LOOK_FLAGS; 73 | exports.look_construction_sites = LOOK_CONSTRUCTION_SITES; 74 | exports.look_nukes = LOOK_NUKES; 75 | exports.look_terrain = LOOK_TERRAIN; 76 | 77 | exports.obstacle_object_types = OBSTACLE_OBJECT_TYPES; 78 | 79 | exports.part_move = MOVE; 80 | exports.part_work = WORK; 81 | exports.part_carry = CARRY; 82 | exports.part_attack = ATTACK; 83 | exports.part_ranged_attack = RANGED_ATTACK; 84 | exports.part_tough = TOUGH; 85 | exports.part_heal = HEAL; 86 | exports.part_claim = CLAIM; 87 | 88 | exports.bodypart_cost = BODYPART_COST; 89 | 90 | exports.creep_life_time = CREEP_LIFE_TIME; 91 | exports.creep_claim_life_time = CREEP_CLAIM_LIFE_TIME; 92 | exports.creep_corpse_rate = CREEP_CORPSE_RATE; 93 | 94 | exports.carry_capacity = CARRY_CAPACITY; 95 | exports.harvest_power = HARVEST_POWER; 96 | exports.harvest_mineral_power = HARVEST_MINERAL_POWER; 97 | exports.repair_power = REPAIR_POWER; 98 | exports.dismantle_power = DISMANTLE_POWER; 99 | exports.build_power = BUILD_POWER; 100 | exports.attack_power = ATTACK_POWER; 101 | exports.upgrade_controller_power = UPGRADE_CONTROLLER_POWER; 102 | exports.ranged_attack_power = RANGED_ATTACK_POWER; 103 | exports.heal_power = HEAL_POWER; 104 | exports.ranged_heal_power = RANGED_HEAL_POWER; 105 | exports.repair_cost = REPAIR_COST; 106 | exports.dismantle_cost = DISMANTLE_COST; 107 | 108 | exports.rampart_decay_amount = RAMPART_DECAY_AMOUNT; 109 | exports.rampart_decay_time = RAMPART_DECAY_TIME; 110 | exports.rampart_hits = RAMPART_HITS; 111 | exports.rampart_hits_max = RAMPART_HITS_MAX; 112 | 113 | exports.energy_regen_time = ENERGY_REGEN_TIME; 114 | exports.energy_decay = ENERGY_DECAY; 115 | 116 | exports.spawn_hits = SPAWN_HITS; 117 | exports.spawn_energy_start = SPAWN_ENERGY_START; 118 | exports.spawn_energy_capacity = SPAWN_ENERGY_CAPACITY; 119 | exports.creep_spawn_time = CREEP_SPAWN_TIME; 120 | 121 | exports.source_energy_capacity = SOURCE_ENERGY_CAPACITY; 122 | exports.source_energy_neutral_capacity = SOURCE_ENERGY_NEUTRAL_CAPACITY; 123 | exports.source_energy_keeper_capacity = SOURCE_ENERGY_KEEPER_CAPACITY; 124 | 125 | exports.wall_hits = WALL_HITS; 126 | exports.wall_hits_max = WALL_HITS_MAX; 127 | 128 | exports.extension_hits = EXTENSION_HITS; 129 | exports.extension_energy_capacity = EXTENSION_ENERGY_CAPACITY; 130 | 131 | exports.road_hits = ROAD_HITS; 132 | exports.road_wearout = ROAD_WEAROUT; 133 | exports.road_decay_amount = ROAD_DECAY_AMOUNT; 134 | exports.road_decay_time = ROAD_DECAY_TIME; 135 | 136 | exports.link_hits = LINK_HITS; 137 | exports.link_hits_max = LINK_HITS_MAX; 138 | exports.link_capacity = LINK_CAPACITY; 139 | exports.link_cooldown = LINK_COOLDOWN; 140 | exports.link_loss_ratio = LINK_LOSS_RATIO; 141 | 142 | exports.storage_capacity = STORAGE_CAPACITY; 143 | exports.storage_hits = STORAGE_HITS; 144 | 145 | exports.structure_spawn = STRUCTURE_SPAWN; 146 | exports.structure_extension = STRUCTURE_EXTENSION; 147 | exports.structure_road = STRUCTURE_ROAD; 148 | exports.structure_wall = STRUCTURE_WALL; 149 | exports.structure_rampart = STRUCTURE_RAMPART; 150 | exports.structure_keeper_lair = STRUCTURE_KEEPER_LAIR; 151 | exports.structure_portal = STRUCTURE_PORTAL; 152 | exports.structure_controller = STRUCTURE_CONTROLLER; 153 | exports.structure_link = STRUCTURE_LINK; 154 | exports.structure_storage = STRUCTURE_STORAGE; 155 | exports.structure_tower = STRUCTURE_TOWER; 156 | exports.structure_observer = STRUCTURE_OBSERVER; 157 | exports.structure_power_bank = STRUCTURE_POWER_BANK; 158 | exports.structure_power_spawn = STRUCTURE_POWER_SPAWN; 159 | exports.structure_extractor = STRUCTURE_EXTRACTOR; 160 | exports.structure_lab = STRUCTURE_LAB; 161 | exports.structure_terminal = STRUCTURE_TERMINAL; 162 | exports.structure_container = STRUCTURE_CONTAINER; 163 | exports.structure_nuker = STRUCTURE_NUKER; 164 | 165 | exports.construction_cost = CONSTRUCTION_COST; 166 | exports.construction_cost_road_swamp_ratio = CONSTRUCTION_COST_ROAD_SWAMP_RATIO; 167 | 168 | exports.controller_levels = CONTROLLER_LEVELS; 169 | exports.controller_structures = CONTROLLER_STRUCTURES; 170 | exports.controller_downgrade = CONTROLLER_DOWNGRADE; 171 | exports.controller_claim_downgrade = CONTROLLER_CLAIM_DOWNGRADE; 172 | exports.controller_reserve = CONTROLLER_RESERVE; 173 | exports.controller_reserve_max = CONTROLLER_RESERVE_MAX; 174 | exports.controller_max_upgrade_per_tick = CONTROLLER_MAX_UPGRADE_PER_TICK; 175 | exports.controller_attack_blocked_upgrade = CONTROLLER_ATTACK_BLOCKED_UPGRADE; 176 | 177 | exports.tower_hits = TOWER_HITS; 178 | exports.tower_capacity = TOWER_CAPACITY; 179 | exports.tower_energy_cost = TOWER_ENERGY_COST; 180 | exports.tower_power_attack = TOWER_POWER_ATTACK; 181 | exports.tower_power_heal = TOWER_POWER_HEAL; 182 | exports.tower_power_repair = TOWER_POWER_REPAIR; 183 | exports.tower_optimal_range = TOWER_OPTIMAL_RANGE; 184 | exports.tower_falloff_range = TOWER_FALLOFF_RANGE; 185 | exports.tower_falloff = TOWER_FALLOFF; 186 | 187 | exports.observer_hits = OBSERVER_HITS; 188 | exports.observer_range = OBSERVER_RANGE; 189 | 190 | exports.power_bank_hits = POWER_BANK_HITS; 191 | exports.power_bank_capacity_max = POWER_BANK_CAPACITY_MAX; 192 | exports.power_bank_capacity_min = POWER_BANK_CAPACITY_MIN; 193 | exports.power_bank_capacity_crit = POWER_BANK_CAPACITY_CRIT; 194 | exports.power_bank_decay = POWER_BANK_DECAY; 195 | exports.power_bank_hit_back = POWER_BANK_HIT_BACK; 196 | 197 | exports.power_spawn_hits = POWER_SPAWN_HITS; 198 | exports.power_spawn_energy_capacity = POWER_SPAWN_ENERGY_CAPACITY; 199 | exports.power_spawn_power_capacity = POWER_SPAWN_POWER_CAPACITY; 200 | exports.power_spawn_energy_ratio = POWER_SPAWN_ENERGY_RATIO; 201 | 202 | exports.extractor_hits = EXTRACTOR_HITS; 203 | 204 | exports.lab_hits = LAB_HITS; 205 | exports.lab_mineral_capacity = LAB_MINERAL_CAPACITY; 206 | exports.lab_energy_capacity = LAB_ENERGY_CAPACITY; 207 | exports.lab_boost_energy = LAB_BOOST_ENERGY; 208 | exports.lab_boost_mineral = LAB_BOOST_MINERAL; 209 | exports.lab_cooldown = LAB_COOLDOWN; 210 | 211 | exports.gcl_pow = GCL_POW; 212 | exports.gcl_multiply = GCL_MULTIPLY; 213 | exports.gcl_novice = GCL_NOVICE; 214 | 215 | exports.mode_simulation = MODE_SIMULATION; 216 | exports.mode_survival = MODE_SURVIVAL; 217 | exports.mode_world = MODE_WORLD; 218 | exports.mode_arena = MODE_ARENA; 219 | 220 | exports.terrain_mask_wall = TERRAIN_MASK_WALL; 221 | exports.terrain_mask_swamp = TERRAIN_MASK_SWAMP; 222 | exports.terrain_mask_lava = TERRAIN_MASK_LAVA; 223 | 224 | exports.max_construction_sites = MAX_CONSTRUCTION_SITES; 225 | exports.max_creep_size = MAX_CREEP_SIZE; 226 | 227 | exports.mineral_regen_time = MINERAL_REGEN_TIME; 228 | exports.mineral_min_amount = MINERAL_MIN_AMOUNT; 229 | exports.mineral_random_factor = MINERAL_RANDOM_FACTOR; 230 | 231 | exports.terminal_capacity = TERMINAL_CAPACITY; 232 | exports.terminal_hits = TERMINAL_HITS; 233 | exports.terminal_send_cost = TERMINAL_SEND_COST; 234 | exports.terminal_min_send = TERMINAL_MIN_SEND; 235 | 236 | exports.container_hits = CONTAINER_HITS; 237 | exports.container_capacity = CONTAINER_CAPACITY; 238 | exports.container_decay = CONTAINER_DECAY; 239 | exports.container_decay_time = CONTAINER_DECAY_TIME; 240 | exports.container_decay_time_owned = CONTAINER_DECAY_TIME_OWNED; 241 | 242 | exports.nuker_hits = NUKER_HITS; 243 | exports.nuker_cooldown = NUKER_COOLDOWN; 244 | exports.nuker_energy_capacity = NUKER_ENERGY_CAPACITY; 245 | exports.nuker_ghodium_capacity = NUKER_GHODIUM_CAPACITY; 246 | exports.nuke_land_time = NUKE_LAND_TIME; 247 | exports.nuke_range = NUKE_RANGE; 248 | exports.nuke_damage = NUKE_DAMAGE; 249 | 250 | exports.resource_energy = RESOURCE_ENERGY; 251 | exports.resource_power = RESOURCE_POWER; 252 | 253 | exports.resource_hydrogen = RESOURCE_HYDROGEN; 254 | exports.resource_oxygen = RESOURCE_OXYGEN; 255 | exports.resource_utrium = RESOURCE_UTRIUM; 256 | exports.resource_lemergium = RESOURCE_LEMERGIUM; 257 | exports.resource_keanium = RESOURCE_KEANIUM; 258 | exports.resource_zynthium = RESOURCE_ZYNTHIUM; 259 | exports.resource_catalyst = RESOURCE_CATALYST; 260 | exports.resource_ghodium = RESOURCE_GHODIUM; 261 | 262 | exports.resource_hydroxide = RESOURCE_HYDROXIDE; 263 | exports.resource_zynthium_keanite = RESOURCE_ZYNTHIUM_KEANITE; 264 | exports.resource_utrium_lemergite = RESOURCE_UTRIUM_LEMERGITE; 265 | 266 | exports.resource_utrium_hydride = RESOURCE_UTRIUM_HYDRIDE; 267 | exports.resource_utrium_oxide = RESOURCE_UTRIUM_OXIDE; 268 | exports.resource_keanium_hydride = RESOURCE_KEANIUM_HYDRIDE; 269 | exports.resource_keanium_oxide = RESOURCE_KEANIUM_OXIDE; 270 | exports.resource_lemergium_hydride = RESOURCE_LEMERGIUM_HYDRIDE; 271 | exports.resource_lemergium_oxide = RESOURCE_LEMERGIUM_OXIDE; 272 | exports.resource_zynthium_hydride = RESOURCE_ZYNTHIUM_HYDRIDE; 273 | exports.resource_zynthium_oxide = RESOURCE_ZYNTHIUM_OXIDE; 274 | exports.resource_ghodium_hydride = RESOURCE_GHODIUM_HYDRIDE; 275 | exports.resource_ghodium_oxide = RESOURCE_GHODIUM_OXIDE; 276 | 277 | exports.resource_utrium_acid = RESOURCE_UTRIUM_ACID; 278 | exports.resource_utrium_alkalide = RESOURCE_UTRIUM_ALKALIDE; 279 | exports.resource_keanium_acid = RESOURCE_KEANIUM_ACID; 280 | exports.resource_keanium_alkalide = RESOURCE_KEANIUM_ALKALIDE; 281 | exports.resource_lemergium_acid = RESOURCE_LEMERGIUM_ACID; 282 | exports.resource_lemergium_alkalide = RESOURCE_LEMERGIUM_ALKALIDE; 283 | exports.resource_zynthium_acid = RESOURCE_ZYNTHIUM_ACID; 284 | exports.resource_zynthium_alkalide = RESOURCE_ZYNTHIUM_ALKALIDE; 285 | exports.resource_ghodium_acid = RESOURCE_GHODIUM_ACID; 286 | exports.resource_ghodium_alkalide = RESOURCE_GHODIUM_ALKALIDE; 287 | 288 | exports.resource_catalyzed_utrium_acid = RESOURCE_CATALYZED_UTRIUM_ACID; 289 | exports.resource_catalyzed_utrium_alkalide = RESOURCE_CATALYZED_UTRIUM_ALKALIDE; 290 | exports.resource_catalyzed_keanium_acid = RESOURCE_CATALYZED_KEANIUM_ACID; 291 | exports.resource_catalyzed_keanium_alkalide = RESOURCE_CATALYZED_KEANIUM_ALKALIDE; 292 | exports.resource_catalyzed_lemergium_acid = RESOURCE_CATALYZED_LEMERGIUM_ACID; 293 | exports.resource_catalyzed_lemergium_alkalide = RESOURCE_CATALYZED_LEMERGIUM_ALKALIDE; 294 | exports.resource_catalyzed_zynthium_acid = RESOURCE_CATALYZED_ZYNTHIUM_ACID; 295 | exports.resource_catalyzed_zynthium_alkalide = RESOURCE_CATALYZED_ZYNTHIUM_ALKALIDE; 296 | exports.resource_catalyzed_ghodium_acid = RESOURCE_CATALYZED_GHODIUM_ACID; 297 | exports.resource_catalyzed_ghodium_alkalide = RESOURCE_CATALYZED_GHODIUM_ALKALIDE; 298 | -------------------------------------------------------------------------------- /src/Screeps/Constants.purs: -------------------------------------------------------------------------------- 1 | module Screeps.Constants where 2 | 3 | import Prelude 4 | 5 | import Screeps.Types 6 | 7 | foreign import ok :: ReturnCode 8 | foreign import err_not_owner :: ReturnCode 9 | foreign import err_no_path :: ReturnCode 10 | foreign import err_name_exists :: ReturnCode 11 | foreign import err_busy :: ReturnCode 12 | foreign import err_not_found :: ReturnCode 13 | foreign import err_not_enough_energy :: ReturnCode 14 | foreign import err_not_enough_resources :: ReturnCode 15 | foreign import err_invalid_target :: ReturnCode 16 | foreign import err_full :: ReturnCode 17 | foreign import err_not_in_range :: ReturnCode 18 | foreign import err_invalid_args :: ReturnCode 19 | foreign import err_tired :: ReturnCode 20 | foreign import err_no_bodypart :: ReturnCode 21 | foreign import err_not_enough_extensions :: ReturnCode 22 | foreign import err_rcl_not_enough :: ReturnCode 23 | foreign import err_gcl_not_enough :: ReturnCode 24 | 25 | foreign import find_exit_top :: FindType RoomPosition 26 | foreign import find_exit_right :: FindType RoomPosition 27 | foreign import find_exit_bottom :: FindType RoomPosition 28 | foreign import find_exit_left :: FindType RoomPosition 29 | foreign import find_exit :: FindType RoomPosition 30 | foreign import find_creeps :: FindType Creep 31 | foreign import find_my_creeps :: FindType Creep 32 | foreign import find_hostile_creeps :: FindType Creep 33 | foreign import find_sources_active :: FindType Source 34 | foreign import find_sources :: FindType Source 35 | foreign import find_dropped_energy :: FindType Resource 36 | foreign import find_dropped_resources :: FindType Resource 37 | foreign import find_structures :: FindType (Structure Unit) 38 | foreign import find_my_structures :: forall a. FindType (Structure a) 39 | foreign import find_hostile_structures :: FindType (Structure Unit) 40 | foreign import find_flags :: FindType Flag 41 | foreign import find_construction_sites :: FindType ConstructionSite 42 | foreign import find_my_spawns :: FindType Spawn 43 | foreign import find_hostile_spawns :: FindType Spawn 44 | foreign import find_my_construction_sites :: FindType ConstructionSite 45 | foreign import find_hostile_construction_sites :: FindType ConstructionSite 46 | foreign import find_minerals :: FindType Mineral 47 | foreign import find_nukes :: FindType Nuke 48 | 49 | foreign import top :: Direction 50 | foreign import top_right :: Direction 51 | foreign import right :: Direction 52 | foreign import bottom_right :: Direction 53 | foreign import bottom :: Direction 54 | foreign import bottom_left :: Direction 55 | foreign import left :: Direction 56 | foreign import top_left :: Direction 57 | 58 | foreign import color_red :: Color 59 | foreign import color_purple :: Color 60 | foreign import color_blue :: Color 61 | foreign import color_cyan :: Color 62 | foreign import color_green :: Color 63 | foreign import color_yellow :: Color 64 | foreign import color_orange :: Color 65 | foreign import color_brown :: Color 66 | foreign import color_grey :: Color 67 | foreign import color_white :: Color 68 | 69 | foreign import look_creeps :: LookType Creep 70 | foreign import look_energy :: LookType Resource 71 | foreign import look_resources :: LookType Resource 72 | foreign import look_sources :: LookType Source 73 | foreign import look_minerals :: LookType Mineral 74 | foreign import look_structures :: LookType (Structure Unit) 75 | foreign import look_flags :: LookType Flag 76 | foreign import look_construction_sites :: LookType ConstructionSite 77 | foreign import look_nukes :: LookType Nuke 78 | foreign import look_terrain :: LookType Terrain 79 | 80 | foreign import obstacle_object_types :: Array String 81 | 82 | foreign import part_move :: BodyPartType 83 | foreign import part_work :: BodyPartType 84 | foreign import part_carry :: BodyPartType 85 | foreign import part_attack :: BodyPartType 86 | foreign import part_ranged_attack :: BodyPartType 87 | foreign import part_tough :: BodyPartType 88 | foreign import part_heal :: BodyPartType 89 | foreign import part_claim :: BodyPartType 90 | 91 | foreign import bodypart_cost :: 92 | { move :: Int 93 | , work :: Int 94 | , attack :: Int 95 | , carry :: Int 96 | , heal :: Int 97 | , ranged_attack :: Int 98 | , tough :: Int 99 | , claim :: Int } 100 | 101 | foreign import creep_life_time :: Int 102 | foreign import creep_claim_life_time :: Int 103 | foreign import creep_corpse_rate :: Int 104 | 105 | foreign import carry_capacity :: Int 106 | foreign import harvest_power :: Int 107 | foreign import harvest_mineral_power :: Int 108 | foreign import repair_power :: Int 109 | foreign import dismantle_power :: Int 110 | foreign import build_power :: Int 111 | foreign import attack_power :: Int 112 | foreign import upgrade_controller_power :: Int 113 | foreign import ranged_attack_power :: Int 114 | foreign import heal_power :: Int 115 | foreign import ranged_heal_power :: Int 116 | foreign import repair_cost :: Int 117 | foreign import dismantle_cost :: Int 118 | 119 | foreign import rampart_decay_amount :: Int 120 | foreign import rampart_decay_time :: Int 121 | foreign import rampart_hits :: Int 122 | foreign import rampart_hits_max :: 123 | { "2" :: Int 124 | , "3" :: Int 125 | , "4" :: Int 126 | , "5" :: Int 127 | , "6" :: Int 128 | , "7" :: Int 129 | , "8" :: Int } 130 | 131 | foreign import energy_regen_time :: Int 132 | foreign import energy_decay :: Int 133 | 134 | foreign import spawn_hits :: Int 135 | foreign import spawn_energy_start :: Int 136 | foreign import spawn_energy_capacity :: Int 137 | foreign import creep_spawn_time :: Int 138 | 139 | foreign import source_energy_capacity :: Int 140 | foreign import source_energy_neutral_capacity :: Int 141 | foreign import source_energy_keeper_capacity :: Int 142 | 143 | foreign import wall_hits :: Int 144 | foreign import wall_hits_max :: Int 145 | 146 | foreign import extension_hits :: Int 147 | foreign import extension_energy_capacity :: 148 | { "0" :: Int 149 | , "1" :: Int 150 | , "2" :: Int 151 | , "3" :: Int 152 | , "4" :: Int 153 | , "5" :: Int 154 | , "6" :: Int 155 | , "7" :: Int 156 | , "8" :: Int } 157 | 158 | foreign import road_hits :: Int 159 | foreign import road_wearout :: Int 160 | foreign import road_decay_amount :: Int 161 | foreign import road_decay_time :: Int 162 | 163 | foreign import link_hits :: Int 164 | foreign import link_hits_max :: Int 165 | foreign import link_capacity :: Int 166 | foreign import link_cooldown :: Int 167 | foreign import link_loss_ratio :: Number 168 | 169 | foreign import storage_capacity :: Int 170 | foreign import storage_hits :: Int 171 | 172 | foreign import structure_spawn :: StructureType 173 | foreign import structure_extension :: StructureType 174 | foreign import structure_road :: StructureType 175 | foreign import structure_wall :: StructureType 176 | foreign import structure_rampart :: StructureType 177 | foreign import structure_keeper_lair :: StructureType 178 | foreign import structure_portal :: StructureType 179 | foreign import structure_controller :: StructureType 180 | foreign import structure_link :: StructureType 181 | foreign import structure_storage :: StructureType 182 | foreign import structure_tower :: StructureType 183 | foreign import structure_observer :: StructureType 184 | foreign import structure_power_bank :: StructureType 185 | foreign import structure_power_spawn :: StructureType 186 | foreign import structure_extractor :: StructureType 187 | foreign import structure_lab :: StructureType 188 | foreign import structure_terminal :: StructureType 189 | foreign import structure_container :: StructureType 190 | foreign import structure_nuker :: StructureType 191 | 192 | foreign import construction_cost :: 193 | { spawn :: Int 194 | , extension :: Int 195 | , road :: Int 196 | , constructedWall :: Int 197 | , rampart :: Int 198 | , link :: Int 199 | , storage :: Int 200 | , tower :: Int 201 | , observer :: Int 202 | , powerSpawn :: Int 203 | , extractor :: Int 204 | , lab :: Int 205 | , terminal :: Int 206 | , container :: Int 207 | , nuker :: Int } 208 | foreign import construction_cost_road_swamp_ratio :: Int 209 | 210 | foreign import controller_levels :: 211 | { "1" :: Int 212 | , "2" :: Int 213 | , "3" :: Int 214 | , "4" :: Int 215 | , "5" :: Int 216 | , "6" :: Int 217 | , "7" :: Int } 218 | foreign import controller_structures :: 219 | { spawn :: StructureInfo 220 | , extension :: StructureInfo 221 | , road :: StructureInfo 222 | , constructedWall :: StructureInfo 223 | , rampart :: StructureInfo 224 | , link :: StructureInfo 225 | , storage :: StructureInfo 226 | , tower :: StructureInfo 227 | , observer :: StructureInfo 228 | , powerSpawn :: StructureInfo 229 | , extractor :: StructureInfo 230 | , lab :: StructureInfo 231 | , terminal :: StructureInfo 232 | , container :: StructureInfo 233 | , nuker :: StructureInfo } 234 | 235 | foreign import controller_downgrade :: StructureInfo 236 | foreign import controller_claim_downgrade :: Number 237 | foreign import controller_reserve :: Int 238 | foreign import controller_reserve_max :: Int 239 | foreign import controller_max_upgrade_per_tick :: Int 240 | foreign import controller_attack_blocked_upgrade :: Int 241 | 242 | foreign import tower_hits :: Int 243 | foreign import tower_capacity :: Int 244 | foreign import tower_energy_cost :: Int 245 | foreign import tower_power_attack :: Int 246 | foreign import tower_power_heal :: Int 247 | foreign import tower_power_repair :: Int 248 | foreign import tower_optimal_range :: Int 249 | foreign import tower_falloff_range :: Int 250 | foreign import tower_falloff :: Number 251 | 252 | foreign import observer_hits :: Int 253 | foreign import observer_range :: Int 254 | 255 | foreign import power_bank_hits :: Int 256 | foreign import power_bank_capacity_max :: Int 257 | foreign import power_bank_capacity_min :: Int 258 | foreign import power_bank_capacity_crit :: Number 259 | foreign import power_bank_decay :: Int 260 | foreign import power_bank_hit_back :: Number 261 | 262 | foreign import power_spawn_hits :: Int 263 | foreign import power_spawn_energy_capacity :: Int 264 | foreign import power_spawn_power_capacity :: Int 265 | foreign import power_spawn_energy_ratio :: Int 266 | 267 | foreign import extractor_hits :: Int 268 | 269 | foreign import lab_hits :: Int 270 | foreign import lab_mineral_capacity :: Int 271 | foreign import lab_energy_capacity :: Int 272 | foreign import lab_boost_energy :: Int 273 | foreign import lab_boost_mineral :: Int 274 | foreign import lab_cooldown :: Int 275 | 276 | foreign import gcl_pow :: Number 277 | foreign import gcl_multiply :: Int 278 | foreign import gcl_novice :: Int 279 | 280 | foreign import mode_simulation :: Mode 281 | foreign import mode_survival :: Mode 282 | foreign import mode_world :: Mode 283 | foreign import mode_arena :: Mode 284 | 285 | foreign import terrain_mask_wall :: TerrainMask 286 | foreign import terrain_mask_swamp :: TerrainMask 287 | foreign import terrain_mask_lava :: TerrainMask 288 | 289 | foreign import max_construction_sites :: Int 290 | foreign import max_creep_size :: Int 291 | 292 | foreign import mineral_regen_time :: Int 293 | foreign import mineral_min_amount :: 294 | { "H" :: Int 295 | , "O" :: Int 296 | , "L" :: Int 297 | , "K" :: Int 298 | , "Z" :: Int 299 | , "U" :: Int 300 | , "X" :: Int } 301 | foreign import mineral_random_factor :: Int 302 | 303 | foreign import terminal_capacity :: Int 304 | foreign import terminal_hits :: Int 305 | foreign import terminal_send_cost :: Number 306 | foreign import terminal_min_send :: Int 307 | 308 | foreign import container_hits :: Int 309 | foreign import container_capacity :: Int 310 | foreign import container_decay :: Int 311 | foreign import container_decay_time :: Int 312 | foreign import container_decay_time_owned :: Int 313 | 314 | foreign import nuker_hits :: Int 315 | foreign import nuker_cooldown :: Int 316 | foreign import nuker_energy_capacity :: Int 317 | foreign import nuker_ghodium_capacity :: Int 318 | foreign import nuke_land_time :: Int 319 | foreign import nuke_range :: Int 320 | foreign import nuke_damage :: 321 | { "0" :: Int 322 | , "1" :: Int 323 | , "4" :: Int } 324 | 325 | foreign import resource_energy :: ResourceType 326 | foreign import resource_power :: ResourceType 327 | 328 | foreign import resource_hydrogen :: ResourceType 329 | foreign import resource_oxygen :: ResourceType 330 | foreign import resource_utrium :: ResourceType 331 | foreign import resource_lemergium :: ResourceType 332 | foreign import resource_keanium :: ResourceType 333 | foreign import resource_zynthium :: ResourceType 334 | foreign import resource_catalyst :: ResourceType 335 | foreign import resource_ghodium :: ResourceType 336 | 337 | foreign import resource_hydroxide :: ResourceType 338 | foreign import resource_zynthium_keanite :: ResourceType 339 | foreign import resource_utrium_lemergite :: ResourceType 340 | 341 | foreign import resource_utrium_hydride :: ResourceType 342 | foreign import resource_utrium_oxide :: ResourceType 343 | foreign import resource_keanium_hydride :: ResourceType 344 | foreign import resource_keanium_oxide :: ResourceType 345 | foreign import resource_lemergium_hydride :: ResourceType 346 | foreign import resource_lemergium_oxide :: ResourceType 347 | foreign import resource_zynthium_hydride :: ResourceType 348 | foreign import resource_zynthium_oxide :: ResourceType 349 | foreign import resource_ghodium_hydride :: ResourceType 350 | foreign import resource_ghodium_oxide :: ResourceType 351 | 352 | foreign import resource_utrium_acid :: ResourceType 353 | foreign import resource_utrium_alkalide :: ResourceType 354 | foreign import resource_keanium_acid :: ResourceType 355 | foreign import resource_keanium_alkalide :: ResourceType 356 | foreign import resource_lemergium_acid :: ResourceType 357 | foreign import resource_lemergium_alkalide :: ResourceType 358 | foreign import resource_zynthium_acid :: ResourceType 359 | foreign import resource_zynthium_alkalide :: ResourceType 360 | foreign import resource_ghodium_acid :: ResourceType 361 | foreign import resource_ghodium_alkalide :: ResourceType 362 | 363 | foreign import resource_catalyzed_utrium_acid :: ResourceType 364 | foreign import resource_catalyzed_utrium_alkalide :: ResourceType 365 | foreign import resource_catalyzed_keanium_acid :: ResourceType 366 | foreign import resource_catalyzed_keanium_alkalide :: ResourceType 367 | foreign import resource_catalyzed_lemergium_acid :: ResourceType 368 | foreign import resource_catalyzed_lemergium_alkalide :: ResourceType 369 | foreign import resource_catalyzed_zynthium_acid :: ResourceType 370 | foreign import resource_catalyzed_zynthium_alkalide :: ResourceType 371 | foreign import resource_catalyzed_ghodium_acid :: ResourceType 372 | foreign import resource_catalyzed_ghodium_alkalide :: ResourceType 373 | -------------------------------------------------------------------------------- /docs/Screeps/Constants.md: -------------------------------------------------------------------------------- 1 | ## Module Screeps.Constants 2 | 3 | #### `ok` 4 | 5 | ``` purescript 6 | ok :: ReturnCode 7 | ``` 8 | 9 | #### `err_not_owner` 10 | 11 | ``` purescript 12 | err_not_owner :: ReturnCode 13 | ``` 14 | 15 | #### `err_no_path` 16 | 17 | ``` purescript 18 | err_no_path :: ReturnCode 19 | ``` 20 | 21 | #### `err_name_exists` 22 | 23 | ``` purescript 24 | err_name_exists :: ReturnCode 25 | ``` 26 | 27 | #### `err_busy` 28 | 29 | ``` purescript 30 | err_busy :: ReturnCode 31 | ``` 32 | 33 | #### `err_not_found` 34 | 35 | ``` purescript 36 | err_not_found :: ReturnCode 37 | ``` 38 | 39 | #### `err_not_enough_energy` 40 | 41 | ``` purescript 42 | err_not_enough_energy :: ReturnCode 43 | ``` 44 | 45 | #### `err_not_enough_resources` 46 | 47 | ``` purescript 48 | err_not_enough_resources :: ReturnCode 49 | ``` 50 | 51 | #### `err_invalid_target` 52 | 53 | ``` purescript 54 | err_invalid_target :: ReturnCode 55 | ``` 56 | 57 | #### `err_full` 58 | 59 | ``` purescript 60 | err_full :: ReturnCode 61 | ``` 62 | 63 | #### `err_not_in_range` 64 | 65 | ``` purescript 66 | err_not_in_range :: ReturnCode 67 | ``` 68 | 69 | #### `err_invalid_args` 70 | 71 | ``` purescript 72 | err_invalid_args :: ReturnCode 73 | ``` 74 | 75 | #### `err_tired` 76 | 77 | ``` purescript 78 | err_tired :: ReturnCode 79 | ``` 80 | 81 | #### `err_no_bodypart` 82 | 83 | ``` purescript 84 | err_no_bodypart :: ReturnCode 85 | ``` 86 | 87 | #### `err_not_enough_extensions` 88 | 89 | ``` purescript 90 | err_not_enough_extensions :: ReturnCode 91 | ``` 92 | 93 | #### `err_rcl_not_enough` 94 | 95 | ``` purescript 96 | err_rcl_not_enough :: ReturnCode 97 | ``` 98 | 99 | #### `err_gcl_not_enough` 100 | 101 | ``` purescript 102 | err_gcl_not_enough :: ReturnCode 103 | ``` 104 | 105 | #### `find_exit_top` 106 | 107 | ``` purescript 108 | find_exit_top :: FindType RoomPosition 109 | ``` 110 | 111 | #### `find_exit_right` 112 | 113 | ``` purescript 114 | find_exit_right :: FindType RoomPosition 115 | ``` 116 | 117 | #### `find_exit_bottom` 118 | 119 | ``` purescript 120 | find_exit_bottom :: FindType RoomPosition 121 | ``` 122 | 123 | #### `find_exit_left` 124 | 125 | ``` purescript 126 | find_exit_left :: FindType RoomPosition 127 | ``` 128 | 129 | #### `find_exit` 130 | 131 | ``` purescript 132 | find_exit :: FindType RoomPosition 133 | ``` 134 | 135 | #### `find_creeps` 136 | 137 | ``` purescript 138 | find_creeps :: FindType Creep 139 | ``` 140 | 141 | #### `find_my_creeps` 142 | 143 | ``` purescript 144 | find_my_creeps :: FindType Creep 145 | ``` 146 | 147 | #### `find_hostile_creeps` 148 | 149 | ``` purescript 150 | find_hostile_creeps :: FindType Creep 151 | ``` 152 | 153 | #### `find_sources_active` 154 | 155 | ``` purescript 156 | find_sources_active :: FindType Source 157 | ``` 158 | 159 | #### `find_sources` 160 | 161 | ``` purescript 162 | find_sources :: FindType Source 163 | ``` 164 | 165 | #### `find_dropped_energy` 166 | 167 | ``` purescript 168 | find_dropped_energy :: FindType Resource 169 | ``` 170 | 171 | #### `find_dropped_resources` 172 | 173 | ``` purescript 174 | find_dropped_resources :: FindType Resource 175 | ``` 176 | 177 | #### `find_structures` 178 | 179 | ``` purescript 180 | find_structures :: FindType (Structure Unit) 181 | ``` 182 | 183 | #### `find_my_structures` 184 | 185 | ``` purescript 186 | find_my_structures :: forall a. FindType (Structure a) 187 | ``` 188 | 189 | #### `find_hostile_structures` 190 | 191 | ``` purescript 192 | find_hostile_structures :: FindType (Structure Unit) 193 | ``` 194 | 195 | #### `find_flags` 196 | 197 | ``` purescript 198 | find_flags :: FindType Flag 199 | ``` 200 | 201 | #### `find_construction_sites` 202 | 203 | ``` purescript 204 | find_construction_sites :: FindType ConstructionSite 205 | ``` 206 | 207 | #### `find_my_spawns` 208 | 209 | ``` purescript 210 | find_my_spawns :: FindType Spawn 211 | ``` 212 | 213 | #### `find_hostile_spawns` 214 | 215 | ``` purescript 216 | find_hostile_spawns :: FindType Spawn 217 | ``` 218 | 219 | #### `find_my_construction_sites` 220 | 221 | ``` purescript 222 | find_my_construction_sites :: FindType ConstructionSite 223 | ``` 224 | 225 | #### `find_hostile_construction_sites` 226 | 227 | ``` purescript 228 | find_hostile_construction_sites :: FindType ConstructionSite 229 | ``` 230 | 231 | #### `find_minerals` 232 | 233 | ``` purescript 234 | find_minerals :: FindType Mineral 235 | ``` 236 | 237 | #### `find_nukes` 238 | 239 | ``` purescript 240 | find_nukes :: FindType Nuke 241 | ``` 242 | 243 | #### `top` 244 | 245 | ``` purescript 246 | top :: Direction 247 | ``` 248 | 249 | #### `top_right` 250 | 251 | ``` purescript 252 | top_right :: Direction 253 | ``` 254 | 255 | #### `right` 256 | 257 | ``` purescript 258 | right :: Direction 259 | ``` 260 | 261 | #### `bottom_right` 262 | 263 | ``` purescript 264 | bottom_right :: Direction 265 | ``` 266 | 267 | #### `bottom` 268 | 269 | ``` purescript 270 | bottom :: Direction 271 | ``` 272 | 273 | #### `bottom_left` 274 | 275 | ``` purescript 276 | bottom_left :: Direction 277 | ``` 278 | 279 | #### `left` 280 | 281 | ``` purescript 282 | left :: Direction 283 | ``` 284 | 285 | #### `top_left` 286 | 287 | ``` purescript 288 | top_left :: Direction 289 | ``` 290 | 291 | #### `color_red` 292 | 293 | ``` purescript 294 | color_red :: Color 295 | ``` 296 | 297 | #### `color_purple` 298 | 299 | ``` purescript 300 | color_purple :: Color 301 | ``` 302 | 303 | #### `color_blue` 304 | 305 | ``` purescript 306 | color_blue :: Color 307 | ``` 308 | 309 | #### `color_cyan` 310 | 311 | ``` purescript 312 | color_cyan :: Color 313 | ``` 314 | 315 | #### `color_green` 316 | 317 | ``` purescript 318 | color_green :: Color 319 | ``` 320 | 321 | #### `color_yellow` 322 | 323 | ``` purescript 324 | color_yellow :: Color 325 | ``` 326 | 327 | #### `color_orange` 328 | 329 | ``` purescript 330 | color_orange :: Color 331 | ``` 332 | 333 | #### `color_brown` 334 | 335 | ``` purescript 336 | color_brown :: Color 337 | ``` 338 | 339 | #### `color_grey` 340 | 341 | ``` purescript 342 | color_grey :: Color 343 | ``` 344 | 345 | #### `color_white` 346 | 347 | ``` purescript 348 | color_white :: Color 349 | ``` 350 | 351 | #### `look_creeps` 352 | 353 | ``` purescript 354 | look_creeps :: LookType Creep 355 | ``` 356 | 357 | #### `look_energy` 358 | 359 | ``` purescript 360 | look_energy :: LookType Resource 361 | ``` 362 | 363 | #### `look_resources` 364 | 365 | ``` purescript 366 | look_resources :: LookType Resource 367 | ``` 368 | 369 | #### `look_sources` 370 | 371 | ``` purescript 372 | look_sources :: LookType Source 373 | ``` 374 | 375 | #### `look_minerals` 376 | 377 | ``` purescript 378 | look_minerals :: LookType Mineral 379 | ``` 380 | 381 | #### `look_structures` 382 | 383 | ``` purescript 384 | look_structures :: LookType (Structure Unit) 385 | ``` 386 | 387 | #### `look_flags` 388 | 389 | ``` purescript 390 | look_flags :: LookType Flag 391 | ``` 392 | 393 | #### `look_construction_sites` 394 | 395 | ``` purescript 396 | look_construction_sites :: LookType ConstructionSite 397 | ``` 398 | 399 | #### `look_nukes` 400 | 401 | ``` purescript 402 | look_nukes :: LookType Nuke 403 | ``` 404 | 405 | #### `look_terrain` 406 | 407 | ``` purescript 408 | look_terrain :: LookType Terrain 409 | ``` 410 | 411 | #### `obstacle_object_types` 412 | 413 | ``` purescript 414 | obstacle_object_types :: Array String 415 | ``` 416 | 417 | #### `part_move` 418 | 419 | ``` purescript 420 | part_move :: BodyPartType 421 | ``` 422 | 423 | #### `part_work` 424 | 425 | ``` purescript 426 | part_work :: BodyPartType 427 | ``` 428 | 429 | #### `part_carry` 430 | 431 | ``` purescript 432 | part_carry :: BodyPartType 433 | ``` 434 | 435 | #### `part_attack` 436 | 437 | ``` purescript 438 | part_attack :: BodyPartType 439 | ``` 440 | 441 | #### `part_ranged_attack` 442 | 443 | ``` purescript 444 | part_ranged_attack :: BodyPartType 445 | ``` 446 | 447 | #### `part_tough` 448 | 449 | ``` purescript 450 | part_tough :: BodyPartType 451 | ``` 452 | 453 | #### `part_heal` 454 | 455 | ``` purescript 456 | part_heal :: BodyPartType 457 | ``` 458 | 459 | #### `part_claim` 460 | 461 | ``` purescript 462 | part_claim :: BodyPartType 463 | ``` 464 | 465 | #### `bodypart_cost` 466 | 467 | ``` purescript 468 | bodypart_cost :: { move :: Int, work :: Int, attack :: Int, carry :: Int, heal :: Int, ranged_attack :: Int, tough :: Int, claim :: Int } 469 | ``` 470 | 471 | #### `creep_life_time` 472 | 473 | ``` purescript 474 | creep_life_time :: Int 475 | ``` 476 | 477 | #### `creep_claim_life_time` 478 | 479 | ``` purescript 480 | creep_claim_life_time :: Int 481 | ``` 482 | 483 | #### `creep_corpse_rate` 484 | 485 | ``` purescript 486 | creep_corpse_rate :: Int 487 | ``` 488 | 489 | #### `carry_capacity` 490 | 491 | ``` purescript 492 | carry_capacity :: Int 493 | ``` 494 | 495 | #### `harvest_power` 496 | 497 | ``` purescript 498 | harvest_power :: Int 499 | ``` 500 | 501 | #### `harvest_mineral_power` 502 | 503 | ``` purescript 504 | harvest_mineral_power :: Int 505 | ``` 506 | 507 | #### `repair_power` 508 | 509 | ``` purescript 510 | repair_power :: Int 511 | ``` 512 | 513 | #### `dismantle_power` 514 | 515 | ``` purescript 516 | dismantle_power :: Int 517 | ``` 518 | 519 | #### `build_power` 520 | 521 | ``` purescript 522 | build_power :: Int 523 | ``` 524 | 525 | #### `attack_power` 526 | 527 | ``` purescript 528 | attack_power :: Int 529 | ``` 530 | 531 | #### `upgrade_controller_power` 532 | 533 | ``` purescript 534 | upgrade_controller_power :: Int 535 | ``` 536 | 537 | #### `ranged_attack_power` 538 | 539 | ``` purescript 540 | ranged_attack_power :: Int 541 | ``` 542 | 543 | #### `heal_power` 544 | 545 | ``` purescript 546 | heal_power :: Int 547 | ``` 548 | 549 | #### `ranged_heal_power` 550 | 551 | ``` purescript 552 | ranged_heal_power :: Int 553 | ``` 554 | 555 | #### `repair_cost` 556 | 557 | ``` purescript 558 | repair_cost :: Int 559 | ``` 560 | 561 | #### `dismantle_cost` 562 | 563 | ``` purescript 564 | dismantle_cost :: Int 565 | ``` 566 | 567 | #### `rampart_decay_amount` 568 | 569 | ``` purescript 570 | rampart_decay_amount :: Int 571 | ``` 572 | 573 | #### `rampart_decay_time` 574 | 575 | ``` purescript 576 | rampart_decay_time :: Int 577 | ``` 578 | 579 | #### `rampart_hits` 580 | 581 | ``` purescript 582 | rampart_hits :: Int 583 | ``` 584 | 585 | #### `rampart_hits_max` 586 | 587 | ``` purescript 588 | rampart_hits_max :: { 2 :: Int, 3 :: Int, 4 :: Int, 5 :: Int, 6 :: Int, 7 :: Int, 8 :: Int } 589 | ``` 590 | 591 | #### `energy_regen_time` 592 | 593 | ``` purescript 594 | energy_regen_time :: Int 595 | ``` 596 | 597 | #### `energy_decay` 598 | 599 | ``` purescript 600 | energy_decay :: Int 601 | ``` 602 | 603 | #### `spawn_hits` 604 | 605 | ``` purescript 606 | spawn_hits :: Int 607 | ``` 608 | 609 | #### `spawn_energy_start` 610 | 611 | ``` purescript 612 | spawn_energy_start :: Int 613 | ``` 614 | 615 | #### `spawn_energy_capacity` 616 | 617 | ``` purescript 618 | spawn_energy_capacity :: Int 619 | ``` 620 | 621 | #### `creep_spawn_time` 622 | 623 | ``` purescript 624 | creep_spawn_time :: Int 625 | ``` 626 | 627 | #### `source_energy_capacity` 628 | 629 | ``` purescript 630 | source_energy_capacity :: Int 631 | ``` 632 | 633 | #### `source_energy_neutral_capacity` 634 | 635 | ``` purescript 636 | source_energy_neutral_capacity :: Int 637 | ``` 638 | 639 | #### `source_energy_keeper_capacity` 640 | 641 | ``` purescript 642 | source_energy_keeper_capacity :: Int 643 | ``` 644 | 645 | #### `wall_hits` 646 | 647 | ``` purescript 648 | wall_hits :: Int 649 | ``` 650 | 651 | #### `wall_hits_max` 652 | 653 | ``` purescript 654 | wall_hits_max :: Int 655 | ``` 656 | 657 | #### `extension_hits` 658 | 659 | ``` purescript 660 | extension_hits :: Int 661 | ``` 662 | 663 | #### `extension_energy_capacity` 664 | 665 | ``` purescript 666 | extension_energy_capacity :: { 0 :: Int, 1 :: Int, 2 :: Int, 3 :: Int, 4 :: Int, 5 :: Int, 6 :: Int, 7 :: Int, 8 :: Int } 667 | ``` 668 | 669 | #### `road_hits` 670 | 671 | ``` purescript 672 | road_hits :: Int 673 | ``` 674 | 675 | #### `road_wearout` 676 | 677 | ``` purescript 678 | road_wearout :: Int 679 | ``` 680 | 681 | #### `road_decay_amount` 682 | 683 | ``` purescript 684 | road_decay_amount :: Int 685 | ``` 686 | 687 | #### `road_decay_time` 688 | 689 | ``` purescript 690 | road_decay_time :: Int 691 | ``` 692 | 693 | #### `link_hits` 694 | 695 | ``` purescript 696 | link_hits :: Int 697 | ``` 698 | 699 | #### `link_hits_max` 700 | 701 | ``` purescript 702 | link_hits_max :: Int 703 | ``` 704 | 705 | #### `link_capacity` 706 | 707 | ``` purescript 708 | link_capacity :: Int 709 | ``` 710 | 711 | #### `link_cooldown` 712 | 713 | ``` purescript 714 | link_cooldown :: Int 715 | ``` 716 | 717 | #### `link_loss_ratio` 718 | 719 | ``` purescript 720 | link_loss_ratio :: Number 721 | ``` 722 | 723 | #### `storage_capacity` 724 | 725 | ``` purescript 726 | storage_capacity :: Int 727 | ``` 728 | 729 | #### `storage_hits` 730 | 731 | ``` purescript 732 | storage_hits :: Int 733 | ``` 734 | 735 | #### `structure_spawn` 736 | 737 | ``` purescript 738 | structure_spawn :: StructureType 739 | ``` 740 | 741 | #### `structure_extension` 742 | 743 | ``` purescript 744 | structure_extension :: StructureType 745 | ``` 746 | 747 | #### `structure_road` 748 | 749 | ``` purescript 750 | structure_road :: StructureType 751 | ``` 752 | 753 | #### `structure_wall` 754 | 755 | ``` purescript 756 | structure_wall :: StructureType 757 | ``` 758 | 759 | #### `structure_rampart` 760 | 761 | ``` purescript 762 | structure_rampart :: StructureType 763 | ``` 764 | 765 | #### `structure_keeper_lair` 766 | 767 | ``` purescript 768 | structure_keeper_lair :: StructureType 769 | ``` 770 | 771 | #### `structure_portal` 772 | 773 | ``` purescript 774 | structure_portal :: StructureType 775 | ``` 776 | 777 | #### `structure_controller` 778 | 779 | ``` purescript 780 | structure_controller :: StructureType 781 | ``` 782 | 783 | #### `structure_link` 784 | 785 | ``` purescript 786 | structure_link :: StructureType 787 | ``` 788 | 789 | #### `structure_storage` 790 | 791 | ``` purescript 792 | structure_storage :: StructureType 793 | ``` 794 | 795 | #### `structure_tower` 796 | 797 | ``` purescript 798 | structure_tower :: StructureType 799 | ``` 800 | 801 | #### `structure_observer` 802 | 803 | ``` purescript 804 | structure_observer :: StructureType 805 | ``` 806 | 807 | #### `structure_power_bank` 808 | 809 | ``` purescript 810 | structure_power_bank :: StructureType 811 | ``` 812 | 813 | #### `structure_power_spawn` 814 | 815 | ``` purescript 816 | structure_power_spawn :: StructureType 817 | ``` 818 | 819 | #### `structure_extractor` 820 | 821 | ``` purescript 822 | structure_extractor :: StructureType 823 | ``` 824 | 825 | #### `structure_lab` 826 | 827 | ``` purescript 828 | structure_lab :: StructureType 829 | ``` 830 | 831 | #### `structure_terminal` 832 | 833 | ``` purescript 834 | structure_terminal :: StructureType 835 | ``` 836 | 837 | #### `structure_container` 838 | 839 | ``` purescript 840 | structure_container :: StructureType 841 | ``` 842 | 843 | #### `structure_nuker` 844 | 845 | ``` purescript 846 | structure_nuker :: StructureType 847 | ``` 848 | 849 | #### `construction_cost` 850 | 851 | ``` purescript 852 | construction_cost :: { spawn :: Int, extension :: Int, road :: Int, constructedWall :: Int, rampart :: Int, link :: Int, storage :: Int, tower :: Int, observer :: Int, powerSpawn :: Int, extractor :: Int, lab :: Int, terminal :: Int, container :: Int, nuker :: Int } 853 | ``` 854 | 855 | #### `construction_cost_road_swamp_ratio` 856 | 857 | ``` purescript 858 | construction_cost_road_swamp_ratio :: Int 859 | ``` 860 | 861 | #### `controller_levels` 862 | 863 | ``` purescript 864 | controller_levels :: { 1 :: Int, 2 :: Int, 3 :: Int, 4 :: Int, 5 :: Int, 6 :: Int, 7 :: Int } 865 | ``` 866 | 867 | #### `controller_structures` 868 | 869 | ``` purescript 870 | controller_structures :: { spawn :: StructureInfo, extension :: StructureInfo, road :: StructureInfo, constructedWall :: StructureInfo, rampart :: StructureInfo, link :: StructureInfo, storage :: StructureInfo, tower :: StructureInfo, observer :: StructureInfo, powerSpawn :: StructureInfo, extractor :: StructureInfo, lab :: StructureInfo, terminal :: StructureInfo, container :: StructureInfo, nuker :: StructureInfo } 871 | ``` 872 | 873 | #### `controller_downgrade` 874 | 875 | ``` purescript 876 | controller_downgrade :: StructureInfo 877 | ``` 878 | 879 | #### `controller_claim_downgrade` 880 | 881 | ``` purescript 882 | controller_claim_downgrade :: Number 883 | ``` 884 | 885 | #### `controller_reserve` 886 | 887 | ``` purescript 888 | controller_reserve :: Int 889 | ``` 890 | 891 | #### `controller_reserve_max` 892 | 893 | ``` purescript 894 | controller_reserve_max :: Int 895 | ``` 896 | 897 | #### `controller_max_upgrade_per_tick` 898 | 899 | ``` purescript 900 | controller_max_upgrade_per_tick :: Int 901 | ``` 902 | 903 | #### `controller_attack_blocked_upgrade` 904 | 905 | ``` purescript 906 | controller_attack_blocked_upgrade :: Int 907 | ``` 908 | 909 | #### `tower_hits` 910 | 911 | ``` purescript 912 | tower_hits :: Int 913 | ``` 914 | 915 | #### `tower_capacity` 916 | 917 | ``` purescript 918 | tower_capacity :: Int 919 | ``` 920 | 921 | #### `tower_energy_cost` 922 | 923 | ``` purescript 924 | tower_energy_cost :: Int 925 | ``` 926 | 927 | #### `tower_power_attack` 928 | 929 | ``` purescript 930 | tower_power_attack :: Int 931 | ``` 932 | 933 | #### `tower_power_heal` 934 | 935 | ``` purescript 936 | tower_power_heal :: Int 937 | ``` 938 | 939 | #### `tower_power_repair` 940 | 941 | ``` purescript 942 | tower_power_repair :: Int 943 | ``` 944 | 945 | #### `tower_optimal_range` 946 | 947 | ``` purescript 948 | tower_optimal_range :: Int 949 | ``` 950 | 951 | #### `tower_falloff_range` 952 | 953 | ``` purescript 954 | tower_falloff_range :: Int 955 | ``` 956 | 957 | #### `tower_falloff` 958 | 959 | ``` purescript 960 | tower_falloff :: Number 961 | ``` 962 | 963 | #### `observer_hits` 964 | 965 | ``` purescript 966 | observer_hits :: Int 967 | ``` 968 | 969 | #### `observer_range` 970 | 971 | ``` purescript 972 | observer_range :: Int 973 | ``` 974 | 975 | #### `power_bank_hits` 976 | 977 | ``` purescript 978 | power_bank_hits :: Int 979 | ``` 980 | 981 | #### `power_bank_capacity_max` 982 | 983 | ``` purescript 984 | power_bank_capacity_max :: Int 985 | ``` 986 | 987 | #### `power_bank_capacity_min` 988 | 989 | ``` purescript 990 | power_bank_capacity_min :: Int 991 | ``` 992 | 993 | #### `power_bank_capacity_crit` 994 | 995 | ``` purescript 996 | power_bank_capacity_crit :: Number 997 | ``` 998 | 999 | #### `power_bank_decay` 1000 | 1001 | ``` purescript 1002 | power_bank_decay :: Int 1003 | ``` 1004 | 1005 | #### `power_bank_hit_back` 1006 | 1007 | ``` purescript 1008 | power_bank_hit_back :: Number 1009 | ``` 1010 | 1011 | #### `power_spawn_hits` 1012 | 1013 | ``` purescript 1014 | power_spawn_hits :: Int 1015 | ``` 1016 | 1017 | #### `power_spawn_energy_capacity` 1018 | 1019 | ``` purescript 1020 | power_spawn_energy_capacity :: Int 1021 | ``` 1022 | 1023 | #### `power_spawn_power_capacity` 1024 | 1025 | ``` purescript 1026 | power_spawn_power_capacity :: Int 1027 | ``` 1028 | 1029 | #### `power_spawn_energy_ratio` 1030 | 1031 | ``` purescript 1032 | power_spawn_energy_ratio :: Int 1033 | ``` 1034 | 1035 | #### `extractor_hits` 1036 | 1037 | ``` purescript 1038 | extractor_hits :: Int 1039 | ``` 1040 | 1041 | #### `lab_hits` 1042 | 1043 | ``` purescript 1044 | lab_hits :: Int 1045 | ``` 1046 | 1047 | #### `lab_mineral_capacity` 1048 | 1049 | ``` purescript 1050 | lab_mineral_capacity :: Int 1051 | ``` 1052 | 1053 | #### `lab_energy_capacity` 1054 | 1055 | ``` purescript 1056 | lab_energy_capacity :: Int 1057 | ``` 1058 | 1059 | #### `lab_boost_energy` 1060 | 1061 | ``` purescript 1062 | lab_boost_energy :: Int 1063 | ``` 1064 | 1065 | #### `lab_boost_mineral` 1066 | 1067 | ``` purescript 1068 | lab_boost_mineral :: Int 1069 | ``` 1070 | 1071 | #### `lab_cooldown` 1072 | 1073 | ``` purescript 1074 | lab_cooldown :: Int 1075 | ``` 1076 | 1077 | #### `gcl_pow` 1078 | 1079 | ``` purescript 1080 | gcl_pow :: Number 1081 | ``` 1082 | 1083 | #### `gcl_multiply` 1084 | 1085 | ``` purescript 1086 | gcl_multiply :: Int 1087 | ``` 1088 | 1089 | #### `gcl_novice` 1090 | 1091 | ``` purescript 1092 | gcl_novice :: Int 1093 | ``` 1094 | 1095 | #### `mode_simulation` 1096 | 1097 | ``` purescript 1098 | mode_simulation :: Mode 1099 | ``` 1100 | 1101 | #### `mode_survival` 1102 | 1103 | ``` purescript 1104 | mode_survival :: Mode 1105 | ``` 1106 | 1107 | #### `mode_world` 1108 | 1109 | ``` purescript 1110 | mode_world :: Mode 1111 | ``` 1112 | 1113 | #### `mode_arena` 1114 | 1115 | ``` purescript 1116 | mode_arena :: Mode 1117 | ``` 1118 | 1119 | #### `terrain_mask_wall` 1120 | 1121 | ``` purescript 1122 | terrain_mask_wall :: TerrainMask 1123 | ``` 1124 | 1125 | #### `terrain_mask_swamp` 1126 | 1127 | ``` purescript 1128 | terrain_mask_swamp :: TerrainMask 1129 | ``` 1130 | 1131 | #### `terrain_mask_lava` 1132 | 1133 | ``` purescript 1134 | terrain_mask_lava :: TerrainMask 1135 | ``` 1136 | 1137 | #### `max_construction_sites` 1138 | 1139 | ``` purescript 1140 | max_construction_sites :: Int 1141 | ``` 1142 | 1143 | #### `max_creep_size` 1144 | 1145 | ``` purescript 1146 | max_creep_size :: Int 1147 | ``` 1148 | 1149 | #### `mineral_regen_time` 1150 | 1151 | ``` purescript 1152 | mineral_regen_time :: Int 1153 | ``` 1154 | 1155 | #### `mineral_min_amount` 1156 | 1157 | ``` purescript 1158 | mineral_min_amount :: { H :: Int, O :: Int, L :: Int, K :: Int, Z :: Int, U :: Int, X :: Int } 1159 | ``` 1160 | 1161 | #### `mineral_random_factor` 1162 | 1163 | ``` purescript 1164 | mineral_random_factor :: Int 1165 | ``` 1166 | 1167 | #### `terminal_capacity` 1168 | 1169 | ``` purescript 1170 | terminal_capacity :: Int 1171 | ``` 1172 | 1173 | #### `terminal_hits` 1174 | 1175 | ``` purescript 1176 | terminal_hits :: Int 1177 | ``` 1178 | 1179 | #### `terminal_send_cost` 1180 | 1181 | ``` purescript 1182 | terminal_send_cost :: Number 1183 | ``` 1184 | 1185 | #### `terminal_min_send` 1186 | 1187 | ``` purescript 1188 | terminal_min_send :: Int 1189 | ``` 1190 | 1191 | #### `container_hits` 1192 | 1193 | ``` purescript 1194 | container_hits :: Int 1195 | ``` 1196 | 1197 | #### `container_capacity` 1198 | 1199 | ``` purescript 1200 | container_capacity :: Int 1201 | ``` 1202 | 1203 | #### `container_decay` 1204 | 1205 | ``` purescript 1206 | container_decay :: Int 1207 | ``` 1208 | 1209 | #### `container_decay_time` 1210 | 1211 | ``` purescript 1212 | container_decay_time :: Int 1213 | ``` 1214 | 1215 | #### `container_decay_time_owned` 1216 | 1217 | ``` purescript 1218 | container_decay_time_owned :: Int 1219 | ``` 1220 | 1221 | #### `nuker_hits` 1222 | 1223 | ``` purescript 1224 | nuker_hits :: Int 1225 | ``` 1226 | 1227 | #### `nuker_cooldown` 1228 | 1229 | ``` purescript 1230 | nuker_cooldown :: Int 1231 | ``` 1232 | 1233 | #### `nuker_energy_capacity` 1234 | 1235 | ``` purescript 1236 | nuker_energy_capacity :: Int 1237 | ``` 1238 | 1239 | #### `nuker_ghodium_capacity` 1240 | 1241 | ``` purescript 1242 | nuker_ghodium_capacity :: Int 1243 | ``` 1244 | 1245 | #### `nuke_land_time` 1246 | 1247 | ``` purescript 1248 | nuke_land_time :: Int 1249 | ``` 1250 | 1251 | #### `nuke_range` 1252 | 1253 | ``` purescript 1254 | nuke_range :: Int 1255 | ``` 1256 | 1257 | #### `nuke_damage` 1258 | 1259 | ``` purescript 1260 | nuke_damage :: { 0 :: Int, 1 :: Int, 4 :: Int } 1261 | ``` 1262 | 1263 | #### `resource_energy` 1264 | 1265 | ``` purescript 1266 | resource_energy :: ResourceType 1267 | ``` 1268 | 1269 | #### `resource_power` 1270 | 1271 | ``` purescript 1272 | resource_power :: ResourceType 1273 | ``` 1274 | 1275 | #### `resource_hydrogen` 1276 | 1277 | ``` purescript 1278 | resource_hydrogen :: ResourceType 1279 | ``` 1280 | 1281 | #### `resource_oxygen` 1282 | 1283 | ``` purescript 1284 | resource_oxygen :: ResourceType 1285 | ``` 1286 | 1287 | #### `resource_utrium` 1288 | 1289 | ``` purescript 1290 | resource_utrium :: ResourceType 1291 | ``` 1292 | 1293 | #### `resource_lemergium` 1294 | 1295 | ``` purescript 1296 | resource_lemergium :: ResourceType 1297 | ``` 1298 | 1299 | #### `resource_keanium` 1300 | 1301 | ``` purescript 1302 | resource_keanium :: ResourceType 1303 | ``` 1304 | 1305 | #### `resource_zynthium` 1306 | 1307 | ``` purescript 1308 | resource_zynthium :: ResourceType 1309 | ``` 1310 | 1311 | #### `resource_catalyst` 1312 | 1313 | ``` purescript 1314 | resource_catalyst :: ResourceType 1315 | ``` 1316 | 1317 | #### `resource_ghodium` 1318 | 1319 | ``` purescript 1320 | resource_ghodium :: ResourceType 1321 | ``` 1322 | 1323 | #### `resource_hydroxide` 1324 | 1325 | ``` purescript 1326 | resource_hydroxide :: ResourceType 1327 | ``` 1328 | 1329 | #### `resource_zynthium_keanite` 1330 | 1331 | ``` purescript 1332 | resource_zynthium_keanite :: ResourceType 1333 | ``` 1334 | 1335 | #### `resource_utrium_lemergite` 1336 | 1337 | ``` purescript 1338 | resource_utrium_lemergite :: ResourceType 1339 | ``` 1340 | 1341 | #### `resource_utrium_hydride` 1342 | 1343 | ``` purescript 1344 | resource_utrium_hydride :: ResourceType 1345 | ``` 1346 | 1347 | #### `resource_utrium_oxide` 1348 | 1349 | ``` purescript 1350 | resource_utrium_oxide :: ResourceType 1351 | ``` 1352 | 1353 | #### `resource_keanium_hydride` 1354 | 1355 | ``` purescript 1356 | resource_keanium_hydride :: ResourceType 1357 | ``` 1358 | 1359 | #### `resource_keanium_oxide` 1360 | 1361 | ``` purescript 1362 | resource_keanium_oxide :: ResourceType 1363 | ``` 1364 | 1365 | #### `resource_lemergium_hydride` 1366 | 1367 | ``` purescript 1368 | resource_lemergium_hydride :: ResourceType 1369 | ``` 1370 | 1371 | #### `resource_lemergium_oxide` 1372 | 1373 | ``` purescript 1374 | resource_lemergium_oxide :: ResourceType 1375 | ``` 1376 | 1377 | #### `resource_zynthium_hydride` 1378 | 1379 | ``` purescript 1380 | resource_zynthium_hydride :: ResourceType 1381 | ``` 1382 | 1383 | #### `resource_zynthium_oxide` 1384 | 1385 | ``` purescript 1386 | resource_zynthium_oxide :: ResourceType 1387 | ``` 1388 | 1389 | #### `resource_ghodium_hydride` 1390 | 1391 | ``` purescript 1392 | resource_ghodium_hydride :: ResourceType 1393 | ``` 1394 | 1395 | #### `resource_ghodium_oxide` 1396 | 1397 | ``` purescript 1398 | resource_ghodium_oxide :: ResourceType 1399 | ``` 1400 | 1401 | #### `resource_utrium_acid` 1402 | 1403 | ``` purescript 1404 | resource_utrium_acid :: ResourceType 1405 | ``` 1406 | 1407 | #### `resource_utrium_alkalide` 1408 | 1409 | ``` purescript 1410 | resource_utrium_alkalide :: ResourceType 1411 | ``` 1412 | 1413 | #### `resource_keanium_acid` 1414 | 1415 | ``` purescript 1416 | resource_keanium_acid :: ResourceType 1417 | ``` 1418 | 1419 | #### `resource_keanium_alkalide` 1420 | 1421 | ``` purescript 1422 | resource_keanium_alkalide :: ResourceType 1423 | ``` 1424 | 1425 | #### `resource_lemergium_acid` 1426 | 1427 | ``` purescript 1428 | resource_lemergium_acid :: ResourceType 1429 | ``` 1430 | 1431 | #### `resource_lemergium_alkalide` 1432 | 1433 | ``` purescript 1434 | resource_lemergium_alkalide :: ResourceType 1435 | ``` 1436 | 1437 | #### `resource_zynthium_acid` 1438 | 1439 | ``` purescript 1440 | resource_zynthium_acid :: ResourceType 1441 | ``` 1442 | 1443 | #### `resource_zynthium_alkalide` 1444 | 1445 | ``` purescript 1446 | resource_zynthium_alkalide :: ResourceType 1447 | ``` 1448 | 1449 | #### `resource_ghodium_acid` 1450 | 1451 | ``` purescript 1452 | resource_ghodium_acid :: ResourceType 1453 | ``` 1454 | 1455 | #### `resource_ghodium_alkalide` 1456 | 1457 | ``` purescript 1458 | resource_ghodium_alkalide :: ResourceType 1459 | ``` 1460 | 1461 | #### `resource_catalyzed_utrium_acid` 1462 | 1463 | ``` purescript 1464 | resource_catalyzed_utrium_acid :: ResourceType 1465 | ``` 1466 | 1467 | #### `resource_catalyzed_utrium_alkalide` 1468 | 1469 | ``` purescript 1470 | resource_catalyzed_utrium_alkalide :: ResourceType 1471 | ``` 1472 | 1473 | #### `resource_catalyzed_keanium_acid` 1474 | 1475 | ``` purescript 1476 | resource_catalyzed_keanium_acid :: ResourceType 1477 | ``` 1478 | 1479 | #### `resource_catalyzed_keanium_alkalide` 1480 | 1481 | ``` purescript 1482 | resource_catalyzed_keanium_alkalide :: ResourceType 1483 | ``` 1484 | 1485 | #### `resource_catalyzed_lemergium_acid` 1486 | 1487 | ``` purescript 1488 | resource_catalyzed_lemergium_acid :: ResourceType 1489 | ``` 1490 | 1491 | #### `resource_catalyzed_lemergium_alkalide` 1492 | 1493 | ``` purescript 1494 | resource_catalyzed_lemergium_alkalide :: ResourceType 1495 | ``` 1496 | 1497 | #### `resource_catalyzed_zynthium_acid` 1498 | 1499 | ``` purescript 1500 | resource_catalyzed_zynthium_acid :: ResourceType 1501 | ``` 1502 | 1503 | #### `resource_catalyzed_zynthium_alkalide` 1504 | 1505 | ``` purescript 1506 | resource_catalyzed_zynthium_alkalide :: ResourceType 1507 | ``` 1508 | 1509 | #### `resource_catalyzed_ghodium_acid` 1510 | 1511 | ``` purescript 1512 | resource_catalyzed_ghodium_acid :: ResourceType 1513 | ``` 1514 | 1515 | #### `resource_catalyzed_ghodium_alkalide` 1516 | 1517 | ``` purescript 1518 | resource_catalyzed_ghodium_alkalide :: ResourceType 1519 | ``` 1520 | 1521 | 1522 | --------------------------------------------------------------------------------