Implemented basic scoring code, so that scoring estimates are drawn at the end of a game
This commit is contained in:
@ -50,6 +50,13 @@ class GoGame(gtk.HBox):
|
||||
for row in info_rows:
|
||||
info_box.pack_start(row, expand=False)
|
||||
|
||||
self.winner_box = gtk.HBox()
|
||||
self.winner_value = gtk.Label('None')
|
||||
self.winner_box.pack_start(gtk.Label('Winner:'), expand=False, padding=5)
|
||||
self.winner_box.pack_end(self.winner_value, expand=False, padding=5)
|
||||
|
||||
info_box.pack_start(self.winner_box, expand=False)
|
||||
|
||||
self.pass_button = gtk.Button('Pass')
|
||||
self.resign_button = gtk.Button('Resign')
|
||||
self.pass_button.connect('clicked', self.on_pass)
|
||||
@ -185,6 +192,16 @@ class GoGame(gtk.HBox):
|
||||
move = 'White'
|
||||
else:
|
||||
move = 'None'
|
||||
|
||||
if self.goban.winner != goban.Goban.EMPTY:
|
||||
if self.goban.winner == goban.Goban.BLACK:
|
||||
self.winner_value.set_text('Black')
|
||||
elif self.goban.winner == goban.Goban.WHITE:
|
||||
self.winner_value.set_text('White')
|
||||
elif self.goban.winner == goban.Goban.SCORING:
|
||||
self.winner_value.set_text('Scoring')
|
||||
self.winner_box.show()
|
||||
|
||||
self.to_move_value.set_text(move)
|
||||
self.black_cap_value.set_text(str(self.goban.black_captures))
|
||||
self.white_cap_value.set_text(str(self.goban.white_captures))
|
||||
@ -210,10 +227,9 @@ def _build_img_res():
|
||||
circle_black = _load_png('go_circle_black.png')
|
||||
circle_white = _load_png('go_circle_white.png')
|
||||
square = _load_png('go_square.png')
|
||||
bs = _load_png('go_bs.png')
|
||||
ws = _load_png('go_ws.png')
|
||||
|
||||
ret['wH'] = _load_png('go_wH.png')
|
||||
ret['bH'] = _load_png('go_bH.png')
|
||||
|
||||
ret['wT'] = _load_png('go_w.png')
|
||||
width = ret['wT'].get_width()
|
||||
height = ret['wT'].get_height()
|
||||
@ -236,7 +252,7 @@ def _build_img_res():
|
||||
ret['d'] = base.copy().rotate_simple(180)
|
||||
ret['r'] = base.copy().rotate_simple(270)
|
||||
|
||||
for d in ('m', 'h', 'w', 'b'):
|
||||
for d in ('m', 'h', 'w', 'b', 'wH', 'bH', 'ws', 'bs'):
|
||||
ret[d] = _load_png('go_' + d + '.png')
|
||||
|
||||
for d in ('u', 'd', 'l', 'r', 'm', 'dl', 'dr', 'ul', 'ur', 'h', 'w', 'b'):
|
||||
@ -260,6 +276,17 @@ def _build_img_res():
|
||||
height = ret[d + 'S'].get_height()
|
||||
square.composite(ret[d + 'S'], 0, 0, width, height, 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255)
|
||||
|
||||
ret[d + 'ws'] = ret[d].copy()
|
||||
width = ret[d + 'ws'].get_width()
|
||||
height = ret[d + 'ws'].get_height()
|
||||
ws.composite(ret[d + 'ws'], 0, 0, width, height, 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255)
|
||||
|
||||
ret[d + 'bs'] = ret[d].copy()
|
||||
width = ret[d + 'bs'].get_width()
|
||||
height = ret[d + 'bs'].get_height()
|
||||
bs.composite(ret[d + 'bs'], 0, 0, width, height, 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255)
|
||||
|
||||
|
||||
|
||||
return ret
|
||||
|
||||
|
Reference in New Issue
Block a user