Skip to content

Instantly share code, notes, and snippets.

@jweimann
Created November 14, 2016 06:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jweimann/3585a428ee4dcceae18bd244e12444d5 to your computer and use it in GitHub Desktop.
Save jweimann/3585a428ee4dcceae18bd244e12444d5 to your computer and use it in GitHub Desktop.
public void Reload()
{
int spaceRemaining = _maxAmmoPerClip - _ammoInClip;
int desiredAmmoToMove = Math.Min(_maxAmmoPerClip, spaceRemaining);
int amountToMove = Math.Min(desiredAmmoToMove, _ammoNotInClip);
if (amountToMove > 0)
{
_ammoNotInClip -= amountToMove;
_ammoInClip += amountToMove;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment