2 * Copyright (c) 2018. Developed by Hedgecode.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.hedgecode.chess.game;
19 import java.util.ArrayList;
20 import java.util.List;
22 import org.hedgecode.chess.position.Color;
23 import org.hedgecode.chess.position.Square;
28 * @author Dmitry Samoshin aka gotty
30 public class GameMoves implements Moves {
32 private int moveNumber;
33 private List<Move> moves;
37 moves = new ArrayList<>();
41 public void move(Move move) {
50 return moves.get(moveNumber);
57 moveNumber = moves.size() - 1;
58 return moves.get(moveNumber);
62 public boolean hasNext() {
63 return moves.size() > moveNumber + 1;
69 return moves.get(++moveNumber);
85 public Move byNumber(int num, Color color) {
89 static class Builder {
91 Move build(Color color, Square from, Square to) {
92 return new GameMove(color, from, to);