summaryrefslogtreecommitdiff
blob: 70268bf4d160a414d654f4952e28417e4d863e62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
module Battlemap.Tile exposing (Tile, generate, set_direction)

import Battlemap.Direction exposing (Direction(..))
import Character exposing (CharacterRef)

import List exposing (map)
import Array exposing (Array, fromList)
import Set exposing (Set)

type alias Tile =
   {
      floor_level : Int,
      nav_level : Direction,
      char_level : (Maybe CharacterRef)
--    mod_level : (Set TileModifier)
   }

set_direction : Direction -> Tile -> Tile
set_direction d t =
   {t |
      nav_level = d
   }

from_int : Int -> Tile
from_int i =
   if (i >= 10)
   then
      {
         floor_level = (i - 10),
         nav_level = None,
         char_level = (Just (toString (i - 10)))
      }
   else
      {
         floor_level = i,
         nav_level = None,
         char_level = Nothing
      }


generate : Int -> Int -> (Array Tile)
generate width height =
   (fromList
      (map
         (from_int)
         [
            10,   1,    1,    2,    2,    2,
            1,    0,    0,    0,    11,   2,
            1,    0,    1,    2,    0,    2,
            3,    0,    3,    4,    0,    4,
            3,    12,   0,    0,    0,    4,
            3,    3,    3,    4,    4,    4
         ]
      )
   )