use getOrDefault
@@ -53,7 +53,6 @@ import java.util.Map.Entry;
import java.util.UUID;
/**
- *
* @author emerald000
*/
public class SpinerockKnoll extends CardImpl {
@@ -134,23 +133,15 @@ class SpinerockKnollWatcher extends Watcher {
if (event.getType() == EventType.DAMAGED_PLAYER) {
UUID playerId = event.getPlayerId();
if (playerId != null) {
- Integer amount = amountOfDamageReceivedThisTurn.get(playerId);
- if (amount == null) {
- amount = event.getAmount();
- } else {
+ Integer amount = amountOfDamageReceivedThisTurn.getOrDefault(playerId, 0);
amount += event.getAmount();
- }
amountOfDamageReceivedThisTurn.put(playerId, amount);
}
}
}
public int getDamageReceived(UUID playerId) {
- Integer amount = amountOfDamageReceivedThisTurn.get(playerId);
- if (amount != null) {
- return amount;
- }
- return 0;
+ return amountOfDamageReceivedThisTurn.getOrDefault(playerId, 0);
}
@Override
