public void AddChips(Player contributedPlayer, decimal chips) { decimal currentSum = 0; if (Contributions.ContainsKey(contributedPlayer)) { currentSum = Contributions[contributedPlayer]; } currentSum += chips; TotalChips += chips; Contributions.Add(contributedPlayer, currentSum); }
public void RemoveChips(Player player, decimal chips) { if (!Contributions.ContainsKey(player)) { return; } decimal currentSum = Contributions[player]; if (chips <= currentSum) { currentSum -= chips; TotalChips -= chips; Contributions.Add(player, currentSum); } else { // TODO: throw Exception, maybe? TotalChips -= currentSum; Contributions.Add(player, 0); } }