Commit 9c1fad01 authored by Boris Mühmer's avatar Boris Mühmer
Browse files

splitted some types to own files

parent 467cb91a
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -8,7 +8,8 @@ import (
	"time"

	"repositories.muehmer.net/bsmrgo/tictactoe/game"
	"repositories.muehmer.net/bsmrgo/tictactoe/grid"
	"repositories.muehmer.net/bsmrgo/tictactoe/grid/cross"
	"repositories.muehmer.net/bsmrgo/tictactoe/grid/nought"
)

func main() {
@@ -25,7 +26,7 @@ func main() {
	rand.Seed(seed)

	g := game.New()
	g.AddPlayer(name1, &grid.Cross{})
	g.AddPlayer(name2, &grid.Nought{})
	g.AddPlayer(name1, &cross.Cross{})
	g.AddPlayer(name2, &nought.Nought{})
	g.Run()
}
+4 −3
Original line number Diff line number Diff line
@@ -4,7 +4,8 @@ import (
	"math/rand"
	"testing"

	"repositories.muehmer.net/bsmrgo/tictactoe/grid"
	"repositories.muehmer.net/bsmrgo/tictactoe/grid/cross"
	"repositories.muehmer.net/bsmrgo/tictactoe/grid/nought"
)

func TestGame(t *testing.T) {
@@ -12,8 +13,8 @@ func TestGame(t *testing.T) {
	seed := int64(1557681173)
	rand.Seed(seed)

	c1 := &grid.Cross{}
	c2 := &grid.Nought{}
	c1 := &cross.Cross{}
	c2 := &nought.Nought{}

	g := New()
	g.AddPlayer("Player 1", c1)

grid/cell.go

0 → 100644
+9 −0
Original line number Diff line number Diff line
package grid

// Cell ...
type Cell interface {
	Symbol() string
	IsEmpty() bool
	IsNought() bool
	IsCross() bool
}

grid/cross/cross.go

0 → 100644
+24 −0
Original line number Diff line number Diff line
package cross

// Cross ...
type Cross struct{}

// Symbol ...
func (c *Cross) Symbol() string {
	return "×"
}

// IsEmpty ...
func (c *Cross) IsEmpty() bool {
	return false
}

// IsNought ...
func (c *Cross) IsNought() bool {
	return false
}

// IsCross ...
func (c *Cross) IsCross() bool {
	return true
}
+1 −0
Original line number Diff line number Diff line
package cross
Loading