def handle_stone(self, node): add = [] for l in node.prop: print "Placing stone at %s" % l x, y = util.pos2xy(l) add.append((x, y)) self.add_stone(x, y, util.str2color(node.name))
def _remove_stones(self, group): remove = [] for prop in group: x, y = util.pos2xy(prop) self.remove_stone(x, y) remove.append((x, y)) super(GoBoard, self).remove_stones(remove)
def handle_move(self, node): "Handle a move. Deal with dead stone, etc. Assuming it's a play node" if node.prop == "": print "PASS" self.emit(QtCore.SIGNAL("newComment(PyQt_PyObject)"), "PASS") return [] else: x, y = util.pos2xy(self.game.where().prop) return self.play_xy(x, y, util.str2color(self.game.where().name))
def refresh_cross(self, node): x, y = util.pos2xy(self.game.where().prop) if (x, y) in self.marks_pos: return cx, cy = self.convert_coord((x, y)) cross = Cross(QtCore.QPointF(cx, cy), 10, self.mask) cross.setZValue(10) self.scene.addItem(cross) self.marks.append(cross) self.marks_pos.append((x, y))
def go_prev(self): prev = self.game.where() if not prev.prop == "": x, y = util.pos2xy(self.game.where().prop) self.remove_stone(x, y) super(GoBoard, self).remove_stones([(x, y)]) try: self.game.back() self.handle_node(prev, self.game.where(), True) except sgf.SGFNoMoreNode: pass
def _handle_MA(self, locs): for l in locs: x, y = util.pos2xy(l) self.add_mark(x, y, 2)
def _handle_SQ(self, locs): for l in locs: x, y = util.pos2xy(l) self.add_square(x, y, 10)
def _handle_TR(self, locs): for l in locs: x, y = util.pos2xy(l) self.add_triangle(x, y, 10)
def _handle_CR(self, locs): for l in locs: x, y = util.pos2xy(l) self.add_circle(x, y, 10)
def _handle_LB(self, labels): for l in labels: pos, char = l.split(":") x, y = util.pos2xy(pos) self.add_label(x, y, char)