X-Git-Url: https://git.ucc.asn.au/?p=progcomp2013.git;a=blobdiff_plain;f=qchess%2Fsrc%2Fpiece.py;h=a2faf9d39d0c1d44f68b1f715047bdff0485e638;hp=400a79a991ee7a2ba8d6b7eede0e71982bba50ff;hb=87681496dec0b1bdadaf0733137010615997fb05;hpb=a35e4dc5f4fb6325785b6f8b123266976107b748 diff --git a/qchess/src/piece.py b/qchess/src/piece.py index 400a79a..a2faf9d 100644 --- a/qchess/src/piece.py +++ b/qchess/src/piece.py @@ -13,13 +13,13 @@ class Piece(): self.types = types # List of possible types the piece can be (should just be two) self.current_type = "unknown" # Current type self.choice = -1 # Index of the current type in self.types (-1 = unknown type) - self.types_revealed = [True, False] # Whether the types are known (by default the first type is always known at game start) - - # + self.last_state = None + self.move_pattern = None - + self.coverage = None + self.possible_moves = {} def init_from_copy(self, c): @@ -29,8 +29,7 @@ class Piece(): self.types = c.types[:] self.current_type = c.current_type self.choice = c.choice - self.types_revealed = c.types_revealed[:] - + self.last_state = None self.move_pattern = None @@ -58,8 +57,11 @@ class Piece(): # Draw the two possible types underneath the current_type image for i in range(len(self.types)): - if always_reveal_states == True or self.types_revealed[i] == True: - img = small_images[self.colour][self.types[i]] + if always_reveal_states == True or self.types[i][0] != '?': + if self.types[i][0] == '?': + img = small_images[self.colour][self.types[i][1:]] + else: + img = small_images[self.colour][self.types[i]] else: img = small_images[self.colour]["unknown"] # If the type hasn't been revealed, show a placeholder @@ -76,17 +78,18 @@ class Piece(): # Collapses the wave function! def select(self): - if self.current_type == "unknown": + if self.current_type == "unknown" or not self.choice in [0,1]: self.choice = random.randint(0,1) + if self.types[self.choice][0] == '?': + self.types[self.choice] = self.types[self.choice][1:] self.current_type = self.types[self.choice] - self.types_revealed[self.choice] = True return self.choice # Uncollapses (?) the wave function! def deselect(self): #print "Deselect called" if (self.x + self.y) % 2 != 0: - if (self.types[0] != self.types[1]) or (self.types_revealed[0] == False or self.types_revealed[1] == False): + if (self.types[0] != self.types[1]) or (self.types[0][0] == '?' or self.types[1][0] == '?'): self.current_type = "unknown" self.choice = -1 else: