From acf9e9f1eb880ffb8ab918c40724eda566aefcc7 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 23 Feb 2018 11:35:45 +0100 Subject: Starting a big refactoring... --- src/type/armor.erl | 51 ------- src/type/attributes.erl | 68 --------- src/type/attributes_shim.erl | 47 ------ src/type/battlemap.erl | 60 -------- src/type/battlemap/cross_5.erl | 63 -------- src/type/battlemap_instance.erl | 133 ---------------- src/type/battlemap_instance_shim.erl | 55 ------- src/type/battlemap_shim.erl | 64 -------- src/type/character.erl | 54 ------- src/type/character_instance.erl | 126 --------------- src/type/character_shim.erl | 57 ------- src/type/glyph.erl | 45 ------ src/type/statistics.erl | 157 ------------------- src/type/weapon.erl | 287 ----------------------------------- src/type/weapon_shim.erl | 24 --- 15 files changed, 1291 deletions(-) delete mode 100644 src/type/armor.erl delete mode 100644 src/type/attributes.erl delete mode 100644 src/type/attributes_shim.erl delete mode 100644 src/type/battlemap.erl delete mode 100644 src/type/battlemap/cross_5.erl delete mode 100644 src/type/battlemap_instance.erl delete mode 100644 src/type/battlemap_instance_shim.erl delete mode 100644 src/type/battlemap_shim.erl delete mode 100644 src/type/character.erl delete mode 100644 src/type/character_instance.erl delete mode 100644 src/type/character_shim.erl delete mode 100644 src/type/glyph.erl delete mode 100644 src/type/statistics.erl delete mode 100644 src/type/weapon.erl delete mode 100644 src/type/weapon_shim.erl (limited to 'src/type') diff --git a/src/type/armor.erl b/src/type/armor.erl deleted file mode 100644 index 89df653..0000000 --- a/src/type/armor.erl +++ /dev/null @@ -1,51 +0,0 @@ --module(armor). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - armor, - { - id, - name, - icon, - type, - prof_max, - pos_stat_mods, - neg_stat_mods - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_id/1, - get_name/1, - get_icon/1, - get_type/1, - get_max_prof/1, - get_pos_stat_mods/1, - get_neg_stat_mods/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors -get_id (Ar) -> Ar#armor.id. -get_name (Ar) -> Ar#armor.name. -get_icon (Ar) -> Ar#armor.icon. -get_type (Ar) -> Ar#armor.type. -get_max_prof (Ar) -> Ar#armor.prof_max. -get_pos_stat_mods (Ar) -> Ar#armor.pos_stat_mods. -get_neg_stat_mods (Ar) -> Ar#armor.neg_stat_mods. diff --git a/src/type/attributes.erl b/src/type/attributes.erl deleted file mode 100644 index b4395cb..0000000 --- a/src/type/attributes.erl +++ /dev/null @@ -1,68 +0,0 @@ --module(attributes). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - attributes, - { - constitution, - dexterity, - intelligence, - mind, - speed, - strength - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_constitution/1, - get_dexterity/1, - get_intelligence/1, - get_mind/1, - get_speed/1, - get_strength/1, - - set_constitution/2, - set_dexterity/2, - set_intelligence/2, - set_mind/2, - set_speed/2, - set_strength/2 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors -get_constitution (Att) -> Att#attributes.constitution. -get_dexterity (Att) -> Att#attributes.dexterity. -get_intelligence (Att) -> Att#attributes.intelligence. -get_mind (Att) -> Att#attributes.mind. -get_speed (Att) -> Att#attributes.speed. -get_strength (Att) -> Att#attributes.strength. - -set_constitution (Att, Val) -> - Att#attributes{ constitution = Val }. -set_dexterity (Att, Val) -> - Att#attributes{ dexterity = Val }. -set_intelligence (Att, Val) -> - Att#attributes{ intelligence = Val }. -set_mind (Att, Val) -> - Att#attributes{ mind = Val }. -set_speed (Att, Val) -> - Att#attributes{ speed = Val }. -set_strength (Att, Val) -> - Att#attributes{ strength = Val }. diff --git a/src/type/attributes_shim.erl b/src/type/attributes_shim.erl deleted file mode 100644 index b80ee6d..0000000 --- a/src/type/attributes_shim.erl +++ /dev/null @@ -1,47 +0,0 @@ --module(attributes_shim). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - attributes, - { - constitution, - dexterity, - intelligence, - mind, - speed, - strength - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - rand/0 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -random_attribute (Min, Max) -> (rand:uniform(Max - Min) - 1) + Min. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -rand () -> - #attributes - { - constitution = random_attribute(10, 100), - dexterity = random_attribute(10, 100), - intelligence = random_attribute(10, 100), - mind = random_attribute(10, 100), - speed = random_attribute(10, 100), - strength = random_attribute(10, 100) - }. diff --git a/src/type/battlemap.erl b/src/type/battlemap.erl deleted file mode 100644 index f55aadb..0000000 --- a/src/type/battlemap.erl +++ /dev/null @@ -1,60 +0,0 @@ --module(battlemap). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - battlemap, - { - id, - width, - height, - content, - instances - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_id/1, - get_width/1, - get_height/1, - list_tiles/1, - get_instances/1 - ] -). - -%%%% Utils --export -( - [ - cross/5, - dist/2 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors -get_id (Battlemap) -> Battlemap#battlemap.id. -get_width (Battlemap) -> Battlemap#battlemap.width. -get_height (Battlemap) -> Battlemap#battlemap.height. -list_tiles (Battlemap) -> array:sparse_to_list(Battlemap#battlemap.content). -get_instances (Battlemap) -> Battlemap#battlemap.instances. - -%%%% Utils --include("battlemap/cross_5.erl"). - -dist ({OX, OY}, {DX, DY}) -> - (abs(OX - DX) + abs(OY - DY)). diff --git a/src/type/battlemap/cross_5.erl b/src/type/battlemap/cross_5.erl deleted file mode 100644 index dccc4b9..0000000 --- a/src/type/battlemap/cross_5.erl +++ /dev/null @@ -1,63 +0,0 @@ -%% -%% battlemap:cross/5 -%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -next_loc (X, Y, <<"L">>) -> {(X - 1), Y}; -next_loc (X, Y, <<"R">>) -> {(X + 1), Y}; -next_loc (X, Y, <<"U">>) -> {X, (Y - 1)}; -next_loc (X, Y, <<"D">>) -> {X, (Y + 1)}. - -loc_to_index(X, Y, Map) -> - if - (X < 0) -> error; - (Y < 0) -> error; - (X >= Map#battlemap.width) -> error; - true -> ((Y * Map#battlemap.width) + X) - end. - -calc_new_loc (X, Y, [], Points, _Map, _CharInstsLocs) -> - io:format("~nPoints remaining: ~p ~n", [Points]), - true = (Points >= 0), - {X, Y}; -calc_new_loc (X, Y, [Step|Path], Points, Map, CharInstsLocs) -> - io:format("~nStep - Points remaining: ~p ~n", [Points]), - {NX, NY} = next_loc(X, Y, Step), - TileCost = - tile:get_cost - ( - array:get - ( - loc_to_index(NX, NY, Map), - Map#battlemap.content - ) - ), - io:format("~nStep cost: ~p ~n", [TileCost]), - NPoints = - ( - Points - - - TileCost - ), - false = lists:member({NX, NY}, CharInstsLocs), - calc_new_loc(NX, NY, Path, NPoints, Map, CharInstsLocs). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -cross (Battlemap, {X, Y}, Points, Path, CharInsts) -> - calc_new_loc - ( - X, - Y, - Path, - Points, - Battlemap, - lists:map - ( - fun character_instance:get_location/1, - CharInsts - ) - ). diff --git a/src/type/battlemap_instance.erl b/src/type/battlemap_instance.erl deleted file mode 100644 index 6a6fe3b..0000000 --- a/src/type/battlemap_instance.erl +++ /dev/null @@ -1,133 +0,0 @@ --module(battlemap_instance). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - battlemap_instance, - { - id, - chars, - curr_player, - players, - rem_chars, - last_turn - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_id/1, - list_characters/1, - get_char_instances/1, - get_char_instance/2, - set_char_instance/3 - ] -). - -%%%% Utils --export -( - [ - can_play_char_instance/3, - post_play_char_instance/2 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors -get_id (BattlemapInstance) -> BattlemapInstance#battlemap_instance.id. - -list_characters (BattlemapInstance) -> - dict:to_list(BattlemapInstance#battlemap_instance.chars). - -get_char_instances (BattlemapInstance) -> - lists:map - ( - fun ({_K, V}) -> V end, - dict:to_list(BattlemapInstance#battlemap_instance.chars) - ). - -can_play_char_instance -( - BattlemapInstance, - PlayerID, - CharInstID -) -> - ( - ( - array:get - ( - BattlemapInstance#battlemap_instance.curr_player, - BattlemapInstance#battlemap_instance.players - ) - =:= - PlayerID - ) - and - lists:member(CharInstID, BattlemapInstance#battlemap_instance.rem_chars) - ). - -post_play_char_instance (BattlemapInstance, CharInstID) -> - case BattlemapInstance#battlemap_instance.rem_chars of - [CharInstID|[]] -> - NextPlayer = - ( - (BattlemapInstance#battlemap_instance.curr_player + 1) - rem - array:size(BattlemapInstance#battlemap_instance.players) - ), - BattlemapInstance#battlemap_instance - { - curr_player = NextPlayer, - rem_chars = - lists:filtermap - ( - fun ({K, V}) -> - case character_instance:get_owner(V) of - NextPlayer -> {true, K}; - _ -> false - end - end, - dict:to_list(BattlemapInstance#battlemap_instance.chars) - ) - }; - - _ -> - BattlemapInstance#battlemap_instance - { - rem_chars = - lists:delete - ( - CharInstID, - BattlemapInstance#battlemap_instance.rem_chars - ) - } - end. - -get_char_instance (BattlemapInstance, CharInstID) -> - dict:fetch(CharInstID, BattlemapInstance#battlemap_instance.chars). - -set_char_instance (BattlemapInstance, CharInstID, CharInst) -> - BattlemapInstance#battlemap_instance - { - chars = - dict:store - ( - CharInstID, - CharInst, - BattlemapInstance#battlemap_instance.chars - ) - }. diff --git a/src/type/battlemap_instance_shim.erl b/src/type/battlemap_instance_shim.erl deleted file mode 100644 index 94ae7ce..0000000 --- a/src/type/battlemap_instance_shim.erl +++ /dev/null @@ -1,55 +0,0 @@ --module(battlemap_instance_shim). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - battlemap_instance, - { - id, - chars, - curr_player, - players, - rem_chars, - last_turn - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - generate_random/2 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -generate_random (CharInsts, Players) -> - #battlemap_instance - { - id = <<"0">>, - chars = dict:from_list(CharInsts), - curr_player = 0, - players = array:from_list(Players), - rem_chars = - lists:filtermap - ( - fun ({K, V}) -> - case character_instance:get_owner(V) of - 0 -> {true, K}; - _ -> false - end - end, - CharInsts - ), - last_turn = [] - }. diff --git a/src/type/battlemap_shim.erl b/src/type/battlemap_shim.erl deleted file mode 100644 index b19a653..0000000 --- a/src/type/battlemap_shim.erl +++ /dev/null @@ -1,64 +0,0 @@ --module(battlemap_shim). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - battlemap, - { - id, - width, - height, - content, - instances - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - generate_random/0 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -generate(_Prev, Result, _X, 0, _BaseWidth) -> - Result; -generate(Prev, Result, 0, Y, BaseWidth) -> - generate(Prev, Result, BaseWidth, (Y - 1), BaseWidth); -generate(Prev, Result, X, Y, BaseWidth) -> - case rand:uniform(100) of - N when (N >= 10) -> - generate(Prev, [Prev|Result], (X - 1), Y, BaseWidth); - - N -> - NewTileType = (N - 1), - generate - ( - NewTileType, - [NewTileType|Result], - (X - 1), - Y, - BaseWidth - ) - end. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -generate_random () -> - Width = (rand:uniform(48) + 16), - Height = (rand:uniform(48) + 16), - #battlemap - { - id = <<"0">>, - width = Width, - height = Height, - content = array:from_list(generate(0, [], Width, Height, Width)) - }. diff --git a/src/type/character.erl b/src/type/character.erl deleted file mode 100644 index 03906e3..0000000 --- a/src/type/character.erl +++ /dev/null @@ -1,54 +0,0 @@ --module(character). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - character, - { - id, - name, - icon, - portrait, - attributes, - weapons, - glyphs, - armors - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_id/1, - get_name/1, - get_icon/1, - get_portrait/1, - get_attributes/1, - get_weapons/1, - get_armors/1, - get_glyphs/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors -get_id (Char) -> Char#character.id. -get_name (Char) -> Char#character.name. -get_icon (Char) -> Char#character.icon. -get_portrait (Char) -> Char#character.portrait. -get_attributes (Char) -> Char#character.attributes. -get_weapons (Char) -> Char#character.weapons. -get_armors (Char) -> Char#character.armors. -get_glyphs (Char) -> Char#character.glyphs. diff --git a/src/type/character_instance.erl b/src/type/character_instance.erl deleted file mode 100644 index 63045a7..0000000 --- a/src/type/character_instance.erl +++ /dev/null @@ -1,126 +0,0 @@ --module(character_instance). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - character_instance, - { - x, - y, - health, - team, - active_wp, - stats - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_location/1, - get_current_health/1, - get_owner/1, - get_active_weapon/2, - get_statistics/1, - set_location/3, - mod_health/3 - ] -). - -%%%% Utils --export -( - [ - new_instance_of/3, - switch_weapon/2, - is_dead/1 % is_alive is reserved. - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -get_new_weapon(CharInst, Char) -> - case CharInst#character_instance.active_wp of - 0 -> - {_, Weapon} = character:get_weapons(Char), - {1, Weapon}; - - 1 -> - {Weapon, _} = character:get_weapons(Char), - {0, Weapon} - end. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors -get_location (CharInst) -> - {CharInst#character_instance.x, CharInst#character_instance.y}. - -get_current_health (CharInst) -> CharInst#character_instance.health. - -get_owner (CharInst) -> CharInst#character_instance.team. - -get_active_weapon (CharInst, Char) -> - case CharInst#character_instance.active_wp of - 0 -> - {_, Weapon} = character:get_weapons(Char), - Weapon; - - 1 -> - {Weapon, _} = character:get_weapons(Char), - Weapon - end. - -get_statistics (CharInst) -> CharInst#character_instance.stats. - -set_location (CharInst, X, Y) -> - CharInst#character_instance - { - x = X, - y = Y - }. - -mod_health (CharInst, MaxHealth, HealthMod) -> - NewHealth = (CharInst#character_instance.health + HealthMod), - if - (NewHealth < 0) -> - CharInst#character_instance{ health = 0 }; - - (NewHealth > MaxHealth) -> - CharInst#character_instance{ health = MaxHealth }; - - true -> - CharInst#character_instance{ health = NewHealth } - end. - -%%%% Utils -new_instance_of (Char, Owner, {X, Y}) -> - {Weapon, _} = character:get_weapons(Char), - Stats = statistics:calc_for(character:get_attributes(Char), Weapon), - #character_instance - { - x = X, - y = Y, - health = statistics:get_health(Stats), - team = Owner, - stats = Stats, - active_wp = 0 - }. - -switch_weapon (CharInst, Char) -> - {NewWpIndex, Weapon} = get_new_weapon(CharInst, Char), - CharInst#character_instance - { - active_wp = NewWpIndex, - stats = statistics:calc_for(character:get_attributes(Char), Weapon) - }. - -is_dead (CharInst) -> (CharInst#character_instance.health == 0). diff --git a/src/type/character_shim.erl b/src/type/character_shim.erl deleted file mode 100644 index 35a0753..0000000 --- a/src/type/character_shim.erl +++ /dev/null @@ -1,57 +0,0 @@ --module(character_shim). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - character, - { - id, - name, - icon, - portrait, - attributes, - weapons, - glyphs, - armors - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - generate_random/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -generate_char (N) -> - IDAsString = list_to_binary(integer_to_list(N)), - #character - { - id = IDAsString, % ID - name = IDAsString, % Name - icon = IDAsString, % Icon - portrait = IDAsString, % Portrait - attributes = attributes_shim:rand(), - weapons = {weapon_shim:rand(), weapon_shim:rand()}, - glyphs = [], - armors = [] - }. - -generate (0, Result) -> - Result; -generate (N, Prev) -> - generate((N - 1), [generate_char(N - 1)|Prev]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -generate_random (N) -> - generate(N, []). diff --git a/src/type/glyph.erl b/src/type/glyph.erl deleted file mode 100644 index 18d8455..0000000 --- a/src/type/glyph.erl +++ /dev/null @@ -1,45 +0,0 @@ --module(glyph). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - glyph, - { - id, - name, - icon, - pos_attrib_mods, - neg_attrib_mods - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_id/1, - get_name/1, - get_icon/1, - get_pos_attrib_mods/1, - get_neg_attrib_mods/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors -get_id (Gh) -> Gh#glyph.id. -get_name (Gh) -> Gh#glyph.name. -get_icon (Gh) -> Gh#glyph.icon. -get_pos_attrib_mods (Gh) -> Gh#glyph.pos_attrib_mods. -get_neg_attrib_mods (Gh) -> Gh#glyph.neg_attrib_mods. diff --git a/src/type/statistics.erl b/src/type/statistics.erl deleted file mode 100644 index 0668fea..0000000 --- a/src/type/statistics.erl +++ /dev/null @@ -1,157 +0,0 @@ --module(statistics). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - statistics, - { - movement_points, - health, - dodges, - parries, - damage_min, - damage_max, - accuracy, - double_hits, - critical_hits - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_movement_points/1, - get_health/1, - get_dodges/1, - get_parries/1, - get_damage_min/1, - get_damage_max/1, - get_accuracy/1, - get_double_hits/1, - get_critical_hits/1 - ] -). - --export -( - [ - calc_for/2 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -ceil (F) -> - I = trunc(F), - case (F > I) of - true -> (I + 1); - _ -> I - end. - -float_to_int (F) -> trunc(ceil(F)). -min_max (Min, Max, V) -> min(Max, max(Min, V)). - -average ([]) -> 0; -average (L) -> lists:sum(L) / length(L). - -% V | 010 | 030 | 050 | 070 | 100 | -% F | 004 | 023 | 058 | 104 | 200 | -gentle_squared_growth (V) -> float_to_int(math:pow(V, 1.8) / 20). - -% V | 010 | 030 | 050 | 070 | 100 | -% F | 001 | 005 | 018 | 041 | 100 | -sudden_squared_growth (V) -> float_to_int(math:pow(V, 2.5) / 1000). - -% V | 010 | 030 | 050 | 070 | 100 | -% F | 002 | 006 | 016 | 049 | 256 | -sudden_exp_growth (V) -> float_to_int(math:pow(4, V / 25)). - -% V | 010 | 030 | 050 | 070 | 100 | -% F | 040 | 066 | 079 | 088 | 099 | -% Seems too generous, values for attributes below 50 should dip faster and -% lower. -already_high_slow_growth (V) -> float_to_int(30 * math:log((V + 5)/4)). -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors -get_movement_points (Stats) -> Stats#statistics.movement_points. -get_health (Stats) -> Stats#statistics.health. -get_dodges (Stats) -> Stats#statistics.dodges. -get_parries (Stats) -> Stats#statistics.parries. -get_damage_min (Stats) -> Stats#statistics.damage_min. -get_damage_max (Stats) -> Stats#statistics.damage_max. -get_accuracy (Stats) -> Stats#statistics.accuracy. -get_double_hits (Stats) -> Stats#statistics.double_hits. -get_critical_hits (Stats) -> Stats#statistics.critical_hits. - -calc_for (Att, _Wp) -> - #statistics - { - movement_points = gentle_squared_growth(attributes:get_speed(Att)), - health = gentle_squared_growth(attributes:get_constitution(Att)), - dodges = - min_max - ( - 0, - 100, - sudden_exp_growth - ( - average - ( - [ - attributes:get_dexterity(Att), - attributes:get_mind(Att), - attributes:get_speed(Att) - ] - ) - ) - ), - parries = - min_max - ( - 0, - 75, - sudden_exp_growth - ( - average - ( - [ - attributes:get_dexterity(Att), - attributes:get_speed(Att), - attributes:get_strength(Att) - ] - ) - ) - ), - damage_min = 0, - damage_max = 100, - accuracy = - % Hitting should involve this stat (not with this formula though), but - % also the target's dodge stat, with three possible results: - % - Missed - % - Grazed (Halved damage) - % - Hit - % Stat = (target.dodge - char.accuracy) - % Roll = RAND(0, 100) - % if (Roll >= (Stat * 2)): Hit - % else if (Roll >= Stat): Grazed - % else: Missed. - min_max - ( - 0, - 100, - sudden_squared_growth(attributes:get_dexterity(Att)) - ), - double_hits = - min_max(0, 100, sudden_squared_growth(attributes:get_speed(Att))), - critical_hits = - min_max(0, 100, sudden_squared_growth(attributes:get_intelligence(Att))) - }. diff --git a/src/type/weapon.erl b/src/type/weapon.erl deleted file mode 100644 index add445a..0000000 --- a/src/type/weapon.erl +++ /dev/null @@ -1,287 +0,0 @@ --module(weapon). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - weapon, - { - id, - name, - range_type, - range_mod, - damage_type, - damage_mod - } -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( - [ - get_id/1 - ] -). - --export -( - [ - from_id/1, - get_ranges/1, - get_damages/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -ranges_of_type (ranged, long) -> {2, 6}; -ranges_of_type (ranged, short) -> {1, 4}; -ranges_of_type (melee, long) -> {0, 2}; -ranges_of_type (melee, short) -> {0, 1}. - -damages_of_type (ranged, heavy) -> {10, 25}; -damages_of_type (ranged, light) -> {5, 20}; -damages_of_type (melee, heavy) -> {20, 35}; -damages_of_type (melee, light) -> {15, 30}. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors -get_id (Wp) -> Wp#weapon.id. - -get_ranges (Wp) -> - ranges_of_type(Wp#weapon.range_type, Wp#weapon.range_mod). -get_damages (Wp) -> - damages_of_type(Wp#weapon.range_type, Wp#weapon.damage_mod). - -from_id (0) -> - #weapon{ - id = 0, - name = "None", - range_type = melee, - range_mod = short, - damage_type = blunt, - damage_mod = light - }; -from_id (1) -> - #weapon{ - id = 1, - name = "Dagger", - range_type = melee, - range_mod = short, - damage_type = slash, - damage_mod = light - }; -from_id (2) -> - #weapon{ - id = 2, - name = "Sword", - range_type = melee, - range_mod = short, - damage_type = slash, - damage_mod = heavy - }; -from_id (3) -> - #weapon{ - id = 3, - name = "Claymore", - range_type = melee, - range_mod = long, - damage_type = slash, - damage_mod = light - }; -from_id (4) -> - #weapon{ - id = 4, - name = "Bardiche", - range_type = melee, - range_mod = long, - damage_type = slash, - damage_mod = heavy - }; -from_id (5) -> - #weapon{ - id = 5, - name = "Stiletto", - range_type = melee, - range_mod = short, - damage_type = pierce, - damage_mod = light - }; -from_id (6) -> - #weapon{ - id = 6, - name = "Pickaxe", - range_type = melee, - range_mod = short, - damage_type = pierce, - damage_mod = heavy - }; -from_id (7) -> - #weapon{ - id = 7, - name = "Rapier", - range_type = melee, - range_mod = long, - damage_type = pierce, - damage_mod = light - }; -from_id (8) -> - #weapon{ - id = 8, - name = "Pike", - range_type = melee, - range_mod = long, - damage_type = pierce, - damage_mod = heavy - }; -from_id (9) -> - #weapon{ - id = 9, - name = "Club", - range_type = melee, - range_mod = short, - damage_type = blunt, - damage_mod = light - }; -from_id (10) -> - #weapon{ - id = 10, - name = "Mace", - range_type = melee, - range_mod = short, - damage_type = blunt, - damage_mod = heavy - }; -from_id (11) -> - #weapon{ - id = 11, - name = "Staff", - range_type = melee, - range_mod = long, - damage_type = blunt, - damage_mod = light - }; -from_id (12) -> - #weapon{ - id = 12, - name = "War Hammer", - range_type = melee, - range_mod = long, - damage_type = blunt, - damage_mod = heavy - }; -from_id (13) -> - #weapon{ - id = 13, - name = "Short Bow (Broadhead)", - range_type = ranged, - range_mod = short, - damage_type = slash, - damage_mod = light - }; -from_id (14) -> - #weapon{ - id = 14, - name = "Short Bow (Blunt)", - range_type = ranged, - range_mod = short, - damage_type = blunt, - damage_mod = light - }; -from_id (15) -> - #weapon{ - id = 15, - name = "Short Bow (Bodkin Point)", - range_type = ranged, - range_mod = short, - damage_type = pierce, - damage_mod = light - }; -from_id (16) -> - #weapon{ - id = 16, - name = "Long Bow (Broadhead)", - range_type = ranged, - range_mod = long, - damage_type = slash, - damage_mod = light - }; -from_id (17) -> - #weapon{ - id = 17, - name = "Long Bow (Blunt)", - range_type = ranged, - range_mod = long, - damage_type = blunt, - damage_mod = light - }; -from_id (18) -> - #weapon{ - id = 18, - name = "Long Bow (Bodkin Point)", - range_type = ranged, - range_mod = long, - damage_type = pierce, - damage_mod = light - }; -from_id (19) -> - #weapon{ - id = 19, - name = "Crossbow (Broadhead)", - range_type = ranged, - range_mod = short, - damage_type = slash, - damage_mod = heavy - }; -from_id (20) -> - #weapon{ - id = 20, - name = "Crossbow (Blunt)", - range_type = ranged, - range_mod = short, - damage_type = blunt, - damage_mod = heavy - }; -from_id (21) -> - #weapon{ - id = 21, - name = "Crossbow (Bodkin Point)", - range_type = ranged, - range_mod = short, - damage_type = pierce, - damage_mod = heavy - }; -from_id (22) -> - #weapon{ - id = 22, - name = "Arbalest (Broadhead)", - range_type = ranged, - range_mod = long, - damage_type = slash, - damage_mod = heavy - }; -from_id (23) -> - #weapon{ - id = 23, - name = "Arbalest (Blunt)", - range_type = ranged, - range_mod = long, - damage_type = blunt, - damage_mod = heavy - }; -from_id (24) -> - #weapon{ - id = 24, - name = "Arbalest (Bodkin Point)", - range_type = ranged, - range_mod = long, - damage_type = pierce, - damage_mod = heavy - }. diff --git a/src/type/weapon_shim.erl b/src/type/weapon_shim.erl deleted file mode 100644 index e0364f0..0000000 --- a/src/type/weapon_shim.erl +++ /dev/null @@ -1,24 +0,0 @@ --module(weapon_shim). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - rand/0 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -rand() -> (rand:uniform(25) - 1). -- cgit v1.2.3-70-g09d2