summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-02-10 18:10:16 +0100
committernsensfel <SpamShield0@noot-noot.org>2018-02-10 18:10:16 +0100
commit83d601479f05f52683bc148a26cf9fe465869dc1 (patch)
treeeb7b6a18d11c608a9db2a99dcc58526f51f293e7
parent5eadad465cd6c21f157de82cbe9f3257a243e0a9 (diff)
Starting to add weapons to the mix.
-rw-r--r--src/battlemap/src/Struct/Character.elm17
-rw-r--r--src/battlemap/src/Struct/Statistics.elm5
-rw-r--r--src/battlemap/src/Struct/Weapon.elm4
-rw-r--r--src/battlemap/src/Struct/WeaponSet.elm39
-rw-r--r--src/battlemap/src/Update/HandleServerReply/AddChar.elm19
5 files changed, 76 insertions, 8 deletions
diff --git a/src/battlemap/src/Struct/Character.elm b/src/battlemap/src/Struct/Character.elm
index 7f40604..f836f5d 100644
--- a/src/battlemap/src/Struct/Character.elm
+++ b/src/battlemap/src/Struct/Character.elm
@@ -20,7 +20,7 @@ module Struct.Character exposing
import Struct.Attributes
import Struct.Location
import Struct.Statistics
-import Struct.Weapon
+import Struct.WeaponSet
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
@@ -36,7 +36,8 @@ type alias Type =
team : Int,
enabled : Bool,
attributes : Struct.Attributes.Type,
- statistics : Struct.Statistics.Type
+ statistics : Struct.Statistics.Type,
+ weapons : Struct.WeaponSet.Type
}
type alias Ref = String
@@ -58,13 +59,14 @@ new : (
Int -> -- team
Bool -> -- enabled
Struct.Attributes.Type ->
+ Struct.WeaponSet.Type ->
Type
)
new
id name icon portrait
location health
team enabled
- attributes =
+ attributes weapons =
{
id = id,
name = name,
@@ -73,9 +75,14 @@ new
location = location,
health = health,
attributes = attributes,
- statistics = (Struct.Statistics.new attributes (Struct.Weapon.none)),
+ statistics =
+ (Struct.Statistics.new
+ attributes
+ weapons
+ ),
team = team,
- enabled = enabled
+ enabled = enabled,
+ weapons = weapons
}
get_ref : Type -> Ref
diff --git a/src/battlemap/src/Struct/Statistics.elm b/src/battlemap/src/Struct/Statistics.elm
index 4e7a0ea..ecc58fe 100644
--- a/src/battlemap/src/Struct/Statistics.elm
+++ b/src/battlemap/src/Struct/Statistics.elm
@@ -19,6 +19,7 @@ import List
-- Battlemap -------------------------------------------------------------------
import Struct.Attributes
import Struct.Weapon
+import Struct.WeaponSet
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
@@ -96,10 +97,10 @@ get_critical_hits t = t.critical_hits
new : (
Struct.Attributes.Type ->
- Struct.Weapon.Type ->
+ Struct.WeaponSet.Type ->
Type
)
-new att wp =
+new att wp_set =
{
movement_points =
(gentle_squared_growth (Struct.Attributes.get_speed att)),
diff --git a/src/battlemap/src/Struct/Weapon.elm b/src/battlemap/src/Struct/Weapon.elm
index 4f0c518..df20541 100644
--- a/src/battlemap/src/Struct/Weapon.elm
+++ b/src/battlemap/src/Struct/Weapon.elm
@@ -1,6 +1,7 @@
module Struct.Weapon exposing
(
Type,
+ new,
none
)
@@ -22,5 +23,8 @@ type alias Type =
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
+new : Int -> Type
+new id = { id = id }
+
none : Type
none = { id = 0 }
diff --git a/src/battlemap/src/Struct/WeaponSet.elm b/src/battlemap/src/Struct/WeaponSet.elm
new file mode 100644
index 0000000..444152d
--- /dev/null
+++ b/src/battlemap/src/Struct/WeaponSet.elm
@@ -0,0 +1,39 @@
+module Struct.WeaponSet exposing
+ (
+ Type,
+ new,
+ get_active_weapon,
+ get_secondary_weapon,
+ switch_weapons
+ )
+
+-- Battlemap -------------------------------------------------------------------
+import Struct.Weapon
+
+--------------------------------------------------------------------------------
+-- TYPES -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+type alias Type =
+ {
+ active : Struct.Weapon.Type,
+ secondary : Struct.Weapon.Type
+ }
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+new : Struct.Weapon.Type -> Struct.Weapon.Type -> Type
+new wp0 wp1 = { active = wp0, secondary = wp1 }
+
+get_active_weapon : Type -> Struct.Weapon.Type
+get_active_weapon set = set.active
+
+get_secondary_weapon : Type -> Struct.Weapon.Type
+get_secondary_weapon set = set.secondary
+
+switch_weapons : Type -> Type
+switch_weapons set = {set | active = set.secondary, secondary = set.active}
diff --git a/src/battlemap/src/Update/HandleServerReply/AddChar.elm b/src/battlemap/src/Update/HandleServerReply/AddChar.elm
index ff554d5..ae406e6 100644
--- a/src/battlemap/src/Update/HandleServerReply/AddChar.elm
+++ b/src/battlemap/src/Update/HandleServerReply/AddChar.elm
@@ -9,6 +9,8 @@ import Struct.Attributes
import Struct.Character
import Struct.Error
import Struct.Model
+import Struct.Weapon
+import Struct.WeaponSet
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
@@ -34,7 +36,10 @@ type alias CharData =
health : Int,
team : Int,
enabled : Bool,
- att : CharAtt
+ att : CharAtt,
+ wp_0 : Int,
+ wp_1 : Int,
+ act_wp : Int
}
--------------------------------------------------------------------------------
@@ -66,6 +71,9 @@ char_decoder =
|> (Json.Decode.Pipeline.required "team" Json.Decode.int)
|> (Json.Decode.Pipeline.required "enabled" Json.Decode.bool)
|> (Json.Decode.Pipeline.required "att" attributes_decoder)
+ |> (Json.Decode.Pipeline.required "wp_0" Json.Decode.int)
+ |> (Json.Decode.Pipeline.required "wp_1" Json.Decode.int)
+ |> (Json.Decode.Pipeline.required "act_wp" Json.Decode.int)
)
--------------------------------------------------------------------------------
@@ -99,6 +107,15 @@ apply_to model serialized_char =
char_data.att.spe
char_data.att.str
)
+ (
+ let
+ wp_0 = (Struct.Weapon.new char_data.wp_0)
+ wp_1 = (Struct.Weapon.new char_data.wp_1)
+ in
+ case char_data.act_wp of
+ 0 -> (Struct.WeaponSet.new wp_0 wp_1)
+ _ -> (Struct.WeaponSet.new wp_1 wp_0)
+ )
)
)