Skip to content

Commit 9e55149

Browse files
committed
Add more test coverage
1 parent 5c6554a commit 9e55149

File tree

3 files changed

+377
-58
lines changed

3 files changed

+377
-58
lines changed

game/game.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ func (level *Level) ResolveDamage() {
281281
// Kill ...
282282
func (level *Level) Kill(c *Character) {
283283
if c.Name == "You" {
284+
level.Player.Hitpoints = 0
284285
level.Player.Speed = 0
285286
groundItems := level.Items[c.Pos]
286287
level.Items[c.Pos] = groundItems
@@ -325,6 +326,11 @@ func (level *Level) lineOfSight() {
325326

326327
// Draw a circle around the player and draw a line to each endpoint
327328
func (level *Level) bresenham(start Pos, end Pos) {
329+
// Boundary checks
330+
if !inRange(level, start) || !inRange(level, end) {
331+
return
332+
}
333+
328334
steep := math.Abs(float64(end.Y-start.Y)) > math.Abs(float64(end.X-start.X)) // Is the line steep or not?
329335
// Swap the x and y for start and end
330336
if steep {

0 commit comments

Comments
 (0)