summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-02-20 17:38:01 +0100
committernsensfel <SpamShield0@noot-noot.org>2018-02-20 17:38:01 +0100
commite8daf731a761dd1e5a0797237715e5384a7cff7e (patch)
tree50a0c83eeb562a351d77e8bb4403c0983999d73e
parent7e7268cfa4e3fbbdee71cc7200923e5b68cea796 (diff)
Starting to work on the weapons.
-rw-r--r--src/battlemap/src/Data/Weapon.elm45
-rw-r--r--src/battlemap/src/Struct/Attributes.elm47
-rw-r--r--src/battlemap/src/Struct/Weapon.elm99
-rw-r--r--src/battlemap/src/Update/HandleServerReply/AddChar.elm7
-rw-r--r--template.elm12
5 files changed, 187 insertions, 23 deletions
diff --git a/src/battlemap/src/Data/Weapon.elm b/src/battlemap/src/Data/Weapon.elm
new file mode 100644
index 0000000..387164f
--- /dev/null
+++ b/src/battlemap/src/Data/Weapon.elm
@@ -0,0 +1,45 @@
+module Data.Weapon exposing (generate_dict, shim_none)
+-- Elm -------------------------------------------------------------------------
+import Dict
+
+-- Battlemap -------------------------------------------------------------------
+import Struct.Weapon
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+dataset : (List (Int, Struct.Weapon.Type))
+dataset =
+ [
+ -- TODO: have those in separate text files, and put them here only at
+ -- compilation.
+ (
+ 0,
+ (Struct.Weapon.new
+ 0
+ "None"
+ Struct.Weapon.Melee
+ Struct.Weapon.Short
+ Struct.Weapon.Blunt
+ Struct.Weapon.Light
+ )
+ )
+ ]
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------
+generate_dict : (Dict.Dict Int Struct.Weapon.Type)
+generate_dict = (Dict.fromList dataset)
+
+-- Let's not handle the dict just yet.
+shim_none : (Struct.Weapon.Type)
+shim_none =
+ (Struct.Weapon.new
+ 0
+ "None"
+ Struct.Weapon.Melee
+ Struct.Weapon.Short
+ Struct.Weapon.Blunt
+ Struct.Weapon.Light
+ )
diff --git a/src/battlemap/src/Struct/Attributes.elm b/src/battlemap/src/Struct/Attributes.elm
index c632684..277a3ec 100644
--- a/src/battlemap/src/Struct/Attributes.elm
+++ b/src/battlemap/src/Struct/Attributes.elm
@@ -7,6 +7,12 @@ module Struct.Attributes exposing
get_mind,
get_speed,
get_strength,
+ mod_constitution,
+ mod_dexterity,
+ mod_intelligence,
+ mod_mind,
+ mod_speed,
+ mod_strength,
new
)
@@ -26,6 +32,11 @@ type alias Type =
--------------------------------------------------------------------------------
-- 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 --------------------------------------------------------------------
@@ -48,6 +59,42 @@ 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))
+ }
+
new : (
Int -> -- constitution
Int -> -- dexterity
diff --git a/src/battlemap/src/Struct/Weapon.elm b/src/battlemap/src/Struct/Weapon.elm
index 180b662..5fcd03e 100644
--- a/src/battlemap/src/Struct/Weapon.elm
+++ b/src/battlemap/src/Struct/Weapon.elm
@@ -1,13 +1,18 @@
module Struct.Weapon exposing
(
Type,
+ RangeType(..),
+ RangeModifier(..),
+ DamageType(..),
+ DamageModifier(..),
new,
get_max_range,
get_min_range,
- none
+ apply_to_attributes
)
-- Battlemap -------------------------------------------------------------------
+import Struct.Attributes
--------------------------------------------------------------------------------
-- TYPES -----------------------------------------------------------------------
@@ -15,42 +20,81 @@ module Struct.Weapon exposing
type alias Type =
{
id : Int,
+ name : String,
+ range_type : RangeType,
+ range_mod : RangeModifier,
+ dmg_type : DamageType,
+ dmg_mod : DamageModifier,
range_min : Int,
- range_max : Int
+ range_max : Int,
+ dmg_min : Int,
+ dmg_max : Int
}
-type WeaponRangeType = Ranged | Melee
-type WeaponRangeModifier = Long | Sort
-type WeaponDamageType = Slash | Blunt | Pierce
+type RangeType = Ranged | Melee
+type RangeModifier = Long | Short
+-- Having multiple types at the same time, like Warframe does, would be nice.
+type DamageType = Slash | Blunt | Pierce
+type DamageModifier = Heavy | Light
type alias WeaponType =
{
- range : WeaponRangeType,
- range_mod : WeaponRangeModifier,
- dmg_type : WeaponDamageType
+ range : RangeType,
+ range_mod : RangeModifier,
+ dmg_type : DamageType
}
--------------------------------------------------------------------------------
-- LOCAL -----------------------------------------------------------------------
--------------------------------------------------------------------------------
+get_ranges : RangeType -> RangeModifier -> (Int, Int)
+get_ranges rt rm =
+ case (rt, rm) of
+ (Ranged, Long) -> (2, 6)
+ (Ranged, Short) -> (2, 4)
+ (Melee, Long) -> (1, 2)
+ (Melee, Short) -> (1, 1)
+
+get_damages : RangeType -> DamageModifier -> (Int, Int)
+get_damages rt dm =
+ case (rt, dm) of
+ (Ranged, Heavy) -> (10, 25)
+ (Ranged, Light) -> (5, 20)
+ (Melee, Heavy) -> (20, 35)
+ (Melee, Light) -> (15, 30)
--------------------------------------------------------------------------------
-- EXPORTED --------------------------------------------------------------------
--------------------------------------------------------------------------------
-new : Int -> Type
-new id =
+new : (
+ Int ->
+ String ->
+ RangeType ->
+ RangeModifier ->
+ DamageType ->
+ DamageModifier ->
+ Type
+ )
+new
+ id name
+ range_type range_mod
+ dmg_type dmg_mod
+ =
+ let
+ (range_min, range_max) = (get_ranges range_type range_mod)
+ (dmg_min, dmg_max) = (get_damages range_type dmg_mod)
+ in
{
id = id,
- range_min = 1,
- range_max = 1
- }
-
-none : Type
-none =
- {
- id = 0,
- range_min = 0,
- range_max = 0
+ name = name,
+ range_type = range_type,
+ range_mod = range_mod,
+ dmg_type = dmg_type,
+ dmg_mod = dmg_mod,
+ range_min = range_min,
+ range_max = range_max,
+ dmg_min = dmg_min,
+ dmg_max = dmg_max
}
get_max_range : Type -> Int
@@ -58,3 +102,18 @@ get_max_range wp = wp.range_max
get_min_range : Type -> Int
get_min_range wp = wp.range_min
+
+apply_to_attributes : Type -> Struct.Attributes.Type -> Struct.Attributes.Type
+apply_to_attributes wp atts =
+ case (wp.range_mod, wp.dmg_mod) of
+ (Long, Heavy) ->
+ (Struct.Attributes.mod_dexterity
+ -20
+ (Struct.Attributes.mod_speed -20 atts)
+ )
+
+ (Long, Light) -> (Struct.Attributes.mod_dexterity -20 atts)
+
+ (Short, Heavy) -> (Struct.Attributes.mod_speed -20 atts)
+
+ (Short, Light) -> atts
diff --git a/src/battlemap/src/Update/HandleServerReply/AddChar.elm b/src/battlemap/src/Update/HandleServerReply/AddChar.elm
index ae406e6..4d6b3d8 100644
--- a/src/battlemap/src/Update/HandleServerReply/AddChar.elm
+++ b/src/battlemap/src/Update/HandleServerReply/AddChar.elm
@@ -5,11 +5,12 @@ import Json.Decode
import Json.Decode.Pipeline
-- Battlemap -------------------------------------------------------------------
+import Data.Weapon
+
import Struct.Attributes
import Struct.Character
import Struct.Error
import Struct.Model
-import Struct.Weapon
import Struct.WeaponSet
--------------------------------------------------------------------------------
@@ -109,8 +110,8 @@ apply_to model serialized_char =
)
(
let
- wp_0 = (Struct.Weapon.new char_data.wp_0)
- wp_1 = (Struct.Weapon.new char_data.wp_1)
+ wp_0 = (Data.Weapon.shim_none)
+ wp_1 = (Data.Weapon.shim_none)
in
case char_data.act_wp of
0 -> (Struct.WeaponSet.new wp_0 wp_1)
diff --git a/template.elm b/template.elm
new file mode 100644
index 0000000..287f826
--- /dev/null
+++ b/template.elm
@@ -0,0 +1,12 @@
+module Update.ChangeScale exposing (apply_to)
+-- Elm -------------------------------------------------------------------------
+
+-- Battlemap -------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- LOCAL -----------------------------------------------------------------------
+--------------------------------------------------------------------------------
+
+--------------------------------------------------------------------------------
+-- EXPORTED --------------------------------------------------------------------
+--------------------------------------------------------------------------------