76 lines
1.8 KiB
Go
76 lines
1.8 KiB
Go
package json
|
|
|
|
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db"
|
|
|
|
type Combat struct {
|
|
Id string `json:"_id"`
|
|
Type string `json:"type"`
|
|
Scene string `json:"scene"`
|
|
Groups []string `json:"groups"`
|
|
Combatants []*Combatant `json:"combatants"`
|
|
Active bool `json:"active"`
|
|
Round int `json:"round"`
|
|
Turn int `json:"turn"`
|
|
Sort int `json:"sort"`
|
|
Stats Stats `json:"stats"`
|
|
// System any `json:"system"`
|
|
// Flags any `json:"flags"`
|
|
}
|
|
|
|
func (c *Combat) ToDB(dest *db.Combat) bool {
|
|
if dest == nil {
|
|
return false
|
|
}
|
|
|
|
dest.ID = c.Id
|
|
dest.Type = c.Type
|
|
dest.Scene = c.Scene
|
|
dest.Active = c.Active
|
|
dest.Round = c.Round
|
|
dest.Turn = c.Turn
|
|
dest.Sort = c.Sort
|
|
|
|
c.Stats.ToDB(&dest.Stats)
|
|
|
|
copy(dest.Groups, c.Groups)
|
|
CopySliceToDB(&dest.Combatants, c.Combatants)
|
|
|
|
return true
|
|
}
|
|
|
|
type Combatant struct {
|
|
TokenId string `json:"tokenId"`
|
|
SceneId string `json:"sceneId"`
|
|
ActorId string `json:"actorId"`
|
|
Hidden bool `json:"hidden"`
|
|
Id string `json:"_id"`
|
|
Type string `json:"type"`
|
|
Img string `json:"img"`
|
|
Initiative int `json:"initiative"`
|
|
Defeated bool `json:"defeated"`
|
|
Group string `json:"group"`
|
|
Stats Stats `json:"stats"`
|
|
// System any `json:"system"`
|
|
// Flags any `json:"flags"`
|
|
}
|
|
|
|
func (c *Combatant) ToDB(dest *db.Combatant) bool {
|
|
if dest == nil {
|
|
return false
|
|
}
|
|
|
|
dest.TokenId = c.TokenId
|
|
dest.SceneId = c.SceneId
|
|
dest.ActorId = c.ActorId
|
|
dest.Hidden = c.Hidden
|
|
dest.ID = c.Id
|
|
dest.Type = c.Type
|
|
dest.Img = c.Img
|
|
dest.Initiative = c.Initiative
|
|
dest.Defeated = c.Defeated
|
|
dest.Group = c.Group
|
|
c.Stats.ToDB(&dest.Stats)
|
|
|
|
return true
|
|
}
|