-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pieces.py
57 lines (45 loc) · 2 KB
/
Pieces.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from Bin import Chess_Images
from abc import ABC, abstractmethod
class Pieces(ABC):
@abstractmethod
def __init__(self,x:int,y:int,side:bool):
self.x = x
self.y = y
self.side = side # True = Black
self.tag = 'Blk' if side else 'Wht' # Naming automation
self.Alive = True # Alive = on board
def Inbound(x,y):
pass
class King(Pieces):
def __init__(self,x,y,side):
Pieces.__init__(self,x,y,side)
self.img = Chess_Images.blk_king if self.side else Chess_Images.wht_king
self.name = self.tag + ' ' + 'King'+ ' ' + str(self.y) +str(self.x)
class Queen(Pieces):
def __init__(self,x,y,side):
Pieces.__init__(self,x,y,side)
self.img = Chess_Images.blk_queen if self.side else Chess_Images.wht_queen
self.name = self.tag + ' ' + 'Queen'+ ' ' + str(self.y) +str(self.x)
class Bishop(Pieces):
def __init__(self,x,y,side):
Pieces.__init__(self,x,y,side)
self.img = Chess_Images.blk_bishop if self.side else Chess_Images.wht_bishop
self.name = self.tag + ' ' + 'Bishop'+ ' ' + str(self.y) +str(self.x)
class Rook(Pieces):
def __init__(self,x,y,side):
Pieces.__init__(self,x,y,side)
self.img = Chess_Images.blk_rook if self.side else Chess_Images.wht_rook
self.name = self.tag + ' ' + 'Rook'+ ' ' + str(self.y) +str(self.x)
class Knight(Pieces):
def __init__(self,x,y,side):
Pieces.__init__(self,x,y,side)
self.img = Chess_Images.blk_knight if self.side else Chess_Images.wht_knight
self.name = self.tag + ' ' + 'Knight'+ ' ' + str(self.y) +str(self.x)
class Pawn(Pieces):
def __init__(self,x,y,side):
Pieces.__init__(self,x,y,side)
self.img = Chess_Images.blk_pawn if self.side else Chess_Images.wht_pawn
self.name = self.tag + ' ' + 'Pawn'+ ' ' + str(self.y) +str(self.x)
def move(self,xnew,ynew,):
if self.side:
self.x +=1