bar works somewhat if black goes on there. Still can't get off it
This commit is contained in:
parent
7993da0db7
commit
716413e2b6
|
@ -82,7 +82,7 @@ class Board_painter:
|
|||
|
||||
self.clock = pygame.time.Clock()
|
||||
|
||||
self.buckets = [[5,-1],[0,0],[0,0],[0,0],[3,1],[0,0],[5,1],[0,0],[0,0],[0,0],[0,0],[2,-1],[5,1],[0,0],[0,0],[0,0],[3,-1],[0,0],[5,-1],[0,0],[0,0],[0,0],[0,0],[2,1]]
|
||||
self.buckets = [[0,0],[5,-1],[0,0],[0,0],[0,0],[3,1],[0,0],[5,1],[0,0],[0,0],[0,0],[0,0],[2,-1],[5,1],[0,0],[0,0],[0,0],[3,-1],[0,0],[5,-1],[0,0],[0,0],[0,0],[0,0],[2,1],[0,0]]
|
||||
self.running = True
|
||||
self.player = -1
|
||||
|
||||
|
@ -114,12 +114,12 @@ class Board_painter:
|
|||
|
||||
def gen_board_from_buckets(self, buckets):
|
||||
board = []
|
||||
board.append([0,0])
|
||||
for i in range(-1,-13,-1):
|
||||
board.append(buckets[0])
|
||||
for i in range(-2,-14,-1):
|
||||
board.append(buckets[i])
|
||||
for i in range(0,12):
|
||||
for i in range(1,13):
|
||||
board.append(buckets[i])
|
||||
board.append([0,0])
|
||||
board.append(buckets[25])
|
||||
board = [x*y for x,y in board]
|
||||
|
||||
return board
|
||||
|
@ -138,25 +138,33 @@ class Board_painter:
|
|||
x -= 50 if x > 550 else 0
|
||||
if y < 175:
|
||||
pin = (13 + int(x / SPACING))
|
||||
idx = int(x / SPACING)
|
||||
idx = 1+int(x / SPACING)
|
||||
elif y > 225:
|
||||
pin = (12 - int(x / SPACING))
|
||||
idx = 12+ int(x / SPACING)
|
||||
idx = 13+ int(x / SPACING)
|
||||
return pin, idx
|
||||
|
||||
# Find the y position based on the chosen pin
|
||||
def calc_pos(self, buckets, chosen):
|
||||
amount = buckets[chosen][0]
|
||||
print(chosen)
|
||||
SPACING = self.SPACING
|
||||
|
||||
if chosen > 11:
|
||||
if chosen == 0:
|
||||
x = 525
|
||||
y = 350
|
||||
elif chosen == 26:
|
||||
x = 525
|
||||
y = 50
|
||||
else:
|
||||
if chosen > 12:
|
||||
# print("Amount at pin:", amount)
|
||||
y = 378 - (30 * amount)
|
||||
chosen -= 11
|
||||
chosen -= 12
|
||||
x = (SPACING*(chosen-1))+(SPACING/2)
|
||||
x += 50 if x > 500 else 0
|
||||
else:
|
||||
chosen += 1
|
||||
|
||||
y = 30 * amount
|
||||
x = (SPACING*(chosen-1))+(SPACING/2)
|
||||
x += 50 if x > 500 else 0
|
||||
|
@ -167,6 +175,7 @@ class Board_painter:
|
|||
board = from_board
|
||||
sets = []
|
||||
total = 0
|
||||
print("board!:",board)
|
||||
for r in roll:
|
||||
# print("Value of r:",r)
|
||||
sets.append([Board.calculate_legal_states(board, player, [r,0]), r])
|
||||
|
@ -256,6 +265,39 @@ class Board_painter:
|
|||
if any(meh):
|
||||
is_true = np.where(meh)[0][0]
|
||||
|
||||
pin, idx = self.find_pin(event.pos)
|
||||
x, y = self.calc_pos(buckets,idx)
|
||||
|
||||
# Need to take care of bar stuff :<
|
||||
if (buckets[idx][1] == player*-1) and buckets[idx][0] == 1:
|
||||
to_idx = 0 if buckets[idx][1] == 1 else 25
|
||||
enemy_rects = self.all_rects[player*-1]
|
||||
|
||||
|
||||
# Have some check if we're looking for either rects in the bottom or top,
|
||||
# instead of having both here
|
||||
neg_tester = [rect.collidepoint(x,y-30) for rect in enemy_rects]
|
||||
pos_tester = [rect.collidepoint(x,y+40) for rect in enemy_rects]
|
||||
print("Neg tester:",neg_tester)
|
||||
print("Pos tester:",pos_tester)
|
||||
if any(neg_tester):
|
||||
enemy = np.where(neg_tester)[0][0]
|
||||
elif any(pos_tester):
|
||||
enemy = np.where(pos_tester)[0][0]
|
||||
|
||||
buckets[to_idx][0] += 1
|
||||
buckets[to_idx][1] = buckets[idx][1]
|
||||
|
||||
bar_x, bar_y = self.calc_pos(buckets, to_idx)
|
||||
enemy_rects[enemy].x = bar_x
|
||||
enemy_rects[enemy].y = bar_y
|
||||
|
||||
|
||||
buckets[idx][0] = 0
|
||||
print("In here"*20)
|
||||
|
||||
|
||||
|
||||
pin, idx = self.find_pin(event.pos)
|
||||
x, y = self.calc_pos(buckets,idx)
|
||||
buckets[idx][0] += 1
|
||||
|
@ -267,11 +309,12 @@ class Board_painter:
|
|||
# print(move_legal(from_board, buckets, [1,2]))
|
||||
|
||||
|
||||
|
||||
print("from board:",self.from_board)
|
||||
# if self.move_legal(self.from_board, buckets, self.roll):
|
||||
|
||||
sets = self.calc_move_sets(self.from_board, self.roll, player)
|
||||
pot_board = self.gen_board_from_buckets(buckets)
|
||||
sets = self.calc_move_sets(self.from_board, self.roll, player)
|
||||
|
||||
print("potential board:",pot_board)
|
||||
# print("board:",pot_board)
|
||||
truth_values = []
|
||||
for t in sets:
|
||||
|
|
Loading…
Reference in New Issue
Block a user