src/chess/rules.c

changeset 155
835776e0338f
parent 154
5336e985bd69
child 156
05fc8a454700
equal deleted inserted replaced
154:5336e985bd69 155:835776e0338f
802 } else { 802 } else {
803 move->piece = getpiece(mstr[0]); 803 move->piece = getpiece(mstr[0]);
804 if (mstr[2] == 'x') { 804 if (mstr[2] == 'x') {
805 move->capture = 1; 805 move->capture = 1;
806 if (move->piece) { 806 if (move->piece) {
807 /* capture (e.g. "Ndxf3") */ 807 /* capture (e.g. "Ndxf3" or "R1xh3") */
808 move->fromfile = fileidx(mstr[1]); 808 if (isfile(mstr[1])) {
809 move->fromfile = fileidx(mstr[1]);
810 } else if (isrow(mstr[1])) {
811 move->fromrow = rowidx(mstr[1]);
812 } else {
813 return INVALID_MOVE_SYNTAX;
814 }
809 } else { 815 } else {
810 /* long notation capture (e.g. "e5xf6") */ 816 /* long notation capture (e.g. "e5xf6") */
811 move->piece = PAWN; 817 move->piece = PAWN;
812 move->fromfile = fileidx(mstr[0]); 818 move->fromfile = fileidx(mstr[0]);
813 move->fromrow = rowidx(mstr[1]); 819 move->fromrow = rowidx(mstr[1]);

mercurial