def removePlayer(self, player): """ Remove all one player's chess from the chessboard. """ from Rule import isValidPlayer if not isValidPlayer(player): raise ValueError("Invalid player id %d" % (player)) for i, Pos in enumerate(self.item): if Pos.isChess(): if Pos.getChess().getOwner() == player: self.remove(i)
def removePlayer( self, player ): """ Remove all one player's chess from the chessboard. """ from Rule import isValidPlayer if not isValidPlayer( player ): raise ValueError( "Invalid player id %d" % ( player ) ) for i, Pos in enumerate( self.item ): if Pos.isChess(): if Pos.getChess().getOwner() == player: self.remove( i )
def fromStringID(cls, source, id): # source = %color "," %name res = source.strip().split(Player.PLAYERSEP, 1) uc = UserColor.valueOf(res[0]) from Rule import isValidPlayer if not isValidPlayer(id) or not uc: raise ValueError("Invalid value of source %s" %(source)) ret = Player(res[1]) ret.setID(id) ret.setColor(uc) print "asdfasdf" return ret
def fromStringID(cls, source, id): # source = %color "," %name res = source.strip().split(Player.PLAYERSEP, 1) uc = UserColor.valueOf(res[0]) from Rule import isValidPlayer if not isValidPlayer(id) or not uc: raise ValueError("Invalid value of source %s" % (source)) ret = Player(res[1]) ret.setID(id) ret.setColor(uc) print "asdfasdf" return ret
def __init__(self, val, own, vis=Visible.VIS_SELF): """ Create a Chess by its value, owner and visibility. If the user cannot see the chess, its value may be unknown. """ from Rule import isValidValue, isValidPlayer if not isValidValue(val): raise ValueError("Invalid chess value %d" % (val)) if not isValidPlayer(own): raise ValueError("Invalid player id %d" % (own)) self.value = val self.owner = own self.visible = vis
def __init__( self, val, own, vis = Visible.VIS_SELF ): """ Create a Chess by its value, owner and visibility. If the user cannot see the chess, its value may be unknown. """ from Rule import isValidValue, isValidPlayer if not isValidValue( val ): raise ValueError( "Invalid chess value %d" % ( val ) ) if not isValidPlayer( own ): raise ValueError( "Invalid player id %d" % ( own ) ) self.value = val self.owner = own self.visible = vis
def setID( self, id ): from Rule import isValidPlayer if isValidPlayer( id ): self.id = id else: raise ValueError("Inappropriate argument value of player.")
def setID(self, id): from Rule import isValidPlayer if isValidPlayer(id): self.id = id else: raise ValueError("Inappropriate argument value of player.")