Exemple #1
0
 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)
Exemple #2
0
 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 )
Exemple #3
0
 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
Exemple #4
0
 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
Exemple #5
0
    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
Exemple #6
0
    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
Exemple #7
0
 def setID( self, id ):
     from Rule import isValidPlayer
     if isValidPlayer( id ):
         self.id = id
     else:
         raise ValueError("Inappropriate argument value of player.")
Exemple #8
0
 def setID(self, id):
     from Rule import isValidPlayer
     if isValidPlayer(id):
         self.id = id
     else:
         raise ValueError("Inappropriate argument value of player.")