In what cases does this happen? When you have more spare ammo or less spare ammo? Also this may not matter too much but is there a reason you have both your statements as independent if statements instead of a if-else? I would imagine in most cases youd probably only want to do one condition or the other and never potentially both
The way I understand your code now, for example if spareAmmo = 30, and requiredAmmo = 20 then the first if makes spareAmmo = 10, and then the second if 10 < 20 is now true as well, so now spareAmmo = 0, which may not be the intended logic your wanting?