Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ちょっとよくわからない状態になったときに、盤面の情報を図示してくれるやつがほしかったので作った
  • Loading branch information
walf443 committed Jul 31, 2011
1 parent ccc06eb commit 0a964c6
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions goban.js
Expand Up @@ -11,6 +11,34 @@ var Goban = (function() {
this.WHITE = 1;
var goban = this;

this.CLIView = function(options) {
this.board = options.board;

this.render = function() {
for ( var i = 0; i < this.board.size; i++ ) {
var line = "|";
for ( var j = 0; j < this.board.size; j++ ) {
var val = this.board.data[i*this.board.size + j];
var char;
switch ( val ) {
case goban.BLACK:
char = "×";
break;
case goban.WHITE:
char = "○";
break;
case undefined:
char = " ";
break;
}
line += char;
}
console.log(line + '|');
};
};
return this;
};

this.Board = function(options)
{
this.size = options.size;
Expand All @@ -30,8 +58,8 @@ var Goban = (function() {

this.turn = goban.BLACK;

this.viewClass = options.viewClass;
this.viewOptions = options.viewOptions;
this.viewClass = options.viewClass ? options.viewClass : CLIView;
this.viewOptions = options.viewOptions ? options.viewOptions : {};

this.changeTurn = function() {
if (this.turn == goban.BLACK) {
Expand Down

0 comments on commit 0a964c6

Please sign in to comment.