Fixed a few bugs - stones can now be placed, but captures aren't working right
This commit is contained in:
parent
1474af0e5f
commit
7652ddd596
15
lib/goban.py
15
lib/goban.py
|
@ -50,8 +50,6 @@ class Goban:
|
|||
if not self._valid_move(rpos):
|
||||
return
|
||||
|
||||
# fixme - update the GRAY status of affected squares
|
||||
|
||||
self.board[rpos] = self.to_move
|
||||
self._capture(rpos)
|
||||
|
||||
|
@ -81,8 +79,8 @@ class Goban:
|
|||
return False
|
||||
|
||||
# Can't play atop another stone
|
||||
if self.board[pos] == Goban.EMPTY:
|
||||
return True
|
||||
if self.board[pos] != Goban.EMPTY:
|
||||
return False
|
||||
|
||||
# Temporarily place the stone
|
||||
self.board[pos] = self.to_move
|
||||
|
@ -113,7 +111,7 @@ class Goban:
|
|||
return 0
|
||||
|
||||
if checked is None:
|
||||
bs = board_size * board_size
|
||||
bs = self.board_size * self.board_size
|
||||
checked = [False] * bs
|
||||
|
||||
if checked[pos]:
|
||||
|
@ -156,7 +154,6 @@ class Goban:
|
|||
self.board[x][y].state = Goban.EMPTY
|
||||
|
||||
|
||||
# fixme - needs to be evaluated with new data model
|
||||
def _delete_group_r(self, pos, who):
|
||||
if not self._on_board(pos):
|
||||
return
|
||||
|
@ -187,9 +184,9 @@ class Goban:
|
|||
if point == Goban.EMPTY:
|
||||
s = img_res[self.def_draw_codes[pos]]
|
||||
elif point == Goban.BLACK:
|
||||
s = img_res('b')
|
||||
s = img_res['b']
|
||||
elif point == Goban.WHITE:
|
||||
s = img_res('w')
|
||||
s = img_res['w']
|
||||
|
||||
s = pygame.transform.scale(s, (inc, inc))
|
||||
ret.blit(s, ((pos % self.board_size) *inc, (pos / self.board_size) *inc))
|
||||
|
@ -263,7 +260,7 @@ class Goban:
|
|||
|
||||
|
||||
def _on_board(self, pos):
|
||||
return pos < 0 or pos > self.board_size * self.board_size - 1
|
||||
return pos >= 0 or pos < self.board_size * self.board_size
|
||||
|
||||
|
||||
def _other_color(self, color):
|
||||
|
|
Loading…
Reference in New Issue
Block a user