test: battle multiple non-crossing enemies

This commit is contained in:
IliaDenisov
2026-02-06 17:21:42 +03:00
parent ef10842dac
commit 449c3273bf
9 changed files with 129 additions and 41 deletions
@@ -8,6 +8,29 @@ import (
"github.com/iliadenisov/galaxy/internal/model/game"
)
func (c *Cache) AddRace(n string) (int, uuid.UUID) {
id := uuid.New()
r := &game.Race{
ID: id,
VoteFor: id,
Name: n,
Tech: game.NewTechSet(),
Relations: make([]game.RaceRelation, len(c.g.Race)),
}
c.g.Race = append(c.g.Race, *r)
for i := range c.g.Race {
if c.g.Race[i].ID != id {
c.g.Race[i].Relations = append(c.g.Race[i].Relations, game.RaceRelation{RaceID: id, Relation: game.RelationPeace})
continue
}
for j := range c.g.Race[i].Relations {
c.g.Race[i].Relations[j].RaceID = c.g.Race[j].ID
c.g.Race[i].Relations[j].Relation = game.RelationPeace
}
}
return len(c.g.Race) - 1, id
}
func (c *Cache) Race(i int) game.Race {
c.validateRaceIndex(i)
return c.g.Race[i]
@@ -102,3 +125,7 @@ func (c *Cache) VotesByRace() map[int]float64 {
func VotingWinners(calc []*VoteGroup, gameVotes float64) []int {
return votingWinners(calc, gameVotes)
}
func (c *Cache) CreateShipsUnsafe_T(ri int, classID uuid.UUID, planet uint, quantity uint) {
c.createShipsUnsafe(ri, classID, planet, quantity)
}