99from graphik import Graphik
1010from grass import Grass
1111from grid import Grid
12+ from rock import Rock
1213from selectedItemPreview import SelectedItemPreview
1314from leaves import Leaves
1415from location import Location
@@ -136,8 +137,7 @@ def movePlayer(self, direction: int):
136137 self .changeRooms ()
137138 return
138139
139- if self .map .locationContainsEntity (newLocation , Wood ):
140- # apple trees are solid
140+ if self .locationContainsSolidEntity (newLocation ):
141141 return
142142
143143 if self .player .getEnergy () < self .player .getMaxEnergy () * 0.95 :
@@ -162,7 +162,7 @@ def movePlayer(self, direction: int):
162162 self .player .setTickLastMoved (self .tick )
163163
164164 def canBePickedUp (self , entity ):
165- itemTypes = [Wood , Leaves , Grass , Apple ]
165+ itemTypes = [Wood , Leaves , Grass , Apple , Rock ]
166166 for itemType in itemTypes :
167167 if isinstance (entity , itemType ):
168168 return True
@@ -203,6 +203,9 @@ def getLocationInFrontOfPlayer(self):
203203 playerLocation = self .getLocationOfPlayer ()
204204 return self .getLocationDirection (direction , self .currentRoom .grid , playerLocation )
205205
206+ def locationContainsSolidEntity (self , location ):
207+ return self .map .locationContainsEntity (location , Wood ) or self .map .locationContainsEntity (location , Rock )
208+
206209 def executePlaceAction (self ):
207210 if len (self .player .getInventory ().getContents ()) == 0 :
208211 self .status .set ("no items" , self .tick )
@@ -215,8 +218,8 @@ def executePlaceAction(self):
215218 if targetLocation == - 2 :
216219 self .status .set ("can't place while moving" , self .tick )
217220 return
218- if self .map . locationContainsEntity (targetLocation , Wood ):
219- self .status .set ("blocked by wood " , self .tick )
221+ if self .locationContainsSolidEntity (targetLocation ):
222+ self .status .set ("location blocked " , self .tick )
220223 return
221224
222225 toPlace = self .player .getInventory ().getContents ().pop ()
0 commit comments