Esempio n. 1
0
class Field():
    id = None
    pawns = None

    def __init__(self, id):
        self.id = id
        self.pawns = Pawns()

    def addPawn(self, pawn: Pawn):
        pawn.fieldId = self.id
        self.pawns.append(pawn)

    def getPawnOnTop(self):
        return self.pawns.getLastPawnInList()

    def removePawnFromTop(self):
        self.pawns.pop()

    def accepts(self, pawn: Pawn) -> bool:
        color = GET_OPPOSITE_COLOR(pawn.color)
        return 2 > self.pawns.countPawnsInColor(color)

    def hasOnePawnToBeat(self, pawn: Pawn) -> bool:
        color = GET_OPPOSITE_COLOR(pawn.color)
        return self.pawns.countPawnsInColor(color) == 1
Esempio n. 2
0
 def getPawnsFromBar(self):
     pawns = Pawns()
     for pawn in self.pawns:
         if pawn.fieldId in (0, 25):
             pawns.append(pawn)
     return pawns