summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2019-03-06 18:44:57 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2019-03-06 18:44:57 +0100 |
commit | 24efb898f526e0aa02a0e15b74436da8ba166cac (patch) | |
tree | 5d5e6e682e0012787255de520dd29292e793d6ad | |
parent | b05eb97d89e690737418ca2aa2e49e9c9da83184 (diff) |
Impr. MapEd tile focus, CSS factoring.
49 files changed, 859 insertions, 621 deletions
diff --git a/src/battle/src/Struct/Tile.elm b/src/battle/src/Struct/Tile.elm index 37a4e0d..459e139 100644 --- a/src/battle/src/Struct/Tile.elm +++ b/src/battle/src/Struct/Tile.elm @@ -3,7 +3,6 @@ module Struct.Tile exposing Ref, VariantID, Type, - new, get_id, get_name, get_cost, @@ -45,15 +44,6 @@ type alias Type = -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -new : Ref -> String -> Int -> Struct.Omnimods.Type -> Type -new id name crossing_cost omnimods = - { - id = id, - name = name, - crossing_cost = crossing_cost, - omnimods = omnimods - } - get_id : Type -> Ref get_id tile = tile.id diff --git a/src/css/src/battle.scss b/src/css/src/battle.scss index 3ba177a..536b2fa 100644 --- a/src/css/src/battle.scss +++ b/src/css/src/battle.scss @@ -1,8 +1,9 @@ -@import 'shared/battleview'; +@import 'shared/battle-view'; +@import 'shared/battle-characters'; +@import 'shared/battle-map'; @import 'shared/omnimod-icons'; @import 'battle/controlled-panel'; -@import 'battle/info-card'; @import 'battle/keyframes'; @import 'battle/map'; @import 'battle/message-board'; diff --git a/src/css/src/battle/constants.scss b/src/css/src/battle/constants.scss index 3e08351..7918a0b 100644 --- a/src/css/src/battle/constants.scss +++ b/src/css/src/battle/constants.scss @@ -1,4 +1,4 @@ -@import '../shared/battleview/constants'; +@import '../shared/battle-view/constants'; $CONTROLLED-MENU-WIDTH: 15em; $SUB-MENU-WIDTH: 20em; diff --git a/src/css/src/battle/controlled-panel.scss b/src/css/src/battle/controlled-panel.scss index fe6cb13..2a52fe6 100644 --- a/src/css/src/battle/controlled-panel.scss +++ b/src/css/src/battle/controlled-panel.scss @@ -1,5 +1,5 @@ -@import '../shared/battleview/constants'; -@import '../shared/battleview/menu-mixins'; +@import '../shared/battle-view/constants'; +@import '../shared/battle-view/menu-mixins'; @import 'constants'; diff --git a/src/css/src/battle/info-card.scss b/src/css/src/battle/info-card.scss deleted file mode 100644 index 7cb1c08..0000000 --- a/src/css/src/battle/info-card.scss +++ /dev/null @@ -1,104 +0,0 @@ -@import "../shared/colors"; -@import "../shared/shadows"; - -.info-card -{ - display: flex; - flex-flow: column; -} - -.info-card-top -{ - position: relative; - - margin-top: 0.5em; -} - -.info-card-picture -{ - top: 0; - left: 0; - - box-sizing: border-box; - - border-radius: 5px; - overflow: hidden; - - margin: 0; - - @include box-shadow(2px, $BROWN-0, 1); - - display: inline-block; -} - -.info-card-text-field -{ - display:flex; - justify-content:center; - align-items:center; - border-radius: 5px; - background-color: $BROWN-2; - width: 100%; -} - -.gauge -{ - position: relative; - border-radius: 5px; - border: 2px solid $BROWN-2; - text-align: center; - height: 2em; -} - -.gauge-text -{ - position: absolute; - top: 0; - left: 0; - height: 100%; - width: 100%; - z-index: 1; - - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; -} - -.gauge-bar -{ - position: absolute; - top: 0; - left: 0; - height: 100%; - width: 100%; - z-index: 0; - - border-radius: 5px; - z-index: 0; - transition: width 3s ease-in-out; -} - -.character-card-health, -.tile-card-cost -{ - position: absolute; - left: 100px; - top: 0; - margin-left: 0.5em; - width: calc(100% - 100px - 0.5em); -} - - -.character-card-movement, -.tile-card-location -{ - position: absolute; - left: 100px; - top: calc(1.5em + 1em); - margin-left: 0.5em; - width: calc(100% - 100px - 0.5em); -} - -@import 'info-card/character'; -@import 'info-card/tile'; diff --git a/src/css/src/battle/info-card/character.scss b/src/css/src/battle/info-card/character.scss deleted file mode 100644 index 114e54d..0000000 --- a/src/css/src/battle/info-card/character.scss +++ /dev/null @@ -1,150 +0,0 @@ -@import "../../shared/colors"; - -.character-portrait -{ - background-size: 100% 100%; - width: 100px; - height: 100px; - overflow: hidden; - cursor: pointer; -} - -.character-portrait * -{ - box-sizing: border-box; - background-size: 100% 100%; - width: inherit; - height: inherit; -} - -.character-portrait-body -{ - z-index: 1; -} - -.character-portrait-armor -{ - position: relative; - z-index: 1; - top: -100%; - background-size: 200% 100%; -} - -.character-portrait-team-0 { background-color: rgba(57, 106, 177, 0.3); } -.character-portrait-team-1 { background-color: rgba(204, 37, 41, 0.3); } -.character-portrait-team-2 { background-color: rgba(62, 150, 81, 0.3); } -.character-portrait-team-3 { background-color: rgba(218, 124, 48, 0.3); } -.character-portrait-team-4 { background-color: rgba(83, 81, 84, 0.3); } -.character-portrait-team-5 { background-color: rgba(107, 76, 154, 0.3); } -.character-portrait-team-6 { background-color: rgba(127, 167, 169, 0.3); } -.character-portrait-team-7 { background-color: rgba(231, 167, 169, 0.3); } - -.character-card-statuses -{ - position: absolute; - left: 100px; - top: calc(2*(1.5em + 0.5em) + 0.7em); - margin-left: 0.5em; - width: calc(100% - 100px - 0.5em); - display: flex; -} - -.character-card-status -{ - height: 1.5em; - width: 1.5em; - background-size: 100%; -} - -.character-card-target-status -{ - background-image: url("/asset/svg/status/target.svg"); -} - -.character-card-commander-status -{ - background-image: url("/asset/svg/status/commander.svg"); -} - -.character-card-health > .gauge-bar -{ - background-color: $RED-3; -} - -.character-card-movement > .gauge-bar -{ - background-color: $BLUE-3; -} - -.character-card-weapon, -.character-card-weapon-summary -{ - display: grid; - - border-radius: 5px; - - padding: 0.3em; - margin-top: 0.3em; -} - -.character-card-weapon -{ - background-color: #6C5D53; -} - -.character-card-weapon-summary -{ - background-color: $BROWN-1; -} - -.character-card-armor -{ - display: grid; - border-radius: 5px; - background-color: $BROWN-2; - - padding: 0.3em; - margin-top: 0.3em; -} - -.character-card-armor-stats -{ - display: flex; - flex-direction: row; - flex-wrap: wrap; -} - -.character-card-stats > *, -.character-card-armor-stats > * -{ - width: 25%; -} - -.character-card-stats -{ - display: flex; - flex-direction: row; - flex-wrap: wrap; - - border-radius: 5px; - background-color: $BROWN-2; - - padding: 0.3em; - margin-top: 0.3em; -} - -.asset-armor-variation-bird -{ - background-size: 200% 100%; - background-position: 100% 0; -} - -.character-card-mod -{ - display: inline-block; -} - -.info-card-mod -{ - display: inline-block; -} diff --git a/src/css/src/battle/map.scss b/src/css/src/battle/map.scss index 9b95adf..1501ca1 100644 --- a/src/css/src/battle/map.scss +++ b/src/css/src/battle/map.scss @@ -1,5 +1,5 @@ -@import '../shared/battleview/constants'; -@import '../shared/battleview/menu-mixins'; +@import '../shared/battle-view/constants'; +@import '../shared/battle-view/menu-mixins'; @import 'constants'; @@ -40,22 +40,6 @@ position: relative; } -.tiled, .tiled * -{ - height: 32px; - width: 32px; - /** Fixes odd behavior of table cell being resized. **/ - /* min-width: 32px; */ - /* max-width: 32px; */ -} - -.tile-icon, .tile-icon * -{ - z-index: 0; - position: absolute; - background-size: 400%; -} - .path-icon-below-markers {z-index: 1;} .marker-icon {z-index: 2;} .path-icon-above-markers {z-index: 3;} @@ -68,18 +52,7 @@ position: absolute; } -.tiles-layer -{ - /*display: table; */ -} - -.tiles-layer-row -{ - /* display: table-row; */ -} - @import 'map/animation.scss'; @import 'map/character.scss'; @import 'map/marker.scss'; @import 'map/path.scss'; -@import 'map/variant.scss'; diff --git a/src/css/src/battle/sub-menus.scss b/src/css/src/battle/sub-menus.scss index d302a4f..29ed0a5 100644 --- a/src/css/src/battle/sub-menus.scss +++ b/src/css/src/battle/sub-menus.scss @@ -1,5 +1,5 @@ -@import '../shared/battleview/constants'; -@import '../shared/battleview/menu-mixins'; +@import '../shared/battle-view/constants'; +@import '../shared/battle-view/menu-mixins'; @import 'constants'; diff --git a/src/css/src/map-editor.scss b/src/css/src/map-editor.scss index 8be26ab..edda499 100644 --- a/src/css/src/map-editor.scss +++ b/src/css/src/map-editor.scss @@ -1,4 +1,6 @@ -@import 'shared/battleview'; +@import 'shared/battle-view'; +@import 'shared/battle-map'; +@import 'shared/omnimod-icons'; @import 'map-editor/map'; @import 'map-editor/sub-menus'; diff --git a/src/css/src/map-editor/constants.scss b/src/css/src/map-editor/constants.scss index a8f67d3..51af535 100644 --- a/src/css/src/map-editor/constants.scss +++ b/src/css/src/map-editor/constants.scss @@ -1,4 +1,4 @@ -@import '../shared/battleview/constants'; +@import '../shared/battle-view/constants'; $TOOLBOX-MENU-WIDTH: 15em; $SUB-MENU-WIDTH: 20em; diff --git a/src/css/src/map-editor/map.scss b/src/css/src/map-editor/map.scss index 66c0207..a1ada34 100644 --- a/src/css/src/map-editor/map.scss +++ b/src/css/src/map-editor/map.scss @@ -1,5 +1,5 @@ -@import '../shared/battleview/constants'; -@import '../shared/battleview/menu-mixins'; +@import '../shared/battle-view/constants'; +@import '../shared/battle-view/menu-mixins'; @import 'constants'; @@ -40,38 +40,20 @@ position: relative; } -.map-tiled, .map-tiled * -{ - height: 32px; - width: 32px; -} - -.map-tile-icon, .map-tile-icon * -{ - z-index: 0; - position: absolute; - background-size: 400%; -} - -.map-tile-selected +.tile-selected { border: 1px dashed white; } -.map-tile-square-corner +.tile-square-corner { animation-name: blinking; animation-duration: 1s; animation-iteration-count: infinite; } -.map-tile, .map-tile * {background-size: 400%;} -.map-tile * {position: absolute;} - @keyframes blinking { 0% {opacity: 1;} 50% {opacity: 0;} 100% {opacity: 1;} } - -@import 'map/variant.scss'; diff --git a/src/css/src/map-editor/map/variant.scss b/src/css/src/map-editor/map/variant.scss deleted file mode 100644 index 109f093..0000000 --- a/src/css/src/map-editor/map/variant.scss +++ /dev/null @@ -1,33 +0,0 @@ - -.map-tile-variant-0 * {background-position: 0 0;} -.map-tile-variant-1 * {background-position: 100% 0;} -.map-tile-variant-2 * {background-position: 200% 0;} -.map-tile-variant-3 * {background-position: 300% 0;} - -.map-tile-variant-4 * {background-position: 0 100%;} -.map-tile-variant-5 * {background-position: 100% 100%;} -.map-tile-variant-6 * {background-position: 200% 100%;} -.map-tile-variant-7 * {background-position: 300% 100%;} - -.map-tile-variant-8 * {background-position: 0 200%;} -.map-tile-variant-9 * {background-position: 100% 200%;} -.map-tile-variant-10 * {background-position: 200% 200%;} -.map-tile-variant-11 * {background-position: 300% 200%;} - -.map-tile-variant-12 * {background-position: 0 300%;} -.map-tile-variant-13 * {background-position: 100% 300%;} -.map-tile-variant-14 * {background-position: 200% 300%;} -.map-tile-variant-15 * {background-position: 300% 300%;} - -.map-tile-icon-bg { z-index: 0; } -.map-tile-icon-dt { z-index: 9; } - -.map-tile-icon-f-0 { z-index: 1; } -.map-tile-icon-f-1 { z-index: 2; } -.map-tile-icon-f-2 { z-index: 3; } -.map-tile-icon-f-3 { z-index: 4; } -.map-tile-icon-f-4 { z-index: 5; } -.map-tile-icon-f-5 { z-index: 6; } -.map-tile-icon-f-6 { z-index: 7; } -.map-tile-icon-f-7 { z-index: 8; } - diff --git a/src/css/src/map-editor/sub-menus.scss b/src/css/src/map-editor/sub-menus.scss index d526238..4a97a22 100644 --- a/src/css/src/map-editor/sub-menus.scss +++ b/src/css/src/map-editor/sub-menus.scss @@ -1,5 +1,5 @@ -@import '../shared/battleview/constants'; -@import '../shared/battleview/menu-mixins'; +@import '../shared/battle-view/constants'; +@import '../shared/battle-view/menu-mixins'; @import 'constants'; diff --git a/src/css/src/map-editor/toolbox.scss b/src/css/src/map-editor/toolbox.scss index 2398796..2b9bdd3 100644 --- a/src/css/src/map-editor/toolbox.scss +++ b/src/css/src/map-editor/toolbox.scss @@ -1,5 +1,5 @@ -@import '../shared/battleview/constants'; -@import '../shared/battleview/menu-mixins'; +@import '../shared/battle-view/constants'; +@import '../shared/battle-view/menu-mixins'; @import 'constants'; diff --git a/src/css/src/roster-editor.scss b/src/css/src/roster-editor.scss index a35188e..49c9fc4 100644 --- a/src/css/src/roster-editor.scss +++ b/src/css/src/roster-editor.scss @@ -1,6 +1,6 @@ -@import 'shared/battleview'; +@import 'shared/battle-view'; +@import 'shared/battle-characters'; @import 'shared/omnimod-icons'; @import 'roster-editor/controlled-panel'; -@import 'roster-editor/info-card'; @import 'roster-editor/selection-window'; diff --git a/src/css/src/roster-editor/constants.scss b/src/css/src/roster-editor/constants.scss index ee4e862..8ce7828 100644 --- a/src/css/src/roster-editor/constants.scss +++ b/src/css/src/roster-editor/constants.scss @@ -1,4 +1,4 @@ -@import '../shared/battleview/constants'; +@import '../shared/battle-view/constants'; $CONTROLLED-MENU-WIDTH: 15em; diff --git a/src/css/src/roster-editor/controlled-panel.scss b/src/css/src/roster-editor/controlled-panel.scss index 23b2a8a..ace0cf0 100644 --- a/src/css/src/roster-editor/controlled-panel.scss +++ b/src/css/src/roster-editor/controlled-panel.scss @@ -1,5 +1,5 @@ -@import '../shared/battleview/constants'; -@import '../shared/battleview/menu-mixins'; +@import '../shared/battle-view/constants'; +@import '../shared/battle-view/menu-mixins'; @import 'constants'; diff --git a/src/css/src/roster-editor/selection-window.scss b/src/css/src/roster-editor/selection-window.scss index c719ea0..f3a63a0 100644 --- a/src/css/src/roster-editor/selection-window.scss +++ b/src/css/src/roster-editor/selection-window.scss @@ -1,5 +1,5 @@ -@import '../shared/battleview/constants'; -@import '../shared/battleview/menu-mixins'; +@import '../shared/battle-view/constants'; +@import '../shared/battle-view/menu-mixins'; @import 'constants'; diff --git a/src/css/src/shared/battle-characters.scss b/src/css/src/shared/battle-characters.scss new file mode 100644 index 0000000..78b6f46 --- /dev/null +++ b/src/css/src/shared/battle-characters.scss @@ -0,0 +1 @@ +@import 'battle-characters/info-card'; diff --git a/src/css/src/roster-editor/info-card/character.scss b/src/css/src/shared/battle-characters/info-card.scss index cb00546..7a90a97 100644 --- a/src/css/src/roster-editor/info-card/character.scss +++ b/src/css/src/shared/battle-characters/info-card.scss @@ -17,6 +17,14 @@ height: inherit; } + +.character-portrait-battle-index +{ + position: relative; + z-index: 2; + top: -200%; +} + .character-portrait-body { z-index: 1; @@ -30,13 +38,6 @@ background-size: 200% 100%; } -.character-portrait-battle-index -{ - position: relative; - z-index: 2; - top: -200%; -} - .character-portrait-team-0 { background-color: rgba(57, 106, 177, 0.3); } .character-portrait-team-1 { background-color: rgba(204, 37, 41, 0.3); } .character-portrait-team-2 { background-color: rgba(62, 150, 81, 0.3); } diff --git a/src/css/src/shared/battle-map.scss b/src/css/src/shared/battle-map.scss new file mode 100644 index 0000000..659ad54 --- /dev/null +++ b/src/css/src/shared/battle-map.scss @@ -0,0 +1,2 @@ +@import 'battle-map/info-card'; +@import 'battle-map/tile'; diff --git a/src/css/src/battle/info-card/tile.scss b/src/css/src/shared/battle-map/info-card.scss index 8a6e1e1..8a6e1e1 100644 --- a/src/css/src/battle/info-card/tile.scss +++ b/src/css/src/shared/battle-map/info-card.scss diff --git a/src/css/src/shared/battle-map/tile.scss b/src/css/src/shared/battle-map/tile.scss new file mode 100644 index 0000000..89e2fc7 --- /dev/null +++ b/src/css/src/shared/battle-map/tile.scss @@ -0,0 +1,24 @@ +.tiled, .tiled * +{ + height: 32px; + width: 32px; +} + +.tiled * +{ + position: absolute; +} + +.tile-icon +{ + z-index: 0; + position: absolute; +} + +.tile-icon *, +.tile * +{ + background-size: 400%; +} + +@import "tile/variant.scss" diff --git a/src/css/src/battle/map/variant.scss b/src/css/src/shared/battle-map/tile/variant.scss index 253d5e3..253d5e3 100644 --- a/src/css/src/battle/map/variant.scss +++ b/src/css/src/shared/battle-map/tile/variant.scss diff --git a/src/css/src/shared/battleview.scss b/src/css/src/shared/battle-view.scss index fc80bee..979740f 100644 --- a/src/css/src/shared/battleview.scss +++ b/src/css/src/shared/battle-view.scss @@ -12,6 +12,7 @@ body background-color: $BROWN-2; } -@import 'battleview/button'; -@import 'battleview/main-menu'; -@import 'battleview/message-board'; +@import 'battle-view/button'; +@import 'battle-view/main-menu'; +@import 'battle-view/info-card'; +@import 'battle-view/message-board'; diff --git a/src/css/src/shared/battleview/button.scss b/src/css/src/shared/battle-view/button.scss index 75788ca..75788ca 100644 --- a/src/css/src/shared/battleview/button.scss +++ b/src/css/src/shared/battle-view/button.scss diff --git a/src/css/src/shared/battleview/constants.scss b/src/css/src/shared/battle-view/constants.scss index 63d4bbf..63d4bbf 100644 --- a/src/css/src/shared/battleview/constants.scss +++ b/src/css/src/shared/battle-view/constants.scss diff --git a/src/css/src/roster-editor/info-card.scss b/src/css/src/shared/battle-view/info-card.scss index bb043a9..d7839cd 100644 --- a/src/css/src/roster-editor/info-card.scss +++ b/src/css/src/shared/battle-view/info-card.scss @@ -1,5 +1,5 @@ -@import "../shared/colors"; -@import "../shared/shadows"; +@import "../../shared/colors"; +@import "../../shared/shadows"; .info-card { @@ -99,5 +99,3 @@ margin-left: 0.5em; width: calc(100% - 100px - 0.5em); } - -@import 'info-card/character'; diff --git a/src/css/src/shared/battleview/main-menu.scss b/src/css/src/shared/battle-view/main-menu.scss index fd5db10..fd5db10 100644 --- a/src/css/src/shared/battleview/main-menu.scss +++ b/src/css/src/shared/battle-view/main-menu.scss diff --git a/src/css/src/shared/battleview/menu-mixins.scss b/src/css/src/shared/battle-view/menu-mixins.scss index 235671f..235671f 100644 --- a/src/css/src/shared/battleview/menu-mixins.scss +++ b/src/css/src/shared/battle-view/menu-mixins.scss diff --git a/src/css/src/shared/battleview/message-board.scss b/src/css/src/shared/battle-view/message-board.scss index 0fc9fa7..0fc9fa7 100644 --- a/src/css/src/shared/battleview/message-board.scss +++ b/src/css/src/shared/battle-view/message-board.scss diff --git a/src/css/src/shared/battleview/message-board/error.scss b/src/css/src/shared/battle-view/message-board/error.scss index 10b9eda..10b9eda 100644 --- a/src/css/src/shared/battleview/message-board/error.scss +++ b/src/css/src/shared/battle-view/message-board/error.scss diff --git a/src/css/src/shared/battleview/message-board/help.scss b/src/css/src/shared/battle-view/message-board/help.scss index bb66c33..bb66c33 100644 --- a/src/css/src/shared/battleview/message-board/help.scss +++ b/src/css/src/shared/battle-view/message-board/help.scss diff --git a/src/map-editor/src/Struct/Attributes.elm b/src/map-editor/src/Struct/Attributes.elm new file mode 100644 index 0000000..ce871dd --- /dev/null +++ b/src/map-editor/src/Struct/Attributes.elm @@ -0,0 +1,173 @@ +module Struct.Attributes exposing + ( + Type, + Category(..), + get_constitution, + get_dexterity, + get_intelligence, + get_mind, + get_speed, + get_strength, + mod_constitution, + mod_dexterity, + mod_intelligence, + mod_mind, + mod_speed, + mod_strength, + mod, + get, + new, + decode_category, + default + ) + +-- Elm ------------------------------------------------------------------------- + +-- Battle ---------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type Category = + Constitution + | Dexterity + | Intelligence + | Mind + | Speed + | Strength + +type alias Type = + { + constitution : Int, + dexterity : Int, + intelligence : Int, + mind : Int, + speed : Int, + strength : Int + } + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_within_range : Int -> Int -> Int -> Int +get_within_range vmin vmax v = (min vmax (max vmin v)) + +get_within_att_range : Int -> Int +get_within_att_range v = (get_within_range 0 100 v) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_constitution : Type -> Int +get_constitution t = t.constitution + +get_dexterity : Type -> Int +get_dexterity t = t.dexterity + +get_intelligence : Type -> Int +get_intelligence t = t.intelligence + +get_mind : Type -> Int +get_mind t = t.mind + +get_speed : Type -> Int +get_speed t = t.speed + +get_strength : Type -> Int +get_strength t = t.strength + +mod_constitution : Int -> Type -> Type +mod_constitution i t = + {t | + constitution = (get_within_att_range (i + t.constitution)) + } + +mod_dexterity : Int -> Type -> Type +mod_dexterity i t = + {t | + dexterity = (get_within_att_range (i + t.dexterity)) + } + +mod_intelligence : Int -> Type -> Type +mod_intelligence i t = + {t | + intelligence = (get_within_att_range (i + t.intelligence)) + } + +mod_mind : Int -> Type -> Type +mod_mind i t = + {t | + mind = (get_within_att_range (i + t.mind)) + } + +mod_speed : Int -> Type -> Type +mod_speed i t = + {t | + speed = (get_within_att_range (i + t.speed)) + } + +mod_strength : Int -> Type -> Type +mod_strength i t = + {t | + strength = (get_within_att_range (i + t.strength)) + } + +mod : Category -> Int -> Type -> Type +mod cat i t = + case cat of + Constitution -> (mod_constitution i t) + Dexterity -> (mod_dexterity i t) + Intelligence -> (mod_intelligence i t) + Mind -> (mod_mind i t) + Speed -> (mod_speed i t) + Strength -> (mod_strength i t) + +get : Category -> Type -> Int +get cat t = + case cat of + Constitution -> (get_constitution t) + Dexterity -> (get_dexterity t) + Intelligence -> (get_intelligence t) + Mind -> (get_mind t) + Speed -> (get_speed t) + Strength -> (get_strength t) + +new : ( + Int -> -- constitution + Int -> -- dexterity + Int -> -- intelligence + Int -> -- mind + Int -> -- speed + Int -> -- strength + Type + ) +new con dex int min spe str = + { + constitution = con, + dexterity = dex, + intelligence = int, + mind = min, + speed = spe, + strength = str + } + +default : Type +default = + { + constitution = 50, + dexterity = 50, + intelligence = 50, + mind = 50, + speed = 50, + strength = 50 + } + +decode_category : String -> Category +decode_category str = + case str of + "con" -> Constitution + "dex" -> Dexterity + "int" -> Intelligence + "min" -> Mind + "spe" -> Speed + _ -> Strength diff --git a/src/map-editor/src/Struct/DamageType.elm b/src/map-editor/src/Struct/DamageType.elm new file mode 100644 index 0000000..b7bced7 --- /dev/null +++ b/src/map-editor/src/Struct/DamageType.elm @@ -0,0 +1,55 @@ +module Struct.DamageType exposing + ( + Type(..), + encode, + decode, + to_string + ) + +-- Elm ------------------------------------------------------------------------- + +-- Map ------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type Type = + Base + | Slash + | Blunt + | Pierce + | None + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +decode : String -> Type +decode str = + case str of + "bse" -> Base + "slh" -> Slash + "pie" -> Pierce + "blu" -> Blunt + _ -> None + +encode : Type -> String +encode t = + case t of + Base -> "bse" + Slash -> "slh" + Pierce -> "pie" + Blunt -> "blu" + None -> "non" + +to_string : Type -> String +to_string t = + case t of + Base -> "Base" + Slash -> "Slash" + Pierce -> "Piercing" + Blunt -> "Bludgeoning" + None -> "ERROR" diff --git a/src/map-editor/src/Struct/Map.elm b/src/map-editor/src/Struct/Map.elm index c175de0..9a09d17 100644 --- a/src/map-editor/src/Struct/Map.elm +++ b/src/map-editor/src/Struct/Map.elm @@ -9,6 +9,7 @@ module Struct.Map exposing get_tiles, set_tile_to, solve_tiles, + get_omnimods_at, try_getting_tile_at, decoder ) @@ -21,10 +22,11 @@ import Dict import Json.Decode -- Map Editor ------------------------------------------------------------------ -import Struct.Tile import Struct.Location -import Struct.TileInstance import Struct.MapMarker +import Struct.Omnimods +import Struct.Tile +import Struct.TileInstance -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- @@ -108,6 +110,22 @@ solve_tiles tiles map = content = (Array.map (Struct.TileInstance.solve tiles) map.content) } +get_omnimods_at : ( + Struct.Location.Type -> + (Dict.Dict Struct.Tile.Ref Struct.Tile.Type) -> + Type -> + Struct.Omnimods.Type + ) +get_omnimods_at loc tiles_solver map = + case (try_getting_tile_at loc map) of + Nothing -> (Struct.Omnimods.none) + (Just tile_inst) -> + case + (Dict.get (Struct.TileInstance.get_class_id tile_inst) tiles_solver) + of + Nothing -> (Struct.Omnimods.none) + (Just tile) -> (Struct.Tile.get_omnimods tile) + decoder : (Json.Decode.Decoder Type) decoder = (Json.Decode.andThen diff --git a/src/map-editor/src/Struct/Model.elm b/src/map-editor/src/Struct/Model.elm index 7b04aa8..419a0e9 100644 --- a/src/map-editor/src/Struct/Model.elm +++ b/src/map-editor/src/Struct/Model.elm @@ -1,6 +1,7 @@ module Struct.Model exposing ( Type, + tile_omnimods_fun, new, invalidate, add_tile, @@ -18,7 +19,9 @@ import Struct.Flags -- Map Editor ------------------------------------------------------------------ import Struct.Error import Struct.HelpRequest +import Struct.Location import Struct.Map +import Struct.Omnimods import Struct.Tile import Struct.TilePattern import Struct.Toolbox @@ -54,6 +57,10 @@ type alias Type = -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- +tile_omnimods_fun : Type -> (Struct.Location.Type -> Struct.Omnimods.Type) +tile_omnimods_fun model = + (\loc -> (Struct.Map.get_omnimods_at loc model.tiles model.map)) + new : Struct.Flags.Type -> Type new flags = let diff --git a/src/map-editor/src/Struct/Omnimods.elm b/src/map-editor/src/Struct/Omnimods.elm new file mode 100644 index 0000000..80fc509 --- /dev/null +++ b/src/map-editor/src/Struct/Omnimods.elm @@ -0,0 +1,91 @@ +module Struct.Omnimods exposing + ( + Type, + none, + get_attributes_mods, + get_statistics_mods, + get_attack_mods, + get_defense_mods, + decoder + ) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Json.Decode +import Json.Decode.Pipeline + +-- Map Editor ------------------------------------------------------------------ +import Struct.Attributes +import Struct.Statistics +import Struct.DamageType + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type alias Type = + { + attributes : (Dict.Dict String Int), + statistics : (Dict.Dict String Int), + attack : (Dict.Dict String Int), + defense : (Dict.Dict String Int) + } + +type alias GenericMod = + { + t : String, + v : Int + } +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +generic_mods_decoder : (Json.Decode.Decoder (Dict.Dict String Int)) +generic_mods_decoder = + (Json.Decode.map + (Dict.fromList) + (Json.Decode.list + (Json.Decode.map + (\gm -> (gm.t, gm.v)) + (Json.Decode.succeed + GenericMod + |> (Json.Decode.Pipeline.required "t" Json.Decode.string) + |> (Json.Decode.Pipeline.required "v" Json.Decode.int) + ) + ) + ) + ) + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +decoder : (Json.Decode.Decoder Type) +decoder = + (Json.Decode.succeed + Type + |> (Json.Decode.Pipeline.required "attm" generic_mods_decoder) + |> (Json.Decode.Pipeline.required "stam" generic_mods_decoder) + |> (Json.Decode.Pipeline.required "atkm" generic_mods_decoder) + |> (Json.Decode.Pipeline.required "defm" generic_mods_decoder) + ) + +none : Type +none = + let empty_dict = (Dict.empty) in + { + attributes = empty_dict, + statistics = empty_dict, + attack = empty_dict, + defense = empty_dict + } + +get_attributes_mods : Type -> (List (String, Int)) +get_attributes_mods omnimods = (Dict.toList omnimods.attributes) + +get_statistics_mods : Type -> (List (String, Int)) +get_statistics_mods omnimods = (Dict.toList omnimods.statistics) + +get_attack_mods : Type -> (List (String, Int)) +get_attack_mods omnimods = (Dict.toList omnimods.attack) + +get_defense_mods : Type -> (List (String, Int)) +get_defense_mods omnimods = (Dict.toList omnimods.defense) diff --git a/src/map-editor/src/Struct/Statistics.elm b/src/map-editor/src/Struct/Statistics.elm new file mode 100644 index 0000000..f676648 --- /dev/null +++ b/src/map-editor/src/Struct/Statistics.elm @@ -0,0 +1,210 @@ +module Struct.Statistics exposing + ( + Type, + Category(..), + get_movement_points, + get_max_health, + get_dodges, + get_parries, + get_accuracy, + get_double_hits, + get_critical_hits, + get_damage_modifier, + decode_category, + mod, + new_raw + ) + +-- Elm ------------------------------------------------------------------------- +import List + +-- Battle ---------------------------------------------------------------------- +import Struct.Attributes + +-------------------------------------------------------------------------------- +-- TYPES ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +type Category = + MovementPoints + | MaxHealth + | Dodges + | Parries + | Accuracy + | DoubleHits + | CriticalHits + +type alias Type = + { + movement_points : Int, + max_health : Int, + dodges : Int, + parries : Int, + accuracy : Int, + double_hits : Int, + critical_hits : Int, + damage_modifier : Float + } + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +average : (List Int) -> Float +average l = ((toFloat (List.sum l)) / (toFloat (List.length l))) + +float_to_int : Float -> Int +float_to_int f = + (ceiling f) + +gentle_squared_growth : Int -> Int +gentle_squared_growth v = (float_to_int (((toFloat v)^1.8)/20.0)) + +gentle_squared_growth_f : Float -> Int +gentle_squared_growth_f v = (float_to_int ((v^1.8)/20.0)) + +sudden_squared_growth : Int -> Int +sudden_squared_growth v = (float_to_int (((toFloat v)^2.5)/1000.0)) + +sudden_squared_growth_f : Float -> Int +sudden_squared_growth_f v = (float_to_int ((v^2.5)/1000.0)) + +sudden_exp_growth : Int -> Int +sudden_exp_growth v = (float_to_int (4.0^((toFloat v)/25.0))) + +sudden_exp_growth_f : Float -> Int +sudden_exp_growth_f f = (float_to_int (4.0^(f/25.0))) + +damage_base_mod : Float -> Float +damage_base_mod str = ((((str + 10) * 4)^1.5)/3000.0) + +make_movement_points_safe : Int -> Int +make_movement_points_safe val = (clamp 0 200 val) + +make_max_health_safe : Int -> Int +make_max_health_safe val = (max 1 val) + +make_dodges_safe : Int -> Int +make_dodges_safe val = (clamp 0 100 val) + +make_parries_safe : Int -> Int +make_parries_safe val = (clamp 0 75 val) + +make_accuracy_safe : Int -> Int +make_accuracy_safe val = (clamp 0 100 val) + +make_double_hits_safe : Int -> Int +make_double_hits_safe val = (clamp 0 100 val) + +make_critical_hits_safe : Int -> Int +make_critical_hits_safe val = (clamp 0 100 val) + +mod_movement_points : Int -> Type -> Type +mod_movement_points v t = + {t | + movement_points = (make_movement_points_safe (t.movement_points + v)) + } + +mod_max_health : Int -> Type -> Type +mod_max_health v t = + {t | + max_health = (make_max_health_safe (t.max_health + v)) + } + +mod_dodges : Int -> Type -> Type +mod_dodges v t = {t | dodges = (make_dodges_safe (t.dodges + v))} + +mod_parries : Int -> Type -> Type +mod_parries v t = {t | parries = (make_parries_safe (t.parries + v))} + +mod_accuracy : Int -> Type -> Type +mod_accuracy v t = {t | accuracy = (make_accuracy_safe (t.accuracy + v))} + +mod_double_hits : Int -> Type -> Type +mod_double_hits v t = + {t | + double_hits = (make_double_hits_safe (t.double_hits + v)) + } + +mod_critical_hits : Int -> Type -> Type +mod_critical_hits v t = + {t | + critical_hits = (make_critical_hits_safe (t.critical_hits + v)) + } + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_movement_points : Type -> Int +get_movement_points t = t.movement_points + +get_max_health : Type -> Int +get_max_health t = t.max_health + +get_dodges : Type -> Int +get_dodges t = t.dodges + +get_parries : Type -> Int +get_parries t = t.parries + +get_accuracy : Type -> Int +get_accuracy t = t.accuracy + +get_double_hits : Type -> Int +get_double_hits t = t.double_hits + +get_critical_hits : Type -> Int +get_critical_hits t = t.critical_hits + +get_damage_modifier : Type -> Float +get_damage_modifier t = t.damage_modifier + +mod : Category -> Int -> Type -> Type +mod cat v t = + case cat of + MaxHealth -> (mod_max_health v t) + MovementPoints -> (mod_movement_points v t) + Dodges -> (mod_dodges v t) + Parries -> (mod_parries v t) + Accuracy -> (mod_accuracy v t) + DoubleHits -> (mod_double_hits v t) + CriticalHits -> (mod_critical_hits v t) + +new_raw : (Struct.Attributes.Type -> Type) +new_raw att = + let + constitution = (Struct.Attributes.get_constitution att) + dexterity = (Struct.Attributes.get_dexterity att) + intelligence = (Struct.Attributes.get_intelligence att) + mind = (Struct.Attributes.get_mind att) + speed = (Struct.Attributes.get_speed att) + strength = (Struct.Attributes.get_strength att) + in + { + movement_points = + (gentle_squared_growth_f + (average [mind, constitution, constitution, speed, speed, speed]) + ), + max_health = + (gentle_squared_growth_f + (average [constitution, constitution, constitution, mind]) + ), + dodges = (sudden_exp_growth_f (average [dexterity, mind, speed])), + parries = + (sudden_exp_growth_f + (average [dexterity, intelligence, speed, strength]) + ), + accuracy = (sudden_squared_growth dexterity), + double_hits = (sudden_squared_growth_f (average [mind, speed])), + critical_hits = (sudden_squared_growth intelligence), + damage_modifier = (damage_base_mod (toFloat strength)) + } + +decode_category : String -> Category +decode_category str = + case str of + "mheal" -> MaxHealth + "mpts" -> MovementPoints + "dodg" -> Dodges + "pary" -> Parries + "accu" -> Accuracy + "dhit" -> DoubleHits + _ -> CriticalHits diff --git a/src/map-editor/src/Struct/Tile.elm b/src/map-editor/src/Struct/Tile.elm index b9d8de2..cafcf03 100644 --- a/src/map-editor/src/Struct/Tile.elm +++ b/src/map-editor/src/Struct/Tile.elm @@ -4,10 +4,10 @@ module Struct.Tile exposing VariantID, FamilyID, Type, - new, get_id, get_name, get_cost, + get_omnimods, get_family, decoder ) @@ -23,6 +23,7 @@ import Constants.UI import Constants.Movement import Struct.Location +import Struct.Omnimods -------------------------------------------------------------------------------- -- TYPES ----------------------------------------------------------------------- @@ -37,7 +38,8 @@ type alias Type = name : String, crossing_cost : Int, family : FamilyID, - depth : Int + depth : Int, + omnimods : Struct.Omnimods.Type } -------------------------------------------------------------------------------- @@ -47,16 +49,6 @@ type alias Type = -------------------------------------------------------------------------------- -- EXPORTED -------------------------------------------------------------------- -------------------------------------------------------------------------------- -new : Ref -> String -> Int -> FamilyID -> Int -> Type -new id name crossing_cost family depth = - { - id = id, - name = name, - crossing_cost = crossing_cost, - family = family, - depth = depth - } - get_id : Type -> Ref get_id tile = tile.id @@ -69,6 +61,9 @@ get_name tile = tile.name get_family : Type -> FamilyID get_family tile = tile.family +get_omnimods : Type -> Struct.Omnimods.Type +get_omnimods t = t.omnimods + decoder : (Json.Decode.Decoder Type) decoder = (Json.Decode.succeed @@ -78,4 +73,5 @@ decoder = |> (Json.Decode.Pipeline.required "ct" Json.Decode.int) |> (Json.Decode.Pipeline.required "fa" Json.Decode.string) |> (Json.Decode.Pipeline.required "de" Json.Decode.int) + |> (Json.Decode.Pipeline.required "omni" Struct.Omnimods.decoder) ) diff --git a/src/map-editor/src/View/Map.elm b/src/map-editor/src/View/Map.elm index d98c088..a022850 100644 --- a/src/map-editor/src/View/Map.elm +++ b/src/map-editor/src/View/Map.elm @@ -31,7 +31,7 @@ get_tiles_html : ( get_tiles_html tb map = (Html.div [ - (Html.Attributes.class "map-tiles-layer"), + (Html.Attributes.class "tiles-layer"), (Html.Attributes.style "width" ( diff --git a/src/map-editor/src/View/Map/Tile.elm b/src/map-editor/src/View/Map/Tile.elm index b5e3505..96fdee6 100644 --- a/src/map-editor/src/View/Map/Tile.elm +++ b/src/map-editor/src/View/Map/Tile.elm @@ -26,7 +26,7 @@ get_layer_html index border = (Html.div [ (Html.Attributes.class - ("map-tile-icon-f-" ++ (String.fromInt index)) + ("tile-icon-f-" ++ (String.fromInt index)) ), (Html.Attributes.style "background-image" @@ -54,7 +54,7 @@ get_content_html tile = ( (Html.div [ - (Html.Attributes.class "map-tile-icon-bg"), + (Html.Attributes.class "tile-icon-bg"), (Html.Attributes.style "background-image" ( @@ -71,7 +71,7 @@ get_content_html tile = ( (Html.div [ - (Html.Attributes.class "map-tile-icon-dt"), + (Html.Attributes.class "tile-icon-dt"), (Html.Attributes.style "background-image" ( @@ -105,21 +105,21 @@ get_html tb tile = in (Html.div [ - (Html.Attributes.class "map-tile-icon"), - (Html.Attributes.class "map-tiled"), + (Html.Attributes.class "tile-icon"), + (Html.Attributes.class "tiled"), ( if (Struct.Toolbox.is_selected tile_loc tb) - then (Html.Attributes.class "map-tile-selected") + then (Html.Attributes.class "tile-selected") else (Html.Attributes.class "") ), ( if (Struct.Toolbox.is_square_corner tile_loc tb) - then (Html.Attributes.class "map-tile-square-corner") + then (Html.Attributes.class "tile-square-corner") else (Html.Attributes.class "") ), (Html.Attributes.class ( - "map-tile-variant-" + "tile-variant-" ++ (String.fromInt (Struct.TileInstance.get_local_variant_ix tile) diff --git a/src/map-editor/src/View/SubMenu.elm b/src/map-editor/src/View/SubMenu.elm index 0b1fbea..70e66cf 100644 --- a/src/map-editor/src/View/SubMenu.elm +++ b/src/map-editor/src/View/SubMenu.elm @@ -13,7 +13,7 @@ import Util.Html import View.SubMenu.Tiles import View.SubMenu.Settings -import View.SubMenu.Status +import View.SubMenu.TileStatus -------------------------------------------------------------------------------- -- LOCAL ----------------------------------------------------------------------- @@ -26,7 +26,7 @@ get_inner_html : ( get_inner_html model tab = case tab of Struct.UI.StatusTab -> - (View.SubMenu.Status.get_html model) + (View.SubMenu.TileStatus.get_html model) Struct.UI.TilesTab -> (View.SubMenu.Tiles.get_html model) diff --git a/src/map-editor/src/View/SubMenu/Status.elm b/src/map-editor/src/View/SubMenu/Status.elm deleted file mode 100644 index 69f5842..0000000 --- a/src/map-editor/src/View/SubMenu/Status.elm +++ /dev/null @@ -1,40 +0,0 @@ -module View.SubMenu.Status exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes - --- Struct.Battlemap ------------------------------------------------------------------- -import Struct.Event -import Struct.Location -import Struct.Model -import Struct.UI - -import View.SubMenu.Status.TileInfo --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) -get_html model = - (Html.div - [ - (Html.Attributes.class "tabmenu-content"), - (Html.Attributes.class "tabmenu-content-status") - ] - [ - (case (Struct.UI.get_previous_action model.ui) of - (Just (Struct.UI.SelectedLocation loc)) -> - (View.SubMenu.Status.TileInfo.get_html - model - (Struct.Location.from_ref loc) - ) - - _ -> - (Html.text "Nothing is being focused.") - ) - ] - ) diff --git a/src/map-editor/src/View/SubMenu/Status/CharacterInfo.elm b/src/map-editor/src/View/SubMenu/Status/CharacterInfo.elm deleted file mode 100644 index 6bfca87..0000000 --- a/src/map-editor/src/View/SubMenu/Status/CharacterInfo.elm +++ /dev/null @@ -1,34 +0,0 @@ -module View.SubMenu.Status.CharacterInfo exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Html -import Html.Attributes - --- Struct.Battlemap ------------------------------------------------------------------- -import Struct.Character -import Struct.Event - -import View.Controlled.CharacterCard - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : ( - Int -> - Struct.Character.Type -> - (Html.Html Struct.Event.Type) - ) -get_html player_ix char = - (Html.div - [ - (Html.Attributes.class "tabmenu-character-info") - ] - [ - (Html.text ("Focusing:")), - (View.Controlled.CharacterCard.get_full_html player_ix char) - ] - ) diff --git a/src/map-editor/src/View/SubMenu/Status/TileInfo.elm b/src/map-editor/src/View/SubMenu/Status/TileInfo.elm deleted file mode 100644 index 166dc42..0000000 --- a/src/map-editor/src/View/SubMenu/Status/TileInfo.elm +++ /dev/null @@ -1,134 +0,0 @@ -module View.SubMenu.Status.TileInfo exposing (get_html) - --- Elm ------------------------------------------------------------------------- -import Dict - -import Html -import Html.Attributes - --- Map Editor ------------------------------------------------------------------ -import Constants.Movement - -import Struct.Map -import Struct.Event -import Struct.Location -import Struct.Model -import Struct.Tile -import Struct.TileInstance - -import Util.Html - -import View.Map.Tile - --------------------------------------------------------------------------------- --- LOCAL ----------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_icon : (Struct.TileInstance.Type -> (Html.Html Struct.Event.Type)) -get_icon tile = - (Html.div - [ - (Html.Attributes.class "map-tile-card-icon"), - (Html.Attributes.class - ( - "map-tile-variant-" - ++ - (String.fromInt - (Struct.TileInstance.get_local_variant_ix tile) - ) - ) - ) - ] - (View.Map.Tile.get_content_html tile) - ) - -get_name : ( - Struct.Model.Type -> - Struct.TileInstance.Type -> - (Html.Html Struct.Event.Type) - ) -get_name model tile = - case (Dict.get (Struct.TileInstance.get_class_id tile) model.tiles) of - Nothing -> (Util.Html.nothing) - (Just tile_type) -> - (Html.div - [ - (Html.Attributes.class "map-tile-card-name") - ] - [ - (Html.text (Struct.Tile.get_name tile_type)) - ] - ) - -get_cost : (Struct.TileInstance.Type -> (Html.Html Struct.Event.Type)) -get_cost tile = - let - cost = (Struct.TileInstance.get_cost tile) - text = - if (cost > Constants.Movement.max_points) - then - "Obstructed" - else - ("Cost: " ++ (String.fromInt cost)) - in - (Html.div - [ - (Html.Attributes.class "map-tile-card-cost") - ] - [ - (Html.text text) - ] - ) - -get_location : (Struct.TileInstance.Type -> (Html.Html Struct.Event.Type)) -get_location tile = - let - tile_location = (Struct.TileInstance.get_location tile) - in - (Html.div - [ - (Html.Attributes.class "map-tile-card-location") - ] - [ - (Html.text - ( - "{x: " - ++ (String.fromInt tile_location.x) - ++ "; y: " - ++ (String.fromInt tile_location.y) - ++ "}" - ) - ) - ] - ) - --------------------------------------------------------------------------------- --- EXPORTED -------------------------------------------------------------------- --------------------------------------------------------------------------------- -get_html : ( - Struct.Model.Type -> - Struct.Location.Type -> - (Html.Html Struct.Event.Type) - ) -get_html model loc = - case (Struct.Map.try_getting_tile_at loc model.map) of - (Just tile) -> - (Html.div - [ - (Html.Attributes.class "map-tile-card") - ] - [ - (get_name model tile), - (Html.div - [ - (Html.Attributes.class "map-tile-card-top") - ] - [ - (get_icon tile), - (get_location tile), - (get_cost tile) - ] - ) - ] - ) - - Nothing -> (Html.text "Error: Unknown tile location selected.") diff --git a/src/map-editor/src/View/SubMenu/TileStatus.elm b/src/map-editor/src/View/SubMenu/TileStatus.elm new file mode 100644 index 0000000..0fd5031 --- /dev/null +++ b/src/map-editor/src/View/SubMenu/TileStatus.elm @@ -0,0 +1,208 @@ +module View.SubMenu.TileStatus exposing (get_html) + +-- Elm ------------------------------------------------------------------------- +import Dict + +import Html +import Html.Attributes + +-- Map Editor ------------------------------------------------------------------ +import Constants.Movement + +import Struct.Event +import Struct.Location +import Struct.Map +import Struct.Model +import Struct.Omnimods +import Struct.Tile +import Struct.TileInstance +import Struct.UI + +import Util.Html + +import View.Map.Tile + +-------------------------------------------------------------------------------- +-- LOCAL ----------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_icon : (Struct.TileInstance.Type -> (Html.Html Struct.Event.Type)) +get_icon tile = + (Html.div + [ + (Html.Attributes.class "tile-card-icon"), + (Html.Attributes.class "info-card-picture"), + (Html.Attributes.class + ( + "tile-variant-" + ++ + (String.fromInt + (Struct.TileInstance.get_local_variant_ix tile) + ) + ) + ) + ] + (View.Map.Tile.get_content_html tile) + ) + +get_name : ( + Struct.Model.Type -> + Struct.TileInstance.Type -> + (Html.Html Struct.Event.Type) + ) +get_name model tile_inst = + case (Dict.get (Struct.TileInstance.get_class_id tile_inst) model.tiles) of + Nothing -> (Util.Html.nothing) + (Just tile) -> + (Html.div + [ + (Html.Attributes.class "info-card-name"), + (Html.Attributes.class "info-card-text-field"), + (Html.Attributes.class "tile-card-name") + ] + [ + (Html.text (Struct.Tile.get_name tile)) + ] + ) + +get_cost : Struct.TileInstance.Type -> (Html.Html Struct.Event.Type) +get_cost tile_inst = + let + cost = (Struct.TileInstance.get_cost tile_inst) + text = + if (cost > Constants.Movement.max_points) + then + "Obstructed" + else + ("Cost: " ++ (String.fromInt cost)) + in + (Html.div + [ + (Html.Attributes.class "info-card-text-field"), + (Html.Attributes.class "tile-card-cost") + ] + [ + (Html.text text) + ] + ) + +get_location : Struct.TileInstance.Type -> (Html.Html Struct.Event.Type) +get_location tile_inst = + let + tile_location = (Struct.TileInstance.get_location tile_inst) + in + (Html.div + [ + (Html.Attributes.class "info-card-text-field"), + (Html.Attributes.class "tile-card-location") + ] + [ + (Html.text + ( + "{x: " + ++ (String.fromInt tile_location.x) + ++ "; y: " + ++ (String.fromInt tile_location.y) + ++ "}" + ) + ) + ] + ) + +get_mod_html : (String, Int) -> (Html.Html Struct.Event.Type) +get_mod_html mod = + let + (category, value) = mod + in + (Html.div + [ + (Html.Attributes.class "info-card-mod") + ] + [ + (Html.text + (category ++ ": " ++ (String.fromInt value)) + ) + ] + ) + +get_omnimods_listing : (List (String, Int)) -> (Html.Html Struct.Event.Type) +get_omnimods_listing mod_list = + (Html.div + [ + (Html.Attributes.class "info-card-omnimods-listing") + ] + (List.map (get_mod_html) mod_list) + ) + +get_omnimods : Struct.Omnimods.Type -> (Html.Html Struct.Event.Type) +get_omnimods omnimods = + (Html.div + [ + (Html.Attributes.class "info-card-omnimods") + ] + [ + (Html.text "Attribute Modifiers"), + (get_omnimods_listing (Struct.Omnimods.get_attributes_mods omnimods)), + (Html.text "Statistics Modifiers"), + (get_omnimods_listing (Struct.Omnimods.get_statistics_mods omnimods)), + (Html.text "Attack Modifiers"), + (get_omnimods_listing (Struct.Omnimods.get_attack_mods omnimods)), + (Html.text "Defense Modifiers"), + (get_omnimods_listing (Struct.Omnimods.get_defense_mods omnimods)) + ] + ) + +get_tile_info_html : ( + Struct.Model.Type -> + Struct.Location.Type -> + (Html.Html Struct.Event.Type) + ) +get_tile_info_html model loc = + case (Struct.Map.try_getting_tile_at loc model.map) of + (Just tile) -> + (Html.div + [ + (Html.Attributes.class "info-card"), + (Html.Attributes.class "tile-card") + ] + [ + (get_name model tile), + (Html.div + [ + (Html.Attributes.class "info-card-top"), + (Html.Attributes.class "tile-card-top") + ] + [ + (get_icon tile), + (get_location tile), + (get_cost tile) + ] + ), + (get_omnimods ((Struct.Model.tile_omnimods_fun model) loc)) + ] + ) + + Nothing -> (Html.text "Error: Unknown tile location selected.") + +-------------------------------------------------------------------------------- +-- EXPORTED -------------------------------------------------------------------- +-------------------------------------------------------------------------------- +get_html : Struct.Model.Type -> (Html.Html Struct.Event.Type) +get_html model = + (Html.div + [ + (Html.Attributes.class "tabmenu-content"), + (Html.Attributes.class "tabmenu-content-status") + ] + [ + (case (Struct.UI.get_previous_action model.ui) of + (Just (Struct.UI.SelectedLocation loc)) -> + (get_tile_info_html + model + (Struct.Location.from_ref loc) + ) + + _ -> + (Html.text "Nothing is being focused.") + ) + ] + ) diff --git a/src/map-editor/src/View/SubMenu/Tiles.elm b/src/map-editor/src/View/SubMenu/Tiles.elm index 5ef324f..511980d 100644 --- a/src/map-editor/src/View/SubMenu/Tiles.elm +++ b/src/map-editor/src/View/SubMenu/Tiles.elm @@ -25,10 +25,10 @@ get_icon_html : ( get_icon_html (ref, tile) = (Html.div [ - (Html.Attributes.class "map-tile"), - (Html.Attributes.class "map-tiled"), + (Html.Attributes.class "tile"), + (Html.Attributes.class "tiled"), (Html.Attributes.class "clickable"), - (Html.Attributes.class "map-tile-variant-0"), + (Html.Attributes.class "tile-variant-0"), (Html.Events.onClick (Struct.Event.TemplateRequested ((Struct.Tile.get_id tile), "0")) ) diff --git a/src/map-editor/src/View/Toolbox.elm b/src/map-editor/src/View/Toolbox.elm index a5ab910..442d01b 100644 --- a/src/map-editor/src/View/Toolbox.elm +++ b/src/map-editor/src/View/Toolbox.elm @@ -28,9 +28,9 @@ get_template_icon_html template = (Html.div [ (Html.Attributes.class "toolbox-template"), - (Html.Attributes.class "map-tiled"), - (Html.Attributes.class "map-tile"), - (Html.Attributes.class "map-tile-variant-0") + (Html.Attributes.class "tiled"), + (Html.Attributes.class "tile"), + (Html.Attributes.class "tile-variant-0") ] (View.Map.Tile.get_content_html template) ) |