onix-chess
Advanced tools
Comparing version 3.1.0 to 3.3.1
@@ -10,4 +10,9 @@ import { Colors } from './Types'; | ||
function flip(c: Colors.BW): Colors.BW; | ||
function isBW(c: number): c is Colors.BW; | ||
function isName(c: string): c is Colors.Name; | ||
function isChar(c: string): c is Colors.Char; | ||
function toName(c: Colors.BW): Colors.Name; | ||
function fromName(c: Colors.Name): Colors.BW; | ||
function toChar(c: Colors.BW): Colors.Char; | ||
function fromChar(c: Colors.Char): Colors.BW; | ||
} |
@@ -23,2 +23,14 @@ "use strict"; | ||
Color.flip = flip; | ||
function isBW(c) { | ||
return c === Color.White || c === Color.Black; | ||
} | ||
Color.isBW = isBW; | ||
function isName(c) { | ||
return c === "white" || c === "black"; | ||
} | ||
Color.isName = isName; | ||
function isChar(c) { | ||
return c === "w" || c === "b"; | ||
} | ||
Color.isChar = isChar; | ||
function toName(c) { | ||
@@ -33,2 +45,11 @@ switch (c) { | ||
Color.toName = toName; | ||
function fromName(c) { | ||
switch (c) { | ||
case "white": | ||
return Color.White; | ||
case "black": | ||
return Color.Black; | ||
} | ||
} | ||
Color.fromName = fromName; | ||
function toChar(c) { | ||
@@ -43,3 +64,12 @@ switch (c) { | ||
Color.toChar = toChar; | ||
function fromChar(c) { | ||
switch (c) { | ||
case "w": | ||
return Color.White; | ||
case "b": | ||
return Color.Black; | ||
} | ||
} | ||
Color.fromChar = fromChar; | ||
})(Color = exports.Color || (exports.Color = {})); | ||
//# sourceMappingURL=Color.js.map |
@@ -70,3 +70,3 @@ "use strict"; | ||
// color | ||
result += (tok[1] === "b") ? " b" : " w"; | ||
result += " " + (Color_1.Color.isChar(tok[1]) ? tok[1] : "w"); | ||
if (flag >= FenFormat.castlingEp) { | ||
@@ -111,3 +111,3 @@ if (tok.length > 2) { | ||
// now the side to move: | ||
result.color = (tok[1] === "b") ? Color_1.Color.Black : Color_1.Color.White; | ||
result.color = Color_1.Color.isChar(tok[1]) ? Color_1.Color.fromChar(tok[1]) : Color_1.Color.White; | ||
} | ||
@@ -220,3 +220,3 @@ if (tok.length > 2) { | ||
if (flag >= FenFormat.color) { | ||
fen += (pos.WhoMove == Color_1.Color.Black ? " b" : " w"); | ||
fen += " " + Color_1.Color.toChar(pos.WhoMove); | ||
if (flag >= FenFormat.castlingEp) { | ||
@@ -223,0 +223,0 @@ fen += " " + pos.Castling.asFen(); |
{ | ||
"name": "onix-chess", | ||
"version": "3.1.0", | ||
"version": "3.3.1", | ||
"description": "Onix chess library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -25,2 +25,14 @@ import { Colors } from './Types'; | ||
} | ||
export function isBW(c: number): c is Colors.BW { | ||
return c === White || c === Black; | ||
} | ||
export function isName(c: string): c is Colors.Name { | ||
return c === "white" || c === "black"; | ||
} | ||
export function isChar(c: string): c is Colors.Char { | ||
return c === "w" || c === "b"; | ||
} | ||
@@ -34,4 +46,13 @@ export function toName(c: Colors.BW): Colors.Name { | ||
} | ||
} | ||
} | ||
export function fromName(c: Colors.Name): Colors.BW { | ||
switch (c) { | ||
case "white": | ||
return White; | ||
case "black": | ||
return Black; | ||
} | ||
} | ||
export function toChar(c: Colors.BW): Colors.Char { | ||
@@ -45,2 +66,11 @@ switch (c) { | ||
} | ||
export function fromChar(c: Colors.Char): Colors.BW { | ||
switch (c) { | ||
case "w": | ||
return White; | ||
case "b": | ||
return Black; | ||
} | ||
} | ||
} |
@@ -97,3 +97,3 @@ import repeat from 'lodash-es/repeat'; | ||
// color | ||
result += (tok[1] === "b") ? " b" : " w"; | ||
result += " " + (Color.isChar(tok[1]) ? tok[1] : "w"); | ||
@@ -147,3 +147,3 @@ if (flag >= FenFormat.castlingEp) { | ||
// now the side to move: | ||
result.color = (tok[1] === "b") ? Color.Black : Color.White; | ||
result.color = Color.isChar(tok[1]) ? Color.fromChar(tok[1]) : Color.White; | ||
} | ||
@@ -269,3 +269,3 @@ | ||
if (flag >= FenFormat.color) { | ||
fen += (pos.WhoMove == Color.Black ? " b" : " w"); | ||
fen += " " + Color.toChar(pos.WhoMove); | ||
@@ -272,0 +272,0 @@ if (flag >= FenFormat.castlingEp) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
450690
8316