fix errors on insertion to game, fix db creation of game

This commit is contained in:
lbenedar
2026-04-23 19:03:56 +03:00
parent f46ff8333e
commit 07025afefc
36 changed files with 1820 additions and 693 deletions

View File

@@ -29,33 +29,37 @@ type Token struct {
// DetectionModes []any `json:"detectionModes"`
}
func (t *Token) ToDB(dest *db.Token) bool {
func (t *Token) ToDB(dest **db.Token) bool {
if dest == nil {
return false
}
dest.DisplayName = t.DisplayName
dest.DisplayBars = t.DisplayBars
dest.Disposition = t.Disposition
dest.Name = t.Name
dest.ActorLink = t.ActorLink
dest.AppendNumber = t.AppendNumber
dest.PrependAdjective = t.PrependAdjective
dest.Width = t.Width
dest.Height = t.Height
dest.LockRotation = t.LockRotation
dest.Rotation = t.Rotation
dest.Alpha = t.Alpha
dest.RandomImg = t.RandomImg
token := &db.Token{
DisplayName: t.DisplayName,
DisplayBars: t.DisplayBars,
Disposition: t.Disposition,
Name: t.Name,
ActorLink: t.ActorLink,
AppendNumber: t.AppendNumber,
PrependAdjective: t.PrependAdjective,
Width: t.Width,
Height: t.Height,
LockRotation: t.LockRotation,
Rotation: t.Rotation,
Alpha: t.Alpha,
RandomImg: t.RandomImg,
}
t.Ring.ToDB(&dest.Ring)
t.Sight.ToDB(&dest.Sight)
t.Texture.ToDB(&dest.Texture)
t.Bar1.ToDB(&dest.Bar1)
t.Bar2.ToDB(&dest.Bar2)
t.Light.ToDB(&dest.Light)
t.Occludable.ToDB(&dest.Occludable)
t.TurnMarker.ToDB(&dest.TurnMarker)
t.Ring.ToDB(&token.Ring)
t.Sight.ToDB(&token.Sight)
t.Texture.ToDB(&token.Texture)
t.Bar1.ToDB(&token.Bar1)
t.Bar2.ToDB(&token.Bar2)
t.Light.ToDB(&token.Light)
t.Occludable.ToDB(&token.Occludable)
t.TurnMarker.ToDB(&token.TurnMarker)
*dest = token
return true
}
@@ -74,22 +78,26 @@ type TokenTexture struct {
AlphaThreshold float64 `json:"alphaThreshold"`
}
func (t *TokenTexture) ToDB(dest *db.TokenTexture) bool {
func (t *TokenTexture) ToDB(dest **db.TokenTexture) bool {
if dest == nil {
return false
}
dest.Src = t.Src
dest.ScaleX = t.ScaleX
dest.ScaleY = t.ScaleY
dest.OffsetX = t.OffsetX
dest.OffsetY = t.OffsetY
dest.Rotation = t.Rotation
dest.AnchorX = t.AnchorX
dest.AnchorY = t.AnchorY
dest.Fit = t.Fit
dest.Tint = t.Tint
dest.AlphaThreshold = t.AlphaThreshold
texture := &db.TokenTexture{
Src: t.Src,
ScaleX: t.ScaleX,
ScaleY: t.ScaleY,
OffsetX: t.OffsetX,
OffsetY: t.OffsetY,
Rotation: t.Rotation,
AnchorX: t.AnchorX,
AnchorY: t.AnchorY,
Fit: t.Fit,
Tint: t.Tint,
AlphaThreshold: t.AlphaThreshold,
}
*dest = texture
return true
}
@@ -104,18 +112,22 @@ type TokenSight struct {
Brightness float64
}
func (t *TokenSight) ToDB(dest *db.TokenSight) bool {
func (t *TokenSight) ToDB(dest **db.TokenSight) bool {
if dest == nil {
return false
}
dest.Color = t.Color
dest.Enabled = t.Enabled
dest.Range = t.Range
dest.Angle = t.Angle
dest.VisionMode = t.VisionMode
dest.Attenuation = t.Attenuation
dest.Brightness = t.Brightness
sight := &db.TokenSight{
Color: t.Color,
Enabled: t.Enabled,
Range: t.Range,
Angle: t.Angle,
VisionMode: t.VisionMode,
Attenuation: t.Attenuation,
Brightness: t.Brightness,
}
*dest = sight
return true
}