Skip to content

Instantly share code, notes, and snippets.

@tetsuzuki tetsuzuki/CanMove.js
Created Feb 20, 2014

Embed
What would you like to do?
//選択した駒が、選択したマスに動けるかどうかしらべる関数
var CanMove = function(pos){
for(var i = 0; i < 12; i++){
if(CanGo[i][selectedKoma]){
if(pos.dan == FromClickDan + Direction[i].dan && pos.suji == FromClickSuji + Direction[i].suji)return 1;
if(CanJump[i][selectedKoma]){
for(var j = 1; j <= 8; j++){
var moved = new Pos(0,0);
moved.dan = FromClickDan + Direction[i].dan * j;
moved.suji = FromClickSuji + Direction[i].suji * j;
if(pos.dan == moved.dan && pos.suji == moved.suji)return 1;
if(board[moved.dan][moved.suji] != EMPTY)break;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.