Skip to content

Commit

Permalink
Add missing doc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
z-riley committed Nov 14, 2024
1 parent 9622000 commit d7d0fc5
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 1 deletion.
32 changes: 32 additions & 0 deletions common/arena.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,18 +490,22 @@ type moveAnimation struct {
dest coord // tile index
}

// Origin satisfies the animation interface.
func (a moveAnimation) Origin() (coord, error) {
return a.origin, nil
}

// Dest satisfies the animation interface.
func (a moveAnimation) Dest() coord {
return a.dest
}

// NewVal satisfies the animation interface.
func (a moveAnimation) NewVal() (int, error) {
return 0, errFieldDoesNotExist
}

// String satisfies the animation interface.
func (a moveAnimation) String() string {
return fmt.Sprint("move from ", a.origin, " to ", a.dest)
}
Expand All @@ -512,18 +516,22 @@ type spawnAnimation struct {
newVal int // value of a newly spawned tile. 0 if N/A
}

// Origin satisfies the animation interface.
func (a spawnAnimation) Origin() (coord, error) {
return coord{-1, -1}, errFieldDoesNotExist
}

// Dest satisfies the animation interface.
func (a spawnAnimation) Dest() coord {
return a.dest
}

// NewVal satisfies the animation interface.
func (a spawnAnimation) NewVal() (int, error) {
return a.newVal, nil
}

// String satisfies the animation interface.
func (a spawnAnimation) String() string {
return fmt.Sprint("spawn at ", a.dest)
}
Expand All @@ -535,18 +543,22 @@ type moveToCombineAnimation struct {
dest coord // tile index
}

// Origin satisfies the animation interface.
func (a moveToCombineAnimation) Origin() (coord, error) {
return a.origin, nil
}

// Dest satisfies the animation interface.
func (a moveToCombineAnimation) Dest() coord {
return a.dest
}

// NewVal satisfies the animation interface.
func (a moveToCombineAnimation) NewVal() (int, error) {
return -1, errFieldDoesNotExist
}

// String satisfies the animation interface.
func (a moveToCombineAnimation) String() string {
return fmt.Sprint("move-to-combine from ", a.origin, " to ", a.dest)
}
Expand All @@ -558,18 +570,22 @@ type newFromCombineAnimation struct {
newVal int // the value of the newly made tile
}

// Origin satisfies the animation interface.
func (a newFromCombineAnimation) Origin() (coord, error) {
return coord{-1, -1}, errFieldDoesNotExist
}

// Dest satisfies the animation interface.
func (a newFromCombineAnimation) Dest() coord {
return a.dest
}

// NewVal satisfies the animation interface.
func (a newFromCombineAnimation) NewVal() (int, error) {
return a.newVal, nil
}

// String satisfies the animation interface.
func (a newFromCombineAnimation) String() string {
return fmt.Sprint("new-from-combine at ", a.dest)
}
Expand Down Expand Up @@ -664,18 +680,22 @@ type moveRowAnimation struct {
dest int // tile index
}

// Origin satisfies rowAnimation.
func (a moveRowAnimation) Origin() (int, error) {
return a.origin, nil
}

// Dest satisfies rowAnimation.
func (a moveRowAnimation) Dest() int {
return a.dest
}

// NewVal satisfies rowAnimation.
func (a moveRowAnimation) NewVal() (int, error) {
return 0, errFieldDoesNotExist
}

// String satisfies rowAnimation.
func (a moveRowAnimation) String() string {
return fmt.Sprint("move from ", a.origin, " to ", a.dest)
}
Expand All @@ -686,18 +706,22 @@ type spawnRowAnimation struct {
newVal int // value of a newly spawned tile. 0 if N/A
}

// Origin satisfies rowAnimation.
func (a spawnRowAnimation) Origin() (int, error) {
return -1, errFieldDoesNotExist
}

// Dest satisfies rowAnimation.
func (a spawnRowAnimation) Dest() int {
return a.dest
}

// NewVal satisfies rowAnimation.
func (a spawnRowAnimation) NewVal() (int, error) {
return a.newVal, nil
}

// String satisfies rowAnimation.
func (a spawnRowAnimation) String() string {
return fmt.Sprint("spawn at ", a.dest)
}
Expand All @@ -709,18 +733,22 @@ type moveToCombineRowAnimation struct {
dest int // tile index
}

// Origin satisfies rowAnimation.
func (a moveToCombineRowAnimation) Origin() (int, error) {
return a.origin, nil
}

// Dest satisfies rowAnimation.
func (a moveToCombineRowAnimation) Dest() int {
return a.dest
}

// NewVal satisfies rowAnimation.
func (a moveToCombineRowAnimation) NewVal() (int, error) {
return -1, errFieldDoesNotExist
}

// String satisfies rowAnimation.
func (a moveToCombineRowAnimation) String() string {
return fmt.Sprint("move-to-combine from ", a.origin, " to ", a.dest)
}
Expand All @@ -732,18 +760,22 @@ type newFromCombineRowAnimation struct {
newVal int // the value of the newly made tile
}

// Origin satisfies rowAnimation.
func (a newFromCombineRowAnimation) Origin() (int, error) {
return -1, errFieldDoesNotExist
}

// Dest satisfies rowAnimation.
func (a newFromCombineRowAnimation) Dest() int {
return a.dest
}

// NewVal satisfies rowAnimation.
func (a newFromCombineRowAnimation) NewVal() (int, error) {
return a.newVal, nil
}

// String satisfies rowAnimation.
func (a newFromCombineRowAnimation) String() string {
return fmt.Sprint("new-from-combine at ", a.dest)
}
Expand Down
2 changes: 2 additions & 0 deletions debug/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/z-riley/turdgl"
)

// Widget displays diagnostic information about the current window.
type Widget struct {
win *turdgl.Window

Expand All @@ -17,6 +18,7 @@ type Widget struct {
tick <-chan time.Time // for measuring FPS
}

// NewDebugWidget constructs a new debug widget.
func NewDebugWidget(win *turdgl.Window) *Widget {
location := turdgl.NewText("Loc: ", turdgl.Vec{X: 1120, Y: 25}, common.FontPathMedium).
SetAlignment(turdgl.AlignBottomRight).
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/brunoga/deep v1.2.4
github.com/google/uuid v1.6.0
github.com/moby/moby v27.3.1+incompatible
github.com/z-riley/turdgl v0.0.0-20241113204523-7589c7e2d94c
github.com/z-riley/turdgl v0.0.0-20241113214650-431600106ef0
github.com/z-riley/turdserve v0.0.0-20241109095301-66eab11d38af
golang.org/x/exp v0.0.0-20240808152545-0cdaa3abc0fa
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ github.com/z-riley/turdgl v0.0.0-20241111212625-8502d81bbf4b h1:Vf/FWjMHQAcLWjDG
github.com/z-riley/turdgl v0.0.0-20241111212625-8502d81bbf4b/go.mod h1:PUy0rnENvtQrZRghi9dYinsUUE7gvC9wOz8C/gcwJ8A=
github.com/z-riley/turdgl v0.0.0-20241113204523-7589c7e2d94c h1:rY4cuGYihAkPwxwA79jHFhpOfMAyds33epNsxl45zwM=
github.com/z-riley/turdgl v0.0.0-20241113204523-7589c7e2d94c/go.mod h1:PUy0rnENvtQrZRghi9dYinsUUE7gvC9wOz8C/gcwJ8A=
github.com/z-riley/turdgl v0.0.0-20241113214650-431600106ef0 h1:rfBZyL0+kOYmTta4OqjBKVxPW1YC96y1VR5YIpWlW2c=
github.com/z-riley/turdgl v0.0.0-20241113214650-431600106ef0/go.mod h1:PUy0rnENvtQrZRghi9dYinsUUE7gvC9wOz8C/gcwJ8A=
github.com/z-riley/turdserve v0.0.0-20241103172943-200ed8c9c094 h1:9ldkpBMZ5+BV8GOGH+4QhrBgevotAprFgMVCasm+td0=
github.com/z-riley/turdserve v0.0.0-20241103172943-200ed8c9c094/go.mod h1:D5VroZVlQvt0vUtZ2xHL8aQOlCumE/9LFEH1BBLE468=
github.com/z-riley/turdserve v0.0.0-20241109095301-66eab11d38af h1:X0XCfUgoGvZaOZtSRcB6UkuEkP4B6EzwvDUkkZkA7p0=
Expand Down
1 change: 1 addition & 0 deletions screen/multiplayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ func (s *MultiplayerScreen) updateLose() {
s.updateGameEnd()
}

// updateGameEnd draws the appropriate game widgets for when the game has ended.
func (s *MultiplayerScreen) updateGameEnd() {
s.menu.Update(s.win)
s.score.SetBody(strconv.Itoa(s.backend.Score))
Expand Down
1 change: 1 addition & 0 deletions screen/multiplayer_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ func (s *MultiplayerHostScreen) handlePlayerData(data comms.PlayerData) error {
return nil
}

// handleOpponentDisconnect handles the opponent disconnecting from the server.
func (s *MultiplayerHostScreen) handleOpponentDisconnect() {
s.opponentStatus.SetText(fmt.Sprintf("Waiting for opponent to join \"%s\"", getIPAddr()))
s.opponentIsConnected = false
Expand Down

0 comments on commit d7d0fc5

Please sign in to comment.