Added basic types for Main and Map.

This commit is contained in:
Jonas Betzendahl 2014-02-08 12:01:40 +01:00
parent d37409a54e
commit 2b2417f37d
3 changed files with 75 additions and 14 deletions

View File

@ -1,5 +1,5 @@
{-# LANGUAGE OverloadedStrings, BangPatterns #-}
module Map.Map
module Map.Graphics
(
mapVertexArrayDescriptor,
@ -26,16 +26,10 @@ import Graphics.Rendering.OpenGL.Raw.Core31
import Foreign.Marshal.Array (withArray)
import Foreign.Storable (sizeOf)
import Foreign.Ptr (Ptr, nullPtr, plusPtr)
import Render.Misc (checkError)
import Linear
--import Render.Misc (checkError)
--import Linear
data TileType =
Grass
| Sand
| Water
| Mountain
deriving (Show, Eq)
import Types
type MapEntry = (
Float, -- ^ Height
@ -228,8 +222,8 @@ colorLookup hs t = if inRange (bounds hs) t then c else (0.0, 0.0, 0.0)
where
(_,tp) = hs ! t
c = case tp of
Water -> (0.5, 0.5, 1)
Sand -> (0.9, 0.85, 0.7)
Ocean -> (0.5, 0.5, 1)
Beach -> (0.9, 0.85, 0.7)
Grass -> (0.3, 0.9, 0.1)
Mountain -> (0.5, 0.5, 0.5)
@ -295,8 +289,8 @@ testmap2 = do
parseTemplate :: [Int] -> Text -> [MapEntry]
parseTemplate (r:rs) t =
(case T.head t of
'~' -> (0, Water)
'S' -> (0, Sand)
'~' -> (0, Ocean)
'S' -> (0, Beach)
'G' -> (fromIntegral (r `mod` 10)/10.0,Grass)
'M' -> (fromIntegral ((r `mod` 10) + 20)/10.0, Mountain)
_ -> error "invalid template format for map"

44
src/Map/Types.hs Normal file
View 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
View 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