\ProvidesPackage{config/arms}
%%%%% Weapons
%
% Weapon entries do two things.
% When used in creatures, they raise stats.
% When used in the weapons chart, they display stats.
%
% Use this 'weapon entry' command to place items in the weapons table, like this:
%\weapon[optional arguments]{Name}%
%{Bonus}
%{Dam}
%
% The AP cost ('heft') = ( Att + Dam ) / 2
% The Weight Rating = ( Att + Dam ) - 3

\newcounter{weaponBonus}
\newcounter{weaponDamage}
\newcounter{weaponWeight}
\newcounter{covering}
\newcounter{armourDR}
\newcounter{armourWeight}

\newcommand\weaponName{}
\newcommand\armourName{}

\newcommand\weapon[4][]{%
  \setcounter{weaponBonus}{#3}%
  \setcounter{weaponDamage}{#4}%
  \setcounter{heft}{#4}%
  \setcounter{weaponWeight}{#4}%
  \ifnum#3>-1% If the weapon's attack bonus is positive,
    \addtocounter{weaponWeight}{#3}% weight rating,
    \addtocounter{weaponWeight}{-2}% weight rating,
    \addtocounter{heft}{#3}% add it to the AP cost and 
    \roundUp{heft}% then the AP cost by 2.
  \fi%
  #1%
  \addtocounter{att}{\value{weaponBonus}}%
  \ifnum\value{heft}<1\setcounter{heft}1\fi%
  \ifnum\value{weaponWeight}<#3\setcounter{weaponWeight}#3\fi%
  \ifnum\value{weaponWeight}<1\setcounter{weaponWeight}1\fi%
  \ifnum#4<0\addtocounter{weaponWeight}{-1}\fi%
  \renewcommand\weaponName{#2}%
}

%% Use this to show weapons in tables.
%% Remember to close it with '\\' after.
%% It remains unterminated so you can add Costs.

\newcommand\showWeapon[1]{%
  #1 \weaponName & \absNum{weaponBonus} & \absNum{weaponDamage} & \arabic{heft} & \arabic{weaponWeight}
}

\newcounter{secondWeaponWeight}

\newcommand\rangedWeapon[4][0]{%
  \setcounter{track}{7}%
  \addtocounter{track}{#1}%
  \addtocounter{track}{\value{Dexterity}}%
  \addtocounter{track}{\value{Projectiles}}%
  \setcounter{secondWeaponWeight}{#3}%
  \addtocounter{secondWeaponWeight}{-4}%
  \setcounter{enc}{#3}%
  #2 (\glsentrytext{tn}~\arabic{track}, \dmg{enc}, \glsentrytext{ap}~{#4})%
}

\newcommand\smolCrossBow{%
  \rangedWeapon[2]{Crossbow}{6}{1}%
}


\newcommand\armour[4][]{
  \renewcommand\armourName{#2}% Name
  \setcounter{armourDR}{#3}%
  \setcounter{covering}{#4}%
  \setcounter{armourWeight}{#4}%
  \addtocounter{armourWeight}{#3}%
  \addtocounter{armourWeight}{1}%
  \divide\value{armourWeight} by 3%
  \addtocounter{armourWeight}{0}%
  #1% <- for adjustments.
}

\newcommand\showArmour[1]{%
  #1 \expandafter\MakeUppercase\armourName & \arabic{armourDR} & \arabic{covering} & \arabic{armourWeight}
}

\newcommand{\boulder}{\weapon[\addtocounter{armourWeight}{3}]{Boulder}{-3}{5}}
\newcommand{\chair}{\weapon[\addtocounter{weaponBonus}{-1}]{Chair}{2}{1}}
\newcommand{\club}{\weapon[\addtocounter{weaponDamage}{-1}]{Club}{1}{1}}
\newcommand{\cudgel}{\weapon[\addtocounter{weaponDamage}{-1}]{Cudgel}{0}{0}}
\newcommand{\Dagger}{\weapon{Dagger}{0}{2}}
\newcommand{\firepoker}{\weapon{Firepoker}{1}{0}}
\newcommand{\flail}{\weapon{Flail}{0}{3}}
\newcommand{\giantsword}{\weapon{Giant Sword}{4}{3}}
\newcommand{\greataxe}{\weapon{Great Axe}{2}{3}}
\newcommand{\greatsword}{\weapon{Greatsword}{3}{3}}
\newcommand{\greatclub}{\weapon[\addtocounter{weaponDamage}{-1}]{Great Club}{3}{4}}
\newcommand{\javelin}{\weapon{Javelin}{2}{1}}
\newcommand{\knife}{\weapon{Knife}{0}{1}}
\newcommand{\Log}{\weapon[\addtocounter{weaponDamage}{-3}]{Log}{1}{0}}
\newcommand{\rapier}{\weapon[\addtocounter{armourWeight}{-1}]{Rapier}{1}{1}}
\newcommand{\largerock}{\weapon[\addtocounter{armourWeight}{3}]{Rock (large)}{-1}{2}}
\newcommand{\longsword}{\weapon{Longsword}{2}{2}}
\newcommand{\maul}{\weapon{Maul}{1}{3}}
\newcommand{\poleaxe}{\weapon{Poleaxe}{3}{3}}
\newcommand{\quarterstaff}{\weapon{Quarterstaff}{3}{0}}
\newcommand{\rock}{\rangedWeapon{rock}{3}{2}}
\newcommand{\scythe}{\weapon[\addtocounter{armourWeight}{2}]{Scythe}{-2}{1}}
\newcommand{\shortsword}{\weapon{Shortsword}{1}{1}}
\newcommand{\skillet}{\weapon[\addtocounter{heft}{1}]{Frying Pan}{1}{2}}
\newcommand{\spear}{\weapon{Spear}{3}{1}}
\newcommand{\glaive}{\weapon{Glaive}{3}{2}}
\newcommand{\stick}{\weapon{Stick}{1}{0}}
\newcommand{\walkingStick}{\weapon{Walking stick}{1}{0}}
\newcommand{\whip}{\weapon[\addtocounter{weaponDamage}{-1}\addtocounter{heft}{1}]{Whip}{2}{0}}
\newcommand{\warhammer}{\weapon{Warhammer}{1}{4}}
\newcommand{\woodaxe}{\weapon[\addtocounter{heft}{1}]{Wood Axe}{1}{2}}

% SHIELDS
\newcommand{\buckler}{\weapon{Buckler}{2}{-2}}
\newcommand{\roundshield}{\weapon{Round Shield}{2}{0}}
\newcommand{\kiteshield}{\weapon{Kite Shield}{3}{0}}

% RANGED WEAPONS
\newcommand{\longbow}{Longbow}

% ARMOUR


%%%%%%%%% Old Armour, Delete Later

%% For perfect armour, stick \perfect Armour in the additional notes category of a \person (#9).

\newcommand{\perfectArmour}{\setcounter{covering}{8}}

\newcommand{\partialelvish}{%
  \armour[\addtocounter{armourWeight}{-1}]{Elvish Ceramic armour}{2}{3}%
}

\newcommand{\partialpadded}{%
  \armour[\addtocounter{armourWeight}{1}]{padded armour}{3}{3}%
}

\newcommand{\partialleather}{%
  \armour{partial leather}{3}{3}%
}

\newcommand{\completeleather}{%
  \armour{complete leather}{3}{5}%
}

\newcommand{\partialchain}{%
  \armour{partial chain}{4}{3}%
}

\newcommand{\completechain}{%
  \armour{complete chain}{4}{5}%
}

\newcommand{\partiallisk}{%
  \armour{partial lisk-hide}{4}{3}%
}

\newcommand{\completelisk}{%
  \armour{complete lisk-hide}{4}{5}%
}

\newcommand{\partialplate}{%
  \armour{partial plate}{5}{3}%
}

\newcommand{\completeplate}{%
  \armour{complete plate}{5}{5}%
}
