diff --git a/xtrn/chess/utils.js b/xtrn/chess/utils.js index 46e72e51e1d515c6a0e8f0f44cf23854dfaa4ffd..c5b2c5abf0634d250d678e126a85d17344dc587e 100644 --- a/xtrn/chess/utils.js +++ b/xtrn/chess/utils.js @@ -16,6 +16,17 @@ function parsePos(pos) return ret; } +function makePos(pos) +{ + if(pos.x == null || pos.x < 1 || pos.x > 8) + throw("Illegal location '"+pos.toSource()+"'"); + if(pos.y == null || pos.y < 1 || pos.y > 8) + throw("Illegal location '"+pos.toSource()+"'"); + var ret=ascii(96+pos.x); + ret += ascii(48+pos.y); + return ret; +} + function parseColour(colour) { if(colour=='w') @@ -37,6 +48,9 @@ function toward(from, to) function copyProps(from, to) { for(prop in from) { - to[prop]=from[prop]; + if(from.__lookupGetter__(prop)) + to.__defineGetter__(prop, from.__lookupGetter__(prop)); + else + to[prop]=from[prop]; } }