summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-03-23 01:10:58 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2019-03-23 01:10:58 +0100
commit8a8e05469c15e8dea34c0466bc70a105628afc8e (patch)
tree4b5ce10718dc81805c43e610511e01cca538f6e6
parent839e90f1e654bd30596f82e6133087a5578d5e6c (diff)
[Broken] ...
-rw-r--r--src/battle/src/Comm/AddChar.elm8
-rw-r--r--src/battle/src/Comm/Send.elm30
-rw-r--r--src/battle/src/Struct/CharacterTurn.elm45
-rw-r--r--src/battle/src/Struct/Model.elm38
-rw-r--r--src/battle/src/Struct/Navigator.elm3
-rw-r--r--src/battle/src/Struct/ServerReply.elm6
-rw-r--r--src/battle/src/Struct/TurnResult.elm34
-rw-r--r--src/battle/src/Update/AttackWithoutMoving.elm6
-rw-r--r--src/battle/src/Update/ChangeScale.elm6
-rw-r--r--src/battle/src/Update/HandleServerReply.elm74
-rw-r--r--src/battle/src/Update/RequestDirection.elm28
-rw-r--r--src/battle/src/Update/SelectCharacter.elm11
-rw-r--r--src/battle/src/Update/SelectTile.elm206
-rw-r--r--src/battle/src/Update/SwitchWeapon.elm46
-rw-r--r--src/battle/src/Update/UndoAction.elm10
-rw-r--r--src/roster-editor/src/Comm/AddGlyphBoard.elm24
-rw-r--r--src/shared/battle-characters/BattleCharacters/Comm/AddArmor.elm (renamed from src/battle/src/Comm/AddArmor.elm)2
-rw-r--r--src/shared/battle-characters/BattleCharacters/Comm/AddGlyph.elm (renamed from src/roster-editor/src/Comm/AddGlyph.elm)12
-rw-r--r--src/shared/battle-characters/BattleCharacters/Comm/AddGlyphBoard.elm (renamed from src/battle/src/Comm/AddPortrait.elm)12
-rw-r--r--src/shared/battle-characters/BattleCharacters/Comm/AddPortrait.elm19
-rw-r--r--src/shared/battle-characters/BattleCharacters/Comm/AddWeapon.elm (renamed from src/battle/src/Comm/AddWeapon.elm)2
-rw-r--r--src/shared/battle-characters/BattleCharacters/Struct/Character.elm13
-rw-r--r--src/shared/battle-map/BattleMap/Comm/AddTile.elm (renamed from src/battle/src/Comm/AddTile.elm)2
-rw-r--r--src/shared/battle-map/BattleMap/Comm/SetMap.elm (renamed from src/battle/src/Comm/SetMap.elm)2
24 files changed, 375 insertions, 264 deletions
diff --git a/src/battle/src/Comm/AddChar.elm b/src/battle/src/Comm/AddChar.elm
index 9b63c6f..9137d17 100644
--- a/src/battle/src/Comm/AddChar.elm
+++ b/src/battle/src/Comm/AddChar.elm
@@ -14,12 +14,8 @@ import Struct.ServerReply
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-
-internal_decoder : (
- Struct.Character.TypeAndEquipmentRef ->
- Struct.ServerReply.Type
- )
-internal_decoder char_and_refs = (Struct.ServerReply.AddCharacter char_and_refs)
+internal_decoder : Struct.Character.Unresolved -> Struct.ServerReply.Type
+internal_decoder ref = (Struct.ServerReply.AddCharacter ref)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
diff --git a/src/battle/src/Comm/Send.elm b/src/battle/src/Comm/Send.elm
index 3394b26..faac297 100644
--- a/src/battle/src/Comm/Send.elm
+++ b/src/battle/src/Comm/Send.elm
@@ -6,14 +6,20 @@ import Http
import Json.Decode
import Json.Encode
+-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Comm.AddArmor
+import BattleCharacters.Comm.AddGlyph
+import BattleCharacters.Comm.AddGlyphBoard
+import BattleCharacters.Comm.AddPortrait
+import BattleCharacters.Comm.AddWeapon
+
+-- Battle Map ------------------------------------------------------------------
+import BattleMap.Comm.AddTile
+import BattleMap.Comm.SetMap
+
-- Local Module ----------------------------------------------------------------
-import Comm.AddArmor
-import Comm.AddPortrait
-import Comm.AddPlayer
import Comm.AddChar
-import Comm.AddTile
-import Comm.AddWeapon
-import Comm.SetMap
+import Comm.AddPlayer
import Comm.SetTimeline
import Comm.TurnResults
@@ -31,13 +37,15 @@ import Struct.Model
internal_decoder : String -> (Json.Decode.Decoder Struct.ServerReply.Type)
internal_decoder reply_type =
case reply_type of
- "add_tile" -> (Comm.AddTile.decode)
- "add_armor" -> (Comm.AddArmor.decode)
+ "add_tile" -> (BattleMap.Comm.AddTile.decode)
+ "add_armor" -> (BattleCharacters.Comm.AddArmor.decode)
"add_char" -> (Comm.AddChar.decode)
- "add_portrait" -> (Comm.AddPortrait.decode)
+ "add_portrait" -> (BattleCharacters.Comm.AddPortrait.decode)
+ "add_glyph_board" -> (BattleCharacters.Comm.AddGlyphBoard.decode)
+ "add_glyph" -> (BattleCharacters.Comm.AddGlyph.decode)
"add_player" -> (Comm.AddPlayer.decode)
- "add_weapon" -> (Comm.AddWeapon.decode)
- "set_map" -> (Comm.SetMap.decode)
+ "add_weapon" -> (BattleCharacters.Comm.AddWeapon.decode)
+ "set_map" -> (BattleMap.Comm.SetMap.decode)
"turn_results" -> (Comm.TurnResults.decode)
"set_timeline" -> (Comm.SetTimeline.decode)
"disconnected" -> (Json.Decode.succeed Struct.ServerReply.Disconnected)
diff --git a/src/battle/src/Struct/CharacterTurn.elm b/src/battle/src/Struct/CharacterTurn.elm
index a017d23..369b851 100644
--- a/src/battle/src/Struct/CharacterTurn.elm
+++ b/src/battle/src/Struct/CharacterTurn.elm
@@ -110,42 +110,25 @@ get_state ct = ct.state
get_path : Type -> (List BattleMap.Struct.Direction.Type)
get_path ct = ct.path
-lock_path : (
- (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) ->
- Type ->
- Type
- )
-lock_path tile_omnimods ct =
- case (ct.navigator, ct.active_character) of
- ((Just old_nav), (Just char)) ->
- let
- current_tile_omnimods =
- (tile_omnimods (Struct.Navigator.get_current_location old_nav))
- in
- {ct |
- active_character =
- (Just
- (Struct.Character.refresh_omnimods
- (\e -> current_tile_omnimods)
- char
- )
- ),
- state = MovedCharacter,
- path = (Struct.Navigator.get_path old_nav),
- target = Nothing,
- navigator = (Just (Struct.Navigator.lock_path old_nav))
- }
+lock_path : Type -> Type
+lock_path ct =
+ case ct.navigator of
+ (Just old_nav) ->
+ {ct |
+ state = MovedCharacter,
+ path = (Struct.Navigator.get_path old_nav),
+ target = Nothing,
+ navigator = (Just (Struct.Navigator.lock_path old_nav))
+ }
(_, _) ->
ct
-unlock_path : (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) -> Type -> Type
-unlock_path tile_omnimods ct =
- case (ct.navigator, ct.active_character) of
- ((Just old_nav), (Just char)) ->
+unlock_path : Type -> Type
+unlock_path ct =
+ case ct.navigator of
+ (Just old_nav) ->
{ct |
- active_character =
- (Just (Struct.Character.refresh_omnimods (tile_omnimods) char)),
state = MovedCharacter,
target = Nothing,
navigator = (Just (Struct.Navigator.unlock_path old_nav))
diff --git a/src/battle/src/Struct/Model.elm b/src/battle/src/Struct/Model.elm
index b65ffb5..10224db 100644
--- a/src/battle/src/Struct/Model.elm
+++ b/src/battle/src/Struct/Model.elm
@@ -34,6 +34,8 @@ import Battle.Struct.Omnimods
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Armor
import BattleCharacters.Struct.Portrait
+import BattleCharacters.Struct.Glyph
+import BattleCharacters.Struct.GlyphBoard
import BattleCharacters.Struct.Weapon
-- Battle Map ------------------------------------------------------------------
@@ -79,6 +81,16 @@ type alias Type =
BattleCharacters.Struct.Portrait.Ref
BattleCharacters.Struct.Portrait.Type
),
+ glyph_boards :
+ (Dict.Dict
+ BattleCharacters.Struct.GlyphBoard.Ref
+ BattleCharacters.Struct.GlyphBoard.Type
+ ),
+ glyphs :
+ (Dict.Dict
+ BattleCharacters.Struct.Glyph.Ref
+ BattleCharacters.Struct.Glyph.Type
+ ),
tiles : (Dict.Dict BattleMap.Struct.Tile.Ref BattleMap.Struct.Tile.Type),
error : (Maybe Struct.Error.Type),
player_id : String,
@@ -118,6 +130,8 @@ new flags =
weapons = (Dict.empty),
armors = (Dict.empty),
portraits = (Dict.empty),
+ glyph_boards = (Dict.empty),
+ glyphs = (Dict.empty),
tiles = (Dict.empty),
players = (Array.empty),
error = Nothing,
@@ -190,6 +204,28 @@ add_portrait pt model =
)
}
+add_glyph_board : BattleCharacters.Struct.GlyphBoard.Type -> Type -> Type
+add_glyph_board pt model =
+ {model |
+ glyph_boards =
+ (Dict.insert
+ (BattleCharacters.Struct.GlyphBoard.get_id pt)
+ pt
+ model.glyph_boards
+ )
+ }
+
+add_glyph : BattleCharacters.Struct.Glyph.Type -> Type -> Type
+add_glyph pt model =
+ {model |
+ glyphs =
+ (Dict.insert
+ (BattleCharacters.Struct.Glyph.get_id pt)
+ pt
+ model.glyphs
+ )
+ }
+
add_player : Struct.Player.Type -> Type -> Type
add_player pl model =
{model |
@@ -233,6 +269,8 @@ full_debug_reset model =
weapons = (Dict.empty),
armors = (Dict.empty),
portraits = (Dict.empty),
+ glyph_boards = (Dict.empty),
+ glyphs = (Dict.empty),
tiles = (Dict.empty),
error = Nothing,
ui = (Struct.UI.default),
diff --git a/src/battle/src/Struct/Navigator.elm b/src/battle/src/Struct/Navigator.elm
index f639a06..5bf3c54 100644
--- a/src/battle/src/Struct/Navigator.elm
+++ b/src/battle/src/Struct/Navigator.elm
@@ -207,7 +207,8 @@ try_adding_step dir navigator =
dir
)
of
- (Just path) -> (Just {navigator | path = path})
+ (Just path) ->
+ (Just {navigator | path = path})
Nothing -> Nothing
try_getting_path_to : (
diff --git a/src/battle/src/Struct/ServerReply.elm b/src/battle/src/Struct/ServerReply.elm
index f8fdc88..f02f791 100644
--- a/src/battle/src/Struct/ServerReply.elm
+++ b/src/battle/src/Struct/ServerReply.elm
@@ -2,6 +2,8 @@ module Struct.ServerReply exposing (Type(..))
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Armor
+import BattleCharacters.Struct.Glyph
+import BattleCharacters.Struct.GlyphBoard
import BattleCharacters.Struct.Portrait
import BattleCharacters.Struct.Weapon
@@ -22,9 +24,11 @@ type Type =
| Disconnected
| AddArmor BattleCharacters.Struct.Armor.Type
| AddPortrait BattleCharacters.Struct.Portrait.Type
+ | AddGlyphBoard BattleCharacters.Struct.GlyphBoard.Type
+ | AddGlyph BattleCharacters.Struct.Glyph.Type
| AddPlayer Struct.Player.Type
| AddWeapon BattleCharacters.Struct.Weapon.Type
- | AddCharacter Struct.Character.TypeAndEquipmentRef
+ | AddCharacter Struct.Character.Unresolved
| AddTile BattleMap.Struct.Tile.Type
| SetMap BattleMap.Struct.Map.Type
| TurnResults (List Struct.TurnResult.Type)
diff --git a/src/battle/src/Struct/TurnResult.elm b/src/battle/src/Struct/TurnResult.elm
index a4d3794..7599a7f 100644
--- a/src/battle/src/Struct/TurnResult.elm
+++ b/src/battle/src/Struct/TurnResult.elm
@@ -32,6 +32,9 @@ import Battle.Struct.Omnimods
import BattleMap.Struct.Location
import BattleMap.Struct.Direction
+-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Character
+
-- Local Module ----------------------------------------------------------------
import Struct.Attack
import Struct.Character
@@ -104,7 +107,7 @@ apply_movement_step tile_omnimods movement characters players =
(\char ->
case (List.head movement.path) of
(Just dir) ->
- (Struct.Character.set_location
+ (Struct.Character.dirty_set_location
(BattleMap.Struct.Location.neighbor
dir
(Struct.Character.get_location char)
@@ -113,7 +116,10 @@ apply_movement_step tile_omnimods movement characters players =
)
Nothing ->
- (Struct.Character.refresh_omnimods (tile_omnimods) char)
+ (Struct.Character.set_location
+ (tile_omnimods (Struct.Character.get_location char))
+ char
+ )
)
characters
),
@@ -153,7 +159,6 @@ apply_inverse_movement_step tile_omnimods movement characters players =
)
apply_switched_weapon : (
- (BattleMap.Struct.Location.Type -> Battle.Struct.Omnimods.Type) ->
WeaponSwitch ->
(Array.Array Struct.Character.Type) ->
(Array.Array Struct.Player.Type) ->
@@ -162,14 +167,15 @@ apply_switched_weapon : (
(Array.Array Struct.Player.Type)
)
)
-apply_switched_weapon tile_omnimods weapon_switch characters players =
+apply_switched_weapon weapon_switch characters players =
(
(Util.Array.update_unsafe
weapon_switch.character_index
(\char ->
- (Struct.Character.refresh_omnimods
- (tile_omnimods)
- (Struct.Character.toggle_is_using_primary char)
+ (Struct.Character.set_base_character
+ (BattleCharacters.Struct.Character.switch_weapons
+ (Struct.Character.get_base_character char)
+ )
)
)
characters
@@ -454,12 +460,7 @@ apply_step tile_omnimods turn_result characters players =
(apply_movement_step (tile_omnimods) movement characters players)
(SwitchedWeapon weapon_switch) ->
- (apply_switched_weapon
- (tile_omnimods)
- weapon_switch
- characters
- players
- )
+ (apply_switched_weapon weapon_switch characters players)
(Attacked attack) ->
(apply_attack_step attack characters players)
@@ -494,12 +495,7 @@ apply_inverse_step tile_omnimods turn_result characters players =
)
(SwitchedWeapon weapon_switch) ->
- (apply_switched_weapon
- (tile_omnimods)
- weapon_switch
- characters
- players
- )
+ (apply_switched_weapon weapon_switch characters players)
(Attacked attack) ->
(apply_inverse_attack attack characters players)
diff --git a/src/battle/src/Update/AttackWithoutMoving.elm b/src/battle/src/Update/AttackWithoutMoving.elm
index 7d29a50..3584e69 100644
--- a/src/battle/src/Update/AttackWithoutMoving.elm
+++ b/src/battle/src/Update/AttackWithoutMoving.elm
@@ -12,11 +12,7 @@ import Struct.Model
make_it_so : Struct.Model.Type -> Struct.Model.Type
make_it_so model =
{model |
- char_turn =
- (Struct.CharacterTurn.lock_path
- (Struct.Model.tile_omnimods_fun model)
- model.char_turn
- )
+ char_turn = (Struct.CharacterTurn.lock_path model.char_turn)
}
--------------------------------------------------------------------------------
diff --git a/src/battle/src/Update/ChangeScale.elm b/src/battle/src/Update/ChangeScale.elm
index 80db1d1..bb98e84 100644
--- a/src/battle/src/Update/ChangeScale.elm
+++ b/src/battle/src/Update/ChangeScale.elm
@@ -19,7 +19,5 @@ apply_to : (
)
apply_to model mod =
if (mod == 0.0)
- then
- ({model | ui = (Struct.UI.reset_zoom_level model.ui)}, Cmd.none)
- else
- ({model | ui = (Struct.UI.mod_zoom_level mod model.ui)}, Cmd.none)
+ then ({model | ui = (Struct.UI.reset_zoom_level model.ui)}, Cmd.none)
+ else ({model | ui = (Struct.UI.mod_zoom_level mod model.ui)}, Cmd.none)
diff --git a/src/battle/src/Update/HandleServerReply.elm b/src/battle/src/Update/HandleServerReply.elm
index a17b20d..9d1aa24 100644
--- a/src/battle/src/Update/HandleServerReply.elm
+++ b/src/battle/src/Update/HandleServerReply.elm
@@ -22,6 +22,9 @@ import Util.Http
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Armor
+import BattleCharacters.Struct.Equipment
+import BattleCharacters.Struct.Glyph
+import BattleCharacters.Struct.GlyphBoard
import BattleCharacters.Struct.Portrait
import BattleCharacters.Struct.Weapon
@@ -79,6 +82,26 @@ portrait_getter model ref =
(Just w) -> w
Nothing -> BattleCharacters.Struct.Portrait.default
+glyph_board_getter : (
+ Struct.Model.Type ->
+ BattleCharacters.Struct.GlyphBoard.Ref ->
+ BattleCharacters.Struct.GlyphBoard.Type
+ )
+glyph_board_getter model ref =
+ case (Dict.get ref model.glyph_boards) of
+ (Just w) -> w
+ Nothing -> BattleCharacters.Struct.GlyphBoard.default
+
+glyph_getter : (
+ Struct.Model.Type ->
+ BattleCharacters.Struct.Glyph.Ref ->
+ BattleCharacters.Struct.Glyph.Type
+ )
+glyph_getter model ref =
+ case (Dict.get ref model.glyphs) of
+ (Just w) -> w
+ Nothing -> BattleCharacters.Struct.Glyph.default
+
-----------
disconnected : (
@@ -124,6 +147,24 @@ add_portrait pt current_state =
let (model, cmds) = current_state in
((Struct.Model.add_portrait pt model), cmds)
+add_glyph_board : (
+ BattleCharacters.Struct.GlyphBoard.Type ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
+ )
+add_glyph_board pt current_state =
+ let (model, cmds) = current_state in
+ ((Struct.Model.add_glyph_board pt model), cmds)
+
+add_glyph : (
+ BattleCharacters.Struct.Glyph.Type ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
+ (Struct.Model.Type, (List (Cmd Struct.Event.Type)))
+ )
+add_glyph pt current_state =
+ let (model, cmds) = current_state in
+ ((Struct.Model.add_glyph pt model), cmds)
+
add_tile : (
BattleMap.Struct.Tile.Type ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
@@ -152,27 +193,24 @@ add_player pl current_state =
((Struct.Model.add_player pl model), cmds)
add_character : (
- Struct.Character.TypeAndEquipmentRef ->
+ Struct.Character.Unresolved ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type))) ->
(Struct.Model.Type, (List (Cmd Struct.Event.Type)))
)
-add_character char_and_refs current_state =
- let
- (model, cmds) = current_state
- awp = (weapon_getter model char_and_refs.main_weapon_ref)
- swp = (weapon_getter model char_and_refs.secondary_weapon_ref)
- ar = (armor_getter model char_and_refs.armor_ref)
- pt = (portrait_getter model char_and_refs.portrait_ref)
- in
+add_character unresolved_char current_state =
+ let (model, cmds) = current_state in
(
(Struct.Model.add_character
- (Struct.Character.fill_missing_equipment_and_omnimods
+ (Struct.Character.resolve
(Struct.Model.tile_omnimods_fun model)
- pt
- awp
- swp
- ar
- char_and_refs.char
+ (BattleCharacters.Struct.Equipment.resolve
+ (weapon_getter model)
+ (armor_getter model)
+ (portrait_getter model)
+ (glyph_board_getter model)
+ (glyph_getter model)
+ )
+ unresolved_char
)
model
),
@@ -254,6 +292,12 @@ apply_command command current_state =
(Struct.ServerReply.AddPortrait pt) ->
(add_portrait pt current_state)
+ (Struct.ServerReply.AddGlyphBoard pt) ->
+ (add_glyph_board pt current_state)
+
+ (Struct.ServerReply.AddGlyph pt) ->
+ (add_glyph pt current_state)
+
(Struct.ServerReply.AddPlayer pl) ->
(add_player pl current_state)
diff --git a/src/battle/src/Update/RequestDirection.elm b/src/battle/src/Update/RequestDirection.elm
index 625d8fe..676b54a 100644
--- a/src/battle/src/Update/RequestDirection.elm
+++ b/src/battle/src/Update/RequestDirection.elm
@@ -3,7 +3,11 @@ module Update.RequestDirection exposing (apply_to)
-- Battle Map ------------------------------------------------------------------
import BattleMap.Struct.Direction
+-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Character
+
-- Local Module ----------------------------------------------------------------
+import Struct.Character
import Struct.CharacterTurn
import Struct.Error
import Struct.Event
@@ -16,18 +20,33 @@ import Struct.UI
--------------------------------------------------------------------------------
make_it_so : (
Struct.Model.Type ->
+ Struct.Character.Type ->
Struct.Navigator.Type ->
BattleMap.Struct.Direction.Type ->
Struct.Model.Type
)
-make_it_so model navigator dir =
+make_it_so model char navigator dir =
case (Struct.Navigator.try_adding_step dir navigator) of
(Just new_navigator) ->
{model |
char_turn =
(Struct.CharacterTurn.set_navigator
new_navigator
- model.char_turn
+ (Struct.CharacterTurn.set_active_character_no_reset
+ (Struct.Character.set_base_character
+ (BattleCharacters.Struct.Character.set_extra_omnimods
+ (Struct.Model.tile_omnimods_fun
+ model
+ (Struct.Navigator.get_current_location
+ new_navigator
+ )
+ )
+ (Struct.Character.get_base_character char)
+ )
+ char
+ )
+ model.char_turn
+ )
),
ui =
(Struct.UI.set_previous_action
@@ -56,10 +75,11 @@ apply_to : (
apply_to model dir =
case
(Struct.CharacterTurn.try_getting_navigator model.char_turn)
+ (Struct.CharacterTurn.try_getting_active_character model.char_turn)
of
- (Just navigator) ->
+ ((Just navigator), (Just char)) ->
(
- (make_it_so model navigator dir),
+ (make_it_so model char navigator dir),
Cmd.none
)
diff --git a/src/battle/src/Update/SelectCharacter.elm b/src/battle/src/Update/SelectCharacter.elm
index b48f6c8..f26e3b8 100644
--- a/src/battle/src/Update/SelectCharacter.elm
+++ b/src/battle/src/Update/SelectCharacter.elm
@@ -9,6 +9,7 @@ import Task
import Battle.Struct.Statistics
-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Character
import BattleCharacters.Struct.Weapon
-- Battle Map ------------------------------------------------------------------
@@ -36,17 +37,13 @@ get_character_navigator : (
)
get_character_navigator model char =
let
- weapon =
- (
- if (Struct.Character.get_is_using_primary char)
- then (Struct.Character.get_primary_weapon char)
- else (Struct.Character.get_secondary_weapon char)
- )
+ base_char = (Struct.Character.get_base_character char)
+ weapon = (BattleCharacters.Struct.Character.get_active_weapon base_char)
in
(Struct.Navigator.new
(Struct.Character.get_location char)
(Battle.Struct.Statistics.get_movement_points
- (Struct.Character.get_statistics char)
+ (BattleCharacters.Struct.Character.get_statistics base_char)
)
(BattleCharacters.Struct.Weapon.get_defense_range weapon)
(BattleCharacters.Struct.Weapon.get_attack_range weapon)
diff --git a/src/battle/src/Update/SelectTile.elm b/src/battle/src/Update/SelectTile.elm
index 575ac13..11899b5 100644
--- a/src/battle/src/Update/SelectTile.elm
+++ b/src/battle/src/Update/SelectTile.elm
@@ -4,7 +4,11 @@ module Update.SelectTile exposing (apply_to)
import BattleMap.Struct.Direction
import BattleMap.Struct.Location
+-- Battle Characters ------------------------------------------------------------
+import BattleCharacters.Struct.Character
+
-- Local Module ----------------------------------------------------------------
+import Struct.Character
import Struct.CharacterTurn
import Struct.Error
import Struct.Event
@@ -20,115 +24,134 @@ try_autopiloting : (
(Maybe Struct.Navigator.Type) ->
(Maybe Struct.Navigator.Type)
)
-try_autopiloting dir maybe_nav =
- case maybe_nav of
+try_autopiloting dir maybe_navigator =
+ case maybe_navigator of
(Just navigator) ->
(Struct.Navigator.try_adding_step dir navigator)
Nothing -> Nothing
-go_to_tile : (
+go_to_current_tile : (
Struct.Model.Type ->
- Struct.Navigator.Type ->
BattleMap.Struct.Location.Ref ->
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
-go_to_tile model navigator loc_ref =
+go_to_current_tile model loc_ref =
if
(
- loc_ref
+ (Struct.UI.get_previous_action model.ui)
==
- (BattleMap.Struct.Location.get_ref
- (Struct.Navigator.get_current_location navigator)
- )
+ (Just (Struct.UI.SelectedLocation loc_ref))
)
then
- -- We are already there.
- if
+ -- And we just clicked on that tile.
(
- (Struct.UI.get_previous_action model.ui)
- ==
- (Just (Struct.UI.SelectedLocation loc_ref))
+ {model |
+ char_turn = (Struct.CharacterTurn.lock_path model.char_turn)
+ },
+ Cmd.none
)
- then
- -- And we just clicked on that tile.
- (
- {model |
- char_turn =
- (Struct.CharacterTurn.lock_path
- (Struct.Model.tile_omnimods_fun model)
- model.char_turn
- )
- },
- Cmd.none
- )
- else
- -- And we didn't just click on that tile.
- (
- {model |
- ui =
- (Struct.UI.reset_displayed_nav
- (Struct.UI.set_displayed_tab
- Struct.UI.StatusTab
- (Struct.UI.set_previous_action
- (Just (Struct.UI.SelectedLocation loc_ref))
- model.ui
- )
+ else
+ -- And we didn't just click on that tile.
+ (
+ {model |
+ ui =
+ (Struct.UI.reset_displayed_nav
+ (Struct.UI.set_displayed_tab
+ Struct.UI.StatusTab
+ (Struct.UI.set_previous_action
+ (Just (Struct.UI.SelectedLocation loc_ref))
+ model.ui
)
)
- },
- Cmd.none
- )
- else
- -- We have to try getting there.
- case
- (Struct.Navigator.try_getting_path_to
- loc_ref
- navigator
- )
- of
- (Just path) ->
- case
- (List.foldr
- (try_autopiloting)
- (Just (Struct.Navigator.clear_path navigator))
- path
)
- of
- (Just new_navigator) ->
- (
- {model |
- char_turn =
- (Struct.CharacterTurn.set_navigator
- new_navigator
- model.char_turn
- ),
- ui =
- (Struct.UI.set_displayed_tab
- Struct.UI.StatusTab
- (Struct.UI.set_previous_action
- (Just (Struct.UI.SelectedLocation loc_ref))
- model.ui
+ },
+ Cmd.none
+ )
+
+go_to_another_tile : (
+ Struct.Model.Type ->
+ Struct.Character.Type ->
+ Struct.Navigator.Type ->
+ BattleMap.Struct.Location.Ref ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+go_to_another_tile model char navigator loc_ref =
+ case (Struct.Navigator.try_getting_path_to loc_ref navigator) of
+ (Just path) ->
+ case
+ (List.foldr
+ (try_autopiloting)
+ (Just (Struct.Navigator.clear_path navigator))
+ path
+ )
+ of
+ (Just new_navigator) ->
+ (
+ {model |
+ char_turn =
+ (Struct.CharacterTurn.set_navigator
+ new_navigator
+ (Struct.CharacterTurn.set_active_char
+ (Struct.Character.set_base_character
+ (BattleCharacters.Struct.Character.set_extra_omnimods
+ (Struct.Model.tile_omnimods_fun
+ model
+ (Struct.Navigator.get_current_location
+ new_navigator
+ )
+ )
+ (Struct.Character.get_base_character char)
+ )
)
)
- },
- Cmd.none
- )
-
- Nothing ->
- (
- (Struct.Model.invalidate
- (Struct.Error.new
- Struct.Error.Programming
- "SelectTile/Navigator: Could not follow own path."
+ model.char_turn
+ ),
+ ui =
+ (Struct.UI.set_displayed_tab
+ Struct.UI.StatusTab
+ (Struct.UI.set_previous_action
+ (Just (Struct.UI.SelectedLocation loc_ref))
+ model.ui
+ )
)
- model
- ),
- Cmd.none
- )
+ },
+ Cmd.none
+ )
+
+ Nothing ->
+ (
+ (Struct.Model.invalidate
+ (Struct.Error.new
+ Struct.Error.Programming
+ "SelectTile/Navigator: Could not follow own path."
+ )
+ model
+ ),
+ Cmd.none
+ )
- Nothing -> -- Clicked outside of the range indicator
- ((Struct.Model.reset model), Cmd.none)
+ Nothing -> -- Clicked outside of the range indicator
+ ((Struct.Model.reset model), Cmd.none)
+
+go_to_tile : (
+ Struct.Model.Type ->
+ Struct.Character.Type ->
+ Struct.Navigator.Type ->
+ BattleMap.Struct.Location.Ref ->
+ (Struct.Model.Type, (Cmd Struct.Event.Type))
+ )
+go_to_tile model char navigator loc_ref =
+ if
+ (
+ loc_ref
+ ==
+ (BattleMap.Struct.Location.get_ref
+ (Struct.Navigator.get_current_location navigator)
+ )
+ )
+ then (go_to_current_tile model loc_ref)
+ else (to_to_another_tile model char navigator loc_ref)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -139,9 +162,14 @@ apply_to : (
(Struct.Model.Type, (Cmd Struct.Event.Type))
)
apply_to model loc_ref =
- case (Struct.CharacterTurn.try_getting_navigator model.char_turn) of
- (Just navigator) ->
- (go_to_tile model navigator loc_ref)
+ case
+ (
+ (Struct.CharacterTurn.try_getting_navigator model.char_turn),
+ (Struct.CharacterTurn.try_getting_active_character model.char_turn)
+ )
+ of
+ ((Just navigator), (Just char)) ->
+ (go_to_tile model char navigator loc_ref)
_ ->
(
diff --git a/src/battle/src/Update/SwitchWeapon.elm b/src/battle/src/Update/SwitchWeapon.elm
index de72880..881689d 100644
--- a/src/battle/src/Update/SwitchWeapon.elm
+++ b/src/battle/src/Update/SwitchWeapon.elm
@@ -1,9 +1,8 @@
module Update.SwitchWeapon exposing (apply_to)
--- FIXME: switching weapon should make the navigator disappear.
-
-- Battle Characters -----------------------------------------------------------
import BattleCharacters.Struct.Weapon
+import BattleCharacters.Struct.Character
-- Local module ----------------------------------------------------------------
import Struct.Character
@@ -11,37 +10,42 @@ import Struct.CharacterTurn
import Struct.Error
import Struct.Event
import Struct.Model
-import Struct.Navigator
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
make_it_so : Struct.Model.Type -> Struct.Model.Type
make_it_so model =
- case
- (
- (Struct.CharacterTurn.try_getting_active_character model.char_turn),
- (Struct.CharacterTurn.try_getting_navigator model.char_turn)
- )
- of
+ case (Struct.CharacterTurn.try_getting_active_character model.char_turn) of
((Just char), (Just nav)) ->
let
- tile_omnimods = (Struct.Model.tile_omnimods_fun model)
- current_tile_omnimods =
- (tile_omnimods (Struct.Navigator.get_current_location nav))
- new_char =
- (Struct.Character.refresh_omnimods
- (\e -> current_tile_omnimods)
- (Struct.Character.toggle_is_using_primary char)
+ new_base_character =
+ (BattleCharacters.Struct.Character.switch_weapons
+ (Struct.Character.get_base_character char)
+ )
+ active_weapon =
+ (BattleCharacters.Struct.Character.get_active_weapon
+ new_base_character
)
in
{model |
char_turn =
- (Struct.CharacterTurn.set_has_switched_weapons
- True
- (Struct.CharacterTurn.set_active_character_no_reset
- new_char
- model.char_turn
+ (Struct.CharacterTurn.show_attack_range_navigator
+ (BattleCharacters.Struct.Weapon.get_defense_range
+ active_weapon
+ )
+ (BattleCharacters.Struct.Weapon.get_attack_range
+ active_weapon
+ )
+ (Struct.CharacterTurn.set_has_switched_weapons
+ True
+ (Struct.CharacterTurn.set_active_character_no_reset
+ (Struct.Character.set_base_character
+ new_base_character
+ char
+ )
+ model.char_turn
+ )
)
)
}
diff --git a/src/battle/src/Update/UndoAction.elm b/src/battle/src/Update/UndoAction.elm
index c30f41b..9d2e710 100644
--- a/src/battle/src/Update/UndoAction.elm
+++ b/src/battle/src/Update/UndoAction.elm
@@ -29,17 +29,13 @@ get_character_navigator : (
)
get_character_navigator model char =
let
- weapon =
- (
- if (Struct.Character.get_is_using_primary char)
- then (Struct.Character.get_primary_weapon char)
- else (Struct.Character.get_secondary_weapon char)
- )
+ base_char = (Struct.Character.get_base_character char)
+ weapon = (BattleCharacters.Struct.Character.get_active_weapon base_char)
in
(Struct.Navigator.new
(Struct.Character.get_location char)
(Battle.Struct.Statistics.get_movement_points
- (Struct.Character.get_statistics char)
+ (BattleCharacters.Struct.Character.get_statistics base_char)
)
(BattleCharacters.Struct.Weapon.get_defense_range weapon)
(BattleCharacters.Struct.Weapon.get_attack_range weapon)
diff --git a/src/roster-editor/src/Comm/AddGlyphBoard.elm b/src/roster-editor/src/Comm/AddGlyphBoard.elm
deleted file mode 100644
index 09169d4..0000000
--- a/src/roster-editor/src/Comm/AddGlyphBoard.elm
+++ /dev/null
@@ -1,24 +0,0 @@
-module Comm.AddGlyphBoard exposing (decode)
-
--- Elm -------------------------------------------------------------------------
-import Json.Decode
-
--- Local Module-----------------------------------------------------------------
-import Struct.GlyphBoard
-import Struct.ServerReply
-
---------------------------------------------------------------------------------
--- TYPES -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-
---------------------------------------------------------------------------------
--- LOCAL -----------------------------------------------------------------------
---------------------------------------------------------------------------------
-internal_decoder : Struct.GlyphBoard.Type -> Struct.ServerReply.Type
-internal_decoder glb = (Struct.ServerReply.AddGlyphBoard glb)
-
---------------------------------------------------------------------------------
--- EXPORTED --------------------------------------------------------------------
---------------------------------------------------------------------------------
-decode : (Json.Decode.Decoder Struct.ServerReply.Type)
-decode = (Json.Decode.map (internal_decoder) (Struct.GlyphBoard.decoder))
diff --git a/src/battle/src/Comm/AddArmor.elm b/src/shared/battle-characters/BattleCharacters/Comm/AddArmor.elm
index 5dd7aad..bdbb137 100644
--- a/src/battle/src/Comm/AddArmor.elm
+++ b/src/shared/battle-characters/BattleCharacters/Comm/AddArmor.elm
@@ -1,4 +1,4 @@
-module Comm.AddArmor exposing (decode)
+module BattleCharacters.Comm.AddArmor exposing (decode)
-- Elm -------------------------------------------------------------------------
import Json.Decode
diff --git a/src/roster-editor/src/Comm/AddGlyph.elm b/src/shared/battle-characters/BattleCharacters/Comm/AddGlyph.elm
index 95f470e..100ed54 100644
--- a/src/roster-editor/src/Comm/AddGlyph.elm
+++ b/src/shared/battle-characters/BattleCharacters/Comm/AddGlyph.elm
@@ -1,10 +1,13 @@
-module Comm.AddGlyph exposing (decode)
+module BattleCharacters.Comm.AddGlyph exposing (decode)
-- Elm -------------------------------------------------------------------------
import Json.Decode
+-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Glyph
+import BattleCharacters.Struct.GlyphBoard
+
-- Local Module ----------------------------------------------------------------
-import Struct.Glyph
import Struct.ServerReply
--------------------------------------------------------------------------------
@@ -14,11 +17,12 @@ import Struct.ServerReply
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-internal_decoder : Struct.Glyph.Type -> Struct.ServerReply.Type
+internal_decoder : BattleCharacters.Struct.Glyph.Type -> Struct.ServerReply.Type
internal_decoder gl = (Struct.ServerReply.AddGlyph gl)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
decode : (Json.Decode.Decoder Struct.ServerReply.Type)
-decode = (Json.Decode.map (internal_decoder) (Struct.Glyph.decoder))
+decode =
+ (Json.Decode.map (internal_decoder) (BattleCharacters.Struct.Glyph.decoder))
diff --git a/src/battle/src/Comm/AddPortrait.elm b/src/shared/battle-characters/BattleCharacters/Comm/AddGlyphBoard.elm
index 8fd29af..825e940 100644
--- a/src/battle/src/Comm/AddPortrait.elm
+++ b/src/shared/battle-characters/BattleCharacters/Comm/AddGlyphBoard.elm
@@ -1,12 +1,12 @@
-module Comm.AddPortrait exposing (decode)
+module BattleCharacters.Comm.AddGlyphBoard exposing (decode)
-- Elm -------------------------------------------------------------------------
import Json.Decode
-- Battle Characters -----------------------------------------------------------
-import BattleCharacters.Struct.Portrait
+import BattleCharacters.Struct.GlyphBoard
--- Local Module ----------------------------------------------------------------
+-- Local Module-----------------------------------------------------------------
import Struct.ServerReply
--------------------------------------------------------------------------------
@@ -17,10 +17,10 @@ import Struct.ServerReply
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
internal_decoder : (
- BattleCharacters.Struct.Portrait.Type ->
+ BattleCharacters.Struct.GlyphBoard.Type ->
Struct.ServerReply.Type
)
-internal_decoder pt = (Struct.ServerReply.AddPortrait pt)
+internal_decoder glb = (Struct.ServerReply.AddGlyphBoard glb)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
@@ -29,5 +29,5 @@ decode : (Json.Decode.Decoder Struct.ServerReply.Type)
decode =
(Json.Decode.map
(internal_decoder)
- (BattleCharacters.Struct.Portrait.decoder)
+ (BattleCharacters.Struct.GlyphBoard.decoder)
)
diff --git a/src/shared/battle-characters/BattleCharacters/Comm/AddPortrait.elm b/src/shared/battle-characters/BattleCharacters/Comm/AddPortrait.elm
index a9c848b..321684c 100644
--- a/src/shared/battle-characters/BattleCharacters/Comm/AddPortrait.elm
+++ b/src/shared/battle-characters/BattleCharacters/Comm/AddPortrait.elm
@@ -1,10 +1,12 @@
-module Comm.AddPortrait exposing (decode)
+module BattleCharacters.Comm.AddPortrait exposing (decode)
-- Elm -------------------------------------------------------------------------
import Json.Decode
--- BattleCharacters ------------------------------------------------------------
-import Struct.Portrait
+-- Battle Characters -----------------------------------------------------------
+import BattleCharacters.Struct.Portrait
+
+-- Local Module ----------------------------------------------------------------
import Struct.ServerReply
--------------------------------------------------------------------------------
@@ -14,11 +16,18 @@ import Struct.ServerReply
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
-internal_decoder : Struct.Portrait.Type -> Struct.ServerReply.Type
+internal_decoder : (
+ BattleCharacters.Struct.Portrait.Type ->
+ Struct.ServerReply.Type
+ )
internal_decoder pt = (Struct.ServerReply.AddPortrait pt)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
decode : (Json.Decode.Decoder Struct.ServerReply.Type)
-decode = (Json.Decode.map (internal_decoder) (Struct.Portrait.decoder))
+decode =
+ (Json.Decode.map
+ (internal_decoder)
+ (BattleCharacters.Struct.Portrait.decoder)
+ )
diff --git a/src/battle/src/Comm/AddWeapon.elm b/src/shared/battle-characters/BattleCharacters/Comm/AddWeapon.elm
index 307dc6a..6a05978 100644
--- a/src/battle/src/Comm/AddWeapon.elm
+++ b/src/shared/battle-characters/BattleCharacters/Comm/AddWeapon.elm
@@ -1,4 +1,4 @@
-module Comm.AddWeapon exposing (decode)
+module BattleCharacters.Comm.AddWeapon exposing (decode)
-- Elm -------------------------------------------------------------------------
import Json.Decode
diff --git a/src/shared/battle-characters/BattleCharacters/Struct/Character.elm b/src/shared/battle-characters/BattleCharacters/Struct/Character.elm
index adf7ca7..7b34bd4 100644
--- a/src/shared/battle-characters/BattleCharacters/Struct/Character.elm
+++ b/src/shared/battle-characters/BattleCharacters/Struct/Character.elm
@@ -6,13 +6,16 @@ module BattleCharacters.Struct.Character exposing
set_name,
get_equipment,
set_equipment,
+ dirty_set_equipment,
get_omnimods,
set_extra_omnimods,
+ dirty_set_extra_omnimods
get_attributes,
get_statistics,
get_active_weapon,
get_inactive_weapon,
switch_weapons,
+ dirty_switch_weapons,
decoder,
encode,
resolve
@@ -122,12 +125,18 @@ get_equipment c = c.equipment
set_equipment : BattleCharacters.Struct.Equipment.Type -> Type -> Type
set_equipment equipment char = (refresh_omnimods {char | equipment = equipment})
+dirty_set_equipment : BattleCharacters.Struct.Equipment.Type -> Type -> Type
+dirty_set_equipment equipment char = {char | equipment = equipment}
+
get_omnimods : Type -> Battle.Struct.Omnimods.Type
get_omnimods c = c.current_omnimods
set_extra_omnimods : Battle.Struct.Omnimods.Type -> Type -> Type
set_extra_omnimods om c = (refresh_omnimods {char | extra_omnimods = om})
+dirty_set_extra_omnimods : Battle.Struct.Omnimods.Type -> Type -> Type
+dirty_set_extra_omnimods om c = {char | extra_omnimods = om}
+
get_attributes : Type -> Battle.Struct.Attributes.Type
get_attributes char = char.attributes
@@ -140,6 +149,10 @@ switch_weapons char =
{char | is_using_secondary = (not char.is_using_secondary)}
)
+dirty_switch_weapons : Type -> Type
+dirty_switch_weapons char =
+ {char | is_using_secondary = (not char.is_using_secondary)}
+
decoder : (Json.Decode.Decoder Unresolved)
decoder :
(Json.Decode.succeed
diff --git a/src/battle/src/Comm/AddTile.elm b/src/shared/battle-map/BattleMap/Comm/AddTile.elm
index 797731b..e904362 100644
--- a/src/battle/src/Comm/AddTile.elm
+++ b/src/shared/battle-map/BattleMap/Comm/AddTile.elm
@@ -1,4 +1,4 @@
-module Comm.AddTile exposing (decode)
+module BattleMap.Comm.AddTile exposing (decode)
-- Elm -------------------------------------------------------------------------
import Json.Decode
diff --git a/src/battle/src/Comm/SetMap.elm b/src/shared/battle-map/BattleMap/Comm/SetMap.elm
index 80f6db1..bfe8425 100644
--- a/src/battle/src/Comm/SetMap.elm
+++ b/src/shared/battle-map/BattleMap/Comm/SetMap.elm
@@ -1,4 +1,4 @@
-module Comm.SetMap exposing (decode)
+module BattleMap.Comm.SetMap exposing (decode)
-- Elm -------------------------------------------------------------------------
import Json.Decode