-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog.py
More file actions
33 lines (24 loc) · 1.1 KB
/
Dog.py
File metadata and controls
33 lines (24 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from Piece import Piece
class Dog(Piece):
def __init__(self, color, name, icon, direction, position):
self.color = color # Blue or Red
self.name = name # Monkey, Cat, Dog or Sheep
self.icon = icon # dog_128_red
self.isActive = False # Is the icon should be active or not
self.direction = direction # 1 = Facing right, -1 = Facing left
self.position = position # Where on the board the piece is, is used for drawing only
def availableMoves(self, currentPos, wantedPos):
print("availableMoves from " + str(currentPos) + " to " + str(wantedPos))
x = currentPos[0]
y = currentPos[1]
x_new = wantedPos[0]
y_new = wantedPos[1]
one_forward_backward = (x + 1 == x_new or x - 1 == x_new) and y == y_new
one_left_right = (y + 1 == y_new or y - 1 == y_new) and x == x_new
return one_forward_backward or one_left_right
def getColor(self):
return self.color
def getName(self):
return self.name
def getPosition(self):
return self.position