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

77 lines
1.8 KiB
Go

package json
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db"
type Table struct {
Name string `json:"name"`
Results []*TableResult `json:"results"`
Description string `json:"description"`
Formula string `json:"formula"`
ID string `json:"_id"`
Img string `json:"img"`
Replacement bool `json:"replacement"`
DisplayRoll bool `json:"displayRoll"`
Folder string `json:"folder"`
Sort int `json:"sort"`
Ownership map[string]int `json:"ownership,omitempty"`
Stats Stats `json:"_stats"`
// TablesFlags any `json:"flags,omitempty"`
}
func (t *Table) ToDB(dest *db.Table) bool {
if dest == nil {
return false
}
dest.Name = t.Name
dest.Description = t.Description
dest.Formula = t.Formula
dest.ID = t.ID
dest.Img = t.Img
dest.Replacement = t.Replacement
dest.DisplayRoll = t.DisplayRoll
dest.Folder = t.Folder
dest.Sort = t.Sort
t.Stats.ToDB(&dest.Stats)
OwnershipToDB(&dest.Ownership, t.Ownership)
CopySliceToDB(&dest.Results, t.Results)
return true
}
type TableResult struct {
Type string `json:"type"`
Weight int `json:"weight"`
Range []int `json:"range"`
Drawn bool `json:"drawn"`
ID string `json:"_id"`
Img string `json:"img"`
Stats Stats `json:"_stats"`
Description string `json:"description"`
Name string `json:"name"`
// ResultsFlags any `json:"flags"`
}
func (t *TableResult) ToDB(dest *db.TableResult) bool {
if dest == nil {
return false
}
dest.Type = t.Type
dest.Weight = t.Weight
dest.Drawn = t.Drawn
dest.ID = t.ID
dest.Img = t.Img
dest.Description = t.Description
dest.Name = t.Name
copy(dest.Range, t.Range)
t.Stats.ToDB(&dest.Stats)
return true
}