finish setup data insertion, add world insertion

This commit is contained in:
lbenedar
2026-04-22 18:18:43 +03:00
parent 21abe68858
commit f46ff8333e
66 changed files with 2257 additions and 676 deletions

View File

@@ -18,26 +18,28 @@ type Table struct {
// TablesFlags any `json:"flags,omitempty"`
}
func (t *Table) ToDB(dest *db.Table) bool {
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
table := &db.Table{
Name: t.Name,
Description: t.Description,
Formula: t.Formula,
ID: t.ID,
Img: t.Img,
Replacement: t.Replacement,
DisplayRoll: t.DisplayRoll,
Folder: t.Folder,
Sort: t.Sort,
}
t.Stats.ToDB(&dest.Stats)
t.Stats.ToDB(&table.Stats)
OwnershipToDB(&dest.Ownership, t.Ownership)
OwnershipToDB(&table.Ownership, t.Ownership)
CopySliceToDB(&dest.Results, t.Results)
CopySliceToDB(&table.Results, t.Results)
return true
}
@@ -55,22 +57,27 @@ type TableResult struct {
// ResultsFlags any `json:"flags"`
}
func (t *TableResult) ToDB(dest *db.TableResult) bool {
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
tableResult := &db.TableResult{
Type: t.Type,
Weight: t.Weight,
Drawn: t.Drawn,
ID: t.ID,
Img: t.Img,
Description: t.Description,
Name: t.Name,
}
copy(dest.Range, t.Range)
tableResult.Range = make([]int, len(t.Range))
copy(tableResult.Range, t.Range)
t.Stats.ToDB(&dest.Stats)
t.Stats.ToDB(&tableResult.Stats)
*dest = tableResult
return true
}