This commit is contained in:
2022-01-12 12:51:22 +01:00
parent 66172c20cb
commit e6090880ec
35 changed files with 102 additions and 128 deletions

View File

@@ -152,34 +152,6 @@ public final class GameData {
return new GameData(newValues, newPresent);
}
/**
* @see #with(Key, Object)
*/
public <T1, T2, T3> GameData with(@NotNull Key<T1> key1, T1 value1, Key<T2> key2, T2 value2, Key<T3> key3, T3 value3) {
int index1 = key1.index();
int index2 = key2.index();
int index3 = key3.index();
if (present[index1]
&& present[index2]
&& present[index3]
&& Objects.equals(values[index1], value1)
&& Objects.equals(values[index2], value2)
&& Objects.equals(values[index3], value3)) {
return this;
}
Object[] newValues = Arrays.copyOf(this.values, SIZE);
boolean[] newPresent = Arrays.copyOf(this.present, SIZE);
newValues[index1] = value1;
newPresent[index1] = true;
newValues[index2] = value2;
newPresent[index2] = true;
newValues[index3] = value3;
newPresent[index3] = true;
return new GameData(newValues, newPresent);
}
/**
* Returns {@code this} if this map contains a mapping for the specified key or throws a
* {@link NoSuchElementException} otherwise.

View File

@@ -35,9 +35,6 @@ public final class PlayingCard extends TrickState {
@Override
public Optional<GameState> onMessage(Game game, UUID player, PlayerMessage message) {
if (get(CURRENT_PLAYER).equals(player) && message instanceof PlayCardMessage cardMessage) {
if (cardMessage.getCard() == null) {
throw new IllegalArgumentException("Card must not be null.");
}
return transition(game, cardMessage.getCard());
} else {
return super.onMessage(game, player, message);

View File

@@ -3,8 +3,6 @@ package eu.jonahbauer.wizard.core.machine.states.trick;
import eu.jonahbauer.wizard.core.machine.Game;
import eu.jonahbauer.wizard.core.machine.GameState;
import eu.jonahbauer.wizard.core.machine.states.GameData;
import eu.jonahbauer.wizard.core.machine.states.SyncState;
import eu.jonahbauer.wizard.core.machine.states.round.RoundState;
import java.util.Optional;

View File

@@ -7,7 +7,6 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;

View File

@@ -24,7 +24,6 @@ import static eu.jonahbauer.wizard.core.machine.GameTestUtils.doFinish;
import static eu.jonahbauer.wizard.core.machine.states.GameData.*;
import static eu.jonahbauer.wizard.core.machine.states.GameData.TypedValue.entry;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.*;
public class DeterminingTrumpTest {