コード例 #1
0
 public static int combinePieces(int p1, int p2)
 {
     // Combines a piece that is a person or house, with a regular piece.  Order is unimportant.
     // Returns the failure piece if neither piece is a plain person or house.
     if (Pieces.isTile(p1))
     {
         int t = p1; p1 = p2; p2 = t;
     }
     if (Pieces.isPerson(p1) && Pieces.isTile(p2))
     {
         return(Pieces.setPersonNumber(p2, Pieces.personNumber(p1)));
     }
     if (Pieces.isHouse(p1) && Pieces.isTile(p2))
     {
         return(Pieces.setHouseNumber(p2, Pieces.houseNumber(p1)));
     }
     return(Pieces.createFailurePiece());
 }