Entities inside a wall can't see anything
The test for "one step in each cardinal direction is always visible" was giving a false-negative for an entity at the same position as a wall - not only is this something that would ostensibly never happen, it's also completely reasonable to assume that someone stuck in a wall (due to a bad teleport perhaps?) wouldn't be able to see anything, on account of their head being INSIDE A WALL.
This commit is contained in:
		
							parent
							
								
									2320cfa8cd
								
							
						
					
					
						commit
						9ec51e5123
					
				
					 2 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -56,8 +56,7 @@ linesOfSight (view _Position -> pos) visionRadius em
 | 
				
			||||||
visibleEntities :: Entity e => Position -> Word -> EntityMap e -> EntityMap e
 | 
					visibleEntities :: Entity e => Position -> Word -> EntityMap e -> EntityMap e
 | 
				
			||||||
visibleEntities pos visionRadius
 | 
					visibleEntities pos visionRadius
 | 
				
			||||||
  = fromEIDsAndPositioned
 | 
					  = fromEIDsAndPositioned
 | 
				
			||||||
  . fold
 | 
					  . foldMap (\(p, es) -> over _2 (Positioned p) <$> es)
 | 
				
			||||||
  . map (\(p, es) -> over _2 (Positioned p) <$> es)
 | 
					 | 
				
			||||||
  . fold
 | 
					  . fold
 | 
				
			||||||
  . linesOfSight pos visionRadius
 | 
					  . linesOfSight pos visionRadius
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,7 @@ test = testGroup "Xanthous.Data.EntityMap.Graphics"
 | 
				
			||||||
  [ testGroup "visiblePositions"
 | 
					  [ testGroup "visiblePositions"
 | 
				
			||||||
    [ testProperty "one step in each cardinal direction is always visible"
 | 
					    [ testProperty "one step in each cardinal direction is always visible"
 | 
				
			||||||
      $ \pos (Cardinal dir) (Positive r) (wallPositions :: Set Position)->
 | 
					      $ \pos (Cardinal dir) (Positive r) (wallPositions :: Set Position)->
 | 
				
			||||||
 | 
					          pos `notMember` wallPositions ==>
 | 
				
			||||||
          let em = review _EntityMap . map (, Wall) . toList $ wallPositions
 | 
					          let em = review _EntityMap . map (, Wall) . toList $ wallPositions
 | 
				
			||||||
              em' = em & atPosition (move dir pos) %~ (Wall <|)
 | 
					              em' = em & atPosition (move dir pos) %~ (Wall <|)
 | 
				
			||||||
              poss = visiblePositions pos r em'
 | 
					              poss = visiblePositions pos r em'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue