public AbstractGameplay getNext(AbstractGameplay current, ResourceState resourceState) { List<AbstractGameplay> possibleGameplays = new List<AbstractGameplay>(); foreach (AbstractGameplay ag in gameplays) { if (ag.getPredecessors().Contains(current) && ag.getConstraint().isSatisfied(resourceState)) { possibleGameplays.Add(ag); } } if (possibleGameplays.Count == 0) { return null; } return possibleGameplays[rndGen.Next(possibleGameplays.Count)]; }
public bool isSatisfied(ResourceState state) { foreach(AbstractResource constraint in constraints) { bool constraintSat = false; foreach(AbstractResource resource in state.getResources()) { if (resource.isMoreThanOrEqual(constraint)) { constraintSat = true; break; } } if (!constraintSat) { return false; } } return true; }