#!usr/bin/python class Piece: """All the pieces making the game... """ colorlist = ["white","black"] valuelist = ["pioni", "ippos", "axiomatikos", "pyrgos", "Quenn","King"] def __init__(self, color = 0, value = 0): self.color = color self.value = value def __str__(self): return self.colorlist[self.color] + " " + self.valuelist[self.value] def __cmp__(self, other): if self.value > other.value: return 1 if self.value < other.value: return -1 return 0 class Set: """Ena set me ola ta pionia tis partidas """ def __init__(self): self.pieces=[] for color in range(2): for value in range(8): #Gia ta pionia self.pieces.append(Piece(color)) for i in range(2): #Gia pyrgous,axiomatikous, ippoys for value in range(1,4): self.pieces.append(Piece(color, value)) for value in range(4,6): #Gia Quenn, King self.pieces.append(Piece(color,value)) def __str__(self): s = "" for piece in range(len(self.pieces)): s = s + " "*piece + str(self.pieces[piece]) + "\n" return s class Square: """ To kathe tetragono tis skakieras """ rowlist = ["narf", "a", "b", "c", "d", "e", "f", "g", "h"] def __init__(self, row = 1, line = 1, piece_here = Piece()): self.line = line self.row = row self.piece_here = Piece() def __str__(self): return self.rowlist[self.row] + str(self.line) class Board: """ H skakiera """ present_value = ["p", "b", "n", "r", "q", "k"] def __init__(self): self.squares = [] for line in range(8,0,-1): for row in range(1,9): self.squares.append(Square(row,line)) def PrintBoard(self): #na allaxei na typonei ta pionia kai oxi tis theseis... opos playBoard... s = "" for square in range(len(self.squares)): if square%8 == 0: s = s + "\n" s = s + str(self.squares[square]) + " " return s def start(self): #Ta pionia, gia ta dio xromata for square in range(8,16): piece = self.squares[square].piece_here piece.color = 1 piece.value = 0 for square in range(48,56): piece = self.squares[square].piece_here piece.color = 2 piece.value = 0 #oi pirgoi, for square in [0,7]: piece = self.squares[square].piece_here piece.color = 1 piece.value = 3 for square in [56,63]: piece = self.squares[square].piece_here piece.color = 2 piece.value = 3 #oi ippoi, for square in [1,6]: piece = self.squares[square].piece_here piece.color = 1 piece.value = 1 for square in [57,62]: piece = self.squares[square].piece_here piece.color = 2 piece.value = 1 #oi axiomatikoi, for square in [2,5]: piece = self.squares[square].piece_here piece.color = 1 piece.value = 2 for square in [58,61]: piece = self.squares[square].piece_here piece.color = 2 piece.value = 2 #Queen square = 3 piece = self.squares[square].piece_here piece.color = 1 piece.value = 4 square = 59 piece = self.squares[square].piece_here piece.color = 2 piece.value = 4 #King square = 4 piece = self.squares[square].piece_here piece.color = 1 piece.value = 5 square = 60 piece = self.squares[square].piece_here piece.color = 2 piece.value = 5 def __str__(self): from string import swapcase s = "" for square in range(len(self.squares)): if square%8 == 0: s = s + "\n" if self.squares[square].piece_here.color == 0 and self.squares[square].piece_here.value == 0: s = s + ". " else: piece_here = self.squares[square].piece_here if piece_here.color == 1: s = s + self.present_value[piece_here.value] + " " else: s = s + swapcase(self.present_value[piece_here.value]) + " " return s class Move: """Oi kiniseis ton pionion... feygei apo mia thesi, emfanizetai se alli... """ pass