Skip to content

Commit

Permalink
adds returns, change a name
Browse files Browse the repository at this point in the history
  • Loading branch information
Grafne23 committed Jul 27, 2018
1 parent a927cff commit 44f86de
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion server/arena/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (a *Arena) holeCollisions() {

for i, junk := range a.Junk {
if areCirclesColliding(junk.Position, models.JunkRadius, hole.Position, hole.Radius) {
playerScored := junk.LastPlayerHit
playerScored := junk.PlayerHitMe
if playerScored != nil {
playerScored.AddPoints(models.PointsPerJunk)
}
Expand Down
4 changes: 2 additions & 2 deletions server/arena/arena_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ func TestPlayerToJunkCollisions(t *testing.T) {
a.Junk[i].Position = tc.testPosition

a.playerCollisions()
if a.Junk[i].LastPlayerHit != tc.expectedPlayer {
t.Errorf("%s detection failed. Test Player at %v. Junk at %v. Junk Last Player Hit %v", tc.description, a.Players["test"].Position, a.Junk[i].Position, a.Junk[i].LastPlayerHit)
if a.Junk[i].PlayerHitMe != tc.expectedPlayer {
t.Errorf("%s detection failed. Test Player at %v. Junk at %v. Junk Last Player Hit %v", tc.description, a.Players["test"].Position, a.Junk[i].Position, a.Junk[i].PlayerHitMe)
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion server/models/junk.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (j *Junk) HitBy(p *Player) {
}

j.Color = p.Color //Assign junk to last recently hit player color
j.LastPlayerHit = p
j.PlayerHitMe = p

if p.Velocity.Dx < 0 {
j.Velocity.Dx = math.Min(p.Velocity.Dx*BumpFactor, -MinimumBump)
Expand Down
2 changes: 1 addition & 1 deletion server/models/junk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestPlayerBumpJunk(t *testing.T) {
j.HitBy(p)

// Junk should take player's colour and ID
if j.Color != p.Color || j.LastPlayerHit != p {
if j.Color != p.Color || j.PlayerHitMe != p {
t.Error("Error: Junk Collsion didn't transfer ownership")
}

Expand Down

0 comments on commit 44f86de

Please sign in to comment.