Skip to content

Instantly share code, notes, and snippets.

@tetsuzuki
Created February 20, 2014 05:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tetsuzuki/9107532 to your computer and use it in GitHub Desktop.
Save tetsuzuki/9107532 to your computer and use it in GitHub Desktop.
//選択した駒が、選択したマスに動けるかどうかしらべる関数
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