| 1080 /* queen side castling "O-O-O" */ |
1080 /* queen side castling "O-O-O" */ |
| 1081 move->piece = mkpiece(KING, color); |
1081 move->piece = mkpiece(KING, color); |
| 1082 move->fromfile = fileidx('e'); |
1082 move->fromfile = fileidx('e'); |
| 1083 move->tofile = fileidx('c'); |
1083 move->tofile = fileidx('c'); |
| 1084 move->fromrank = move->torank = color == WHITE ? 0 : 7; |
1084 move->fromrank = move->torank = color == WHITE ? 0 : 7; |
| |
1085 } else if (mstr[2] == '-') { |
| |
1086 /* long notation pawn move with hyphen (e.g. "d4-d5") */ |
| |
1087 if (isfile(mstr[0]) && isrank(mstr[1]) && |
| |
1088 isfile(mstr[3]) && isrank(mstr[4])) { |
| |
1089 move->piece = mkpiece(PAWN, color); |
| |
1090 move->fromfile = fileidx(mstr[0]); |
| |
1091 move->fromrank = rankidx(mstr[1]); |
| |
1092 move->tofile = fileidx(mstr[3]); |
| |
1093 move->torank = rankidx(mstr[4]); |
| |
1094 } else { |
| |
1095 return INVALID_MOVE_SYNTAX; |
| |
1096 } |
| 1085 } else { |
1097 } else { |
| 1086 move->piece = getpiece(mstr[0], color); |
1098 move->piece = getpiece(mstr[0], color); |
| 1087 if (mstr[2] == 'x') { |
1099 if (mstr[2] == 'x') { |
| 1088 move->capture = true; |
1100 move->capture = true; |
| 1089 if (move->piece) { |
1101 if (move->piece) { |
| 1108 } |
1120 } |
| 1109 move->tofile = fileidx(mstr[3]); |
1121 move->tofile = fileidx(mstr[3]); |
| 1110 move->torank = rankidx(mstr[4]); |
1122 move->torank = rankidx(mstr[4]); |
| 1111 } |
1123 } |
| 1112 } else if (len == 6) { |
1124 } else if (len == 6) { |
| 1113 /* long notation capture (e.g. "Nc5xf3") */ |
|
| 1114 if (mstr[3] == 'x') { |
1125 if (mstr[3] == 'x') { |
| |
1126 /* long notation capture (e.g. "Nc5xf3") */ |
| 1115 move->capture = true; |
1127 move->capture = true; |
| 1116 move->piece = getpiece(mstr[0], color); |
1128 move->piece = getpiece(mstr[0], color); |
| 1117 move->fromfile = fileidx(mstr[1]); |
1129 move->fromfile = fileidx(mstr[1]); |
| 1118 move->fromrank = rankidx(mstr[2]); |
1130 move->fromrank = rankidx(mstr[2]); |
| 1119 move->tofile = fileidx(mstr[4]); |
1131 move->tofile = fileidx(mstr[4]); |
| 1120 move->torank = rankidx(mstr[5]); |
1132 move->torank = rankidx(mstr[5]); |
| |
1133 } else if (mstr[3] == '-') { |
| |
1134 /* long notation move with hyphen (e.g. "Nb1-c3") */ |
| |
1135 Piece p = getpiece(mstr[0], color); |
| |
1136 if (p != 0 && isfile(mstr[1]) && isrank(mstr[2]) && |
| |
1137 isfile(mstr[4]) && isrank(mstr[5])) { |
| |
1138 move->piece = p; |
| |
1139 move->fromfile = fileidx(mstr[1]); |
| |
1140 move->fromrank = rankidx(mstr[2]); |
| |
1141 move->tofile = fileidx(mstr[4]); |
| |
1142 move->torank = rankidx(mstr[5]); |
| |
1143 } else { |
| |
1144 return INVALID_MOVE_SYNTAX; |
| |
1145 } |
| 1121 } |
1146 } |
| 1122 } |
1147 } |
| 1123 |
1148 |
| 1124 |
1149 |
| 1125 if (!move->piece) { |
1150 if (!move->piece) { |