Created
November 14, 2016 06:06
-
-
Save jweimann/3585a428ee4dcceae18bd244e12444d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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