It would look like a simpler form of what Shogi does, as it would move the piece to an already identified space.
if capture:
set mynewpiece flipcase realname alias $old;
add #mynewpiece $origin;
endif;
This should work if you're not using aliases:
if capture:
add $old $origin;
flip $origin;
endif;
It looks like the code for Shogi omits doing this in the stalemated subroutine, as moving a captured piece off-board does not affect whether the move leaves the King in check. If your game had check in it, you might have to deal with this in the stalemated subroutine. But since you don't have check, maybe putting the piece back on the board will not affect the evaluation of which moves are legal. In that case, it may not be essential to deal with it during the simulation of potential legal moves.
It would look like a simpler form of what Shogi does, as it would move the piece to an already identified space.
This should work if you're not using aliases:
It looks like the code for Shogi omits doing this in the stalemated subroutine, as moving a captured piece off-board does not affect whether the move leaves the King in check. If your game had check in it, you might have to deal with this in the stalemated subroutine. But since you don't have check, maybe putting the piece back on the board will not affect the evaluation of which moves are legal. In that case, it may not be essential to deal with it during the simulation of potential legal moves.