letters to numbers, numbers to letters
This commit is contained in:
parent
b4cfdd77fb
commit
be58e3b9d9
34
board.py
34
board.py
@ -98,8 +98,40 @@ class Board:
|
||||
#print(self.board.boardlist[self.final_row][self.final_column].piece.name)
|
||||
#print(self.initial_row, self.initial_column)
|
||||
#print(self.final_row, self.final_column)
|
||||
if self.initial_column == 0:
|
||||
self.initial_column = "A"
|
||||
elif self.initial_column == 1:
|
||||
self.initial_column = "B"
|
||||
elif self.initial_column == 2:
|
||||
self.initial_column = "C"
|
||||
elif self.initial_column == 3:
|
||||
self.initial_column = "D"
|
||||
elif self.initial_column == 4:
|
||||
self.initial_column = "E"
|
||||
elif self.initial_column == 5:
|
||||
self.initial_column = "F"
|
||||
elif self.initial_column == 6:
|
||||
self.initial_column = "G"
|
||||
elif self.initial_column == 7:
|
||||
self.initial_column = "H"
|
||||
|
||||
self.ruch = str(self.initial_row) + str(self.initial_column) + ' ' + str(self.final_row) + str(self.final_column)
|
||||
if self.final_column == 0:
|
||||
self.final_column = "A"
|
||||
elif self.final_column == 1:
|
||||
self.final_column = "B"
|
||||
elif self.final_column == 2:
|
||||
self.final_column = "C"
|
||||
elif self.final_column == 3:
|
||||
self.final_column = "D"
|
||||
elif self.final_column == 4:
|
||||
self.final_column = "E"
|
||||
elif self.final_column == 5:
|
||||
self.final_column = "F"
|
||||
elif self.final_column == 6:
|
||||
self.final_column = "G"
|
||||
elif self.final_column == 7:
|
||||
self.final_column = "H"
|
||||
self.ruch = str(self.initial_column)+str(self.initial_row) + ' ' +str(self.final_column)+ str(self.final_row)
|
||||
return self.ruch
|
||||
|
||||
|
||||
|
65
game.py
65
game.py
@ -72,37 +72,54 @@ class Game:
|
||||
self.b.append('6')
|
||||
self.b.append('7')
|
||||
print(self.b)
|
||||
# sprawdzenie
|
||||
# H
|
||||
# self.board.calc_moves(self.board.boardlist[7][6].piece, 7, 6)
|
||||
# print(self.board.boardlist[7][6].piece.valid_moves)
|
||||
# P
|
||||
# print(self.board.boardlist[6][0].piece.valid_moves)
|
||||
# R
|
||||
#print(self.board.boardlist[5][1].piece.color)
|
||||
#print(self.board.boardlist[5][1].piece.valid_moves)
|
||||
|
||||
|
||||
def nextMove(self, ruch):
|
||||
if ruch == 'noone':
|
||||
return Board.move_boot(self, 'white')
|
||||
|
||||
else:
|
||||
self.from_row = int(ruch[0])
|
||||
self.from_column=int(ruch[1])
|
||||
self.to_row=int(ruch[3])
|
||||
self.to_column=int(ruch[4])
|
||||
self.from_column = ruch[0]
|
||||
self.from_row = int(ruch[1])
|
||||
self.to_column = ruch[3]
|
||||
self.to_row = int(ruch[4])
|
||||
|
||||
if self.from_column == 'A':
|
||||
self.from_column = 0
|
||||
elif self.from_column == 'B':
|
||||
self.from_column = 1
|
||||
elif self.from_column == 'C':
|
||||
self.from_column = 2
|
||||
elif self.from_column == 'D':
|
||||
self.from_column = 3
|
||||
elif self.from_column == 'E':
|
||||
self.from_column = 4
|
||||
elif self.from_column == 'F':
|
||||
self.from_column = 5
|
||||
elif self.from_column == 'G':
|
||||
self.from_column = 6
|
||||
elif self.from_column == 'H':
|
||||
self.from_column = 7
|
||||
|
||||
if self.to_column == 'A':
|
||||
self.to_column = 0
|
||||
elif self.to_column == 'B':
|
||||
self.to_column = 1
|
||||
elif self.to_column == 'C':
|
||||
self.to_column = 2
|
||||
elif self.to_column == 'D':
|
||||
self.to_column = 3
|
||||
elif self.to_column == 'E':
|
||||
self.to_column = 4
|
||||
elif self.to_column == 'F':
|
||||
self.to_column = 5
|
||||
elif self.to_column == 'G':
|
||||
self.to_column = 6
|
||||
elif self.to_column == 'H':
|
||||
self.to_column = 7
|
||||
|
||||
self.color = Board.move_rival(self, self.from_row, self.from_column, self.to_row, self.to_column)
|
||||
return Board.move_boot(self, self.color)
|
||||
|
||||
"""
|
||||
def make_move_rival(self):
|
||||
self.przeciwnik = input(str('Podaj ruch: '))
|
||||
self.from_row = int(self.przeciwnik[0])
|
||||
self.from_column = int(self.przeciwnik[1])
|
||||
self.to_row = int(self.przeciwnik[3])
|
||||
self.to_column = int(self.przeciwnik[4])
|
||||
return Board.move_rival(self, self.from_row, self.from_column, self.to_row, self.to_column)
|
||||
def make_move_boot(self, color):
|
||||
return Board.move_boot(self, color)
|
||||
"""
|
||||
|
||||
|
||||
|
13
main.py
13
main.py
@ -7,12 +7,15 @@ print('')
|
||||
game2.printBoard()
|
||||
print('')
|
||||
boot_color = 'white'
|
||||
a=0
|
||||
#a=0
|
||||
ruch='noone'
|
||||
|
||||
|
||||
|
||||
while True:
|
||||
print('')
|
||||
a=a+1
|
||||
print(a)
|
||||
#a=a+1
|
||||
#print(a)
|
||||
ruch = game.nextMove(ruch)
|
||||
if(ruch==1):
|
||||
game.printBoard()
|
||||
@ -20,8 +23,8 @@ while True:
|
||||
exit(0)
|
||||
game.printBoard()
|
||||
print('')
|
||||
a = a + 1
|
||||
print(a)
|
||||
#a = a + 1
|
||||
#print(a)
|
||||
ruch = game2.nextMove(ruch)
|
||||
if (ruch == 1):
|
||||
game2.printBoard()
|
||||
|
Loading…
Reference in New Issue
Block a user