Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
katacliny committed Nov 1, 2020
1 parent ccaa79a commit c603e17
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 102 deletions.
Binary file modified __pycache__/bishop.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/handletablemove.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/horse.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/king.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/move.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/pawn.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/pice.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/piece.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/queen.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/table.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/tower.cpython-38.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion bishop.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#test
from pice import Piece
from piece import Piece
from move import up, down, rigth, left, bishopDownRigth, bishopDownLeft, bishopUpRigth, bishopUpLeft

class Bishop(Piece):
Expand Down
66 changes: 33 additions & 33 deletions chess.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pygame as py
from table import Table
from pice import Piece
from piece import Piece
from pawn import Pawn
from queen import Queen
from bishop import Bishop
Expand All @@ -23,42 +23,42 @@
def mainThread():

table = Table()
table.addPice(1, 0, Pawn(1, 0, pawn_color, table.table_map))
table.addPice(1, 1, Pawn(1, 1, pawn_color, table.table_map))
table.addPice(1, 2, Pawn(1, 2, pawn_color, table.table_map))
table.addPice(1, 3, Pawn(1, 3, pawn_color, table.table_map))
table.addPice(1, 4, Pawn(1, 4, pawn_color, table.table_map))
table.addPice(1, 5, Pawn(1, 5, pawn_color, table.table_map))
table.addPice(1, 6, Pawn(1, 6, pawn_color, table.table_map))
table.addPice(1, 7, Pawn(1, 7, pawn_color, table.table_map))
table.addpiece(1, 0, Pawn(1, 0, pawn_color, table.table_map))
table.addpiece(1, 1, Pawn(1, 1, pawn_color, table.table_map))
table.addpiece(1, 2, Pawn(1, 2, pawn_color, table.table_map))
table.addpiece(1, 3, Pawn(1, 3, pawn_color, table.table_map))
table.addpiece(1, 4, Pawn(1, 4, pawn_color, table.table_map))
table.addpiece(1, 5, Pawn(1, 5, pawn_color, table.table_map))
table.addpiece(1, 6, Pawn(1, 6, pawn_color, table.table_map))
table.addpiece(1, 7, Pawn(1, 7, pawn_color, table.table_map))

table.addPice(0, 0, Tower(0, 0, tower_color, table.table_map))
table.addPice(0, 1, Horse(0, 1, horse_color, table.table_map))
table.addPice(0, 2, Bishop(0, 2, bishop_color, table.table_map))
table.addPice(0, 3, King(0, 3, king_color, table.table_map))
table.addPice(0, 4, Queen(0, 4, quin_color, table.table_map))
table.addPice(0, 5, Bishop(0, 5, bishop_color, table.table_map))
table.addPice(0, 6, Horse(0, 6, horse_color, table.table_map))
table.addPice(0, 7, Tower(0, 7, tower_color, table.table_map))
table.addpiece(0, 0, Tower(0, 0, tower_color, table.table_map))
table.addpiece(0, 1, Horse(0, 1, horse_color, table.table_map))
table.addpiece(0, 2, Bishop(0, 2, bishop_color, table.table_map))
table.addpiece(0, 3, King(0, 3, king_color, table.table_map))
table.addpiece(0, 4, Queen(0, 4, quin_color, table.table_map))
table.addpiece(0, 5, Bishop(0, 5, bishop_color, table.table_map))
table.addpiece(0, 6, Horse(0, 6, horse_color, table.table_map))
table.addpiece(0, 7, Tower(0, 7, tower_color, table.table_map))


table.addPice(6, 0, Pawn(6, 0, pawn_color, table.table_map, True))
table.addPice(6, 1, Pawn(6, 1, pawn_color, table.table_map, True))
table.addPice(6, 2, Pawn(6, 2, pawn_color, table.table_map, True))
table.addPice(6, 3, Pawn(6, 3, pawn_color, table.table_map, True))
table.addPice(6, 4, Pawn(6, 4, pawn_color, table.table_map, True))
table.addPice(6, 5, Pawn(6, 5, pawn_color, table.table_map, True))
table.addPice(6, 6, Pawn(6, 6, pawn_color, table.table_map, True))
table.addPice(6, 7, Pawn(6, 7, pawn_color, table.table_map, True))
table.addpiece(6, 0, Pawn(6, 0, pawn_color, table.table_map, True))
table.addpiece(6, 1, Pawn(6, 1, pawn_color, table.table_map, True))
table.addpiece(6, 2, Pawn(6, 2, pawn_color, table.table_map, True))
table.addpiece(6, 3, Pawn(6, 3, pawn_color, table.table_map, True))
table.addpiece(6, 4, Pawn(6, 4, pawn_color, table.table_map, True))
table.addpiece(6, 5, Pawn(6, 5, pawn_color, table.table_map, True))
table.addpiece(6, 6, Pawn(6, 6, pawn_color, table.table_map, True))
table.addpiece(6, 7, Pawn(6, 7, pawn_color, table.table_map, True))

table.addPice(7, 0, Tower(7, 0, tower_color, table.table_map))
table.addPice(7, 1, Horse(7, 1, horse_color, table.table_map))
table.addPice(7, 2, Bishop(7, 2, bishop_color, table.table_map))
table.addPice(7, 3, King(7, 3, king_color, table.table_map))
table.addPice(7, 4, Queen(7, 4, quin_color, table.table_map))
table.addPice(7, 5, Bishop(7, 5, bishop_color, table.table_map))
table.addPice(7, 6, Horse(7, 6, horse_color, table.table_map))
table.addPice(7, 7, Tower(7, 7, tower_color, table.table_map))
table.addpiece(7, 0, Tower(7, 0, tower_color, table.table_map))
table.addpiece(7, 1, Horse(7, 1, horse_color, table.table_map))
table.addpiece(7, 2, Bishop(7, 2, bishop_color, table.table_map))
table.addpiece(7, 3, King(7, 3, king_color, table.table_map))
table.addpiece(7, 4, Queen(7, 4, quin_color, table.table_map))
table.addpiece(7, 5, Bishop(7, 5, bishop_color, table.table_map))
table.addpiece(7, 6, Horse(7, 6, horse_color, table.table_map))
table.addpiece(7, 7, Tower(7, 7, tower_color, table.table_map))

while True:
for evento in py.event.get():
Expand Down
16 changes: 9 additions & 7 deletions handletablemove.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ class HandlerTableMove:

currentSelection = []
table_map = []
block = False

def interchange(self):

print("intercambio")

@staticmethod
Expand All @@ -15,19 +15,21 @@ def getCurrentSelection(cls):

@staticmethod
def setSelection(cls, selection):
print("entraaaa")
if selection not in cls.currentSelection:
if selection not in cls.currentSelection and len(cls.currentSelection) < 2:
cls.currentSelection.append(selection)

@staticmethod
def select(cls):
if len(cls.currentSelection) == 2:
if len(cls.currentSelection) > 1:
first = cls.currentSelection[1][2]
second = cls.currentSelection[0][2]
save = (second.posx, second.posy)
second.posx = first.posx
second.posy = first.posy
first.posx = save[0]
first.posy = save[1]
cls.table_map[cls.currentSelection[0][0]][cls.currentSelection[0][1]] = first
cls.table_map[cls.currentSelection[1][0]][cls.currentSelection[1][1]] = second
print(cls.currentSelection)
print("hace la seleccion")
print(cls.table_map)

cls.currentSelection = []

2 changes: 1 addition & 1 deletion horse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pice import Piece
from piece import Piece
from move import up, down, rigth, left, horseDownRigth, horseDownLeft, horseUpnLeft, horseUpnRigth

class Horse(Piece):
Expand Down
2 changes: 1 addition & 1 deletion king.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pice import Piece
from piece import Piece
from move import up, down, rigth, left

class King(Piece):
Expand Down
80 changes: 40 additions & 40 deletions move.py
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
def up(pice, rangelen, currentiteration=0):
def up(piece, rangelen, currentiteration=0):
positions = []
for y in range(pice.posy-rangelen, pice.posy):
for y in range(piece.posy-rangelen, piece.posy):
if y > 0:
positions.append((pice.posx, y))
positions.append((piece.posx, y))
return positions


def down(pice, rangelen, currentiteration=0):
def down(piece, rangelen, currentiteration=0):
positions = []
for y in range(pice.posy + 1, pice.posy + rangelen + 1):
for y in range(piece.posy + 1, piece.posy + rangelen + 1):
if y < 8:
positions.append((pice.posx, y))
positions.append((piece.posx, y))
return positions


def rigth(pice, rangelen, currentiteration=0):
def rigth(piece, rangelen, currentiteration=0):
positions = []
for x in range(pice.posx + 1, pice.posx + rangelen + 1):
for x in range(piece.posx + 1, piece.posx + rangelen + 1):
if x < 8:
positions.append((x, pice.posy))
positions.append((x, piece.posy))
return positions


def left(pice, rangelen, currentiteration=0):
def left(piece, rangelen, currentiteration=0):
positions = []
for x in range(pice.posx-rangelen, pice.posx):
for x in range(piece.posx-rangelen, piece.posx):
if x > 0:
positions.append((x, pice.posy))
positions.append((x, piece.posy))
return positions


def bishopDownRigth(pice, rangelen, currentiteration=0):
def bishopDownRigth(piece, rangelen, currentiteration=0):
positions = []
for x in range(pice.posy, pice.posy + rangelen + 1):
if pice.posx + x < 8 and pice.posy + x < 8:
positions.append((pice.posx + x, pice.posy + x))
for x in range(piece.posy, piece.posy + rangelen + 1):
if piece.posx + x < 8 and piece.posy + x < 8:
positions.append((piece.posx + x, piece.posy + x))
return positions


def bishopDownLeft(pice, rangelen, currentiteration=0):
def bishopDownLeft(piece, rangelen, currentiteration=0):
positions = []
for x in range(pice.posy, pice.posy + rangelen + 1):
if pice.posx - x >= 0 and pice.posy + x < 8:
positions.append((pice.posx - x, pice.posy + x))
for x in range(piece.posy, piece.posy + rangelen + 1):
if piece.posx - x >= 0 and piece.posy + x < 8:
positions.append((piece.posx - x, piece.posy + x))
return positions


def bishopUpRigth(pice, rangelen, currentiteration=0):
def bishopUpRigth(piece, rangelen, currentiteration=0):
positions = []
for x in range(pice.posy - rangelen, pice.posy):
if pice.posx + (abs(x)) < 8 and pice.posy - abs(x) >= 0:
positions.append((pice.posx + (abs(x)), pice.posy - abs(x)))
for x in range(piece.posy - rangelen, piece.posy):
if piece.posx + (abs(x)) < 8 and piece.posy - abs(x) >= 0:
positions.append((piece.posx + (abs(x)), piece.posy - abs(x)))
return positions


def bishopUpLeft(pice, rangelen, currentiteration=0):
def bishopUpLeft(piece, rangelen, currentiteration=0):
positions = []
for x in range(pice.posy - rangelen, pice.posy):
if pice.posx - (abs(x)) >= 0 and pice.posy - abs(x) >= 0:
positions.append((pice.posx - (abs(x)), pice.posy - abs(x)))
for x in range(piece.posy - rangelen, piece.posy):
if piece.posx - (abs(x)) >= 0 and piece.posy - abs(x) >= 0:
positions.append((piece.posx - (abs(x)), piece.posy - abs(x)))
return positions


def horseDownRigth(pice, rangelen, currentiteration=0):
def horseDownRigth(piece, rangelen, currentiteration=0):
positions = []
if pice.posx + 1 < 8 and pice.posy + rangelen < 8:
positions.append((pice.posx + 1, pice.posy + rangelen))
if piece.posx + 1 < 8 and piece.posy + rangelen < 8:
positions.append((piece.posx + 1, piece.posy + rangelen))

return positions


def horseDownLeft(pice, rangelen, currentiteration=0):
def horseDownLeft(piece, rangelen, currentiteration=0):
positions = []
if pice.posx - 1 >= 0 and pice.posy + rangelen < 8:
positions.append((pice.posx - 1, pice.posy + rangelen))
if piece.posx - 1 >= 0 and piece.posy + rangelen < 8:
positions.append((piece.posx - 1, piece.posy + rangelen))

return positions

def horseUpnLeft(pice, rangelen, currentiteration=0):
def horseUpnLeft(piece, rangelen, currentiteration=0):
positions = []
if pice.posx - 1 >= 0 and pice.posy - rangelen >= 0:
positions.append((pice.posx - 1, pice.posy - rangelen))
if piece.posx - 1 >= 0 and piece.posy - rangelen >= 0:
positions.append((piece.posx - 1, piece.posy - rangelen))

return positions


def horseUpnRigth(pice, rangelen, currentiteration=0):
def horseUpnRigth(piece, rangelen, currentiteration=0):
positions = []
if pice.posx + 1 < 8 and pice.posy - rangelen >= 0:
positions.append((pice.posx + 1, pice.posy - rangelen))
if piece.posx + 1 < 8 and piece.posy - rangelen >= 0:
positions.append((piece.posx + 1, piece.posy - rangelen))

return positions

2 changes: 1 addition & 1 deletion pawn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pice import Piece
from piece import Piece
from move import up, down, rigth, left

class Pawn(Piece):
Expand Down
14 changes: 7 additions & 7 deletions pice.py → piece.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

class Piece:

def __init__(self, posx, posy, table_map, p_type="N", text_color=(0,0,0), move = [], rangelen = 1, color = ()):
def __init__(self, posx: int, posy: int, table_map, p_type: str ="N", text_color: tuple =(0,0,0), move = [], rangelen: int = 1, color: tuple = ()):
self.posx = posx
self.posy = posy
self.table_map = table_map
self.higthLight = (250, 0, 0)
self.higthLight = (250, 200, 100)
self.p_type = p_type
self.text_color = text_color
self.is_selected = False
Expand All @@ -31,18 +31,18 @@ def rangeAtackShow(self):
def rangeAtackValidate(self):
pass

def isOverSelected(self, py, pice):
def isOverSelected(self, py, piece):
mouseposs = py.mouse.get_pos()
is_over_selected = [False, False]
if mouseposs[0] > (pice.posx * 50) and mouseposs[0] < (pice.posx * 50) + 50 and mouseposs[1] > (pice.posy * 50) and mouseposs[1] < (pice.posy * 50) + 50:
if py.mouse.get_pressed()[0] is 1 and not self.is_selected:
HandlerTableMove.setSelection(HandlerTableMove, (pice.posx, pice.posy, pice))
if mouseposs[0] > (piece.posx * 50) and mouseposs[0] < (piece.posx * 50) + 50 and mouseposs[1] > (piece.posy * 50) and mouseposs[1] < (piece.posy * 50) + 50:
if py.mouse.get_pressed()[0] == 1 and not self.is_selected:
HandlerTableMove.setSelection(HandlerTableMove, (piece.posx, piece.posy, piece))
HandlerTableMove.table_map = self.table_map
HandlerTableMove.select(HandlerTableMove)
self.is_selected = True
is_over_selected[0] = True
else:
if py.mouse.get_pressed()[0] is 1:
if py.mouse.get_pressed()[0] == 1:
self.is_selected = False
is_over_selected[0] = False

Expand Down
2 changes: 1 addition & 1 deletion queen.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pice import Piece
from piece import Piece
from move import up, down, rigth, left, bishopDownRigth, bishopDownLeft, bishopUpRigth, bishopUpLeft

class Queen(Piece):
Expand Down
18 changes: 9 additions & 9 deletions table.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pice import Piece
from piece import Piece

class WhiteSpace(Piece):

Expand All @@ -18,7 +18,7 @@ class Table:
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0],]

table_pices = []
table_pieces = []

@staticmethod
def getTableMap(cls):
Expand All @@ -29,21 +29,21 @@ def getTableMap(cls):
def updateTableMap(cls, table_map):
cls.table_map = table_map

def deletePice(self, pice):
self.table_pices.remove(pice)
def deletepiece(self, piece):
self.table_pieces.remove(piece)

def addPice(self, posy, posx, pice):
self.table_map[posx][posy] = pice
def addpiece(self, posy, posx, piece):
self.table_map[posx][posy] = piece

def render(self, display, py, font):
contx = 0
conty = 0
for row in self.table_map:
for pice in row:
if pice is 0:
for piece in row:
if piece == 0:
pass
else:
pice.render(display, py, self.table_map, font)
piece.render(display, py, self.table_map, font)
conty+=1
contx += 1
conty = 0
2 changes: 1 addition & 1 deletion tower.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pice import Piece
from piece import Piece
from move import up, down, rigth, left

class Tower(Piece):
Expand Down
Empty file added validators.py
Empty file.

0 comments on commit c603e17

Please sign in to comment.