Added basic types for Main and Map.
This commit is contained in:
parent
d37409a54e
commit
2b2417f37d
@ -1,5 +1,5 @@
|
|||||||
{-# LANGUAGE OverloadedStrings, BangPatterns #-}
|
{-# LANGUAGE OverloadedStrings, BangPatterns #-}
|
||||||
module Map.Map
|
module Map.Graphics
|
||||||
|
|
||||||
(
|
(
|
||||||
mapVertexArrayDescriptor,
|
mapVertexArrayDescriptor,
|
||||||
@ -26,16 +26,10 @@ import Graphics.Rendering.OpenGL.Raw.Core31
|
|||||||
import Foreign.Marshal.Array (withArray)
|
import Foreign.Marshal.Array (withArray)
|
||||||
import Foreign.Storable (sizeOf)
|
import Foreign.Storable (sizeOf)
|
||||||
import Foreign.Ptr (Ptr, nullPtr, plusPtr)
|
import Foreign.Ptr (Ptr, nullPtr, plusPtr)
|
||||||
import Render.Misc (checkError)
|
--import Render.Misc (checkError)
|
||||||
import Linear
|
--import Linear
|
||||||
|
|
||||||
|
import Types
|
||||||
data TileType =
|
|
||||||
Grass
|
|
||||||
| Sand
|
|
||||||
| Water
|
|
||||||
| Mountain
|
|
||||||
deriving (Show, Eq)
|
|
||||||
|
|
||||||
type MapEntry = (
|
type MapEntry = (
|
||||||
Float, -- ^ Height
|
Float, -- ^ Height
|
||||||
@ -228,8 +222,8 @@ colorLookup hs t = if inRange (bounds hs) t then c else (0.0, 0.0, 0.0)
|
|||||||
where
|
where
|
||||||
(_,tp) = hs ! t
|
(_,tp) = hs ! t
|
||||||
c = case tp of
|
c = case tp of
|
||||||
Water -> (0.5, 0.5, 1)
|
Ocean -> (0.5, 0.5, 1)
|
||||||
Sand -> (0.9, 0.85, 0.7)
|
Beach -> (0.9, 0.85, 0.7)
|
||||||
Grass -> (0.3, 0.9, 0.1)
|
Grass -> (0.3, 0.9, 0.1)
|
||||||
Mountain -> (0.5, 0.5, 0.5)
|
Mountain -> (0.5, 0.5, 0.5)
|
||||||
|
|
||||||
@ -295,8 +289,8 @@ testmap2 = do
|
|||||||
parseTemplate :: [Int] -> Text -> [MapEntry]
|
parseTemplate :: [Int] -> Text -> [MapEntry]
|
||||||
parseTemplate (r:rs) t =
|
parseTemplate (r:rs) t =
|
||||||
(case T.head t of
|
(case T.head t of
|
||||||
'~' -> (0, Water)
|
'~' -> (0, Ocean)
|
||||||
'S' -> (0, Sand)
|
'S' -> (0, Beach)
|
||||||
'G' -> (fromIntegral (r `mod` 10)/10.0,Grass)
|
'G' -> (fromIntegral (r `mod` 10)/10.0,Grass)
|
||||||
'M' -> (fromIntegral ((r `mod` 10) + 20)/10.0, Mountain)
|
'M' -> (fromIntegral ((r `mod` 10) + 20)/10.0, Mountain)
|
||||||
_ -> error "invalid template format for map"
|
_ -> error "invalid template format for map"
|
44
src/Map/Types.hs
Normal file
44
src/Map/Types.hs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
module Map.Types
|
||||||
|
where
|
||||||
|
|
||||||
|
import PioneerTypes
|
||||||
|
|
||||||
|
newtype XCoord = XCoord Int
|
||||||
|
newtype YCoord = YCoord Int
|
||||||
|
newtype ZCoord = ZCoord Float
|
||||||
|
|
||||||
|
newtype Coord = Coord (XCoord, YCoord, ZCoord)
|
||||||
|
|
||||||
|
-- | Ownership information, Parameter to occupied is player number
|
||||||
|
data PlayerInfo = NoPlayer
|
||||||
|
| Occupied Int
|
||||||
|
|
||||||
|
-- | Path info, is this node part of a path?
|
||||||
|
data PathInfo = NoPath
|
||||||
|
| Path
|
||||||
|
| Border
|
||||||
|
|
||||||
|
-- | What resources can be harvested here?
|
||||||
|
data ResInfo = ResInfo Resource Amount
|
||||||
|
|
||||||
|
-- | What commodities are currently stored here?
|
||||||
|
data StorInfo = StorInfo Commodity Amount
|
||||||
|
|
||||||
|
-- | What kind of structures may be erected here?
|
||||||
|
data BuildInfo = BStruc Structure
|
||||||
|
| BFlag
|
||||||
|
| BSmall
|
||||||
|
| BMedium
|
||||||
|
| BLarge
|
||||||
|
|
||||||
|
data TileType = Ocean
|
||||||
|
| Beach
|
||||||
|
| Grass
|
||||||
|
| Desert
|
||||||
|
| Lake
|
||||||
|
| Hill -- ^ Accessible
|
||||||
|
| Mountain -- ^ Not accessible
|
||||||
|
deriving (Eq)
|
||||||
|
|
||||||
|
data Node = Full Coord TileType BuildInfo PlayerInfo PathInfo ResInfo StorInfo
|
||||||
|
| Minimal Coord
|
23
src/PioneerTypes.hs
Normal file
23
src/PioneerTypes.hs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
module PioneerTypes
|
||||||
|
where
|
||||||
|
|
||||||
|
data Structure = Flag -- Flag
|
||||||
|
| Barrack -- Small
|
||||||
|
| Sawmill -- Medium
|
||||||
|
| Castle -- Large
|
||||||
|
|
||||||
|
data Amount = Infinite -- Neverending supply
|
||||||
|
| Finite Int -- Finite supply
|
||||||
|
|
||||||
|
-- Extremely preliminary, expand when needed
|
||||||
|
data Commodity = WoodPlank
|
||||||
|
| Sword
|
||||||
|
| Fish
|
||||||
|
|
||||||
|
data Resource = Coal
|
||||||
|
| Iron
|
||||||
|
| Gold
|
||||||
|
| Granite
|
||||||
|
| Water
|
||||||
|
| Fishes
|
||||||
|
deriving Eq
|
Loading…
Reference in New Issue
Block a user