Skip to content

Commit

Permalink
Change guide message on win
Browse files Browse the repository at this point in the history
  • Loading branch information
z-riley committed Oct 19, 2024
1 parent ed84730 commit 96d7add
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions backend/grid/grid.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (g *Grid) Outcome() Outcome {
switch {
case g.isLoss():
return Lose
case g.highestTile() >= 2048:
case g.HighestTile() >= 2048:
return Win
default:
return None
Expand Down Expand Up @@ -266,8 +266,8 @@ func (g *Grid) isLoss() bool {
return true
}

// highestTile returns the value of the highest tile on the grid.
func (g *Grid) highestTile() int {
// HighestTile returns the value of the highest tile on the grid.
func (g *Grid) HighestTile() int {
highest := 0
for a := range gridHeight {
for b := range gridWidth {
Expand Down
3 changes: 1 addition & 2 deletions common/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ func NewArena(pos turdgl.Vec) *Arena {
}

// Destroy tears down the arena.
func (a *Arena) Destroy() {
}
func (a *Arena) Destroy() {}

// Draw draws the arena.
func (a *Arena) Draw(buf *turdgl.FrameBuffer) {
Expand Down
3 changes: 1 addition & 2 deletions screen/multiplayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ type MultiplayerScreen struct {
opponentArena *common.Arena
opponentBackend *backend.Game

// TODO: find a neater way of doing client/server polymorphism
// but don't forget to account for 1 server -> multiple clients
// EITHER server or client will exist
server *turdserve.Server
client *turdserve.Client
}
Expand Down
8 changes: 5 additions & 3 deletions screen/singleplayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ func (s *SingleplayerScreen) Update() {

// Check for win or lose
switch game.Grid.Outcome() {
case grid.None:
s.updateNormal(game)
case grid.Win:
s.updateWin(game)
case grid.Lose:
s.updateLose(game)
default:
s.updateNormal(game)
}

// Draw temporary debug grid
Expand Down Expand Up @@ -255,7 +255,9 @@ func (s *SingleplayerScreen) updateNormal(game backend.Game) {

// updateWin updates and draws the singleplayer screen in a winning state.
func (s *SingleplayerScreen) updateWin(game backend.Game) {
// No special win screen for now
s.guide.SetText(
fmt.Sprintf("Your next goal is to get to the %d tile!", game.Grid.HighestTile()*2),
)
s.updateNormal(game)
}

Expand Down

0 comments on commit 96d7add

Please sign in to comment.