예제 #1
0
파일: tableau.py 프로젝트: jdiller/gaps
    def find_moveable_for_gap(self, gap):
        if gap[1] == 0:
            twos = [pos for pos in self.find_by_rank(Ranks.TWO) if pos[1] > 0]
            return twos[0]

        neighbour = self.card_at((gap[0], gap[1]-1))
        loc = None
        if neighbour != None and neighbour.rank != Ranks.KING:
            loc = self.find_card(Card(neighbour.suit,
                Ranks.higher_rank(neighbour.rank)))
        return loc
예제 #2
0
파일: tableau.py 프로젝트: jdiller/gaps
 def find_moveable(self):
     gaps = self.find_gaps()
     moveable = []
     for g in gaps:
         if g[1] == 0:
             twos = self.find_by_rank(Ranks.TWO)
             for two in twos:
                 if not two[1] == 0:
                     moveable.append(two)
         else:
             neighbour = self.card_at((g[0], g[1]-1))
             if neighbour != None and neighbour.rank != Ranks.KING:
                 next_rank = Ranks.higher_rank(neighbour.rank)
                 moveable_card = Card(neighbour.suit, next_rank)
                 moveable_loc = self.find_card(moveable_card)
                 moveable.append(moveable_loc)
     return moveable