use of com.janfic.games.computercombat.model.animations.SwitchAnimation in project computercombat by janfic.
the class MatchComponentsMove method doMove.
@Override
public List<MoveResult> doMove(MatchState originalState) {
List<MoveResult> results = new ArrayList<>();
// Record Original State
MoveResult r = new MoveResult(this, MatchState.record(originalState), new ArrayList<>());
results.add(r);
// Apply Switch
Component[][] board = originalState.getComponentBoard();
Component switchB = board[b.getX()][b.getY()];
Component switchA = board[a.getX()][a.getY()];
int bColor = switchB.getColor();
switchB.changeColor(switchA.getColor());
switchA.changeColor(bColor);
// Switch and Create 1st MoveResult
SwitchAnimation switchAnimation = new SwitchAnimation(a, b);
List<MoveAnimation> animations = new ArrayList<>();
animations.add(switchAnimation);
// Record Switch
MoveResult mr = new MoveResult(this, MatchState.record(originalState), animations);
results.add(mr);
switchA.invalidate();
switchB.invalidate();
switchA.invalidateNeighbors();
switchB.invalidateNeighbors();
List<MoveResult> collectLoop = originalState.results(this);
// collectLoop = Move.collectComponentsCheck(originalState, this);
results.addAll(collectLoop);
GameRules.isGameOver(originalState);
return results;
}
use of com.janfic.games.computercombat.model.animations.SwitchAnimation in project computercombat by janfic.
the class SwitchComponentsAbility method doAbility.
@Override
public List<MoveResult> doAbility(MatchState state, Move move) {
List<MoveResult> results = new ArrayList<>();
UseAbilityMove useAbility = (UseAbilityMove) move;
Component[][] newBoard = state.componentBoard;
Component a = useAbility.getSelectedComponents().get(0);
Component b = useAbility.getSelectedComponents().get(1);
Component bb = newBoard[b.getX()][b.getY()];
Component ba = newBoard[a.getX()][a.getY()];
bb.invalidate();
ba.invalidate();
ba.invalidateNeighbors();
bb.invalidateNeighbors();
List<Card> drained = new ArrayList<>();
drained.add(((UseAbilityMove) (move)).getCard());
List<MoveAnimation> anims = new ArrayList<>();
anims.add(new ConsumeProgressAnimation(move.getPlayerUID(), drained));
anims.add(new SwitchAnimation(bb, ba));
MoveResult r = new MoveResult(move, MatchState.record(state), anims);
List<MoveResult> collectCheckResults = state.results(move);
results.add(r);
results.addAll(collectCheckResults);
return results;
}
Aggregations