public List<Action> getAllLegalMoves(GameState state, int nextID) {
// we assume that state has had hand/deck sorted before making a decision
List<Action> retValue = allRules.stream()
.map(r -> r.execute(nextID, state))
.filter(Objects::nonNull)
.filter(p -> {
// this section should use Action.isLegal(). But that is broken for Play and Discard
// as it uses hand.getCard() != null, which will always be true for the acting player
// when we use the state provided by GameRunner
if (p instanceof PlayCard) {
int slot = ((PlayCard) p).slot;
return state.getHand(nextID).hasCard(slot);
} else if (p instanceof DiscardCard) {
int slot = ((DiscardCard) p).slot;
return state.getHand(nextID).hasCard(slot) && state.getInfomation() != state.getStartingInfomation();
} else {
return state.getInfomation() != 0;
}
})
.distinct()
.collect(Collectors.toList());
return retValue;
}