Files
Foundry-Scrapping-API/internal/foundry/temp_models/json/card.go

131 lines
2.8 KiB
Go

package json
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db"
type CardDeck struct {
Name string `json:"name"`
Type string `json:"type"`
Description string `json:"description"`
Img string `json:"img"`
Cards []*Card `json:"cards"`
Width int `json:"width"`
Height int `json:"height"`
Rotation int `json:"rotation"`
DisplayCount bool `json:"displayCount"`
Stats Stats `json:"_stats"`
Ownership Ownership `json:"ownership"`
Folder string `json:"folder"`
Sort int `json:"sort"`
ID string `json:"_id"`
// Flags any `json:"flags"`
// Cards0System any `json:"system"`
}
func (c *CardDeck) ToDB(dest *db.CardDeck) bool {
if dest == nil {
return false
}
dest.Name = c.Name
dest.Type = c.Type
dest.Description = c.Description
dest.Img = c.Img
dest.Width = c.Width
dest.Height = c.Height
dest.Rotation = c.Rotation
dest.DisplayCount = c.DisplayCount
dest.Folder = c.Folder
dest.Sort = c.Sort
dest.ID = c.ID
c.Stats.ToDB(&dest.Stats)
c.Ownership.ToDB(&dest.Ownership)
CopySliceToDB(&dest.Cards, c.Cards)
return true
}
type Card struct {
Name string `json:"name"`
Faces []*Face `json:"faces"`
Width int `json:"width"`
Height int `json:"height"`
Rotation int `json:"rotation"`
Type string `json:"type"`
Value int `json:"value"`
Suit string `json:"suit"`
Description string `json:"description"`
Face int `json:"face"`
Drawn bool `json:"drawn"`
Sort int `json:"sort"`
Back Back `json:"back"`
Origin string `json:"origin"`
ID string `json:"_id"`
Stats Stats `json:"_stats"`
// Flags any `json:"flags"`
// System any `json:"system"`
}
func (c *Card) ToDB(dest *db.Card) bool {
if dest == nil {
return false
}
dest.Name = c.Name
dest.Width = c.Width
dest.Height = c.Height
dest.Rotation = c.Rotation
dest.Type = c.Type
dest.Value = c.Value
dest.Suit = c.Suit
dest.Description = c.Description
dest.Face = c.Face
dest.Drawn = c.Drawn
dest.Origin = c.Origin
dest.ID = c.ID
dest.Sort = c.Sort
c.Back.ToDB(&dest.Back)
c.Stats.ToDB(&dest.Stats)
CopySliceToDB(&dest.Faces, c.Faces)
return true
}
type Face struct {
Name string `json:"name"`
Img string `json:"img"`
Text string `json:"text"`
}
func (f *Face) ToDB(dest *db.Face) bool {
if dest == nil {
return false
}
dest.Name = f.Name
dest.Img = f.Img
dest.Text = f.Text
return true
}
type Back struct {
Img any `json:"img"`
Name string `json:"name"`
Text string `json:"text"`
}
func (b *Back) ToDB(dest *db.Back) bool {
if dest == nil {
return false
}
dest.Name = b.Name
dest.Text = b.Text
return true
}