Skip to content

Commit

Permalink
Fix Game fullmoves from Position
Browse files Browse the repository at this point in the history
  • Loading branch information
nvzqz committed Aug 3, 2016
1 parent 892c2a9 commit be76167
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Sources/Game.swift
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,7 @@ public final class Game {
}

/// The current fullmove number.
public var fullmoves: UInt {
return 1 + (UInt(moveCount) / 2)
}
public private(set) var fullmoves: UInt

/// The current halfmove clock.
public private(set) var halfmoves: UInt
Expand Down Expand Up @@ -512,6 +510,7 @@ public final class Game {
self.variant = game.variant
self.attackersToKing = game.attackersToKing
self.halfmoves = game.halfmoves
self.fullmoves = game.fullmoves
}

/// Creates a new chess game.
Expand All @@ -532,6 +531,7 @@ public final class Game {
self.variant = variant
self.attackersToKing = 0
self.halfmoves = 0
self.fullmoves = 1
}

/// Creates a chess game from a `Position`.
Expand Down Expand Up @@ -560,6 +560,7 @@ public final class Game {
self.enPassantTarget = position.enPassantTarget
self.attackersToKing = position.board.attackersToKing(for: position.playerTurn)
self.halfmoves = position.halfmoves
self.fullmoves = position.fullmoves
}

/// Creates a chess game with `moves`.
Expand Down Expand Up @@ -772,6 +773,7 @@ public final class Game {
} else {
attackersToKing = board.attackersToKing(for: playerTurn)
}
fullmoves = 1 + (UInt(moveCount) / 2)
_undoHistory = []
}

Expand Down Expand Up @@ -858,6 +860,7 @@ public final class Game {
} else {
attackersToKing = board.attackersToKing(for: playerTurn)
}
fullmoves = 1 + (UInt(moveCount) / 2)
_undoHistory = []
}

Expand Down Expand Up @@ -995,6 +998,7 @@ public final class Game {
playerTurn.invert()
self.enPassantTarget = enPassantTarget
self.attackersToKing = attackers
self.fullmoves = 1 + (UInt(moveCount) / 2)
self.halfmoves = halfmoves
self.castlingRights = rights
return move
Expand Down

0 comments on commit be76167

Please sign in to comment.