Koniec wygladu planszy

This commit is contained in:
Arkadiusz 2019-06-05 01:19:55 +01:00
parent 818eb2e8df
commit 4b20e617b4
11 changed files with 158 additions and 50 deletions

View File

@ -2,12 +2,11 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="152ea650-8e02-4ed6-aa8c-04d44b275be4" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/wasteTable.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Images/stolik.png" beforeDir="false" afterPath="$PROJECT_DIR$/Images/stolik.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Images/waiter.png" beforeDir="false" afterPath="$PROJECT_DIR$/Images/waiter.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/game.py" beforeDir="false" afterPath="$PROJECT_DIR$/game.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/orderTable.py" beforeDir="false" afterPath="$PROJECT_DIR$/orderTable.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/savedPaths.txt" beforeDir="false" afterPath="$PROJECT_DIR$/savedPaths.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/table.py" beforeDir="false" afterPath="$PROJECT_DIR$/table.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/waiter.py" beforeDir="false" afterPath="$PROJECT_DIR$/waiter.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -30,8 +29,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/game.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264">
<caret line="66" column="56" selection-start-line="66" selection-start-column="56" selection-end-line="66" selection-end-column="56" />
<state relative-caret-position="792">
<caret line="69" column="62" selection-start-line="69" selection-start-column="62" selection-end-line="69" selection-end-column="62" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
@ -56,7 +55,7 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/table.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-16">
<state relative-caret-position="72">
<caret line="10" column="6" selection-start-line="10" selection-start-column="6" selection-end-line="10" selection-end-column="6" />
</state>
</provider>
@ -74,23 +73,32 @@
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/orderTable.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264">
<caret line="12" column="37" lean-forward="true" selection-start-line="12" selection-start-column="37" selection-end-line="12" selection-end-column="37" />
<state relative-caret-position="198">
<caret line="9" column="45" lean-forward="true" selection-start-line="9" selection-start-column="45" selection-end-line="9" selection-end-column="45" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/waiter.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="305">
<caret line="441" column="34" selection-start-line="441" selection-start-column="34" selection-end-line="441" selection-end-column="34" />
<folding>
<element signature="e#0#14#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/waiter.py">
<entry file="file://$PROJECT_DIR$/wasteTable.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-87">
<caret line="109" column="28" lean-forward="true" selection-start-line="109" selection-start-column="28" selection-end-line="109" selection-end-column="28" />
<folding>
<element signature="e#0#14#0" expanded="true" />
</folding>
<state>
<caret column="13" lean-forward="true" selection-start-column="13" selection-end-column="13" />
</state>
</provider>
</entry>
@ -109,6 +117,7 @@
<find>self.last</find>
<find>tmp</find>
<find>visited</find>
<find>drow</find>
</findStrings>
</component>
<component name="Git.Settings">
@ -131,10 +140,11 @@
<option value="$PROJECT_DIR$/run.py" />
<option value="$PROJECT_DIR$/order.py" />
<option value="$PROJECT_DIR$/pool.py" />
<option value="$PROJECT_DIR$/waiter.py" />
<option value="$PROJECT_DIR$/table.py" />
<option value="$PROJECT_DIR$/game.py" />
<option value="$PROJECT_DIR$/orderTable.py" />
<option value="$PROJECT_DIR$/wasteTable.py" />
<option value="$PROJECT_DIR$/game.py" />
<option value="$PROJECT_DIR$/waiter.py" />
</list>
</option>
</component>
@ -431,16 +441,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/order.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="132">
<caret line="6" selection-start-line="6" selection-end-line="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/Images/tableSmall.png">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/pool.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
@ -451,10 +451,20 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/table.py">
<entry file="file://$PROJECT_DIR$/Images/tableSmall.png">
<provider selected="true" editor-type-id="images" />
</entry>
<entry file="file://$PROJECT_DIR$/orderTable.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-16">
<caret line="10" column="6" selection-start-line="10" selection-start-column="6" selection-end-line="10" selection-end-column="6" />
<state relative-caret-position="198">
<caret line="9" column="45" lean-forward="true" selection-start-line="9" selection-start-column="45" selection-end-line="9" selection-end-column="45" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/wasteTable.py">
<provider selected="true" editor-type-id="text-editor">
<state>
<caret column="13" lean-forward="true" selection-start-column="13" selection-end-column="13" />
</state>
</provider>
</entry>
@ -465,32 +475,39 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/table.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="72">
<caret line="10" column="6" selection-start-line="10" selection-start-column="6" selection-end-line="10" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/game.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264">
<caret line="66" column="56" selection-start-line="66" selection-start-column="56" selection-end-line="66" selection-end-column="56" />
<state relative-caret-position="792">
<caret line="69" column="62" selection-start-line="69" selection-start-column="62" selection-end-line="69" selection-end-column="62" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/order.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="132">
<caret line="6" selection-start-line="6" selection-end-line="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/waiter.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-87">
<caret line="109" column="28" lean-forward="true" selection-start-line="109" selection-start-column="28" selection-end-line="109" selection-end-column="28" />
<state relative-caret-position="305">
<caret line="441" column="34" selection-start-line="441" selection-start-column="34" selection-end-line="441" selection-end-column="34" />
<folding>
<element signature="e#0#14#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/orderTable.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264">
<caret line="12" column="37" lean-forward="true" selection-start-line="12" selection-start-column="37" selection-end-line="12" selection-end-column="37" />
</state>
</provider>
</entry>
</component>
</project>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
Images/waiterJedzenie.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

BIN
Images/zmywak.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Binary file not shown.

View File

@ -5,6 +5,7 @@ from gridElement import GridElement
from pygame.math import Vector2
from orderTable import OrderTable
from pool import Pool
from wasteTable import WasteTable
from operator import attrgetter
import copy
@ -52,8 +53,10 @@ class Game(object):
self.waiterNumberInGrid.x = i
self.waiterNumberInGrid.y = b
elif (((((b > 0 and b < 6) and (i > 0 and i < 9)) and not((i == 1 or i == 8) and (b == 1 or b == 5))) \
or (b > 6 and (i < 4 or i > 5)))) and not i == 4 and not (b == 3):
or (b > 6 and (i < 4 or i > 5)))) and not i == 4 and not (b == 3) and not (i==3 and b==9):
self.row.append(Pool(i * 50, b * 50, self))
elif i == 3 and b == 9:
self.row.append(WasteTable(i * 50, b * 50, self))
else:
self.row.append(GridElement(i * 50, b * 50, self))
if i == self.x-1:
@ -113,6 +116,8 @@ class Game(object):
return 'O'
elif object.type == "pool":
return 'P'
elif object.type == "wasteTable":
return 'Z'
def showGrid(self, grid):

View File

@ -40,3 +40,30 @@
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']
['Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Up', 'Left', 'Left', 'Left', 'Left']
['Right', 'Right', 'Right', 'Down', 'Down', 'Down', 'Down', 'Down', 'Down', 'Right', 'Right', 'Right', 'Right', 'Right']

View File

@ -20,7 +20,7 @@ class Waiter(object):
self.image.set_colorkey((255, 255, 255))
self.type = "waiter"
self.lastStep = []
self.whatKeep = 0
self.dfsStack = []
self.dfsPaths = []
@ -52,7 +52,7 @@ class Waiter(object):
#print(self.positionX)
self.lastStep.append("Left")
else:
pass
self.work(collisionObject)
def moveRight(self):
if self.positionX != self.game.x-1:
collisionObject = self.game.grid[self.positionY][self.positionX + 1]
@ -67,7 +67,7 @@ class Waiter(object):
#print(self.positionX)
self.lastStep.append("Right")
else:
pass
self.work(collisionObject)
def moveUp(self):
if self.positionY != 0:
@ -82,7 +82,7 @@ class Waiter(object):
self.positionY -= 1
self.lastStep.append("Up")
else:
pass
self.work(collisionObject)
def moveDown(self):
if self.positionY != self.game.y-1:
@ -97,7 +97,7 @@ class Waiter(object):
self.positionY += 1
self.lastStep.append("Down")
else:
pass
self.work(collisionObject)
# SPRAWDZA NACIŚNIĘTE KLAWISZE
@ -119,8 +119,12 @@ class Waiter(object):
def draw(self):
self.rect1 = pygame.Rect(self.x, self.y, 50, 50)
pygame.draw.rect(self.game.screen, (0, 150, 255), self.rect1)
#print(self.lastStep)
self.game.screen.blit(self.image, (self.x, self.y))
if self.whatKeep == 0:
self.game.screen.blit(self.image, (self.x, self.y))
elif self.whatKeep == 1:
self.game.screen.blit(pygame.image.load("./Images/waiterJedzenie.png"), (self.x, self.y))
elif self.whatKeep == 2:
self.game.screen.blit(pygame.image.load("./Images/waiterBrudneTalerze.png"), (self.x, self.y))
# SPRAWDZA CZY ELELEMNT, KTORY POBIERAMY NIE JEST SPOZA PLANSZY
def isMoveInRange(self, move, position):
@ -322,24 +326,28 @@ class Waiter(object):
if self.isMoveInRange("Up", position):
if self.grid[positionY - 1][positionX].type == "table":
if self.grid[positionY - 1][positionX].id == idTable:
currentOperation.append("Up")
self.bfsPaths.append(currentOperation)
print("Dodalem sciezke: ", currentOperation)
return 0
if self.isMoveInRange("Down", position):
if self.grid[positionY + 1][positionX].type == "table":
if self.grid[positionY + 1][positionX].id == idTable:
currentOperation.append("Down")
self.bfsPaths.append(currentOperation)
print("Dodalem sciezke: ", currentOperation)
return 0
if self.isMoveInRange("Left", position):
if self.grid[positionY][positionX - 1].type == "table":
if self.grid[positionY][positionX - 1].id == idTable:
currentOperation.append("Left")
self.bfsPaths.append(currentOperation)
print("Dodalem sciezke: ", currentOperation)
return 0
if self.isMoveInRange("Right", position):
if self.grid[positionY][positionX + 1].type == "table":
if self.grid[positionY][positionX + 1].id == idTable:
currentOperation.append("Right")
self.bfsPaths.append(currentOperation)
print("Dodalem sciezke: ", currentOperation)
return 0
@ -404,4 +412,37 @@ class Waiter(object):
if direction == "Down":
self.moveDown()
self.game.draw()
time.sleep(.50)
time.sleep(.50)
def takeDish(self, orderTable):
orderTable.hasDish = False
self.whatKeep = 1
def putDish(self, table):
self.whatKeep = 0
table.hasDish = True
table.isWaiting = False
def takePlate(self, table):
table.hasDish = False
table.isClean = True
self.whatKeep = 2
def putPlate(self):
self.whatKeep = 0
def takeOrder(self, table):
table.isOrdering = False
def work(self, object: object) -> object:
if object.type == "wasteTable":
self.putPlate()
elif object.type == "orderTable":
self.takeDish(object)
elif object.type == "table":
if not object.isClean:
self.takePlate(object)
elif object.isOrdering:
self.takeOrder(object)
elif object.isWaiting and self.whatKeep == 1:
self.putDish(object)

18
wasteTable.py Normal file
View File

@ -0,0 +1,18 @@
import pygame
class WasteTable(object):
def __init__(self, x, y, game):
self.game = game
game.idItem += 1
self.idItem = game.idItem
self.x = x
self.y = y
self.image = pygame.image.load("./Images/zmywak.png")
self.type = "wasteTable"
def draw(self):
self.rect = pygame.Rect(self.x, self.y, 50, 50)
self.game.screen.blit(pygame.image.load("./Images/zmywak.png"), (self.x, self.y))