@@ -0,0 +1,3 @@
|
||||
module github.com/iliadenisov/galaxy/client
|
||||
|
||||
go 1.26.0
|
||||
@@ -0,0 +1,11 @@
|
||||
module galaxy/error
|
||||
|
||||
go 1.26.0
|
||||
|
||||
require github.com/stretchr/testify v1.11.1
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
@@ -0,0 +1,15 @@
|
||||
go 1.26.0
|
||||
|
||||
use (
|
||||
./client
|
||||
./error
|
||||
./model
|
||||
./server
|
||||
./util
|
||||
)
|
||||
|
||||
replace (
|
||||
galaxy/error v0.0.0 => ./error
|
||||
galaxy/model v0.0.0 => ./model
|
||||
galaxy/util v0.0.0 => ./util
|
||||
)
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
||||
github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI=
|
||||
github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc=
|
||||
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
|
||||
golang.org/x/term v0.33.0/go.mod h1:s18+ql9tYWp1IfpV9DmCtQDDSRBUjKaw9M1eAv5UeF0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
@@ -0,0 +1,3 @@
|
||||
module galaxy/model
|
||||
|
||||
go 1.26.0
|
||||
@@ -3,8 +3,9 @@ package report
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
n "galaxy/util"
|
||||
|
||||
"github.com/google/uuid"
|
||||
n "github.com/iliadenisov/galaxy/internal/number"
|
||||
)
|
||||
|
||||
type Float float64
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/router"
|
||||
"github.com/iliadenisov/galaxy/server/internal/router"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -1,4 +1,4 @@
|
||||
module github.com/iliadenisov/galaxy
|
||||
module github.com/iliadenisov/galaxy/server
|
||||
|
||||
go 1.26.0
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/bitmap"
|
||||
"github.com/iliadenisov/galaxy/server/internal/bitmap"
|
||||
)
|
||||
|
||||
func TestBitVectorSize(t *testing.T) {
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
type Battle struct {
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"galaxy/model/report"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/report"
|
||||
)
|
||||
|
||||
func TransformBattle(c *Cache, b *Battle) *report.BattleReport {
|
||||
@@ -2,7 +2,7 @@ package controller
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) ProduceBombings() []*game.Bombing {
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
type Cache struct {
|
||||
@@ -3,9 +3,10 @@ package controller
|
||||
import (
|
||||
"strings"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
// RaceID returns ID of race with given actor's name or error when race not found or extinct
|
||||
@@ -4,10 +4,12 @@ import (
|
||||
"errors"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/model/order"
|
||||
"github.com/iliadenisov/galaxy/internal/model/report"
|
||||
"github.com/iliadenisov/galaxy/internal/repo"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
|
||||
"galaxy/model/order"
|
||||
"galaxy/model/report"
|
||||
|
||||
"github.com/iliadenisov/galaxy/server/internal/repo"
|
||||
)
|
||||
|
||||
type Configurer func(*Param)
|
||||
+3
-2
@@ -3,9 +3,10 @@ package controller
|
||||
import (
|
||||
"iter"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) CreateShips(ri int, shipTypeName string, planetNumber uint, quantity int) error {
|
||||
+2
-2
@@ -4,8 +4,8 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -6,10 +6,12 @@ import (
|
||||
"math"
|
||||
"slices"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
var fleetStateNil = game.ShipGroupState("-")
|
||||
@@ -1,9 +1,11 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) FleetSend(ri, fi int, planetNumber uint) error {
|
||||
+3
-2
@@ -4,8 +4,9 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -5,9 +5,10 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/generator"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/generator"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func NewGame(r Repo, races []string) (uuid.UUID, error) {
|
||||
+5
-4
@@ -6,11 +6,12 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/repo"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"github.com/iliadenisov/galaxy/server/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/repo"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"galaxy/model/report"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/model/report"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Controller) MakeTurn() error {
|
||||
@@ -4,10 +4,12 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"galaxy/model/order"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/model/order"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Controller) ValidateOrder(actor string, commands ...order.DecodableCommand) (err error) {
|
||||
@@ -5,11 +5,12 @@ import (
|
||||
"iter"
|
||||
"slices"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/number"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) PlanetRename(ri int, number int, name string) error {
|
||||
@@ -184,7 +185,7 @@ func (c *Cache) TurnPlanetProductions() {
|
||||
cost := sg.StateUpgrade.Cost()
|
||||
if productionAvailable >= cost {
|
||||
for i := range sg.StateUpgrade.UpgradeTech {
|
||||
sg.Tech = sg.Tech.Set(sg.StateUpgrade.UpgradeTech[i].Tech, number.Fixed3(sg.StateUpgrade.UpgradeTech[i].Level.F()))
|
||||
sg.Tech = sg.Tech.Set(sg.StateUpgrade.UpgradeTech[i].Tech, util.Fixed3(sg.StateUpgrade.UpgradeTech[i].Level.F()))
|
||||
}
|
||||
productionAvailable -= cost
|
||||
}
|
||||
@@ -4,11 +4,13 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/number"
|
||||
"github.com/iliadenisov/galaxy/server/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -280,7 +282,7 @@ func TestProduceShip(t *testing.T) {
|
||||
(&hw).Material = 900. // no material deficit
|
||||
r = controller.ProduceShip(&hw, hw.ProductionCapacity(), BattleShip.EmptyMass())
|
||||
assert.Equal(t, uint(1), r)
|
||||
assert.Equal(t, number.Fixed12(1./9.), (*hw.Production.Progress).F())
|
||||
assert.Equal(t, util.Fixed12(1./9.), (*hw.Production.Progress).F())
|
||||
|
||||
//
|
||||
// real report data
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"iter"
|
||||
"slices"
|
||||
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) Relation(r1, r2 int) game.Relation {
|
||||
@@ -3,8 +3,9 @@ package controller_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -6,10 +6,12 @@ import (
|
||||
"iter"
|
||||
"slices"
|
||||
|
||||
mr "galaxy/model/report"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
mr "github.com/iliadenisov/galaxy/internal/model/report"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) Report(t uint, battles []*mr.BattleReport, bombings []*mr.Bombing) iter.Seq[*mr.Report] {
|
||||
@@ -3,7 +3,7 @@ package controller_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/model/report"
|
||||
"galaxy/model/report"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -8,9 +8,11 @@ import (
|
||||
"math/rand/v2"
|
||||
"slices"
|
||||
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) PlanetRouteSet(ri int, rt game.RouteType, origin, destination uint) error {
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/iliadenisov/galaxy/server/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
@@ -4,10 +4,12 @@ import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) ScienceCreate(ri int, name string, drive, weapons, shileds, cargo float64) error {
|
||||
@@ -3,10 +3,11 @@ package controller_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -5,10 +5,12 @@ import (
|
||||
"iter"
|
||||
"slices"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) ShipClassCreate(ri int, typeName string, drive float64, ammo int, weapons, shileds, cargo float64) error {
|
||||
+2
-1
@@ -5,7 +5,8 @@ import (
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -7,11 +7,12 @@ import (
|
||||
"maps"
|
||||
"slices"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/number"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
// ShipGroup is a proxy func, nothing to cache
|
||||
@@ -526,16 +527,16 @@ func (c *Cache) unsafeCreateShips(ri int, classID uuid.UUID, planet uint, quanti
|
||||
st := c.MustShipType(ri, classID)
|
||||
level := func(t game.Tech) float64 {
|
||||
if t == game.TechDrive && st.DriveBlockMass() > 0 {
|
||||
return number.Fixed3(c.g.Race[ri].TechLevel(game.TechDrive))
|
||||
return util.Fixed3(c.g.Race[ri].TechLevel(game.TechDrive))
|
||||
}
|
||||
if t == game.TechWeapons && st.WeaponsBlockMass() > 0 {
|
||||
return number.Fixed3(c.g.Race[ri].TechLevel(game.TechWeapons))
|
||||
return util.Fixed3(c.g.Race[ri].TechLevel(game.TechWeapons))
|
||||
}
|
||||
if t == game.TechShields && st.ShieldsBlockMass() > 0 {
|
||||
return number.Fixed3(c.g.Race[ri].TechLevel(game.TechShields))
|
||||
return util.Fixed3(c.g.Race[ri].TechLevel(game.TechShields))
|
||||
}
|
||||
if t == game.TechCargo && st.CargoBlockMass() > 0 {
|
||||
return number.Fixed3(c.g.Race[ri].TechLevel(game.TechCargo))
|
||||
return util.Fixed3(c.g.Race[ri].TechLevel(game.TechCargo))
|
||||
}
|
||||
return 0
|
||||
}
|
||||
+3
-2
@@ -4,8 +4,9 @@ import (
|
||||
"fmt"
|
||||
"iter"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"galaxy/util"
|
||||
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) MoveShipGroups() {
|
||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
||||
"slices"
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
+5
-3
@@ -1,10 +1,12 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) shipGroupSend(ri int, groupID uuid.UUID, planetNumber uint) error {
|
||||
+4
-3
@@ -3,10 +3,11 @@ package controller_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
+13
-11
@@ -6,10 +6,12 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/number"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -177,9 +179,9 @@ func TestShipGroupBreak(t *testing.T) {
|
||||
assert.NotNil(t, c.ShipGroup(3).FleetID)
|
||||
|
||||
assert.Equal(t, game.CargoColonist.Ref(), c.ShipGroup(0).CargoType)
|
||||
assert.Equal(t, 24.6, number.Fixed3(c.ShipGroup(0).Load.F()))
|
||||
assert.Equal(t, 24.6, util.Fixed3(c.ShipGroup(0).Load.F()))
|
||||
assert.Equal(t, game.CargoColonist.Ref(), c.ShipGroup(3).CargoType)
|
||||
assert.Equal(t, 8.2, number.Fixed3(c.ShipGroup(3).Load.F()))
|
||||
assert.Equal(t, 8.2, util.Fixed3(c.ShipGroup(3).Load.F()))
|
||||
|
||||
// group #1 -> MAX 6 off the fleet
|
||||
assert.NoError(t, g.ShipGroupBreak(Race_0.Name, c.ShipGroup(0).ID, uuid.New(), 6)) // group #1 (0)
|
||||
@@ -452,22 +454,22 @@ func TestShipGroupUnload(t *testing.T) {
|
||||
|
||||
// unload MAT on foreign planet / limited
|
||||
assert.NoError(t, g.ShipGroupUnload(Race_0.Name, c.ShipGroup(5).ID, 20.1))
|
||||
assert.Equal(t, 20.1, number.Fixed3(c.MustPlanet(R1_Planet_1_num).Material.F()))
|
||||
assert.Equal(t, 20.1, util.Fixed3(c.MustPlanet(R1_Planet_1_num).Material.F()))
|
||||
assert.Equal(t, game.CargoMaterial.Ref(), c.ShipGroup(5).CargoType)
|
||||
assert.Equal(t, 79.9, number.Fixed3(c.ShipGroup(5).Load.F()))
|
||||
assert.Equal(t, 79.9, util.Fixed3(c.ShipGroup(5).Load.F()))
|
||||
|
||||
// unload MAT on foreign planet / ALL
|
||||
assert.NoError(t, g.ShipGroupUnload(Race_0.Name, c.ShipGroup(5).ID, 0))
|
||||
assert.Equal(t, 100.0, number.Fixed3(c.MustPlanet(R1_Planet_1_num).Material.F()))
|
||||
assert.Equal(t, 0.0, number.Fixed3(c.ShipGroup(5).Load.F()))
|
||||
assert.Equal(t, 100.0, util.Fixed3(c.MustPlanet(R1_Planet_1_num).Material.F()))
|
||||
assert.Equal(t, 0.0, util.Fixed3(c.ShipGroup(5).Load.F()))
|
||||
assert.Nil(t, c.ShipGroup(5).CargoType)
|
||||
|
||||
// unload ALL
|
||||
c.ShipGroup(0).CargoType = game.CargoColonist.Ref()
|
||||
c.ShipGroup(0).Load = 100
|
||||
assert.NoError(t, g.ShipGroupUnload(Race_0.Name, c.ShipGroup(0).ID, 101))
|
||||
assert.Equal(t, 100.0, number.Fixed3(c.MustPlanet(R0_Planet_0_num).Colonists.F()))
|
||||
assert.Equal(t, 0.0, number.Fixed3(c.ShipGroup(0).Load.F()))
|
||||
assert.Equal(t, 100.0, util.Fixed3(c.MustPlanet(R0_Planet_0_num).Colonists.F()))
|
||||
assert.Equal(t, 0.0, util.Fixed3(c.ShipGroup(0).Load.F()))
|
||||
assert.Nil(t, c.ShipGroup(0).CargoType)
|
||||
}
|
||||
|
||||
+3
-2
@@ -5,9 +5,10 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
func (c *Cache) shipGroupUpgrade(ri int, groupID uuid.UUID, techInput string, limitLevel float64) error {
|
||||
+5
-4
@@ -3,11 +3,12 @@ package controller_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
e "galaxy/error"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
e "github.com/iliadenisov/galaxy/internal/error"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
g "github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
g "github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"slices"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
)
|
||||
|
||||
type VoteGroup struct {
|
||||
@@ -4,8 +4,8 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/controller"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/generator"
|
||||
"github.com/iliadenisov/galaxy/server/internal/generator"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -4,8 +4,9 @@ import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/generator/plotter"
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"galaxy/util"
|
||||
|
||||
"github.com/iliadenisov/galaxy/server/internal/generator/plotter"
|
||||
)
|
||||
|
||||
type Map struct {
|
||||
@@ -4,7 +4,8 @@ import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/number"
|
||||
"galaxy/util"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -21,7 +22,7 @@ func TestShortDistance(t *testing.T) {
|
||||
t.Run(fmt.Sprint(i), func(t *testing.T) {
|
||||
m := Map{Width: tc.w, Height: tc.h}
|
||||
d := m.ShortDistance(Coordinate{tc.x1, tc.y1}, Coordinate{tc.x2, tc.y2})
|
||||
assert.Equal(t, tc.d, number.Fixed3(d))
|
||||
assert.Equal(t, tc.d, util.Fixed3(d))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
g "github.com/iliadenisov/galaxy/internal/generator"
|
||||
g "github.com/iliadenisov/galaxy/server/internal/generator"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import (
|
||||
"math"
|
||||
"math/rand"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/bitmap"
|
||||
"github.com/iliadenisov/galaxy/server/internal/bitmap"
|
||||
)
|
||||
|
||||
type Plotter struct {
|
||||
+1
-1
@@ -3,7 +3,7 @@ package plotter_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/generator/plotter"
|
||||
"github.com/iliadenisov/galaxy/server/internal/generator/plotter"
|
||||
)
|
||||
|
||||
func TestNewPlotter(t *testing.T) {
|
||||
@@ -5,8 +5,9 @@ import (
|
||||
"fmt"
|
||||
"maps"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/number"
|
||||
)
|
||||
|
||||
type Float float64
|
||||
@@ -20,7 +21,7 @@ func (f Float) Add(v float64) Float {
|
||||
}
|
||||
|
||||
func (f Float) F() float64 {
|
||||
return number.Fixed12(float64(f))
|
||||
return util.Fixed12(float64(f))
|
||||
}
|
||||
|
||||
type TechSet map[Tech]Float
|
||||
@@ -3,7 +3,7 @@ package game_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -4,9 +4,10 @@ import (
|
||||
"math/rand/v2"
|
||||
"testing"
|
||||
|
||||
"galaxy/util"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/internal/number"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -116,9 +117,9 @@ func TestBombingPower(t *testing.T) {
|
||||
game.TechCargo: game.F(1.0),
|
||||
},
|
||||
}
|
||||
assert.Equal(t, 139.295, number.Fixed3(sg.BombingPower(&BattleStation)))
|
||||
assert.Equal(t, 139.295, util.Fixed3(sg.BombingPower(&BattleStation)))
|
||||
sg.Number = 2
|
||||
assert.Equal(t, 278.590, number.Fixed3(sg.BombingPower(&BattleStation)))
|
||||
assert.Equal(t, 278.590, util.Fixed3(sg.BombingPower(&BattleStation)))
|
||||
}
|
||||
|
||||
func TestDriveEffective(t *testing.T) {
|
||||
@@ -3,7 +3,7 @@ package game_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ package game_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -3,7 +3,7 @@ package game_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/model/game"
|
||||
"github.com/iliadenisov/galaxy/server/internal/model/game"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/galaxy/internal/util"
|
||||
"galaxy/util"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user