| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-07-11 18:02:26 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-07-11 18:02:26 +0200 | 
| commit | acb9dd3220a3edcac93aa11d1d74d008e2fb23ed (patch) | |
| tree | 98b45af3f7eb9c7d812ed33a07e6a0f665a7a8cd | |
| parent | fde827cba1ff3d889135c74ee1978098465fd200 (diff) | |
"sh_" -> "shr_".
31 files changed, 234 insertions, 234 deletions
| diff --git a/src/battle/btl_handler.erl b/src/battle/btl_handler.erl index 19b0e20..a7e5ca0 100644 --- a/src/battle/btl_handler.erl +++ b/src/battle/btl_handler.erl @@ -18,10 +18,10 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -spec start (pid()) -> 'ok'.  start (TimedCachesManagerPid) -> -   case sh_database:fetch(battle_db, <<"0">>) of +   case shr_database:fetch(battle_db, <<"0">>) of        {ok, _} -> ok;        not_found -> -         sh_database:insert +         shr_database:insert           (              battle_db,              <<"0">>, @@ -29,5 +29,5 @@ start (TimedCachesManagerPid) ->              btl_shim:generate_random_battle()           )     end, -   sh_timed_caches_manager:new_cache(TimedCachesManagerPid, battle_db, none), +   shr_timed_caches_manager:new_cache(TimedCachesManagerPid, battle_db, none),     ok. diff --git a/src/battle/btl_shim.erl b/src/battle/btl_shim.erl index 07d5854..fddc2f6 100644 --- a/src/battle/btl_shim.erl +++ b/src/battle/btl_shim.erl @@ -132,8 +132,8 @@ demo_map () ->  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -spec generate_random_battle () -> btl_battle:type().  generate_random_battle () -> -   %BattlemapWidth = 32, % sh_roll:between(16, 32), -   %BattlemapHeight = 32, %sh_roll:between(16, 32), +   %BattlemapWidth = 32, % shr_roll:between(16, 32), +   %BattlemapHeight = 32, %shr_roll:between(16, 32),     %Battlemap = btl_battlemap:random(0, BattlemapWidth, BattlemapHeight),     Battlemap = btl_battlemap:from_list(0, 32, 32, demo_map()),     Characters = generate_random_characters(1, 8, 8, 0, Battlemap, [], []), diff --git a/src/battle/game-logic/btl_next_turn.erl b/src/battle/game-logic/btl_next_turn.erl index 82eec98..9ed4926 100644 --- a/src/battle/game-logic/btl_next_turn.erl +++ b/src/battle/game-logic/btl_next_turn.erl @@ -17,7 +17,7 @@  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -spec set_player_turn_to_next (btl_battle:type()) -   -> {btl_battle:type(), sh_db_query:op()}. +   -> {btl_battle:type(), shr_db_query:op()}.  set_player_turn_to_next (Battle) ->     Players = btl_battle:get_players(Battle),     CurrentPlayerTurn = btl_battle:get_current_player_turn(Battle), @@ -27,7 +27,7 @@ set_player_turn_to_next (Battle) ->     UpdatedBattle = btl_battle:set_current_player_turn(NextPlayerTurn, Battle),     DBQuery = -      sh_db_query:set_field +      shr_db_query:set_field        (           btl_battle:get_current_player_turn_field(),           NextPlayerTurn @@ -36,7 +36,7 @@ set_player_turn_to_next (Battle) ->     {UpdatedBattle, DBQuery}.  -spec reset_next_player_timeline (btl_battle:type()) -   -> {btl_battle:type(), btl_player:type(), sh_db_query:op()}. +   -> {btl_battle:type(), btl_player:type(), shr_db_query:op()}.  reset_next_player_timeline (Battle) ->     NextPlayerTurn = btl_battle:get_current_player_turn(Battle),     NextPlayerIX = btl_player_turn:get_player_ix(NextPlayerTurn), @@ -47,24 +47,24 @@ reset_next_player_timeline (Battle) ->        btl_battle:set_player(NextPlayerIX, UpdatedNextPlayer, Battle),     DBQuery = -      sh_db_query:update_indexed +      shr_db_query:update_indexed        (           btl_battle:get_players_field(),           NextPlayerIX, -         [ sh_db_query:set_field(btl_player:get_timeline_field(), []) ] +         [ shr_db_query:set_field(btl_player:get_timeline_field(), []) ]        ),     {UpdatedBattle, UpdatedNextPlayer, DBQuery}.  -spec activate_next_players_characters (btl_battle:type(), btl_player:type()) -   -> {btl_battle:type(), list(sh_db_query:op())}. +   -> {btl_battle:type(), list(shr_db_query:op())}.  activate_next_players_characters (Battle, NextPlayer) ->     NextPlayerIX = btl_player:get_index(NextPlayer),     Characters = btl_battle:get_characters(Battle),     {UpdatedCharacters, ModifiedIXs} = -      sh_array_util:mapiff +      shr_array_util:mapiff        (           fun (Character) ->              (btl_character:get_player_index(Character) == NextPlayerIX) @@ -79,12 +79,12 @@ activate_next_players_characters (Battle, NextPlayer) ->        lists:map        (           fun (IX) -> -            sh_db_query:update_indexed +            shr_db_query:update_indexed              (                 btl_battle:get_characters_field(),                 IX,                 [ -                  sh_db_query:set_field +                  shr_db_query:set_field                    (                       btl_character:get_is_active_field(),                       true @@ -143,7 +143,7 @@ requires_update (Update) ->     Battle = btl_character_turn_data:get_battle(Data),     Characters = btl_battle:get_characters(Battle), -   sh_array_util:none(fun btl_character:get_is_active/1, Characters). +   shr_array_util:none(fun btl_character:get_is_active/1, Characters).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/battle/game-logic/btl_turn_actions.erl b/src/battle/game-logic/btl_turn_actions.erl index 21205ac..e7153f9 100644 --- a/src/battle/game-logic/btl_turn_actions.erl +++ b/src/battle/game-logic/btl_turn_actions.erl @@ -33,7 +33,7 @@ handle_switch_weapon (Update) ->     UpdatedWeaponIDs = {SecondaryWeaponID, PrimaryWeaponID},     UpdatedCharacterStatistics = -      sh_statistics:new(CharacterAttributes, UpdatedWeaponIDs, ArmorID), +      shr_statistics:new(CharacterAttributes, UpdatedWeaponIDs, ArmorID),     UpdatedCharacter =        btl_character:set_statistics        ( @@ -44,17 +44,17 @@ handle_switch_weapon (Update) ->     TimelineItem = btl_turn_result:new_character_switched_weapons(CharacterIX),     DBQuery = -      sh_db_query:update_indexed +      shr_db_query:update_indexed        (           btl_battle:get_characters_field(),           CharacterIX,           [ -            sh_db_query:set_field +            shr_db_query:set_field              (                 btl_character:get_weapons_field(),                 UpdatedWeaponIDs              ), -            sh_db_query:set_field +            shr_db_query:set_field              (                 btl_character:get_statistics_field(),                 UpdatedCharacterStatistics @@ -117,7 +117,7 @@ assert_character_can_move (Data, Cost) ->     Character = btl_character_turn_data:get_character(Data),     CharacterStatistics = btl_character:get_statistics(Character),     CharacterMovementPoints = -      sh_statistics:get_movement_points(CharacterStatistics), +      shr_statistics:get_movement_points(CharacterStatistics),     true = (Cost =< CharacterMovementPoints), @@ -143,12 +143,12 @@ commit_move (Update, Path, NewLocation) ->        btl_turn_result:new_character_moved(CharacterIX, Path, NewLocation),     DBQuery = -      sh_db_query:update_indexed +      shr_db_query:update_indexed        (           btl_battle:get_characters_field(),           CharacterIX,           [ -            sh_db_query:set_field +            shr_db_query:set_field              (                 btl_character:get_location_field(),                 NewLocation @@ -258,8 +258,8 @@ get_attack_sequence (Character, TargetCharacter) ->     {AttackingWeaponID, _} = btl_character:get_weapon_ids(Character),     {DefendingWeaponID, _} = btl_character:get_weapon_ids(TargetCharacter), -   AttackingWeapon = sh_weapon:from_id(AttackingWeaponID), -   DefendingWeapon = sh_weapon:from_id(DefendingWeaponID), +   AttackingWeapon = shr_weapon:from_id(AttackingWeaponID), +   DefendingWeapon = shr_weapon:from_id(DefendingWeaponID),     btl_attack:get_sequence(Range, AttackingWeapon, DefendingWeapon). @@ -312,12 +312,12 @@ handle_attack (BattleAction, Update) ->        ),     DBQuery0 = -      sh_db_query:update_indexed +      shr_db_query:update_indexed        (           btl_battle:get_characters_field(),           TargetIX,           [ -            sh_db_query:set_field +            shr_db_query:set_field              (                 btl_character:get_current_health_field(),                 RemainingDefenderHealth @@ -326,12 +326,12 @@ handle_attack (BattleAction, Update) ->        ),     DBQuery1 = -      sh_db_query:update_indexed +      shr_db_query:update_indexed        (           btl_battle:get_characters_field(),           CharacterIX,           [ -            sh_db_query:set_field +            shr_db_query:set_field              (                 btl_character:get_current_health_field(),                 RemainingAttackerHealth diff --git a/src/battle/game-logic/btl_victory.erl b/src/battle/game-logic/btl_victory.erl index eef42ad..5611302 100644 --- a/src/battle/game-logic/btl_victory.erl +++ b/src/battle/game-logic/btl_victory.erl @@ -23,7 +23,7 @@        array:array(btl_character:type())     ) -> {array:array(btl_character:type()), list(non_neg_integer())}.  mark_players_characters_as_defeated (PlayerIX, Characters) -> -   sh_array_util:mapiff +   shr_array_util:mapiff     (        fun (Character) ->           (btl_character:get_player_index(Character) == PlayerIX) @@ -43,12 +43,12 @@ mark_players_characters_as_defeated (PlayerIX, Characters) ->  add_db_query_to_mark_character_as_defeated (IX, Update) ->     btl_character_turn_update:add_to_db     ( -      sh_db_query:update_indexed +      shr_db_query:update_indexed        (           btl_battle:get_characters_field(),           IX,           [ -            sh_db_query:set_field +            shr_db_query:set_field              (                 btl_character:get_is_defeated_field(),                 true @@ -88,12 +88,12 @@ handle_player_defeat (PlayerIX, Update) ->     S2Update = btl_character_turn_update:set_data(UpdatedData, S1Update),     DBQuery = -      sh_db_query:update_indexed +      shr_db_query:update_indexed        (           btl_battle:get_players_field(),           PlayerIX,           [ -            sh_db_query:set_field +            shr_db_query:set_field              (                 btl_player:get_is_active_field(),                 false @@ -129,7 +129,7 @@ actually_handle_character_lost_health (CharIX, Update) ->        optional ->           %% Let's not assume there is a commander           StillHasAliveChar = -            sh_array_util:any_indexed +            shr_array_util:any_indexed              (                 fun (IX, Char) ->                    ( @@ -150,7 +150,7 @@ actually_handle_character_lost_health (CharIX, Update) ->        target ->           StillHasAliveChar = -            sh_array_util:any_indexed +            shr_array_util:any_indexed              (                 fun (IX, Char) ->                    ( @@ -188,7 +188,7 @@ handle_character_lost_health (CharIX, _Health, Update) ->     S2Update = actually_handle_character_lost_health(CharIX, S1Update),     S2Data = btl_character_turn_update:get_data(S2Update), -   S3Data = btl_character_turn_data:refresh_character(S2Data), +   S3Data = btl_character_turn_data:refreshr_character(S2Data),     S3Update = btl_character_turn_update:set_data(S3Data, S2Update),     S3Update. diff --git a/src/battle/query/btl_character_turn.erl b/src/battle/query/btl_character_turn.erl index c232ab0..ed6ca86 100644 --- a/src/battle/query/btl_character_turn.erl +++ b/src/battle/query/btl_character_turn.erl @@ -45,7 +45,7 @@ fetch_data (Request) ->     PlayerID = btl_character_turn_request:get_player_id(Request),     BattleID = btl_character_turn_request:get_battle_id(Request),     CharacterIX = btl_character_turn_request:get_character_ix(Request), -   Battle = sh_timed_cache:fetch(battle_db, PlayerID, BattleID), +   Battle = shr_timed_cache:fetch(battle_db, PlayerID, BattleID),     btl_character_turn_data:new(Battle, CharacterIX). @@ -119,11 +119,11 @@ finalize_character (Update) ->     FinalizedData = btl_character_turn_data:clean_battle(UpdatedData),     DBQuery = -      sh_db_query:update_indexed +      shr_db_query:update_indexed        (           btl_battle:get_characters_field(),           btl_character_turn_data:get_character_ix(Data), -         [ sh_db_query:set_field(btl_character:get_is_active_field(), false) ] +         [ shr_db_query:set_field(btl_character:get_is_active_field(), false) ]        ),     S0Update = btl_character_turn_update:set_data(FinalizedData, Update), @@ -164,12 +164,12 @@ update_timeline (Update) ->     UpdatedData = btl_character_turn_data:set_battle(UpdatedBattle, Data),     DBQuery = -      sh_db_query:update_indexed +      shr_db_query:update_indexed        (           btl_battle:get_players_field(),           PlayerIX,           [ -            sh_db_query:add_to_field +            shr_db_query:add_to_field              (                 btl_player:get_timeline_field(),                 NewTimelineElements, @@ -207,9 +207,9 @@ send_to_database (Update, Request) ->     PlayerID = btl_character_turn_request:get_player_id(Request),     BattleID = btl_character_turn_request:get_battle_id(Request),     Ops = btl_character_turn_update:get_db(Update), -   Query = sh_db_query:new(battle_db, BattleID, {user, PlayerID}, Ops), +   Query = shr_db_query:new(battle_db, BattleID, {user, PlayerID}, Ops), -   sh_database:commit(Query), +   shr_database:commit(Query),     ok. @@ -225,7 +225,7 @@ send_to_cache (Update, Request) ->     Data = btl_character_turn_update:get_data(Update),     Battle = btl_character_turn_data:get_battle(Data), -   sh_timed_cache:update(battle_db, PlayerID, BattleID, Battle), +   shr_timed_cache:update(battle_db, PlayerID, BattleID, Battle),     ok. diff --git a/src/battle/query/btl_load_state.erl b/src/battle/query/btl_load_state.erl index f79e24e..2026222 100644 --- a/src/battle/query/btl_load_state.erl +++ b/src/battle/query/btl_load_state.erl @@ -53,7 +53,7 @@ fetch_data (Input) ->     PlayerID = Input#input.player_id,     BattleID = Input#input.battle_id, -   Battle = sh_timed_cache:fetch(battle_db, PlayerID, BattleID), +   Battle = shr_timed_cache:fetch(battle_db, PlayerID, BattleID),     #query_state     { @@ -67,7 +67,7 @@ generate_reply (QueryState, Input) ->     Players = btl_battle:get_players(Battle),     PlayerIX = -      sh_array_util:first +      shr_array_util:first        (           fun (Player) ->              (btl_player:get_id(Player) == PlayerID) @@ -101,7 +101,7 @@ generate_reply (QueryState, Input) ->        lists:map        (           fun (WeaponID) -> -            btl_add_weapon:generate(sh_weapon:from_id(WeaponID)) +            btl_add_weapon:generate(shr_weapon:from_id(WeaponID))           end,           btl_battle:get_used_weapon_ids(Battle)        ), @@ -110,7 +110,7 @@ generate_reply (QueryState, Input) ->        lists:map        (           fun (ArmorID) -> -            btl_add_armor:generate(sh_armor:from_id(ArmorID)) +            btl_add_armor:generate(shr_armor:from_id(ArmorID))           end,           btl_battle:get_used_armor_ids(Battle)        ), diff --git a/src/battle/reply/btl_add_armor.erl b/src/battle/reply/btl_add_armor.erl index 2c6a875..01c99ad 100644 --- a/src/battle/reply/btl_add_armor.erl +++ b/src/battle/reply/btl_add_armor.erl @@ -12,7 +12,7 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec encode_category (sh_armor:category()) -> binary(). +-spec encode_category (shr_armor:category()) -> binary().  encode_category (kinetic) -> <<"k">>;  encode_category (leather) -> <<"l">>;  encode_category (chain) -> <<"c">>; @@ -21,14 +21,14 @@ encode_category (plate) -> <<"p">>.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec generate (sh_armor:type()) -> {list(any())}. +-spec generate (shr_armor:type()) -> {list(any())}.  generate (Armor) ->     {        [           {<<"msg">>, <<"add_armor">>}, -         {<<"id">>, sh_armor:get_id(Armor)}, -         {<<"nam">>, sh_armor:get_name(Armor)}, -         {<<"ct">>, encode_category(sh_armor:get_category(Armor))}, -         {<<"cf">>, sh_armor:get_coefficient(Armor)} +         {<<"id">>, shr_armor:get_id(Armor)}, +         {<<"nam">>, shr_armor:get_name(Armor)}, +         {<<"ct">>, encode_category(shr_armor:get_category(Armor))}, +         {<<"cf">>, shr_armor:get_coefficient(Armor)}        ]     }. diff --git a/src/battle/reply/btl_add_char.erl b/src/battle/reply/btl_add_char.erl index 75b6fcd..f0b70e9 100644 --- a/src/battle/reply/btl_add_char.erl +++ b/src/battle/reply/btl_add_char.erl @@ -22,18 +22,18 @@ rank_to_string (Rank) ->  -spec attributes_as_json     ( -      sh_attributes:type() +      shr_attributes:type()     ) ->     {list({binary(), non_neg_integer()})}.  attributes_as_json (Attributes) ->     {        [ -         {<<"con">>, sh_attributes:get_constitution(Attributes)}, -         {<<"dex">>, sh_attributes:get_dexterity(Attributes)}, -         {<<"int">>, sh_attributes:get_intelligence(Attributes)}, -         {<<"min">>, sh_attributes:get_mind(Attributes)}, -         {<<"spe">>, sh_attributes:get_speed(Attributes)}, -         {<<"str">>, sh_attributes:get_strength(Attributes)} +         {<<"con">>, shr_attributes:get_constitution(Attributes)}, +         {<<"dex">>, shr_attributes:get_dexterity(Attributes)}, +         {<<"int">>, shr_attributes:get_intelligence(Attributes)}, +         {<<"min">>, shr_attributes:get_mind(Attributes)}, +         {<<"spe">>, shr_attributes:get_speed(Attributes)}, +         {<<"str">>, shr_attributes:get_strength(Attributes)}        ]     }. diff --git a/src/battle/reply/btl_add_weapon.erl b/src/battle/reply/btl_add_weapon.erl index d4edbef..5484a76 100644 --- a/src/battle/reply/btl_add_weapon.erl +++ b/src/battle/reply/btl_add_weapon.erl @@ -12,43 +12,43 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec encode_range_type (sh_weapon:range_type()) -> binary(). +-spec encode_range_type (shr_weapon:range_type()) -> binary().  encode_range_type (melee) -> <<"m">>;  encode_range_type (ranged) -> <<"r">>. --spec encode_range_modifier (sh_weapon:range_modifier()) -> binary(). +-spec encode_range_modifier (shr_weapon:range_modifier()) -> binary().  encode_range_modifier (long) -> <<"l">>;  encode_range_modifier (short) -> <<"s">>. --spec encode_damage_type (sh_weapon:damage_type()) -> binary(). +-spec encode_damage_type (shr_weapon:damage_type()) -> binary().  encode_damage_type (slash) -> <<"s">>;  encode_damage_type (pierce) -> <<"p">>;  encode_damage_type (blunt) -> <<"b">>. --spec encode_damage_modifier (sh_weapon:damage_modifier()) -> binary(). +-spec encode_damage_modifier (shr_weapon:damage_modifier()) -> binary().  encode_damage_modifier (heavy) -> <<"h">>;  encode_damage_modifier (light) -> <<"l">>.  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec generate (sh_weapon:type()) -> {list(any())}. +-spec generate (shr_weapon:type()) -> {list(any())}.  generate (Weapon) ->     {        [           {<<"msg">>, <<"add_weapon">>}, -         {<<"id">>, sh_weapon:get_id(Weapon)}, -         {<<"nam">>, sh_weapon:get_name(Weapon)}, -         {<<"rt">>, encode_range_type(sh_weapon:get_range_type(Weapon))}, +         {<<"id">>, shr_weapon:get_id(Weapon)}, +         {<<"nam">>, shr_weapon:get_name(Weapon)}, +         {<<"rt">>, encode_range_type(shr_weapon:get_range_type(Weapon))},           {              <<"rm">>, -            encode_range_modifier(sh_weapon:get_range_modifier(Weapon)) +            encode_range_modifier(shr_weapon:get_range_modifier(Weapon))           }, -         {<<"dt">>, encode_damage_type(sh_weapon:get_damage_type(Weapon))}, +         {<<"dt">>, encode_damage_type(shr_weapon:get_damage_type(Weapon))},           {              <<"dm">>, -            encode_damage_modifier(sh_weapon:get_damage_modifier(Weapon)) +            encode_damage_modifier(shr_weapon:get_damage_modifier(Weapon))           }, -         {<<"cf">>, sh_weapon:get_coefficient(Weapon)} +         {<<"cf">>, shr_weapon:get_coefficient(Weapon)}        ]     }. diff --git a/src/battle/struct/btl_attack.erl b/src/battle/struct/btl_attack.erl index aa7659f..fae8341 100644 --- a/src/battle/struct/btl_attack.erl +++ b/src/battle/struct/btl_attack.erl @@ -47,15 +47,15 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -spec roll_precision     ( -      sh_statistics:type(), -      sh_statistics:type() +      shr_statistics:type(), +      shr_statistics:type()     )     -> precision().  roll_precision (AttackerStatistics, DefenderStatistics) -> -   DefenderDodges = sh_statistics:get_dodges(DefenderStatistics), -   AttackerAccuracy = sh_statistics:get_accuracy(AttackerStatistics), +   DefenderDodges = shr_statistics:get_dodges(DefenderStatistics), +   AttackerAccuracy = shr_statistics:get_accuracy(AttackerStatistics),     MissChance = max(0, (DefenderDodges - AttackerAccuracy)), -   case sh_roll:percentage() of +   case shr_roll:percentage() of        X when (X =< MissChance) -> misses;        X when (X =< (MissChance * 2)) -> grazes;        _ -> hits @@ -63,25 +63,25 @@ roll_precision (AttackerStatistics, DefenderStatistics) ->  -spec roll_damage     ( -      sh_statistics:type(), -      sh_statistics:type() +      shr_statistics:type(), +      shr_statistics:type()     )     -> {non_neg_integer(), boolean()}.  roll_damage (AttackerStatistics, _DefenderStatistics) ->     {MinimumDamage, MaximumDamage} = -      sh_statistics:get_damages(AttackerStatistics), +      shr_statistics:get_damages(AttackerStatistics),     MaximumRoll = max(1, MaximumDamage - MinimumDamage),     BaseDamage = MinimumDamage + (rand:uniform(MaximumRoll) - 1), -   CriticalHitChance = sh_statistics:get_critical_hits(AttackerStatistics), -   case sh_roll:percentage() of +   CriticalHitChance = shr_statistics:get_critical_hits(AttackerStatistics), +   case shr_roll:percentage() of        X when (X =< CriticalHitChance) -> {(BaseDamage * 2), true};        _ -> {BaseDamage, false}     end. --spec roll_parry (sh_statistics:type()) -> boolean(). +-spec roll_parry (shr_statistics:type()) -> boolean().  roll_parry (DefenderStatistics) -> -   DefenderParryChance = sh_statistics:get_parries(DefenderStatistics), -   (sh_roll:percentage() =< DefenderParryChance). +   DefenderParryChance = shr_statistics:get_parries(DefenderStatistics), +   (shr_roll:percentage() =< DefenderParryChance).  -spec effect_of_attack     ( @@ -108,10 +108,10 @@ effect_of_attack (Order, Attacker, Defender, CanParry) ->           false -> {Attacker, Defender}        end, -   ActualDefArmor = sh_armor:from_id(btl_character:get_armor_id(ActualDefender)), +   ActualDefArmor = shr_armor:from_id(btl_character:get_armor_id(ActualDefender)),     {ActualAtkWeaponID, _} = btl_character:get_weapon_ids(ActualAttacker),     ActualAtkWeaponDmgType = -      sh_weapon:get_damage_type(sh_weapon:from_id(ActualAtkWeaponID)), +      shr_weapon:get_damage_type(shr_weapon:from_id(ActualAtkWeaponID)),     Precision = roll_precision(ActualAtkStatistics, ActualDefStatistics),     {Damage, IsCritical} = roll_damage(ActualAtkStatistics, ActualDefStatistics), @@ -122,7 +122,7 @@ effect_of_attack (Order, Attacker, Defender, CanParry) ->           hits -> Damage        end,     ArmorResistance = -      sh_armor:get_resistance_to(ActualAtkWeaponDmgType, ActualDefArmor), +      shr_armor:get_resistance_to(ActualAtkWeaponDmgType, ActualDefArmor),     ActualDamage = max(0, (S0Damage - ArmorResistance)),     #attack @@ -160,9 +160,9 @@ get_description_of ({first, CanParry}, Attacker, Defender) ->  get_description_of ({second, CanParry}, Attacker, Defender) ->     AttackerStatistics = btl_character:get_statistics(Attacker),     AttackerDoubleAttackChange = -      sh_statistics:get_double_hits(AttackerStatistics), +      shr_statistics:get_double_hits(AttackerStatistics), -   case sh_roll:percentage() of +   case shr_roll:percentage() of        X when (X =< AttackerDoubleAttackChange) ->           effect_of_attack (second, Attacker, Defender, CanParry); @@ -252,28 +252,28 @@ when  -spec get_sequence     (        non_neg_integer(), -      sh_weapon:type(), -      sh_weapon:type() +      shr_weapon:type(), +      shr_weapon:type()     )     -> list(step()).  get_sequence (AttackRange, AttackerWeapon, DefenderWeapon) ->     {AttackerDefenseRange, AttackerAttackRange} = -      sh_weapon:get_ranges(AttackerWeapon), +      shr_weapon:get_ranges(AttackerWeapon),     {DefenderDefenseRange, DefenderAttackRange} = -      sh_weapon:get_ranges(DefenderWeapon), +      shr_weapon:get_ranges(DefenderWeapon),     AttackerCanAttack = (AttackRange =< AttackerAttackRange),     AttackerCanAttack = true,     AttackerCanDefend =        (AttackerCanAttack and (AttackRange > AttackerDefenseRange)),     AttackerCanParry = -      (AttackerCanDefend and sh_weapon:can_parry(AttackerWeapon)), +      (AttackerCanDefend and shr_weapon:can_parry(AttackerWeapon)),     DefenderCanAttack = (AttackRange =< DefenderAttackRange),     DefenderCanDefend =        (DefenderCanAttack and (AttackRange > DefenderDefenseRange)),     DefenderCanParry = -      (DefenderCanDefend and sh_weapon:can_parry(DefenderWeapon)), +      (DefenderCanDefend and shr_weapon:can_parry(DefenderWeapon)),     First = {first, DefenderCanParry},     Second = {second, DefenderCanParry}, diff --git a/src/battle/struct/btl_battle.erl b/src/battle/struct/btl_battle.erl index 8befc4e..dd68b42 100644 --- a/src/battle/struct/btl_battle.erl +++ b/src/battle/struct/btl_battle.erl @@ -10,8 +10,8 @@     battle,     {        id :: id(), -      used_armor_ids :: list(sh_armor:id()), -      used_weapon_ids :: list(sh_weapon:id()), +      used_armor_ids :: list(shr_armor:id()), +      used_weapon_ids :: list(shr_weapon:id()),        used_tile_ids :: list(btl_tile:id()),        battlemap :: btl_battlemap:type(),        characters :: array:array(btl_character:type()), @@ -86,10 +86,10 @@ get_all_timelines (Result, CurrentIndex, EndPoint, ArraySize, Players) ->  -spec get_id (type()) -> id().  get_id (Battle) -> Battle#battle.id. --spec get_used_weapon_ids (type()) -> list(sh_weapon:id()). +-spec get_used_weapon_ids (type()) -> list(shr_weapon:id()).  get_used_weapon_ids (Battle) -> Battle#battle.used_weapon_ids. --spec get_used_armor_ids (type()) -> list(sh_armor:id()). +-spec get_used_armor_ids (type()) -> list(shr_armor:id()).  get_used_armor_ids (Battle) -> Battle#battle.used_armor_ids.  -spec get_used_tile_ids (type()) -> list(btl_tile:id()). @@ -187,8 +187,8 @@ set_current_player_turn (PlayerTurn, Battle) ->        list(btl_player:type()),        btl_battlemap:type(),        list(btl_character:type()), -      list(sh_weapon:id()), -      list(sh_armor:id()), +      list(shr_weapon:id()), +      list(shr_armor:id()),        list(btl_tile:id())     )     -> type(). diff --git a/src/battle/struct/btl_character.erl b/src/battle/struct/btl_character.erl index 841f4ea..d9362ea 100644 --- a/src/battle/struct/btl_character.erl +++ b/src/battle/struct/btl_character.erl @@ -16,10 +16,10 @@        rank :: rank(),        icon :: binary(),        portrait :: binary(), -      attributes :: sh_attributes:type(), -      statistics :: sh_statistics:type(), -      weapon_ids :: {sh_weapon:id(), sh_weapon:id()}, -      armor_id :: sh_armor:id(), +      attributes :: shr_attributes:type(), +      statistics :: shr_statistics:type(), +      weapon_ids :: {shr_weapon:id(), shr_weapon:id()}, +      armor_id :: shr_armor:id(),        location :: {non_neg_integer(), non_neg_integer()},        current_health :: integer(), %% Negative integers let us reverse attacks.        is_active :: boolean(), @@ -90,8 +90,8 @@     )     -> {non_neg_integer(), non_neg_integer()}.  find_random_location (BattlemapWidth, BattlemapHeight, ForbiddenLocations) -> -   X = sh_roll:between(0, (BattlemapWidth - 1)), -   Y = sh_roll:between(0, (BattlemapHeight - 1)), +   X = shr_roll:between(0, (BattlemapWidth - 1)), +   Y = shr_roll:between(0, (BattlemapHeight - 1)),     IsForbidden = lists:member({X, Y}, ForbiddenLocations), @@ -129,16 +129,16 @@ get_icon (Char) -> Char#character.icon.  -spec get_portrait (type()) -> binary().  get_portrait (Char) -> Char#character.portrait. --spec get_attributes (type()) -> sh_attributes:type(). +-spec get_attributes (type()) -> shr_attributes:type().  get_attributes (Char) -> Char#character.attributes. --spec get_armor_id (type()) -> sh_armor:id(). +-spec get_armor_id (type()) -> shr_armor:id().  get_armor_id (Char) -> Char#character.armor_id. --spec get_weapon_ids (type()) -> {sh_weapon:id(), sh_weapon:id()}. +-spec get_weapon_ids (type()) -> {shr_weapon:id(), shr_weapon:id()}.  get_weapon_ids (Char) -> Char#character.weapon_ids. --spec get_statistics (type()) -> sh_statistics:type(). +-spec get_statistics (type()) -> shr_statistics:type().  get_statistics (Char) -> Char#character.statistics.  -spec get_location (type()) -> {non_neg_integer(), non_neg_integer()}. @@ -205,14 +205,14 @@ set_is_defeated (Defeated, Char) ->        is_defeated = Defeated     }. --spec set_armor_id (sh_armor:id(), type()) -> type(). +-spec set_armor_id (shr_armor:id(), type()) -> type().  set_armor_id (ArmorID, Char) ->     Char#character     {        armor_id = ArmorID     }. --spec set_weapon_ids ({sh_weapon:id(), sh_weapon:id()}, type()) -> type(). +-spec set_weapon_ids ({shr_weapon:id(), shr_weapon:id()}, type()) -> type().  set_weapon_ids (WeaponIDs, Char) ->     Char#character     { @@ -221,7 +221,7 @@ set_weapon_ids (WeaponIDs, Char) ->  -spec set_statistics     ( -      sh_statistics:type(), +      shr_statistics:type(),        type()     )     -> type(). @@ -244,10 +244,10 @@ set_statistics (Stats, Char) ->  random (ID, PlayerIX, BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->     Location =        find_random_location(BattlemapWidth, BattlemapHeight, ForbiddenLocations), -   WeaponIDs = {sh_weapon:random_id(), sh_weapon:random_id()}, -   ArmorID = sh_armor:random_id(), -   Attributes = sh_attributes:random(), -   Statistics = sh_statistics:new(Attributes, WeaponIDs, ArmorID), +   WeaponIDs = {shr_weapon:random_id(), shr_weapon:random_id()}, +   ArmorID = shr_armor:random_id(), +   Attributes = shr_attributes:random(), +   Statistics = shr_statistics:new(Attributes, WeaponIDs, ArmorID),     IDAsListString = integer_to_list(ID),     IDAsBinaryString = list_to_binary(IDAsListString), @@ -269,7 +269,7 @@ random (ID, PlayerIX, BattlemapWidth, BattlemapHeight, ForbiddenLocations) ->        armor_id = ArmorID,        statistics = Statistics,        location = Location, -      current_health = sh_statistics:get_health(Statistics), +      current_health = shr_statistics:get_health(Statistics),        is_active = false,        is_defeated = false     }. diff --git a/src/battle/struct/btl_character_turn_data.erl b/src/battle/struct/btl_character_turn_data.erl index 31a4b7d..64df29f 100644 --- a/src/battle/struct/btl_character_turn_data.erl +++ b/src/battle/struct/btl_character_turn_data.erl @@ -40,7 +40,7 @@  (     [        clean_battle/1, -      refresh_character/1 +      refreshr_character/1     ]  ). @@ -101,8 +101,8 @@ clean_battle (Data) ->           )     }. --spec refresh_character (type()) -> type(). -refresh_character (Data) -> +-spec refreshr_character (type()) -> type(). +refreshr_character (Data) ->     Data#type     {        dirty = false, diff --git a/src/battle/struct/btl_character_turn_update.erl b/src/battle/struct/btl_character_turn_update.erl index a6b29d9..d63e437 100644 --- a/src/battle/struct/btl_character_turn_update.erl +++ b/src/battle/struct/btl_character_turn_update.erl @@ -9,7 +9,7 @@     {        data :: btl_character_turn_data:type(),        timeline :: list(any()), -      db :: list(sh_db_query:op()) +      db :: list(shr_db_query:op())     }  ). @@ -57,7 +57,7 @@ get_data (Update) -> Update#type.data.  -spec get_timeline (type()) -> list(any()).  get_timeline (Update) -> Update#type.timeline. --spec get_db (type()) -> list(sh_db_query:op()). +-spec get_db (type()) -> list(shr_db_query:op()).  get_db (Update) -> Update#type.db.  -spec set_data (btl_character_turn_data:type(), type()) -> type(). @@ -67,7 +67,7 @@ set_data (Data, Update) ->  -spec add_to_timeline     (        btl_turn_result:type(), -      sh_db_query:op(), +      shr_db_query:op(),        type()     ) -> type().  add_to_timeline (Item, DBUpdate, Update) -> @@ -80,6 +80,6 @@ add_to_timeline (Item, DBUpdate, Update) ->        }     ). --spec add_to_db (sh_db_query:op(), type()) -> type(). +-spec add_to_db (shr_db_query:op(), type()) -> type().  add_to_db (Item, Update) ->     Update#type{ db = [Item|Update#type.db] }. diff --git a/src/db/logic/db_access.erl b/src/db/logic/db_access.erl index 99d17ea..f7393f0 100644 --- a/src/db/logic/db_access.erl +++ b/src/db/logic/db_access.erl @@ -18,9 +18,9 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec get_value (list(sh_db_item:type())) -> ({'ok', any()} | 'not_found'). +-spec get_value (list(shr_db_item:type())) -> ({'ok', any()} | 'not_found').  get_value ([]) -> not_found; -get_value ([Regval]) -> {ok, sh_db_item:get_value(Regval)}. +get_value ([Regval]) -> {ok, shr_db_item:get_value(Regval)}.  -spec read_transaction (atom(), any()) -> ({'ok', any()} | 'not_found').  read_transaction (DB, ID) -> @@ -30,23 +30,23 @@ read_transaction (DB, ID) ->     (        atom(),        any(), -      sh_db_user:permission(), +      shr_db_user:permission(),        any()     )     -> 'ok'.  insert_transaction (DB, ID, Perm, Value) -> -   StoredItem = sh_db_item:new(ID, Perm, Value), +   StoredItem = shr_db_item:new(ID, Perm, Value),     % FIXME: handle return value, mnesia:write -> (transaction abort | ok).     % FIXME: is this an atomic OP? Is the lock freed afterwards?     mnesia:write(DB, StoredItem, sticky_write),     ok. --spec query_transaction (sh_db_query:type()) -> 'ok'. +-spec query_transaction (shr_db_query:type()) -> 'ok'.  query_transaction (Query) -> -   DB = sh_db_query:get_database(Query), -   ID = sh_db_query:get_entry_id(Query), +   DB = shr_db_query:get_database(Query), +   ID = shr_db_query:get_entry_id(Query),     [Item] = mnesia:read(DB, ID), -   {ok, UpdatedItem} = sh_db_query:apply_to(Query, Item), +   {ok, UpdatedItem} = shr_db_query:apply_to(Query, Item),     % FIXME: handle return value, mnesia:write -> (transaction abort | ok).     % FIXME: is this an atomic OP? Is the lock freed afterwards?     mnesia:write(DB, UpdatedItem, sticky_write), @@ -60,11 +60,11 @@ query_transaction (Query) ->  read (DB, ID) ->     mnesia:transaction(fun read_transaction/2, [DB, ID]). --spec insert (atom(), any(), sh_db_user:permission(), any()) +-spec insert (atom(), any(), shr_db_user:permission(), any())     -> ({'aborted', any()} | {'atomic', 'ok'}).  insert (DB, ID, Perm, Value) ->     mnesia:transaction(fun insert_transaction/4, [DB, ID, Perm, Value]). --spec query (sh_db_query:type()) -> ({'aborted', any()} | {'atomic', 'ok'}). +-spec query (shr_db_query:type()) -> ({'aborted', any()} | {'atomic', 'ok'}).  query (Query) ->     mnesia:transaction(fun query_transaction/1, [Query]). diff --git a/src/db/struct/db_model.erl b/src/db/struct/db_model.erl index 3e00b95..e6ec721 100644 --- a/src/db/struct/db_model.erl +++ b/src/db/struct/db_model.erl @@ -61,8 +61,8 @@ start (Model) ->     (        DBName,        [ -         {record_name, sh_db_item:get_record_name()}, -         {attributes, sh_db_item:get_record_info()}, +         {record_name, shr_db_item:get_record_name()}, +         {attributes, shr_db_item:get_record_info()},           {disc_copies, [node()|Neighbors]},           {disc_only_copies, []},           {ram_copies, []}, diff --git a/src/query/qry_handler.erl b/src/query/qry_handler.erl index ecf3263..606c08d 100644 --- a/src/query/qry_handler.erl +++ b/src/query/qry_handler.erl @@ -18,6 +18,6 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  -spec start (any()) -> 'ok'.  start (_YawsParams) -> -   {ok, TimedCachesManagerPid} = sh_timed_caches_manager:start(), +   {ok, TimedCachesManagerPid} = shr_timed_caches_manager:start(),     ok = btl_handler:start(TimedCachesManagerPid),     ok. diff --git a/src/shared/io/sh_database.erl b/src/shared/io/shr_database.erl index 233e37d..bffcb9f 100644 --- a/src/shared/io/sh_database.erl +++ b/src/shared/io/shr_database.erl @@ -1,4 +1,4 @@ --module(sh_database). +-module(shr_database).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -34,12 +34,12 @@ do_remote_operation (Op, Params) ->  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec insert (atom(), any(), sh_db_user:permission(), any()) -> 'ok'. +-spec insert (atom(), any(), shr_db_user:permission(), any()) -> 'ok'.  insert (DB, ObjectID, Permission, Value) ->     {atomic, _} = do_remote_operation(insert, [DB, ObjectID, Permission, Value]),     io:format     ( -      "~nsh_database:insert(~p) -> ok.~n", +      "~nshr_database:insert(~p) -> ok.~n",        [{DB, ObjectID, Permission, Value}]     ), @@ -48,11 +48,11 @@ insert (DB, ObjectID, Permission, Value) ->  -spec fetch (atom(), any()) -> ({'ok', any()} | 'not_found').  fetch (DB, ObjectID) ->     {atomic, Reply} = do_remote_operation(read, [DB, ObjectID]), -   io:format("~nsh_database:fetch(~p) -> ~p.~n", [{DB, ObjectID}, Reply]), +   io:format("~nshr_database:fetch(~p) -> ~p.~n", [{DB, ObjectID}, Reply]),     Reply. --spec commit (sh_db_query:type()) -> 'ok'. +-spec commit (shr_db_query:type()) -> 'ok'.  commit (Query) ->     {atomic, ok} = do_remote_operation(query, [Query]), -   io:format("~nsh_database:commit(~p) -> ok.~n", [Query]), +   io:format("~nshr_database:commit(~p) -> ok.~n", [Query]),     ok. diff --git a/src/shared/io/sh_timed_cache.erl b/src/shared/io/shr_timed_cache.erl index 6f3d973..b89de48 100644 --- a/src/shared/io/sh_timed_cache.erl +++ b/src/shared/io/shr_timed_cache.erl @@ -1,4 +1,4 @@ --module(sh_timed_cache). +-module(shr_timed_cache).  -behavior(gen_server).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -38,7 +38,7 @@  -spec add_to_cache (atom(), any(), any()) -> any().  add_to_cache (DB, Owner, ObjectID) ->     {ok, TimerPID} = gen_server:start(?MODULE, {DB, {Owner, ObjectID}}, []), -   {ok, Data} = sh_database:fetch(DB, ObjectID), +   {ok, Data} = shr_database:fetch(DB, ObjectID),     ets:insert(DB, {{Owner, ObjectID}, TimerPID, Data}),     Data. @@ -54,17 +54,17 @@ add_update_to_cache (DB, Owner, ObjectID, Data) ->  %%%% 'gen_server' functions  init ({DB, ObjectID}) ->     io:format("~nCache entry added: ~p.~n", [{DB, ObjectID}]), -   {ok, {DB, ObjectID}, sh_timed_caches_manager:get_timeout()}. +   {ok, {DB, ObjectID}, shr_timed_caches_manager:get_timeout()}.  handle_call (invalidate, _, State) ->     {stop, normal, State};  handle_call (ping, _, State) -> -   {noreply, State, sh_timed_caches_manager:get_timeout()}. +   {noreply, State, shr_timed_caches_manager:get_timeout()}.  handle_cast (invalidate, State) ->     {stop, normal, State};  handle_cast (ping, State) -> -   {noreply, State, sh_timed_caches_manager:get_timeout()}. +   {noreply, State, shr_timed_caches_manager:get_timeout()}.  terminate (_, {DB, ObjectID}) ->     io:format @@ -83,7 +83,7 @@ format_status (_, [_, State]) ->  handle_info(timeout, State) ->     {stop, normal, State};  handle_info(_, {DB, ObjectID}) -> -   {noreply, {DB, ObjectID}, sh_timed_caches_manager:get_timeout()}. +   {noreply, {DB, ObjectID}, shr_timed_caches_manager:get_timeout()}.  %%%% Interface Functions  -spec fetch (atom(), any(), any()) -> any(). diff --git a/src/shared/io/sh_timed_caches_manager.erl b/src/shared/io/shr_timed_caches_manager.erl index ea92c08..8303cb8 100644 --- a/src/shared/io/sh_timed_caches_manager.erl +++ b/src/shared/io/shr_timed_caches_manager.erl @@ -1,4 +1,4 @@ --module(sh_timed_caches_manager). +-module(shr_timed_caches_manager).  -behavior(gen_server).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/shared/sh_roll.erl b/src/shared/shr_roll.erl index f2212b1..8e688c7 100644 --- a/src/shared/sh_roll.erl +++ b/src/shared/shr_roll.erl @@ -1,4 +1,4 @@ --module(sh_roll). +-module(shr_roll).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/shared/struct/sh_armor.erl b/src/shared/struct/shr_armor.erl index cea2ce9..65445ca 100644 --- a/src/shared/struct/sh_armor.erl +++ b/src/shared/struct/shr_armor.erl @@ -1,4 +1,4 @@ --module(sh_armor). +-module(shr_armor).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -106,61 +106,61 @@ from_id (4) ->     }.  -spec random_id () -> id(). -random_id () -> sh_roll:between(0, 4). +random_id () -> shr_roll:between(0, 4).  -spec apply_to_attributes     (        type(), -      sh_attributes:type() +      shr_attributes:type()     ) -   -> sh_attributes:type(). +   -> shr_attributes:type().  apply_to_attributes (Ar, Att) -> -   Constitution = sh_attributes:get_constitution(Att), -   Dexterity = sh_attributes:get_dexterity(Att), -   Speed = sh_attributes:get_speed(Att), -   Strength = sh_attributes:get_strength(Att), -   Mind = sh_attributes:get_mind(Att), -   Impact = sh_math_util:ceil(20.0 * Ar#armor.coef), -   HalfImpact = sh_math_util:ceil(10.0 * Ar#armor.coef), +   Constitution = shr_attributes:get_constitution(Att), +   Dexterity = shr_attributes:get_dexterity(Att), +   Speed = shr_attributes:get_speed(Att), +   Strength = shr_attributes:get_strength(Att), +   Mind = shr_attributes:get_mind(Att), +   Impact = shr_math_util:ceil(20.0 * Ar#armor.coef), +   HalfImpact = shr_math_util:ceil(10.0 * Ar#armor.coef),     Category = Ar#armor.category,     case Category of -      kinetic -> sh_attributes:set_unsafe_mind((Mind - Impact), Att); +      kinetic -> shr_attributes:set_unsafe_mind((Mind - Impact), Att);        leather -> -         sh_attributes:set_unsafe_constitution +         shr_attributes:set_unsafe_constitution           (              (Constitution - HalfImpact), -            sh_attributes:set_unsafe_dexterity((Dexterity - HalfImpact), Att) +            shr_attributes:set_unsafe_dexterity((Dexterity - HalfImpact), Att)           );        chain -> -         sh_attributes:set_unsafe_constitution +         shr_attributes:set_unsafe_constitution           (              (Constitution - HalfImpact), -            sh_attributes:set_unsafe_dexterity +            shr_attributes:set_unsafe_dexterity              (                 (Dexterity - HalfImpact), -               sh_attributes:set_unsafe_speed((Speed - Impact), Att) +               shr_attributes:set_unsafe_speed((Speed - Impact), Att)              )           );        plate -> -         sh_attributes:set_unsafe_constitution +         shr_attributes:set_unsafe_constitution           (              (Constitution - HalfImpact), -            sh_attributes:set_unsafe_dexterity +            shr_attributes:set_unsafe_dexterity              (                 (Dexterity - HalfImpact), -               sh_attributes:set_unsafe_speed +               shr_attributes:set_unsafe_speed                 (                    (Speed - Impact), -                  sh_attributes:set_unsafe_strength((Strength - Impact), Att) +                  shr_attributes:set_unsafe_strength((Strength - Impact), Att)                 )              )           )     end. --spec get_resistance_to (sh_weapon:damage_type(), type()) -> non_neg_integer(). +-spec get_resistance_to (shr_weapon:damage_type(), type()) -> non_neg_integer().  get_resistance_to (DamageType, Armor) ->     ArmorCategory = Armor#armor.category,     BaseResistance = @@ -182,4 +182,4 @@ get_resistance_to (DamageType, Armor) ->     ArmorCoefficient = Armor#armor.coef,     ActualResistance = (ArmorCoefficient * BaseResistance), -   sh_math_util:ceil(ActualResistance). +   shr_math_util:ceil(ActualResistance). diff --git a/src/shared/struct/sh_attributes.erl b/src/shared/struct/shr_attributes.erl index 9b4478f..23824e4 100644 --- a/src/shared/struct/sh_attributes.erl +++ b/src/shared/struct/shr_attributes.erl @@ -1,4 +1,4 @@ --module(sh_attributes). +-module(shr_attributes).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -126,10 +126,10 @@ set_unsafe_strength (Val, Att) -> set_strength(make_safe(Val), Att).  random () ->     #attributes     { -      constitution = sh_roll:percentage(), -      dexterity = sh_roll:percentage(), -      intelligence = sh_roll:percentage(), -      mind = sh_roll:percentage(), -      speed = sh_roll:percentage(), -      strength = sh_roll:percentage() +      constitution = shr_roll:percentage(), +      dexterity = shr_roll:percentage(), +      intelligence = shr_roll:percentage(), +      mind = shr_roll:percentage(), +      speed = shr_roll:percentage(), +      strength = shr_roll:percentage()     }. diff --git a/src/shared/struct/sh_db_item.erl b/src/shared/struct/shr_db_item.erl index 3692a88..546462e 100644 --- a/src/shared/struct/sh_db_item.erl +++ b/src/shared/struct/shr_db_item.erl @@ -1,4 +1,4 @@ --module(sh_db_item). +-module(shr_db_item).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -8,7 +8,7 @@     db_item,     {        id :: any(), -      perm :: sh_db_user:permission(), +      perm :: shr_db_user:permission(),        val :: any()     }  ). @@ -47,7 +47,7 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec new (any(), sh_db_user:permission(), any()) -> type(). +-spec new (any(), shr_db_user:permission(), any()) -> type().  new (ID, Permission, Value) ->     #db_item     { @@ -59,13 +59,13 @@ new (ID, Permission, Value) ->  -spec get_id (type()) -> any().  get_id (#db_item { id = Result }) -> Result. --spec get_permission (type()) -> sh_db_user:permission(). +-spec get_permission (type()) -> shr_db_user:permission().  get_permission (#db_item { perm = Result }) -> Result.  -spec get_value (type()) -> any().  get_value (#db_item { val = Result }) -> Result. --spec set_permission (sh_db_user:permission(), type()) -> type(). +-spec set_permission (shr_db_user:permission(), type()) -> type().  set_permission (Perm, Item) -> Item#db_item{ perm = Perm }.  -spec set_value (any(), type()) -> type(). diff --git a/src/shared/struct/sh_db_query.erl b/src/shared/struct/shr_db_query.erl index 47d85d6..284cc2c 100644 --- a/src/shared/struct/sh_db_query.erl +++ b/src/shared/struct/shr_db_query.erl @@ -1,4 +1,4 @@ --module(sh_db_query). +-module(shr_db_query).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -36,7 +36,7 @@  (     set_perm,     { -      perm :: sh_db_user:permission() +      perm :: shr_db_user:permission()     }  ). @@ -54,7 +54,7 @@     {        db :: atom(),        id :: any(), -      user :: sh_db_user:user(), +      user :: shr_db_user:user(),        ops :: list(db_query_master_op())     }  ). @@ -92,7 +92,7 @@  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec get_user (db_query()) -> sh_db_user:user(). +-spec get_user (db_query()) -> shr_db_user:user().  get_user (#db_query{ user = Result }) -> Result.  -spec apply_update_indexed (#update_indexed{}, any()) -> any(). @@ -142,27 +142,27 @@ apply_op_to (Op, Elem) when is_record(Op, update_indexed) ->  -spec apply_master_op_to     (        db_query_master_op(), -      sh_db_item:type() +      shr_db_item:type()     ) -   -> sh_db_item:type(). +   -> shr_db_item:type().  apply_master_op_to (MOp, Elem) when is_record(MOp, set_perm) ->     NewPerm = MOp#set_perm.perm, -   sh_db_item:set_permission(NewPerm, Elem); +   shr_db_item:set_permission(NewPerm, Elem);  apply_master_op_to (MOp, Elem) when is_record(MOp, set_val) ->     NewVal = MOp#set_val.val, -   sh_db_item:set_value(NewVal, Elem); +   shr_db_item:set_value(NewVal, Elem);  apply_master_op_to (MOp, Elem) -> -   OldValue = sh_db_item:get_value(Elem), +   OldValue = shr_db_item:get_value(Elem),     NewValue = apply_op_to(MOp, OldValue), -   sh_db_item:set_value(NewValue, Elem). +   shr_db_item:set_value(NewValue, Elem).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec new (atom(), any(), sh_db_user:user(), list(op())) -> type(). +-spec new (atom(), any(), shr_db_user:user(), list(op())) -> type().  new (DBName, ObjectID, User, Ops) ->     #db_query     { @@ -199,14 +199,14 @@ get_entry_id (#db_query{ id = Result }) -> Result.  -spec apply_to     (        db_query(), -      sh_db_item:type() +      shr_db_item:type()     ) -   -> ({'ok', sh_db_item:type()} | 'error'). +   -> ({'ok', shr_db_item:type()} | 'error').  apply_to (DBQuery, DBItem) ->     true = -      sh_db_user:can_access +      shr_db_user:can_access        ( -         sh_db_item:get_permission(DBItem), +         shr_db_item:get_permission(DBItem),           get_user(DBQuery)        ),     MOps = DBQuery#db_query.ops, diff --git a/src/shared/struct/sh_db_user.erl b/src/shared/struct/shr_db_user.erl index f2d4dfe..01840e2 100644 --- a/src/shared/struct/sh_db_user.erl +++ b/src/shared/struct/shr_db_user.erl @@ -1,4 +1,4 @@ --module(sh_db_user). +-module(shr_db_user).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/shared/struct/sh_statistics.erl b/src/shared/struct/shr_statistics.erl index 497cf41..cf48d96 100644 --- a/src/shared/struct/sh_statistics.erl +++ b/src/shared/struct/shr_statistics.erl @@ -1,4 +1,4 @@ --module(sh_statistics). +-module(shr_statistics).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -143,28 +143,28 @@ get_damages (Stats) ->  -spec new     ( -      sh_attributes:type(), -      {sh_weapon:id(), sh_weapon:id()}, -      sh_armor:id() +      shr_attributes:type(), +      {shr_weapon:id(), shr_weapon:id()}, +      shr_armor:id()     )     -> type().  new (BaseAttributes, WeaponIDs, ArmorID) ->     {ActiveWeaponID, _} = WeaponIDs, -   ActiveWeapon = sh_weapon:from_id(ActiveWeaponID), -   {MinDamage, MaxDamage} = sh_weapon:get_damages(ActiveWeapon), -   Armor = sh_armor:from_id(ArmorID), +   ActiveWeapon = shr_weapon:from_id(ActiveWeaponID), +   {MinDamage, MaxDamage} = shr_weapon:get_damages(ActiveWeapon), +   Armor = shr_armor:from_id(ArmorID),     Attributes = -      sh_armor:apply_to_attributes +      shr_armor:apply_to_attributes        (           Armor, -         sh_weapon:apply_to_attributes(ActiveWeapon, BaseAttributes) +         shr_weapon:apply_to_attributes(ActiveWeapon, BaseAttributes)        ), -   Constitution = sh_attributes:get_constitution(Attributes), -   Dexterity = sh_attributes:get_dexterity(Attributes), -   Intelligence = sh_attributes:get_intelligence(Attributes), -   Mind = sh_attributes:get_mind(Attributes), -   Speed = sh_attributes:get_speed(Attributes), -   Strength = sh_attributes:get_strength(Attributes), +   Constitution = shr_attributes:get_constitution(Attributes), +   Dexterity = shr_attributes:get_dexterity(Attributes), +   Intelligence = shr_attributes:get_intelligence(Attributes), +   Mind = shr_attributes:get_mind(Attributes), +   Speed = shr_attributes:get_speed(Attributes), +   Strength = shr_attributes:get_strength(Attributes),     DamageBaseModifier = damage_base_modifier(Strength),     #statistics diff --git a/src/shared/struct/sh_weapon.erl b/src/shared/struct/shr_weapon.erl index 74c7a42..3ecb749 100644 --- a/src/shared/struct/sh_weapon.erl +++ b/src/shared/struct/shr_weapon.erl @@ -1,4 +1,4 @@ --module(sh_weapon). +-module(shr_weapon).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -124,7 +124,7 @@ get_ranges (Wp) ->  get_damages (Wp) ->     Coef = Wp#weapon.coef,     {Min, Max} = damages_of_type(Wp#weapon.range_type, Wp#weapon.damage_mod), -   {sh_math_util:ceil(Min * Coef), sh_math_util:ceil(Max * Coef)}. +   {shr_math_util:ceil(Min * Coef), shr_math_util:ceil(Max * Coef)}.  -spec can_parry (type()) -> boolean().  can_parry (Wp) -> (Wp#weapon.range_type == melee). @@ -382,23 +382,23 @@ from_id (24) ->     }.  -spec random_id () -> id(). -random_id () -> sh_roll:between(0, 24). +random_id () -> shr_roll:between(0, 24).  -spec apply_to_attributes     (        type(), -      sh_attributes:type() +      shr_attributes:type()     ) -   -> sh_attributes:type(). +   -> shr_attributes:type().  apply_to_attributes (Weapon, Attributes) -> -   Dexterity = sh_attributes:get_dexterity(Attributes), -   Speed = sh_attributes:get_speed(Attributes), +   Dexterity = shr_attributes:get_dexterity(Attributes), +   Speed = shr_attributes:get_speed(Attributes),     RangeModifier = Weapon#weapon.range_mod,     DamageModifier = Weapon#weapon.damage_mod,     Impact = (20.0 * Weapon#weapon.coef), -   FullImpact = sh_math_util:ceil(Impact), -   QuarterImpact = sh_math_util:ceil(Impact / 4.0), +   FullImpact = shr_math_util:ceil(Impact), +   QuarterImpact = shr_math_util:ceil(Impact / 4.0),     ResultingDexterity =        case RangeModifier of @@ -411,8 +411,8 @@ apply_to_attributes (Weapon, Attributes) ->           light -> (Speed - QuarterImpact)        end, -   S0Attributes = sh_attributes:set_unsafe_speed(ResultingSpeed, Attributes), +   S0Attributes = shr_attributes:set_unsafe_speed(ResultingSpeed, Attributes),     S1Attributes = -      sh_attributes:set_unsafe_dexterity(ResultingDexterity, S0Attributes), +      shr_attributes:set_unsafe_dexterity(ResultingDexterity, S0Attributes),     S1Attributes. diff --git a/src/shared/util/sh_array_util.erl b/src/shared/util/shr_array_util.erl index 6d976bc..0faff99 100644 --- a/src/shared/util/sh_array_util.erl +++ b/src/shared/util/shr_array_util.erl @@ -1,4 +1,4 @@ --module(sh_array_util). +-module(shr_array_util).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/shared/util/sh_math_util.erl b/src/shared/util/shr_math_util.erl index b2e2109..874bacc 100644 --- a/src/shared/util/sh_math_util.erl +++ b/src/shared/util/shr_math_util.erl @@ -1,4 +1,4 @@ --module(sh_math_util). +-module(shr_math_util).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | 


