From ed88747493d14cfe1841a21eb22908b3d3dd9b17 Mon Sep 17 00:00:00 2001 From: Jared Folkins Date: Tue, 8 Mar 2016 17:09:31 -0800 Subject: fix: HandleRight() not updating LastAction, edge case player is kicked --- game.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/game.go b/game.go index 18c10fd..209b776 100644 --- a/game.go +++ b/game.go @@ -4,13 +4,14 @@ import ( "bufio" "bytes" "fmt" - "github.com/dustinkirkland/golang-petname" - "github.com/fatih/color" - "golang.org/x/crypto/ssh" "io" "math/rand" "sort" "time" + + "github.com/dustinkirkland/golang-petname" + "github.com/fatih/color" + "golang.org/x/crypto/ssh" ) type Hub struct { @@ -197,6 +198,7 @@ func (p *Player) HandleDown() { func (p *Player) HandleRight() { p.Direction = PlayerRight p.Marker = playerRightRune + p.s.didAction() } func (p *Player) Score() int { -- cgit v1.2.3 From 4f460ef4a040ae0f144660ef2aceb469de196510 Mon Sep 17 00:00:00 2001 From: Jared Folkins Date: Tue, 8 Mar 2016 17:52:36 -0800 Subject: enhc: prevent player from immediately reversing into their own trail --- game.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/game.go b/game.go index 209b776..f51b726 100644 --- a/game.go +++ b/game.go @@ -178,24 +178,36 @@ func (p *Player) calculateScore(delta float64, playerCount int) float64 { } func (p *Player) HandleUp() { + if p.Direction == PlayerDown { + return + } p.Direction = PlayerUp p.Marker = playerUpRune p.s.didAction() } func (p *Player) HandleLeft() { + if p.Direction == PlayerRight { + return + } p.Direction = PlayerLeft p.Marker = playerLeftRune p.s.didAction() } func (p *Player) HandleDown() { + if p.Direction == PlayerUp { + return + } p.Direction = PlayerDown p.Marker = playerDownRune p.s.didAction() } func (p *Player) HandleRight() { + if p.Direction == PlayerLeft { + return + } p.Direction = PlayerRight p.Marker = playerRightRune p.s.didAction() -- cgit v1.2.3