From 2b2417f37dea06973703ad4903ce7e9dd1c21572 Mon Sep 17 00:00:00 2001 From: Jonas Betzendahl Date: Sat, 8 Feb 2014 12:01:40 +0100 Subject: [PATCH] Added basic types for Main and Map. --- src/Map/{Map.hs => Graphics.hs} | 22 ++++++----------- src/Map/Types.hs | 44 +++++++++++++++++++++++++++++++++ src/PioneerTypes.hs | 23 +++++++++++++++++ 3 files changed, 75 insertions(+), 14 deletions(-) rename src/Map/{Map.hs => Graphics.hs} (96%) create mode 100644 src/Map/Types.hs create mode 100644 src/PioneerTypes.hs diff --git a/src/Map/Map.hs b/src/Map/Graphics.hs similarity index 96% rename from src/Map/Map.hs rename to src/Map/Graphics.hs index 49d73fc..a3d6bf2 100644 --- a/src/Map/Map.hs +++ b/src/Map/Graphics.hs @@ -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" diff --git a/src/Map/Types.hs b/src/Map/Types.hs new file mode 100644 index 0000000..c653c64 --- /dev/null +++ b/src/Map/Types.hs @@ -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 diff --git a/src/PioneerTypes.hs b/src/PioneerTypes.hs new file mode 100644 index 0000000..1bd75a3 --- /dev/null +++ b/src/PioneerTypes.hs @@ -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