summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2018-02-27 14:16:16 +0100 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2018-02-27 14:16:16 +0100 |
commit | 292022649270d36c8ab0c813e4d7e07f3e067231 (patch) | |
tree | 8e25f8c3e5db7f6bae7001d405f24e29115750f3 /src/struct/character.erl | |
parent | be9a65dd6d24ca8e7006c0b8825a3fa46419e201 (diff) |
Starting to specify types everywhere...
Diffstat (limited to 'src/struct/character.erl')
-rw-r--r-- | src/struct/character.erl | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/src/struct/character.erl b/src/struct/character.erl index 90e449c..3ee9a31 100644 --- a/src/struct/character.erl +++ b/src/struct/character.erl @@ -3,22 +3,27 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-opaque id() :: integer(). + -record ( character, { - id, - owner_id, - name, - icon, - portrait, - attributes, - statistics, - glyphs, - weapon_ids + id :: id(), + owner_id :: player:id(), + name :: binary(), + icon :: binary(), + portrait :: binary(), + attributes :: attributes:struct(), + statistics :: statistics:struct(), + glyphs :: list(glyph:id()), + weapon_ids :: {weapon:id(), weapon:id()} } ). +-opaque struct() :: #character{}. + +-export_type([struct/0, id/0]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -56,29 +61,63 @@ %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%% Accessors +-spec get_id (struct()) -> id(). get_id (Char) -> Char#character.id. + +-spec get_owner_id (struct()) -> player:id(). get_owner_id (Char) -> Char#character.owner_id. + +-spec get_name (struct()) -> binary(). get_name (Char) -> Char#character.name. + +-spec get_icon (struct()) -> binary(). get_icon (Char) -> Char#character.icon. + +-spec get_portrait (struct()) -> binary(). get_portrait (Char) -> Char#character.portrait. + +-spec get_attributes (struct()) -> attributes:struct(). get_attributes (Char) -> Char#character.attributes. + +-spec get_weapon_ids (struct()) -> {weapon:id(), weapon:id()}. get_weapon_ids (Char) -> Char#character.weapon_ids. + +-spec get_glyphs (struct()) -> list(glyph:id()). get_glyphs (Char) -> Char#character.glyphs. +-spec get_statistics (struct()) -> statistics:struct(). get_statistics (Char) -> Char#character.statistics. +-spec set_weapon_ids + ( + {weapon:id(), weapon:id()}, + struct() + ) + -> struct(). set_weapon_ids (WeaponIDs, Char) -> Char#character { weapon_ids = WeaponIDs }. +-spec set_statistics + ( + statistics:struct(), + struct() + ) + -> struct(). set_statistics (Stats, Char) -> Char#character { statistics = Stats }. +-spec random + ( + id(), + player:id() + ) + -> struct(). random (ID, OwnerID) -> WeaponIDs = {weapon:random_id(), weapon:random_id()}, Attributes = attributes:random(), |