finish world initialization, set up init on startup and on shutdown, move all models to main directory
This commit is contained in:
45
internal/foundry/models/json/actor.go
Normal file
45
internal/foundry/models/json/actor.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Actor struct {
|
||||
PrototypeToken Token `json:"prototypeToken"`
|
||||
Img string `json:"img"`
|
||||
Items []*Item `json:"items"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Folder string `json:"folder"`
|
||||
Ownership map[string]int `json:"ownership,omitempty"`
|
||||
Stats Stats `json:"_stats"`
|
||||
Sort int `json:"sort"`
|
||||
ID string `json:"_id"`
|
||||
// System any `json:"system,omitempty"`
|
||||
// Flags any `json:"flags,omitempty"`
|
||||
// ActorsEffects []any `json:"effects"`
|
||||
}
|
||||
|
||||
func (a *Actor) ToDB(dest **db.Actor) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
actor := &db.Actor{
|
||||
Img: a.Img,
|
||||
Name: a.Name,
|
||||
Type: a.Type,
|
||||
Folder: a.Folder,
|
||||
Sort: a.Sort,
|
||||
ID: a.ID,
|
||||
}
|
||||
|
||||
a.PrototypeToken.ToDB(&actor.PrototypeToken)
|
||||
a.Stats.ToDB(&actor.Stats)
|
||||
|
||||
OwnershipToDB(&actor.Ownership, a.Ownership)
|
||||
|
||||
CopySliceToDB(&actor.Items, a.Items)
|
||||
|
||||
*dest = actor
|
||||
|
||||
return true
|
||||
}
|
||||
21
internal/foundry/models/json/addresses.go
Normal file
21
internal/foundry/models/json/addresses.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Addresses struct {
|
||||
Local string `json:"local"`
|
||||
Remote string `json:"remote"`
|
||||
RemoteIsAccessible bool `json:"remoteIsAccessible"`
|
||||
}
|
||||
|
||||
func (a *Addresses) ToDB(dest *db.Addresses) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Local = a.Local
|
||||
dest.Remote = a.Remote
|
||||
dest.RemoteIsAccessible = a.RemoteIsAccessible
|
||||
|
||||
return true
|
||||
}
|
||||
28
internal/foundry/models/json/authors.go
Normal file
28
internal/foundry/models/json/authors.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Author struct {
|
||||
Name string `json:"name"`
|
||||
URL string `json:"url"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Discord string `json:"discord,omitempty"`
|
||||
// SystemAuthorsFlags SystemAuthorsFlags `json:"flags"`
|
||||
}
|
||||
|
||||
func (a *Author) ToDB(dest **db.Author) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
author := &db.Author{
|
||||
Name: a.Name,
|
||||
URL: a.URL,
|
||||
Email: a.Email,
|
||||
Discord: a.Discord,
|
||||
}
|
||||
|
||||
*dest = author
|
||||
|
||||
return true
|
||||
}
|
||||
138
internal/foundry/models/json/card.go
Normal file
138
internal/foundry/models/json/card.go
Normal file
@@ -0,0 +1,138 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/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 map[string]int `json:"ownership,omitempty"`
|
||||
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
|
||||
}
|
||||
|
||||
cardDeck := &db.CardDeck{
|
||||
Name: c.Name,
|
||||
Type: c.Type,
|
||||
Description: c.Description,
|
||||
Img: c.Img,
|
||||
Width: c.Width,
|
||||
Height: c.Height,
|
||||
Rotation: c.Rotation,
|
||||
DisplayCount: c.DisplayCount,
|
||||
Folder: c.Folder,
|
||||
Sort: c.Sort,
|
||||
ID: c.ID,
|
||||
}
|
||||
|
||||
c.Stats.ToDB(&cardDeck.Stats)
|
||||
|
||||
OwnershipToDB(&cardDeck.Ownership, c.Ownership)
|
||||
CopySliceToDB(&cardDeck.Cards, c.Cards)
|
||||
|
||||
*dest = cardDeck
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
card := &db.Card{
|
||||
Name: c.Name,
|
||||
Width: c.Width,
|
||||
Height: c.Height,
|
||||
Rotation: c.Rotation,
|
||||
Type: c.Type,
|
||||
Value: c.Value,
|
||||
Suit: c.Suit,
|
||||
Description: c.Description,
|
||||
Face: c.Face,
|
||||
Drawn: c.Drawn,
|
||||
Origin: c.Origin,
|
||||
ID: c.ID,
|
||||
Sort: c.Sort,
|
||||
}
|
||||
|
||||
c.Back.ToDB(&card.Back)
|
||||
c.Stats.ToDB(&card.Stats)
|
||||
|
||||
CopySliceToDB(&card.Faces, c.Faces)
|
||||
|
||||
*dest = card
|
||||
|
||||
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
|
||||
}
|
||||
85
internal/foundry/models/json/combat.go
Normal file
85
internal/foundry/models/json/combat.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/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
|
||||
}
|
||||
|
||||
combat := &db.Combat{
|
||||
ID: c.Id,
|
||||
Type: c.Type,
|
||||
Scene: c.Scene,
|
||||
Active: c.Active,
|
||||
Round: c.Round,
|
||||
Turn: c.Turn,
|
||||
Sort: c.Sort,
|
||||
}
|
||||
|
||||
c.Stats.ToDB(&combat.Stats)
|
||||
|
||||
combat.Groups = make([]string, len(c.Groups))
|
||||
copy(combat.Groups, c.Groups)
|
||||
CopySliceToDB(&combat.Combatants, c.Combatants)
|
||||
|
||||
*dest = combat
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
combatant := &db.Combatant{
|
||||
TokenId: c.TokenId,
|
||||
SceneId: c.SceneId,
|
||||
ActorId: c.ActorId,
|
||||
Hidden: c.Hidden,
|
||||
ID: c.Id,
|
||||
Type: c.Type,
|
||||
Img: c.Img,
|
||||
Initiative: c.Initiative,
|
||||
Defeated: c.Defeated,
|
||||
Group: c.Group,
|
||||
}
|
||||
|
||||
c.Stats.ToDB(&combatant.Stats)
|
||||
|
||||
*dest = combatant
|
||||
|
||||
return true
|
||||
}
|
||||
21
internal/foundry/models/json/compatibility.go
Normal file
21
internal/foundry/models/json/compatibility.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Compatibility struct {
|
||||
Minimum string `json:"minimum,omitempty"`
|
||||
Verified string `json:"verified,omitempty"`
|
||||
Maximum string `json:"maximum,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Compatibility) ToDB(dest *db.Compatibility) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Minimum = c.Minimum
|
||||
dest.Verified = c.Verified
|
||||
dest.Maximum = c.Maximum
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type FoundryState struct {
|
||||
IsAdmin bool `json:"isAdmin,omitempty"`
|
||||
IsSetup bool `json:"isSetup,omitempty"`
|
||||
Languages []Language `json:"languages,omitempty"`
|
||||
Modules []DataTemplate `json:"modules"`
|
||||
Release Release `json:"release"`
|
||||
Systems []DataTemplate `json:"systems,omitempty"`
|
||||
Worlds []DataTemplate `json:"worlds,omitempty"`
|
||||
World *DataTemplate `json:"world,omitempty"`
|
||||
Users Users `json:"users,omitempty"`
|
||||
Options Options `json:"options,omitempty"`
|
||||
|
||||
//coreUpdate struct{}
|
||||
//featuredContent struct{}
|
||||
//files struct{}
|
||||
//news struct{}
|
||||
|
||||
//packageWarnings struct{} think about it
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
Language string `json:"language,omitempty"`
|
||||
}
|
||||
|
||||
func (state FoundryState) GetRelease() Release {
|
||||
return state.Release
|
||||
}
|
||||
|
||||
func (state FoundryState) GetFoundryStateDB(stateType db.StateType) *db.FoundryState {
|
||||
dbFoundryState := db.FoundryState{
|
||||
IsAdmin: state.IsAdmin,
|
||||
IsSetup: state.IsSetup,
|
||||
Type: stateType,
|
||||
Options: db.Options{Language: state.Options.Language},
|
||||
}
|
||||
|
||||
dbFoundryState.Modules = state.GetModules()
|
||||
dbFoundryState.Systems = state.GetSystems()
|
||||
dbFoundryState.Worlds = state.GetWorlds()
|
||||
dbFoundryState.Users = state.GetUsers()
|
||||
|
||||
return &dbFoundryState
|
||||
}
|
||||
|
||||
func (state *FoundryState) GetModules() db.Modules {
|
||||
modulesCopy := make([]db.Module, 0, 8)
|
||||
for i := range state.Modules {
|
||||
module := &(state.Modules[i])
|
||||
moduleCopy := db.Module{
|
||||
TextId: module.Id,
|
||||
Title: module.Title,
|
||||
Description: module.Description,
|
||||
Compatibility: db.Compatibility{
|
||||
Minimum: module.Compatibility.Minimum,
|
||||
Maximum: module.Compatibility.Maximum,
|
||||
},
|
||||
Url: module.Url,
|
||||
Version: module.CoreVersion,
|
||||
|
||||
Availability: module.Availability,
|
||||
}
|
||||
for j := range module.Languages {
|
||||
lang := db.Language{
|
||||
Lang: module.Languages[j].Lang,
|
||||
Name: module.Languages[j].Name,
|
||||
Path: module.Languages[j].Path,
|
||||
}
|
||||
moduleCopy.Languages = append(moduleCopy.Languages, lang)
|
||||
}
|
||||
modulesCopy = append(modulesCopy, moduleCopy)
|
||||
}
|
||||
return modulesCopy
|
||||
}
|
||||
|
||||
func (state *FoundryState) GetSystems() db.Systems {
|
||||
systemsCopy := make([]db.System, 0, 8)
|
||||
for i := range state.Systems {
|
||||
system := &(state.Systems[i])
|
||||
systemCopy := db.System{
|
||||
TextId: system.Id,
|
||||
Title: system.Title,
|
||||
Description: system.Description,
|
||||
Url: system.Url,
|
||||
Compatibility: db.Compatibility{
|
||||
Minimum: system.Compatibility.Minimum,
|
||||
Maximum: system.Compatibility.Maximum,
|
||||
},
|
||||
Download: system.Download,
|
||||
}
|
||||
systemsCopy = append(systemsCopy, systemCopy)
|
||||
}
|
||||
return systemsCopy
|
||||
}
|
||||
|
||||
func (state *FoundryState) GetWorld() *db.World {
|
||||
return &db.World{
|
||||
TextId: state.World.Id,
|
||||
Title: state.World.Title,
|
||||
Description: state.World.Description,
|
||||
Compatibility: db.Compatibility{
|
||||
Minimum: state.World.Compatibility.Minimum,
|
||||
Maximum: state.World.Compatibility.Maximum,
|
||||
},
|
||||
System: state.World.System,
|
||||
CoreVersion: state.World.CoreVersion,
|
||||
SystemVersion: state.World.SystemVersion,
|
||||
LastPlayed: state.World.LastPlayed,
|
||||
PlayTime: state.World.PlayTime,
|
||||
NextSession: state.World.NextSession,
|
||||
}
|
||||
}
|
||||
|
||||
func (state *FoundryState) GetWorlds() db.Worlds {
|
||||
worldsCopy := make([]db.World, 0, 8)
|
||||
for i := range state.Worlds {
|
||||
world := &(state.Worlds[i])
|
||||
worldCopy := db.World{
|
||||
TextId: world.Id,
|
||||
Title: world.Title,
|
||||
Description: world.Description,
|
||||
Compatibility: db.Compatibility{
|
||||
Minimum: world.Compatibility.Minimum,
|
||||
Maximum: world.Compatibility.Maximum,
|
||||
},
|
||||
System: world.System,
|
||||
CoreVersion: world.CoreVersion,
|
||||
SystemVersion: world.SystemVersion,
|
||||
LastPlayed: world.LastPlayed,
|
||||
PlayTime: world.PlayTime,
|
||||
NextSession: world.NextSession,
|
||||
}
|
||||
worldsCopy = append(worldsCopy, worldCopy)
|
||||
}
|
||||
|
||||
if state.World != nil {
|
||||
worldsCopy = append(worldsCopy, *state.GetWorld())
|
||||
}
|
||||
return worldsCopy
|
||||
}
|
||||
|
||||
func (state *FoundryState) GetUsers() db.Users {
|
||||
usersCopy := make(db.Users, 0, 8)
|
||||
for i := range state.Users {
|
||||
user := &(state.Users[i])
|
||||
userCopy := db.User{
|
||||
Name: user.Name,
|
||||
Role: user.Role,
|
||||
Character: user.Character,
|
||||
Color: user.Color,
|
||||
Pronouns: user.Pronouns,
|
||||
Hotbar: user.Hotbar,
|
||||
Stats: db.UserStats{
|
||||
CoreVersion: user.Stats.CoreVersion,
|
||||
SystemId: user.Stats.SystemId,
|
||||
SystemVersion: user.Stats.SystemVersion,
|
||||
CreatedTime: user.Stats.CreatedTime,
|
||||
ModifiedTime: user.Stats.ModifiedTime,
|
||||
LastModifiedBy: user.Stats.LastModifiedBy,
|
||||
},
|
||||
}
|
||||
usersCopy = append(usersCopy, userCopy)
|
||||
}
|
||||
return usersCopy
|
||||
}
|
||||
|
||||
func ParseSetupModel(data []byte) (*FoundryState, error) {
|
||||
var modelSetup []FoundryState
|
||||
err := json.Unmarshal(data, &modelSetup)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(modelSetup) > 1 {
|
||||
return nil, ErrorSetupMoreThanOne
|
||||
}
|
||||
return &modelSetup[0], nil
|
||||
}
|
||||
17
internal/foundry/models/json/details_language.go
Normal file
17
internal/foundry/models/json/details_language.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type DetailsLanguages struct {
|
||||
Details string `json:"details"`
|
||||
}
|
||||
|
||||
func (d *DetailsLanguages) ToDB(dest *db.DetailsLanguages) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Details = d.Details
|
||||
|
||||
return true
|
||||
}
|
||||
39
internal/foundry/models/json/document_types.go
Normal file
39
internal/foundry/models/json/document_types.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type DocumentTypes struct {
|
||||
Actor DocumentTypeData `json:"Actor"`
|
||||
Item DocumentTypeData `json:"Item"`
|
||||
RegionBehavior RegionBehavior `json:"RegionBehavior,omitempty"`
|
||||
}
|
||||
|
||||
func (d *DocumentTypes) ToDB(dest *db.DocumentTypes) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Data = make([]*db.DocumentTypeData, 2)
|
||||
|
||||
dest.Data[0] = &db.DocumentTypeData{Type: "Actor"}
|
||||
d.Actor.ToDB(dest.Data[0])
|
||||
|
||||
dest.Data[1] = &db.DocumentTypeData{Type: "Item"}
|
||||
d.Item.ToDB(dest.Data[1])
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type DocumentTypeData struct {
|
||||
HtmlFields []string `json:"htmlFields"`
|
||||
}
|
||||
|
||||
func (d *DocumentTypeData) ToDB(dest *db.DocumentTypeData) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.HtmlFields = d.HtmlFields
|
||||
|
||||
return true
|
||||
}
|
||||
97
internal/foundry/models/json/environment.go
Normal file
97
internal/foundry/models/json/environment.go
Normal file
@@ -0,0 +1,97 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Environment struct {
|
||||
GlobalLight EnvironmentGlobalLight `json:"globalLight"`
|
||||
DarknessLevel float64 `json:"darknessLevel"`
|
||||
DarknessLock bool `json:"darknessLock"`
|
||||
Cycle bool `json:"cycle"`
|
||||
ScenesEnvironmentBase EnvironmentBase `json:"base"`
|
||||
Dark EnvironmentBase `json:"dark"`
|
||||
}
|
||||
|
||||
func (e *Environment) ToDB(dest *db.Environment) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
e.GlobalLight.ToDB(&dest.GlobalLight)
|
||||
dest.DarknessLevel = e.DarknessLevel
|
||||
dest.DarknessLock = e.DarknessLock
|
||||
dest.Cycle = e.Cycle
|
||||
e.ScenesEnvironmentBase.ToDB(&dest.ScenesEnvironmentBase)
|
||||
e.Dark.ToDB(&dest.Dark)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type EnvironmentGlobalLight struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Darkness GlobalLightDarkness `json:"darkness"`
|
||||
Alpha float64 `json:"alpha"`
|
||||
Bright bool `json:"bright"`
|
||||
Color string `json:"color"`
|
||||
Coloration float64 `json:"coloration"`
|
||||
Luminosity float64 `json:"luminosity"`
|
||||
Saturation float64 `json:"saturation"`
|
||||
Contrast float64 `json:"contrast"`
|
||||
Shadows float64 `json:"shadows"`
|
||||
}
|
||||
|
||||
func (e *EnvironmentGlobalLight) ToDB(dest *db.EnvironmentGlobalLight) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Enabled = e.Enabled
|
||||
e.Darkness.ToDB(&dest.Darkness)
|
||||
dest.Alpha = e.Alpha
|
||||
dest.Bright = e.Bright
|
||||
dest.Color = e.Color
|
||||
dest.Coloration = e.Coloration
|
||||
dest.Luminosity = e.Luminosity
|
||||
dest.Saturation = e.Saturation
|
||||
dest.Contrast = e.Contrast
|
||||
dest.Shadows = e.Shadows
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type EnvironmentBase struct {
|
||||
Hue float64 `json:"hue"`
|
||||
Intensity float64 `json:"intensity"`
|
||||
Luminosity float64 `json:"luminosity"`
|
||||
Saturation float64 `json:"saturation"`
|
||||
Shadows float64 `json:"shadows"`
|
||||
}
|
||||
|
||||
func (e *EnvironmentBase) ToDB(dest *db.EnvironmentBase) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Hue = e.Hue
|
||||
dest.Intensity = e.Intensity
|
||||
dest.Luminosity = e.Luminosity
|
||||
dest.Saturation = e.Saturation
|
||||
dest.Shadows = e.Shadows
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type GlobalLightDarkness struct {
|
||||
Max int `json:"max"`
|
||||
Min int `json:"min"`
|
||||
}
|
||||
|
||||
func (g *GlobalLightDarkness) ToDB(dest *db.GlobalLightDarkness) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Max = g.Max
|
||||
dest.Min = g.Min
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package json
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrorSetupMoreThanOne = errors.New("Passed more than one setupData")
|
||||
ErrorSetupNotFound = errors.New("Not found setup data from your request")
|
||||
)
|
||||
21
internal/foundry/models/json/files.go
Normal file
21
internal/foundry/models/json/files.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Files struct {
|
||||
Storages []string `json:"storages"`
|
||||
S3 any `json:"s3"`
|
||||
}
|
||||
|
||||
func (f *Files) ToDB(dest *db.Files) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Storages = make([]db.FilesStorage, len(f.Storages))
|
||||
for i := range f.Storages {
|
||||
dest.Storages[i].Storage = f.Storages[i]
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
67
internal/foundry/models/json/folder.go
Normal file
67
internal/foundry/models/json/folder.go
Normal file
@@ -0,0 +1,67 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Folder struct {
|
||||
Name string `json:"name"`
|
||||
Sorting string `json:"sorting"`
|
||||
Color string `json:"color,omitempty"`
|
||||
Packs []string `json:"packs"`
|
||||
Folders []*Folder `json:"folders,omitempty"`
|
||||
}
|
||||
|
||||
func (f *Folder) ToDB(dest **db.Folder) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
folder := &db.Folder{
|
||||
Name: f.Name,
|
||||
Sorting: f.Sorting,
|
||||
Color: f.Color,
|
||||
}
|
||||
|
||||
folder.Packs = make([]string, len(f.Packs))
|
||||
copy(folder.Packs, f.Packs)
|
||||
CopySliceToDB(&folder.Folders, f.Folders)
|
||||
|
||||
*dest = folder
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type WorldFolder struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
ID string `json:"_id"`
|
||||
Folder string `json:"folder"`
|
||||
Sorting string `json:"sorting"`
|
||||
Sort int `json:"sort"`
|
||||
Stats Stats `json:"_stats,omitempty"`
|
||||
Description string `json:"description"`
|
||||
Color string `json:"color"`
|
||||
// Flags any `json:"flags,omitempty"`
|
||||
}
|
||||
|
||||
func (w *WorldFolder) ToDB(dest **db.WorldFolder) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
worldFolder := &db.WorldFolder{
|
||||
Name: w.Name,
|
||||
Type: w.Type,
|
||||
ID: w.ID,
|
||||
Folder: w.Folder,
|
||||
Sorting: w.Sorting,
|
||||
Sort: w.Sort,
|
||||
Description: w.Description,
|
||||
Color: w.Color,
|
||||
}
|
||||
|
||||
w.Stats.ToDB(&worldFolder.Stats)
|
||||
|
||||
*dest = worldFolder
|
||||
|
||||
return true
|
||||
}
|
||||
95
internal/foundry/models/json/game.go
Normal file
95
internal/foundry/models/json/game.go
Normal file
@@ -0,0 +1,95 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type Game struct {
|
||||
UserID string `json:"userId"`
|
||||
Release Release `json:"release"`
|
||||
World World `json:"world"`
|
||||
System System `json:"system"`
|
||||
Modules []*Module `json:"modules"`
|
||||
DemoMode bool `json:"demoMode"`
|
||||
IdleLogout bool `json:"idleLogout"`
|
||||
Addresses Addresses `json:"addresses"`
|
||||
Files Files `json:"files"`
|
||||
Options GameOptions `json:"options"`
|
||||
ActiveUsers []string `json:"activeUsers"`
|
||||
Paused bool `json:"paused"`
|
||||
PackageWarnings map[string]PackageWarningsData `json:"packageWarnings"`
|
||||
Packs []*Pack `json:"packs"`
|
||||
Messages []*Message `json:"messages,omitempty"`
|
||||
Combats []*Combat `json:"combats"`
|
||||
CardDeck []*CardDeck `json:"cards"`
|
||||
Users []*User `json:"users"`
|
||||
Macros []*Macro `json:"macros"`
|
||||
Folders []*WorldFolder `json:"folders"`
|
||||
Items []*Item `json:"items"`
|
||||
Settings []*Setting `json:"settings"`
|
||||
Journals []*Journal `json:"journal"`
|
||||
Tables []*Table `json:"tables"`
|
||||
Playlists []*Playlist `json:"playlists"`
|
||||
Scenes []*Scene `json:"scenes"`
|
||||
Actors []*Actor `json:"actors"`
|
||||
CoreUpdate CoreUpdate `json:"coreUpdate"`
|
||||
SystemUpdate SystemUpdate `json:"systemUpdate"`
|
||||
// Model Model `json:"model"`
|
||||
// Template Template `json:"template"`
|
||||
}
|
||||
|
||||
func ParseGame(data []byte) (*Game, error) {
|
||||
var modelGame []Game
|
||||
err := json.Unmarshal(data, &modelGame)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(modelGame) > 1 {
|
||||
return nil, ErrorSetupMoreThanOne
|
||||
}
|
||||
return &modelGame[0], nil
|
||||
}
|
||||
|
||||
func (g *Game) ToDB(dest *db.Game) bool {
|
||||
dest.UserID = g.UserID
|
||||
dest.DemoMode = g.DemoMode
|
||||
dest.IdleLogout = g.IdleLogout
|
||||
dest.Paused = g.Paused
|
||||
PackageWarningsToDB(&dest.PackageWarnings, g.PackageWarnings)
|
||||
|
||||
g.Addresses.ToDB(&dest.Addresses)
|
||||
g.Files.ToDB(&dest.Files)
|
||||
g.Release.ToDB(&dest.Release)
|
||||
g.World.ToDB(&dest.World)
|
||||
g.System.ToDB(&dest.System)
|
||||
g.Options.ToDB(&dest.Options)
|
||||
g.CoreUpdate.ToDB(&dest.CoreUpdate)
|
||||
g.SystemUpdate.ToDB(&dest.SystemUpdate)
|
||||
|
||||
dest.ActiveUsers = make([]string, len(g.ActiveUsers))
|
||||
copy(dest.ActiveUsers, g.ActiveUsers)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
CopySliceToDBParallel(&wg, &dest.Modules, g.Modules)
|
||||
CopySliceToDBParallel(&wg, &dest.Packs, g.Packs)
|
||||
CopySliceToDBParallel(&wg, &dest.Messages, g.Messages)
|
||||
CopySliceToDBParallel(&wg, &dest.Combats, g.Combats)
|
||||
CopySliceToDBParallel(&wg, &dest.CardDeck, g.CardDeck)
|
||||
CopySliceToDBParallel(&wg, &dest.Users, g.Users)
|
||||
CopySliceToDBParallel(&wg, &dest.Macros, g.Macros)
|
||||
CopySliceToDBParallel(&wg, &dest.Folders, g.Folders)
|
||||
CopySliceToDBParallel(&wg, &dest.Items, g.Items)
|
||||
CopySliceToDBParallel(&wg, &dest.Settings, g.Settings)
|
||||
CopySliceToDBParallel(&wg, &dest.Journals, g.Journals)
|
||||
CopySliceToDBParallel(&wg, &dest.Tables, g.Tables)
|
||||
CopySliceToDBParallel(&wg, &dest.Playlists, g.Playlists)
|
||||
CopySliceToDBParallel(&wg, &dest.Actors, g.Actors)
|
||||
// go CopySliceToDBParallel(&wg, &dest.Scenes, g.Scenes)
|
||||
wg.Wait()
|
||||
|
||||
return true
|
||||
}
|
||||
37
internal/foundry/models/json/grid.go
Normal file
37
internal/foundry/models/json/grid.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Grid struct {
|
||||
Type int `json:"type"`
|
||||
Size int `json:"size,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
Alpha float64 `json:"alpha,omitempty"`
|
||||
Distance int `json:"distance"`
|
||||
Units string `json:"units"`
|
||||
Diagonals int `json:"diagonals,omitempty"`
|
||||
Style string `json:"style,omitempty"`
|
||||
Thickness int `json:"thickness,omitempty"`
|
||||
}
|
||||
|
||||
func (g *Grid) ToDB(dest **db.Grid) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
grid := &db.Grid{
|
||||
Type: g.Type,
|
||||
Size: g.Size,
|
||||
Color: g.Color,
|
||||
Alpha: g.Alpha,
|
||||
Distance: g.Distance,
|
||||
Units: g.Units,
|
||||
Diagonals: g.Diagonals,
|
||||
Style: g.Style,
|
||||
Thickness: g.Thickness,
|
||||
}
|
||||
|
||||
*dest = grid
|
||||
|
||||
return true
|
||||
}
|
||||
29
internal/foundry/models/json/index.go
Normal file
29
internal/foundry/models/json/index.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Index struct {
|
||||
Id string `json:"_id"`
|
||||
Folder string `json:"folder"`
|
||||
Img string `json:"img"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
func (i *Index) ToDB(dest **db.Index) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
index := &db.Index{
|
||||
ID: i.Id,
|
||||
Folder: i.Folder,
|
||||
Img: i.Img,
|
||||
Name: i.Name,
|
||||
Type: i.Type,
|
||||
}
|
||||
|
||||
*dest = index
|
||||
|
||||
return true
|
||||
}
|
||||
38
internal/foundry/models/json/item.go
Normal file
38
internal/foundry/models/json/item.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Item struct {
|
||||
Img string `json:"img"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Folder string `json:"folder"`
|
||||
Ownership map[string]int `json:"ownership"`
|
||||
Stats Stats `json:"_stats"`
|
||||
ID string `json:"_id"`
|
||||
Sort int `json:"sort"`
|
||||
// System any `json:"system,omitempty"`
|
||||
// Flags any `json:"flags,omitempty"`
|
||||
// Effects []any `json:"effects"`
|
||||
}
|
||||
|
||||
func (i *Item) ToDB(dest **db.Item) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
item := &db.Item{
|
||||
Img: i.Img,
|
||||
Name: i.Name,
|
||||
Type: i.Type,
|
||||
Folder: i.Folder,
|
||||
ID: i.ID,
|
||||
Sort: i.Sort,
|
||||
}
|
||||
|
||||
i.Stats.ToDB(&item.Stats)
|
||||
|
||||
*dest = item
|
||||
|
||||
return true
|
||||
}
|
||||
34
internal/foundry/models/json/journal.go
Normal file
34
internal/foundry/models/json/journal.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Journal struct {
|
||||
Folder any `json:"folder"`
|
||||
Name string `json:"name"`
|
||||
Pages []*JournalPage `json:"pages"`
|
||||
Sort int `json:"sort"`
|
||||
Ownership map[string]int `json:"ownership,omitempty"`
|
||||
ID string `json:"_id"`
|
||||
// JournalFlags any `json:"flags,omitempty"`
|
||||
// JournalStats Stats `json:"_stats"`
|
||||
// Categories []any `json:"categories"`
|
||||
}
|
||||
|
||||
func (j *Journal) ToDB(dest **db.Journal) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
journal := &db.Journal{
|
||||
Name: j.Name,
|
||||
Sort: j.Sort,
|
||||
ID: j.ID,
|
||||
}
|
||||
|
||||
OwnershipToDB(&journal.Ownership, j.Ownership)
|
||||
CopySliceToDB(&journal.Pages, j.Pages)
|
||||
|
||||
*dest = journal
|
||||
|
||||
return true
|
||||
}
|
||||
95
internal/foundry/models/json/journal_page.go
Normal file
95
internal/foundry/models/json/journal_page.go
Normal file
@@ -0,0 +1,95 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type JournalPage struct {
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Text PageText `json:"text,omitempty"`
|
||||
ID string `json:"_id"`
|
||||
Title PageTitle `json:"title"`
|
||||
Video PageVideo `json:"video"`
|
||||
Src string `json:"src"`
|
||||
Sort int `json:"sort"`
|
||||
Ownership map[string]int `json:"ownership"`
|
||||
Stats Stats `json:"_stats,omitempty"`
|
||||
// System PagesSystem `json:"system"`
|
||||
// Image any `json:"image"`
|
||||
// Flags any `json:"flags"`
|
||||
// Category any `json:"category"`
|
||||
}
|
||||
|
||||
func (j *JournalPage) ToDB(dest **db.JournalPage) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
journalPage := &db.JournalPage{
|
||||
Name: j.Name,
|
||||
Type: j.Type,
|
||||
ID: j.ID,
|
||||
Src: j.Src,
|
||||
Sort: j.Sort,
|
||||
}
|
||||
|
||||
j.Text.ToDB(&journalPage.Text)
|
||||
j.Title.ToDB(&journalPage.Title)
|
||||
j.Video.ToDB(&journalPage.Video)
|
||||
j.Stats.ToDB(&journalPage.Stats)
|
||||
|
||||
OwnershipToDB(&journalPage.Ownership, j.Ownership)
|
||||
|
||||
*dest = journalPage
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type PageText struct {
|
||||
Content string `json:"content"`
|
||||
Format int `json:"format"`
|
||||
Markdown string `json:"markdown,omitempty"`
|
||||
}
|
||||
|
||||
func (p *PageText) ToDB(dest *db.PageText) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Content = p.Content
|
||||
dest.Format = p.Format
|
||||
dest.Markdown = p.Markdown
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type PageTitle struct {
|
||||
Show bool `json:"show"`
|
||||
Level int `json:"level"`
|
||||
}
|
||||
|
||||
func (p *PageTitle) ToDB(dest *db.PageTitle) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Show = p.Show
|
||||
dest.Level = p.Level
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type PageVideo struct {
|
||||
Controls bool `json:"controls"`
|
||||
Volume float64 `json:"volume"`
|
||||
}
|
||||
|
||||
func (p *PageVideo) ToDB(dest *db.PageVideo) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Controls = p.Controls
|
||||
dest.Volume = p.Volume
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,13 +1,67 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Language struct {
|
||||
Id string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Modules []LangModule `json:"modules"`
|
||||
Lang string `json:"lang"`
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
// SystemLanguagesFlags SystemLanguagesFlags `json:"flags"`
|
||||
}
|
||||
|
||||
type LangModule struct {
|
||||
Id string `json:"id"`
|
||||
func (l *Language) ToDB(dest **db.Language) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
lang := &db.Language{
|
||||
Lang: l.Lang,
|
||||
Name: l.Name,
|
||||
Path: l.Path,
|
||||
}
|
||||
|
||||
*dest = lang
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SetupLanguage struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Modules []*SetupLanguageModule `json:"modules"`
|
||||
}
|
||||
|
||||
func (s *SetupLanguage) ToDB(dest **db.SetupLanguage) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
lang := &db.SetupLanguage{
|
||||
ID: s.ID,
|
||||
Label: s.Label,
|
||||
}
|
||||
|
||||
CopySliceToDB(&lang.Modules, s.Modules)
|
||||
|
||||
*dest = lang
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SetupLanguageModule struct {
|
||||
ID string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
func (s *SetupLanguageModule) ToDB(dest *db.SetupLanguageModule) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.ID = s.ID
|
||||
dest.Label = s.Label
|
||||
dest.Path = s.Path
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
85
internal/foundry/models/json/light.go
Normal file
85
internal/foundry/models/json/light.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Light struct {
|
||||
Alpha float64 `json:"alpha"`
|
||||
Angle int `json:"angle"`
|
||||
Bright float64 `json:"bright"`
|
||||
Coloration float64 `json:"coloration"`
|
||||
Dim float64 `json:"dim"`
|
||||
Attenuation float64 `json:"attenuation"`
|
||||
Luminosity float64 `json:"luminosity"`
|
||||
Saturation float64 `json:"saturation"`
|
||||
Contrast float64 `json:"contrast"`
|
||||
Shadows float64 `json:"shadows"`
|
||||
LightAnimation LightAnimation `json:"animation"`
|
||||
LightDarkness LightDarkness `json:"darkness"`
|
||||
Negative bool `json:"negative"`
|
||||
Priority int `json:"priority"`
|
||||
Color string `json:"color"`
|
||||
}
|
||||
|
||||
func (l *Light) ToDB(dest **db.Light) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
light := &db.Light{
|
||||
Alpha: l.Alpha,
|
||||
Angle: l.Angle,
|
||||
Bright: l.Bright,
|
||||
Coloration: l.Coloration,
|
||||
Dim: l.Dim,
|
||||
Attenuation: l.Attenuation,
|
||||
Luminosity: l.Luminosity,
|
||||
Saturation: l.Saturation,
|
||||
Contrast: l.Contrast,
|
||||
Shadows: l.Shadows,
|
||||
Negative: l.Negative,
|
||||
Priority: l.Priority,
|
||||
Color: l.Color,
|
||||
}
|
||||
|
||||
l.LightAnimation.ToDB(&light.LightAnimation)
|
||||
l.LightDarkness.ToDB(&light.LightDarkness)
|
||||
|
||||
*dest = light
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type LightAnimation struct {
|
||||
Type any `json:"type"`
|
||||
Speed int `json:"speed"`
|
||||
Intensity int `json:"intensity"`
|
||||
Reverse bool `json:"reverse"`
|
||||
}
|
||||
|
||||
func (l *LightAnimation) ToDB(dest *db.LightAnimation) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Speed = l.Speed
|
||||
dest.Intensity = l.Intensity
|
||||
dest.Reverse = l.Reverse
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type LightDarkness struct {
|
||||
Min float64 `json:"min"`
|
||||
Max float64 `json:"max"`
|
||||
}
|
||||
|
||||
func (l *LightDarkness) ToDB(dest *db.LightDarkness) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Min = l.Min
|
||||
dest.Max = l.Max
|
||||
|
||||
return true
|
||||
}
|
||||
44
internal/foundry/models/json/macro.go
Normal file
44
internal/foundry/models/json/macro.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Macro struct {
|
||||
Command string `json:"command"`
|
||||
Name string `json:"name"`
|
||||
Type string `json:"type"`
|
||||
Img string `json:"img"`
|
||||
ID string `json:"_id"`
|
||||
Author string `json:"author"`
|
||||
Scope string `json:"scope"`
|
||||
Folder string `json:"folder"`
|
||||
Sort int `json:"sort"`
|
||||
Ownership map[string]int `json:"ownership,omitempty"`
|
||||
Stats Stats `json:"_stats"`
|
||||
// Flags any `json:"flags,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Macro) ToDB(dest **db.Macro) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
macro := &db.Macro{
|
||||
Command: m.Command,
|
||||
Name: m.Name,
|
||||
Type: m.Type,
|
||||
Img: m.Img,
|
||||
ID: m.ID,
|
||||
Author: m.Author,
|
||||
Scope: m.Scope,
|
||||
Folder: m.Folder,
|
||||
Sort: m.Sort,
|
||||
}
|
||||
|
||||
m.Stats.ToDB(¯o.Stats)
|
||||
|
||||
OwnershipToDB(¯o.Ownership, m.Ownership)
|
||||
|
||||
*dest = macro
|
||||
|
||||
return true
|
||||
}
|
||||
25
internal/foundry/models/json/media.go
Normal file
25
internal/foundry/models/json/media.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Media struct {
|
||||
Type string `json:"type"`
|
||||
URL string `json:"url"`
|
||||
Caption string `json:"caption"`
|
||||
}
|
||||
|
||||
func (m *Media) ToDB(dest **db.Media) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
media := &db.Media{
|
||||
Type: m.Type,
|
||||
URL: m.URL,
|
||||
Caption: m.Caption,
|
||||
}
|
||||
|
||||
*dest = media
|
||||
|
||||
return true
|
||||
}
|
||||
73
internal/foundry/models/json/message.go
Normal file
73
internal/foundry/models/json/message.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Message struct {
|
||||
Content string `json:"content"`
|
||||
Style int `json:"style"`
|
||||
Author string `json:"author"`
|
||||
Id string `json:"_id"`
|
||||
Type string `json:"type"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Flavor string `json:"flavor"`
|
||||
Speaker Speaker `json:"speaker"`
|
||||
Whisper []string `json:"whisper"`
|
||||
Blind bool `json:"blind"`
|
||||
Rolls []string `json:"rolls"`
|
||||
Sound string `json:"sound"`
|
||||
Emote bool `json:"emote"`
|
||||
Stats Stats `json:"_stats"`
|
||||
// System any `json:"system"`
|
||||
// Flags any `json:"flags"`
|
||||
}
|
||||
|
||||
func (m *Message) ToDB(dest **db.Message) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
message := &db.Message{
|
||||
Content: m.Content,
|
||||
Style: m.Style,
|
||||
Author: m.Author,
|
||||
ID: m.Id,
|
||||
Type: m.Type,
|
||||
Timestamp: m.Timestamp,
|
||||
Flavor: m.Flavor,
|
||||
Blind: m.Blind,
|
||||
Sound: m.Sound,
|
||||
Emote: m.Emote,
|
||||
}
|
||||
|
||||
m.Speaker.ToDB(&message.Speaker)
|
||||
m.Stats.ToDB(&message.Stats)
|
||||
|
||||
message.Whisper = make([]string, len(m.Whisper))
|
||||
copy(message.Whisper, m.Whisper)
|
||||
message.Rolls = make([]string, len(m.Rolls))
|
||||
copy(message.Rolls, m.Rolls)
|
||||
|
||||
*dest = message
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type Speaker struct {
|
||||
Scene string `json:"scene,omitempty"`
|
||||
Actor string `json:"actor,omitempty"`
|
||||
Token string `json:"token,omitempty"`
|
||||
Alias string `json:"alias,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Speaker) ToDB(dest *db.Speaker) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Scene = s.Scene
|
||||
dest.Actor = s.Actor
|
||||
dest.Token = s.Token
|
||||
dest.Alias = s.Alias
|
||||
|
||||
return true
|
||||
}
|
||||
100
internal/foundry/models/json/module.go
Normal file
100
internal/foundry/models/json/module.go
Normal file
@@ -0,0 +1,100 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type Module struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Authors []*Author `json:"authors"`
|
||||
URL string `json:"url,omitempty"`
|
||||
License string `json:"license,omitempty"`
|
||||
Readme string `json:"readme,omitempty"`
|
||||
Bugs string `json:"bugs,omitempty"`
|
||||
Changelog string `json:"changelog,omitempty"`
|
||||
Media []*Media `json:"media"`
|
||||
Version string `json:"version"`
|
||||
Compatibility Compatibility `json:"compatibility,omitempty"`
|
||||
Scripts []string `json:"scripts"`
|
||||
Esmodules []string `json:"esmodules"`
|
||||
Styles []*Style `json:"styles"`
|
||||
Languages []*Language `json:"languages"`
|
||||
Packs []*Pack `json:"packs"`
|
||||
PackFolders []*Folder `json:"packFolders"`
|
||||
Relationships Relationships `json:"relationships"`
|
||||
Socket bool `json:"socket"`
|
||||
Manifest string `json:"manifest,omitempty"`
|
||||
Download string `json:"download,omitempty"`
|
||||
Protected bool `json:"protected"`
|
||||
Exclusive bool `json:"exclusive"`
|
||||
PersistentStorage bool `json:"persistentStorage"`
|
||||
CoreTranslation bool `json:"coreTranslation"`
|
||||
Library bool `json:"library"`
|
||||
DocumentTypes DocumentTypes `json:"documentTypes"`
|
||||
Availability int `json:"availability"`
|
||||
Locked bool `json:"locked"`
|
||||
Owned bool `json:"owned"`
|
||||
Tags []string `json:"tags"`
|
||||
HasStorage bool `json:"hasStorage"`
|
||||
Active bool `json:"active,omitempty"`
|
||||
// ModulesFlags ModulesFlags `json:"flags,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Module) ToDB(dest **db.Module) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
module := &db.Module{
|
||||
ID: m.ID,
|
||||
Title: m.Title,
|
||||
Description: m.Description,
|
||||
URL: m.URL,
|
||||
License: m.License,
|
||||
Readme: m.Readme,
|
||||
Bugs: m.Bugs,
|
||||
Changelog: m.Changelog,
|
||||
Version: m.Version,
|
||||
Socket: m.Socket,
|
||||
Manifest: m.Manifest,
|
||||
Download: m.Download,
|
||||
Protected: m.Protected,
|
||||
Exclusive: m.Exclusive,
|
||||
PersistentStorage: m.PersistentStorage,
|
||||
CoreTranslation: m.CoreTranslation,
|
||||
Library: m.Library,
|
||||
Availability: m.Availability,
|
||||
Locked: m.Locked,
|
||||
Owned: m.Owned,
|
||||
HasStorage: m.HasStorage,
|
||||
Active: m.Active,
|
||||
}
|
||||
|
||||
module.Scripts = make([]string, len(m.Scripts))
|
||||
copy(module.Scripts, m.Scripts)
|
||||
module.Esmodules = make([]string, len(m.Esmodules))
|
||||
copy(module.Esmodules, m.Esmodules)
|
||||
module.Tags = make([]string, len(m.Tags))
|
||||
copy(module.Tags, m.Tags)
|
||||
|
||||
m.Compatibility.ToDB(&module.Compatibility)
|
||||
m.Relationships.ToDB(&module.Relationships)
|
||||
m.DocumentTypes.ToDB(&module.DocumentTypes)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
CopySliceToDBParallel(&wg, &module.Authors, m.Authors)
|
||||
CopySliceToDBParallel(&wg, &module.Media, m.Media)
|
||||
CopySliceToDBParallel(&wg, &module.Styles, m.Styles)
|
||||
CopySliceToDBParallel(&wg, &module.Languages, m.Languages)
|
||||
CopySliceToDBParallel(&wg, &module.Packs, m.Packs)
|
||||
CopySliceToDBParallel(&wg, &module.PackFolders, m.PackFolders)
|
||||
wg.Wait()
|
||||
|
||||
*dest = module
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package modules
|
||||
|
||||
type DiceStats struct {
|
||||
PlayerRollData DiceStatsRollData `json:"player_roll_data"`
|
||||
}
|
||||
|
||||
type DiceStatsRollData struct {
|
||||
PlayerDice []DicePlayerDice `json:"PLAYER_DICE"`
|
||||
Username string `json:"USERNAME"`
|
||||
Userid string `json:"USERID"`
|
||||
Gm bool `json:"GM"`
|
||||
PlayerRollInfo DiceRollInfo `json:"PLAYER_ROLL_INFO"`
|
||||
}
|
||||
|
||||
type DicePlayerDice struct {
|
||||
Type string `json:"TYPE"`
|
||||
Max int `json:"MAX"`
|
||||
TotalRolls int `json:"TOTAL_ROLLS"`
|
||||
Rolls []int `json:"ROLLS"`
|
||||
BlindRolls []int `json:"BLIND_ROLLS"`
|
||||
StreakSize int `json:"STREAK_SIZE"`
|
||||
StreakInit int `json:"STREAK_INIT"`
|
||||
StreakIsBlind bool `json:"STREAK_ISBLIND"`
|
||||
LongestStreak int `json:"LONGEST_STREAK"`
|
||||
LongestStreakInit int `json:"LONGEST_STREAK_INIT"`
|
||||
Mean int `json:"MEAN"`
|
||||
Median int `json:"MEDIAN"`
|
||||
Mode int `json:"MODE"`
|
||||
Means []int `json:"MEANS"`
|
||||
Medians []int `json:"MEDIANS"`
|
||||
Modes []int `json:"MODES"`
|
||||
RollCounters []int `json:"ROLL_COUNTERS"`
|
||||
AtkRolls []int `json:"ATK_ROLLS"`
|
||||
DmgRolls []int `json:"DMG_ROLLS"`
|
||||
SavesRolls []int `json:"SAVES_ROLLS"`
|
||||
SkillsRolls []int `json:"SKILLS_ROLLS"`
|
||||
AbilityRolls []int `json:"ABILITY_ROLLS"`
|
||||
UnknownRolls []int `json:"UNKNOWN_ROLLS"`
|
||||
PerceptionRolls []int `json:"PERCEPTION_ROLLS"`
|
||||
InitiativeRolls []int `json:"INITIATIVE_ROLLS"`
|
||||
AtkRollsBlind []int `json:"ATK_ROLLS_BLIND"`
|
||||
DmgRollsBlind []int `json:"DMG_ROLLS_BLIND"`
|
||||
SavesRollsBlind []int `json:"SAVES_ROLLS_BLIND"`
|
||||
SkillsRollsBlind []int `json:"SKILLS_ROLLS_BLIND"`
|
||||
AbilityRollsBlind []int `json:"ABILITY_ROLLS_BLIND"`
|
||||
UnknownRollsBlind []int `json:"UNKNOWN_ROLLS_BLIND"`
|
||||
PerceptionRollsBlind []int `json:"PERCEPTION_ROLLS_BLIND"`
|
||||
InitiativeRollsBlind []int `json:"INITIATIVE_ROLLS_BLIND"`
|
||||
}
|
||||
|
||||
type DiceRollInfo struct {
|
||||
IsRollInfoTracked bool `json:"IS_ROLL_INFO_TRACKED"`
|
||||
AtkOutcomeTracker []int `json:"ATK_OUTCOME_TRACKER"`
|
||||
NumUntargetedAtks int `json:"NUM_UNTARGETED_ATKS"`
|
||||
TotalAttacks int `json:"TOTAL_ATTACKS"`
|
||||
SaveOutcomeTracker []int `json:"SAVE_OUTCOME_TRACKER"`
|
||||
NumUntargetedSaves int `json:"NUM_UNTARGETED_SAVES"`
|
||||
TotalSaves int `json:"TOTAL_SAVES"`
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package modules
|
||||
|
||||
type Pf2eModule struct {
|
||||
settings Pf2eSettings
|
||||
}
|
||||
|
||||
type Pf2eSettings struct {
|
||||
showEffectPanel bool
|
||||
showCheckDialogs bool
|
||||
showDamageDialogs bool
|
||||
monochromeDarkvision bool
|
||||
}
|
||||
81
internal/foundry/models/json/notes.go
Normal file
81
internal/foundry/models/json/notes.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Note struct {
|
||||
EntryID string `json:"entryId"`
|
||||
PageID string `json:"pageId"`
|
||||
Text string `json:"text"`
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Global bool `json:"global"`
|
||||
IconSize int `json:"iconSize"`
|
||||
Texture NoteTexture `json:"texture"`
|
||||
FontFamily string `json:"fontFamily"`
|
||||
FontSize int `json:"fontSize"`
|
||||
TextColor string `json:"textColor"`
|
||||
TextAnchor int `json:"textAnchor"`
|
||||
ID string `json:"_id"`
|
||||
Elevation int `json:"elevation"`
|
||||
Sort int `json:"sort"`
|
||||
// NotesFlags any `json:"flags"`
|
||||
}
|
||||
|
||||
func (n *Note) ToDB(dest *db.Note) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.EntryID = n.EntryID
|
||||
dest.PageID = n.PageID
|
||||
dest.Text = n.Text
|
||||
dest.X = n.X
|
||||
dest.Y = n.Y
|
||||
dest.Global = n.Global
|
||||
dest.IconSize = n.IconSize
|
||||
dest.FontFamily = n.FontFamily
|
||||
dest.FontSize = n.FontSize
|
||||
dest.TextColor = n.TextColor
|
||||
dest.TextAnchor = n.TextAnchor
|
||||
dest.ID = n.ID
|
||||
dest.Elevation = n.Elevation
|
||||
dest.Sort = n.Sort
|
||||
|
||||
n.Texture.ToDB(&dest.Texture)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type NoteTexture struct {
|
||||
Tint string `json:"tint"`
|
||||
Src string `json:"src"`
|
||||
ScaleX int `json:"scaleX"`
|
||||
ScaleY int `json:"scaleY"`
|
||||
OffsetX float64 `json:"offsetX"`
|
||||
OffsetY float64 `json:"offsetY"`
|
||||
Rotation int `json:"rotation"`
|
||||
AnchorX float64 `json:"anchorX"`
|
||||
AnchorY float64 `json:"anchorY"`
|
||||
Fit string `json:"fit"`
|
||||
AlphaThreshold int `json:"alphaThreshold"`
|
||||
}
|
||||
|
||||
func (n *NoteTexture) ToDB(dest *db.NoteTexture) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Tint = n.Tint
|
||||
dest.Src = n.Src
|
||||
dest.ScaleX = n.ScaleX
|
||||
dest.ScaleY = n.ScaleY
|
||||
dest.OffsetX = n.OffsetX
|
||||
dest.OffsetY = n.OffsetY
|
||||
dest.Rotation = n.Rotation
|
||||
dest.AnchorX = n.AnchorX
|
||||
dest.AnchorY = n.AnchorY
|
||||
dest.Fit = n.Fit
|
||||
dest.AlphaThreshold = n.AlphaThreshold
|
||||
|
||||
return true
|
||||
}
|
||||
80
internal/foundry/models/json/options.go
Normal file
80
internal/foundry/models/json/options.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type GameOptions struct {
|
||||
Language string `json:"language"`
|
||||
Port int `json:"port"`
|
||||
RoutePrefix any `json:"routePrefix"`
|
||||
UpdateChannel string `json:"updateChannel"`
|
||||
}
|
||||
|
||||
func (g *GameOptions) ToDB(dest *db.GameOptions) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Language = g.Language
|
||||
dest.Port = g.Port
|
||||
dest.UpdateChannel = g.UpdateChannel
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SetupOptions struct {
|
||||
AwsConfig any `json:"awsConfig"`
|
||||
CompressSocket bool `json:"compressSocket"`
|
||||
CompressStatic bool `json:"compressStatic"`
|
||||
CSSTheme string `json:"cssTheme"`
|
||||
DataPath string `json:"dataPath"`
|
||||
Fullscreen bool `json:"fullscreen"`
|
||||
Hostname string `json:"hostname"`
|
||||
HotReload bool `json:"hotReload"`
|
||||
Language string `json:"language"`
|
||||
LocalHostname string `json:"localHostname"`
|
||||
Port int `json:"port"`
|
||||
ProxySSL bool `json:"proxySSL"`
|
||||
Telemetry bool `json:"telemetry"`
|
||||
UpdateChannel string `json:"updateChannel"`
|
||||
Upnp bool `json:"upnp"`
|
||||
DeleteNEDB bool `json:"deleteNEDB"`
|
||||
NoBackups bool `json:"noBackups"`
|
||||
// PasswordSalt any `json:"passwordSalt"`
|
||||
// Protocol any `json:"protocol"`
|
||||
// ProxyPort any `json:"proxyPort"`
|
||||
// RoutePrefix any `json:"routePrefix"`
|
||||
// SslCert any `json:"sslCert"`
|
||||
// SslKey any `json:"sslKey"`
|
||||
// UpnpLeaseDuration any `json:"upnpLeaseDuration"`
|
||||
// World any `json:"world"`
|
||||
// AdminPassword string `json:"adminPassword"`
|
||||
}
|
||||
|
||||
func (s *SetupOptions) ToDB(dest **db.SetupOptions) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
options := &db.SetupOptions{
|
||||
CompressSocket: s.CompressSocket,
|
||||
CompressStatic: s.CompressStatic,
|
||||
CSSTheme: s.CSSTheme,
|
||||
DataPath: s.DataPath,
|
||||
Fullscreen: s.Fullscreen,
|
||||
Hostname: s.Hostname,
|
||||
HotReload: s.HotReload,
|
||||
Language: s.Language,
|
||||
LocalHostname: s.LocalHostname,
|
||||
Port: s.Port,
|
||||
ProxySSL: s.ProxySSL,
|
||||
Telemetry: s.Telemetry,
|
||||
UpdateChannel: s.UpdateChannel,
|
||||
Upnp: s.Upnp,
|
||||
DeleteNEDB: s.DeleteNEDB,
|
||||
NoBackups: s.NoBackups,
|
||||
}
|
||||
|
||||
*dest = options
|
||||
|
||||
return true
|
||||
}
|
||||
15
internal/foundry/models/json/ownership.go
Normal file
15
internal/foundry/models/json/ownership.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Ownership struct {
|
||||
Player string `json:"PLAYER,omitempty"`
|
||||
Trusted string `json:"TRUSTED,omitempty"`
|
||||
Assistant string `json:"ASSISTANT,omitempty"`
|
||||
}
|
||||
|
||||
func (o *Ownership) ToDB(dest *db.Ownership) {
|
||||
dest.Player = o.Player
|
||||
dest.Trusted = o.Trusted
|
||||
dest.Assistant = o.Assistant
|
||||
}
|
||||
83
internal/foundry/models/json/pack.go
Normal file
83
internal/foundry/models/json/pack.go
Normal file
@@ -0,0 +1,83 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type Pack struct {
|
||||
Name string `json:"name"`
|
||||
Label string `json:"label"`
|
||||
Banner string `json:"banner"`
|
||||
Path string `json:"path"`
|
||||
Type string `json:"type"`
|
||||
System string `json:"system"`
|
||||
Ownership Ownership `json:"ownership"`
|
||||
PackageType string `json:"packageType,omitempty"`
|
||||
PackageName string `json:"packageName,omitempty"`
|
||||
Id string `json:"id,omitempty"`
|
||||
Index []*Index `json:"index"`
|
||||
Folders []*PackFolder `json:"folders"`
|
||||
// SystemPacksFlags SystemPacksFlags `json:"flags"`
|
||||
}
|
||||
|
||||
func (p *Pack) ToDB(dest **db.Pack) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
pack := &db.Pack{
|
||||
Name: p.Name,
|
||||
Label: p.Label,
|
||||
Banner: p.Banner,
|
||||
Path: p.Path,
|
||||
Type: p.Type,
|
||||
System: p.System,
|
||||
PackageType: p.PackageType,
|
||||
PackageName: p.PackageName,
|
||||
ID: p.Id,
|
||||
}
|
||||
|
||||
p.Ownership.ToDB(&pack.Ownership)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
CopySliceToDBParallel(&wg, &pack.Index, p.Index)
|
||||
CopySliceToDBParallel(&wg, &pack.Folders, p.Folders)
|
||||
wg.Wait()
|
||||
|
||||
*dest = pack
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type PackFolder struct {
|
||||
ID string `json:"_id"`
|
||||
Color any `json:"color"`
|
||||
Description string `json:"description"`
|
||||
Folder any `json:"folder"`
|
||||
Name string `json:"name"`
|
||||
Sort int `json:"sort"`
|
||||
Sorting string `json:"sorting"`
|
||||
Type string `json:"type"`
|
||||
// Packs0FoldersFlags any `json:"flags"`
|
||||
}
|
||||
|
||||
func (p *PackFolder) ToDB(dest **db.PackFolder) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
packFolder := &db.PackFolder{
|
||||
ID: p.ID,
|
||||
Description: p.Description,
|
||||
Name: p.Name,
|
||||
Sort: p.Sort,
|
||||
Sorting: p.Sorting,
|
||||
Type: p.Type,
|
||||
}
|
||||
|
||||
*dest = packFolder
|
||||
|
||||
return true
|
||||
}
|
||||
35
internal/foundry/models/json/package_warnings.go
Normal file
35
internal/foundry/models/json/package_warnings.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type PackageWarningsData struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Warning []string `json:"warning"`
|
||||
Error []string `json:"error"`
|
||||
Reinstallable bool `json:"reinstallable"`
|
||||
Manifest string `json:"manifest,omitempty"`
|
||||
}
|
||||
|
||||
func (p *PackageWarningsData) ToDB(dest **db.PackageWarningsData) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
packageData := &db.PackageWarningsData{
|
||||
ID: p.Id,
|
||||
Type: p.Type,
|
||||
Reinstallable: p.Reinstallable,
|
||||
Manifest: p.Manifest,
|
||||
}
|
||||
|
||||
packageData.Warning = make([]string, len(p.Warning))
|
||||
copy(packageData.Warning, p.Warning)
|
||||
|
||||
packageData.Error = make([]string, len(p.Error))
|
||||
copy(packageData.Error, p.Error)
|
||||
|
||||
*dest = packageData
|
||||
|
||||
return true
|
||||
}
|
||||
90
internal/foundry/models/json/playlist.go
Normal file
90
internal/foundry/models/json/playlist.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Playlist struct {
|
||||
Name string `json:"name"`
|
||||
ID string `json:"_id"`
|
||||
Sounds []*Sound `json:"sounds"`
|
||||
Mode int `json:"mode"`
|
||||
Playing bool `json:"playing"`
|
||||
Fade int `json:"fade,omitempty"`
|
||||
Folder string `json:"folder"`
|
||||
Sorting string `json:"sorting"`
|
||||
Seed int `json:"seed,omitempty"`
|
||||
Sort int `json:"sort"`
|
||||
Ownership map[string]int `json:"ownership,omitempty"`
|
||||
Stats Stats `json:"_stats"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Channel string `json:"channel"`
|
||||
// Flags any `json:"flags,omitempty"`
|
||||
}
|
||||
|
||||
func (p *Playlist) ToDB(dest **db.Playlist) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
playlist := &db.Playlist{
|
||||
Name: p.Name,
|
||||
ID: p.ID,
|
||||
Mode: p.Mode,
|
||||
Playing: p.Playing,
|
||||
Fade: p.Fade,
|
||||
Folder: p.Folder,
|
||||
Sorting: p.Sorting,
|
||||
Seed: p.Seed,
|
||||
Sort: p.Sort,
|
||||
Description: p.Description,
|
||||
Channel: p.Channel,
|
||||
}
|
||||
|
||||
p.Stats.ToDB(&playlist.Stats)
|
||||
|
||||
OwnershipToDB(&playlist.Ownership, p.Ownership)
|
||||
|
||||
CopySliceToDB(&playlist.Sounds, p.Sounds)
|
||||
|
||||
*dest = playlist
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type Sound struct {
|
||||
Name string `json:"name"`
|
||||
Path string `json:"path"`
|
||||
ID string `json:"_id"`
|
||||
Playing bool `json:"playing"`
|
||||
PausedTime float64 `json:"pausedTime"`
|
||||
Repeat bool `json:"repeat"`
|
||||
Volume float64 `json:"volume"`
|
||||
Fade int `json:"fade"`
|
||||
Sort int `json:"sort"`
|
||||
Channel string `json:"channel"`
|
||||
Description string `json:"description,omitempty"`
|
||||
// Flags any `json:"flags"`
|
||||
}
|
||||
|
||||
func (s *Sound) ToDB(dest **db.Sound) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
sound := &db.Sound{
|
||||
Name: s.Name,
|
||||
Path: s.Path,
|
||||
ID: s.ID,
|
||||
Playing: s.Playing,
|
||||
PausedTime: s.PausedTime,
|
||||
Repeat: s.Repeat,
|
||||
Volume: s.Volume,
|
||||
Fade: s.Fade,
|
||||
Sort: s.Sort,
|
||||
Channel: s.Channel,
|
||||
Description: s.Description,
|
||||
}
|
||||
|
||||
*dest = sound
|
||||
|
||||
return true
|
||||
}
|
||||
15
internal/foundry/models/json/region_behavior.go
Normal file
15
internal/foundry/models/json/region_behavior.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package json
|
||||
|
||||
type RegionBehavior struct {
|
||||
AdjustDarknessLevel any `json:"adjustDarknessLevel,omitempty"`
|
||||
DisplayScrollingText any `json:"displayScrollingText,omitempty"`
|
||||
ExecuteMacro any `json:"executeMacro,omitempty"`
|
||||
ExecuteScript any `json:"executeScript,omitempty"`
|
||||
ModifyMovementCost any `json:"modifyMovementCost,omitempty"`
|
||||
PauseGame any `json:"pauseGame,omitempty"`
|
||||
SuppressWeather any `json:"suppressWeather,omitempty"`
|
||||
TeleportToken any `json:"teleportToken,omitempty"`
|
||||
ToggleBehavior any `json:"toggleBehavior,omitempty"`
|
||||
RegionBehaviorEnvironment any `json:"environment,omitempty"`
|
||||
RegionBehaviorEnvironmentFeature any `json:"environmentFeature,omitempty"`
|
||||
}
|
||||
51
internal/foundry/models/json/relationships.go
Normal file
51
internal/foundry/models/json/relationships.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type Relationships struct {
|
||||
Systems []*RelationshipsData `json:"systems,omitempty"`
|
||||
Requires []*RelationshipsData `json:"requires,omitempty"`
|
||||
Recommends []*RelationshipsData `json:"recommends,omitempty"`
|
||||
Conflicts []*RelationshipsData `json:"conflicts,omitempty"`
|
||||
// RelationshipsFlags RelationshipsFlags `json:"flags"`
|
||||
}
|
||||
|
||||
func (r *Relationships) ToDB(dest *db.Relationships) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
CopySliceToDBParallel(&wg, &dest.Systems, r.Systems)
|
||||
CopySliceToDBParallel(&wg, &dest.Requires, r.Requires)
|
||||
CopySliceToDBParallel(&wg, &dest.Recommends, r.Recommends)
|
||||
CopySliceToDBParallel(&wg, &dest.Conflicts, r.Conflicts)
|
||||
wg.Wait()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type RelationshipsData struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Manifest string `json:"manifest"`
|
||||
Compatibility Compatibility `json:"compatibility"`
|
||||
}
|
||||
|
||||
func (r *RelationshipsData) ToDB(dest *db.RelationshipsData) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Key = r.Id
|
||||
dest.Type = r.Type
|
||||
dest.Manifest = r.Manifest
|
||||
|
||||
r.Compatibility.ToDB(&dest.Compatibility)
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,11 +1,32 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Release struct {
|
||||
Generation int `json:"generation"`
|
||||
Channel string `json:"channel"`
|
||||
Suffix string `json:"suffix"`
|
||||
Build int `json:"build"`
|
||||
Node_version int `json:"node_version"`
|
||||
Time int64 `json:"time"`
|
||||
flags struct{} `json:"-"`
|
||||
Generation int `json:"generation"`
|
||||
Channel string `json:"channel"`
|
||||
Suffix string `json:"suffix"`
|
||||
Build int `json:"build"`
|
||||
NodeVersion int `json:"node_version"`
|
||||
MaxGeneration int `json:"maxGeneration"`
|
||||
MaxStableGeneration int `json:"maxStableGeneration"`
|
||||
Time int64 `json:"time"`
|
||||
// Flags Flags `json:"flags"`
|
||||
}
|
||||
|
||||
func (r *Release) ToDB(dest *db.Release) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Generation = r.Generation
|
||||
dest.Channel = r.Channel
|
||||
dest.Suffix = r.Suffix
|
||||
dest.Build = r.Build
|
||||
dest.NodeVersion = r.NodeVersion
|
||||
dest.MaxGeneration = r.MaxGeneration
|
||||
dest.MaxStableGeneration = r.MaxStableGeneration
|
||||
dest.Time = r.Time
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
60
internal/foundry/models/json/ring.go
Normal file
60
internal/foundry/models/json/ring.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Ring struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
RingColors RingColors `json:"colors"`
|
||||
Effects int `json:"effects"`
|
||||
Subject Subject `json:"subject"`
|
||||
}
|
||||
|
||||
func (r *Ring) ToDB(dest **db.Ring) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
ring := &db.Ring{
|
||||
Enabled: r.Enabled,
|
||||
Effects: r.Effects,
|
||||
}
|
||||
|
||||
r.RingColors.ToDB(&ring.RingColors)
|
||||
r.Subject.ToDB(&ring.Subject)
|
||||
|
||||
*dest = ring
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type RingColors struct {
|
||||
Ring string `json:"ring"`
|
||||
Background string `json:"background"`
|
||||
}
|
||||
|
||||
func (r *RingColors) ToDB(dest *db.RingColors) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Ring = r.Ring
|
||||
dest.Background = r.Background
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type Subject struct {
|
||||
Scale int `json:"scale"`
|
||||
Texture string `json:"texture"`
|
||||
}
|
||||
|
||||
func (s *Subject) ToDB(dest *db.Subject) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Scale = s.Scale
|
||||
dest.Texture = s.Texture
|
||||
|
||||
return true
|
||||
}
|
||||
414
internal/foundry/models/json/scene.go
Normal file
414
internal/foundry/models/json/scene.go
Normal file
@@ -0,0 +1,414 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type Scene struct {
|
||||
Folder string `json:"folder"`
|
||||
Name string `json:"name"`
|
||||
Active bool `json:"active"`
|
||||
Navigation bool `json:"navigation"`
|
||||
NavOrder int `json:"navOrder"`
|
||||
NavName string `json:"navName"`
|
||||
Background SceneBackground `json:"background"`
|
||||
Foreground string `json:"foreground"`
|
||||
ForegroundElevation int `json:"foregroundElevation"`
|
||||
Thumb string `json:"thumb"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
Padding float64 `json:"padding"`
|
||||
Initial SceneInitial `json:"initial"`
|
||||
BackgroundColor string `json:"backgroundColor"`
|
||||
Grid SceneGrid `json:"grid"`
|
||||
TokenVision bool `json:"tokenVision"`
|
||||
Drawings []*SceneDrawing `json:"drawings"`
|
||||
Tokens []*Token `json:"tokens"`
|
||||
Lights []*SceneLight `json:"lights"`
|
||||
Notes []*Note `json:"notes"`
|
||||
Sounds []*ScenesSound `json:"sounds"`
|
||||
Walls []*Wall `json:"walls"`
|
||||
Playlist string `json:"playlist"`
|
||||
PlaylistSound string `json:"playlistSound"`
|
||||
Journal string `json:"journal"`
|
||||
JournalEntryPage string `json:"journalEntryPage"`
|
||||
Weather string `json:"weather"`
|
||||
Sort int `json:"sort"`
|
||||
Ownership map[string]int `json:"ownership,omitempty"`
|
||||
Stats Stats `json:"_stats"`
|
||||
ID string `json:"_id"`
|
||||
Fog SceneFog `json:"fog,omitempty"`
|
||||
Environment Environment `json:"environment"`
|
||||
|
||||
// ScenesTemplates []any `json:"templates"`
|
||||
// Tiles []any `json:"tiles"`
|
||||
// ScenesFlags any `json:"flags,omitempty"`
|
||||
// Regions []any `json:"regions"`
|
||||
}
|
||||
|
||||
func (s *Scene) ToDB(dest *db.Scene) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Folder = s.Folder
|
||||
dest.Name = s.Name
|
||||
dest.Active = s.Active
|
||||
dest.Navigation = s.Navigation
|
||||
dest.NavOrder = s.NavOrder
|
||||
dest.NavName = s.NavName
|
||||
dest.Foreground = s.Foreground
|
||||
dest.ForegroundElevation = s.ForegroundElevation
|
||||
dest.Thumb = s.Thumb
|
||||
dest.Width = s.Width
|
||||
dest.Height = s.Height
|
||||
dest.Padding = s.Padding
|
||||
dest.BackgroundColor = s.BackgroundColor
|
||||
dest.TokenVision = s.TokenVision
|
||||
dest.Playlist = s.Playlist
|
||||
dest.PlaylistSound = s.PlaylistSound
|
||||
dest.Journal = s.Journal
|
||||
dest.JournalEntryPage = s.JournalEntryPage
|
||||
dest.Weather = s.Weather
|
||||
dest.Sort = s.Sort
|
||||
dest.ID = s.ID
|
||||
|
||||
s.Background.ToDB(&dest.Background)
|
||||
s.Initial.ToDB(&dest.Initial)
|
||||
s.Grid.ToDB(&dest.Grid)
|
||||
s.Stats.ToDB(&dest.Stats)
|
||||
s.Fog.ToDB(&dest.Fog)
|
||||
s.Environment.ToDB(&dest.Environment)
|
||||
|
||||
OwnershipToDB(&dest.Ownership, s.Ownership)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
CopySliceToDBParallel(&wg, &dest.Drawings, s.Drawings)
|
||||
CopySliceToDBParallel(&wg, &dest.Tokens, s.Tokens)
|
||||
CopySliceToDBParallel(&wg, &dest.Lights, s.Lights)
|
||||
CopySliceToDBParallel(&wg, &dest.Notes, s.Notes)
|
||||
CopySliceToDBParallel(&wg, &dest.Sounds, s.Sounds)
|
||||
CopySliceToDBParallel(&wg, &dest.Walls, s.Walls)
|
||||
wg.Wait()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SceneBackground struct {
|
||||
Src string `json:"src"`
|
||||
ScaleX float64 `json:"scaleX"`
|
||||
ScaleY float64 `json:"scaleY"`
|
||||
OffsetX float64 `json:"offsetX"`
|
||||
OffsetY float64 `json:"offsetY"`
|
||||
Rotation int `json:"rotation"`
|
||||
Tint string `json:"tint"`
|
||||
AnchorX float64 `json:"anchorX"`
|
||||
AnchorY float64 `json:"anchorY"`
|
||||
Fit string `json:"fit"`
|
||||
AlphaThreshold int `json:"alphaThreshold"`
|
||||
}
|
||||
|
||||
func (s *SceneBackground) ToDB(dest *db.SceneBackground) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Src = s.Src
|
||||
dest.ScaleX = s.ScaleX
|
||||
dest.ScaleY = s.ScaleY
|
||||
dest.OffsetX = s.OffsetX
|
||||
dest.OffsetY = s.OffsetY
|
||||
dest.Rotation = s.Rotation
|
||||
dest.Tint = s.Tint
|
||||
dest.AnchorX = s.AnchorX
|
||||
dest.AnchorX = s.AnchorY
|
||||
dest.Fit = s.Fit
|
||||
dest.AlphaThreshold = s.AlphaThreshold
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SceneInitial struct {
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Scale float64 `json:"scale"`
|
||||
}
|
||||
|
||||
func (s *SceneInitial) ToDB(dest *db.SceneInitial) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.X = s.X
|
||||
dest.Y = s.Y
|
||||
dest.Scale = s.Scale
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SceneGrid struct {
|
||||
Type int `json:"type"`
|
||||
Size int `json:"size"`
|
||||
Color string `json:"color"`
|
||||
Alpha float64 `json:"alpha"`
|
||||
Distance int `json:"distance"`
|
||||
Units string `json:"units"`
|
||||
Style string `json:"style"`
|
||||
Thickness int `json:"thickness"`
|
||||
}
|
||||
|
||||
func (s *SceneGrid) ToDB(dest *db.SceneGrid) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Type = s.Type
|
||||
dest.Size = s.Size
|
||||
dest.Color = s.Color
|
||||
dest.Alpha = s.Alpha
|
||||
dest.Distance = s.Distance
|
||||
dest.Units = s.Units
|
||||
dest.Style = s.Style
|
||||
dest.Thickness = s.Thickness
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SceneDrawing struct {
|
||||
Author string `json:"author"`
|
||||
Shape SceneDrawingShape `json:"shape"`
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Rotation int `json:"rotation"`
|
||||
BezierFactor int `json:"bezierFactor"`
|
||||
FillType int `json:"fillType"`
|
||||
FillColor string `json:"fillColor"`
|
||||
FillAlpha float64 `json:"fillAlpha"`
|
||||
StrokeWidth int `json:"strokeWidth"`
|
||||
StrokeColor string `json:"strokeColor"`
|
||||
StrokeAlpha int `json:"strokeAlpha"`
|
||||
Texture string `json:"texture"`
|
||||
Text string `json:"text"`
|
||||
FontFamily string `json:"fontFamily"`
|
||||
FontSize int `json:"fontSize"`
|
||||
TextColor string `json:"textColor"`
|
||||
TextAlpha int `json:"textAlpha"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Locked bool `json:"locked"`
|
||||
ID string `json:"_id"`
|
||||
Interface bool `json:"interface"`
|
||||
Elevation int `json:"elevation"`
|
||||
Sort int `json:"sort"`
|
||||
// Flags any `json:"flags"`
|
||||
}
|
||||
|
||||
func (s *SceneDrawing) ToDB(dest *db.SceneDrawing) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Author = s.Author
|
||||
dest.X = s.X
|
||||
dest.Y = s.Y
|
||||
dest.Rotation = s.Rotation
|
||||
dest.BezierFactor = s.BezierFactor
|
||||
dest.FillType = s.FillType
|
||||
dest.FillColor = s.FillColor
|
||||
dest.FillAlpha = s.FillAlpha
|
||||
dest.StrokeWidth = s.StrokeWidth
|
||||
dest.StrokeColor = s.StrokeColor
|
||||
dest.StrokeAlpha = s.StrokeAlpha
|
||||
dest.Texture = s.Texture
|
||||
dest.Text = s.Text
|
||||
dest.FontFamily = s.FontFamily
|
||||
dest.FontSize = s.FontSize
|
||||
dest.TextColor = s.TextColor
|
||||
dest.TextAlpha = s.TextAlpha
|
||||
dest.Hidden = s.Hidden
|
||||
dest.Locked = s.Locked
|
||||
dest.ID = s.ID
|
||||
dest.Interface = s.Interface
|
||||
dest.Elevation = s.Elevation
|
||||
dest.Sort = s.Sort
|
||||
|
||||
s.Shape.ToDB(&dest.Shape)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SceneDrawingShape struct {
|
||||
Type string `json:"type"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
Radius any `json:"radius"`
|
||||
Points []any `json:"points"`
|
||||
}
|
||||
|
||||
func (s *SceneDrawingShape) ToDB(dest *db.SceneDrawingShape) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Type = s.Type
|
||||
dest.Width = s.Width
|
||||
dest.Height = s.Height
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SceneLight struct {
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Rotation int `json:"rotation"`
|
||||
Walls bool `json:"walls"`
|
||||
Vision bool `json:"vision"`
|
||||
Config Light `json:"config"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Flags any `json:"flags"`
|
||||
Id string `json:"_id"`
|
||||
Elevation int `json:"elevation"`
|
||||
}
|
||||
|
||||
func (s *SceneLight) ToDB(dest *db.SceneLight) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.X = s.X
|
||||
dest.Y = s.Y
|
||||
dest.Rotation = s.Rotation
|
||||
dest.Walls = s.Walls
|
||||
dest.Vision = s.Vision
|
||||
dest.Hidden = s.Hidden
|
||||
dest.ID = s.Id
|
||||
dest.Elevation = s.Elevation
|
||||
|
||||
s.Config.ToDB(&dest.Config)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type ScenesSound struct {
|
||||
Path string `json:"path"`
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Radius float64 `json:"radius"`
|
||||
Easing bool `json:"easing"`
|
||||
Walls bool `json:"walls"`
|
||||
Volume float64 `json:"volume"`
|
||||
Darkness ScenesSoundsDarkness `json:"darkness"`
|
||||
ID string `json:"_id"`
|
||||
Repeat bool `json:"repeat"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Elevation float64 `json:"elevation"`
|
||||
Effects ScenesSoundsEffects `json:"effects"`
|
||||
// Flags any `json:"flags"`
|
||||
}
|
||||
|
||||
func (s *ScenesSound) ToDB(dest *db.ScenesSound) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Path = s.Path
|
||||
dest.X = s.X
|
||||
dest.Y = s.Y
|
||||
dest.Radius = s.Radius
|
||||
dest.Easing = s.Easing
|
||||
dest.Walls = s.Walls
|
||||
dest.Volume = s.Volume
|
||||
dest.ID = s.ID
|
||||
dest.Repeat = s.Repeat
|
||||
dest.Hidden = s.Hidden
|
||||
dest.Elevation = s.Elevation
|
||||
|
||||
s.Darkness.ToDB(&dest.Darkness)
|
||||
s.Effects.ToDB(&dest.Effects)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type ScenesSoundsDarkness struct {
|
||||
Min int `json:"min"`
|
||||
Max int `json:"max"`
|
||||
}
|
||||
|
||||
func (s *ScenesSoundsDarkness) ToDB(dest *db.ScenesSoundsDarkness) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Min = s.Min
|
||||
dest.Max = s.Max
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type ScenesSoundsEffects struct {
|
||||
Base ScenesSoundsEffectsBase `json:"base"`
|
||||
Muffled ScenesSoundsEffectsBase `json:"muffled"`
|
||||
}
|
||||
|
||||
func (s *ScenesSoundsEffects) ToDB(dest *db.ScenesSoundsEffects) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
s.Base.ToDB(&dest.Base)
|
||||
s.Muffled.ToDB(&dest.Muffled)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type ScenesSoundsEffectsBase struct {
|
||||
Intensity int `json:"intensity"`
|
||||
}
|
||||
|
||||
func (s *ScenesSoundsEffectsBase) ToDB(dest *db.ScenesSoundsEffectsBase) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Intensity = s.Intensity
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SceneFog struct {
|
||||
Exploration bool `json:"exploration"`
|
||||
Reset int64 `json:"reset"`
|
||||
Overlay string `json:"overlay"`
|
||||
Colors SceneFogColors `json:"colors"`
|
||||
}
|
||||
|
||||
func (s *SceneFog) ToDB(dest *db.SceneFog) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Exploration = s.Exploration
|
||||
dest.Reset = s.Reset
|
||||
dest.Overlay = s.Overlay
|
||||
|
||||
s.Colors.ToDB(&dest.Colors)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SceneFogColors struct {
|
||||
Explored string `json:"explored"`
|
||||
Unexplored string `json:"unexplored"`
|
||||
}
|
||||
|
||||
func (s *SceneFogColors) ToDB(dest *db.SceneFogColors) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Explored = s.Explored
|
||||
dest.Unexplored = s.Unexplored
|
||||
|
||||
return true
|
||||
}
|
||||
29
internal/foundry/models/json/settings.go
Normal file
29
internal/foundry/models/json/settings.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Setting struct {
|
||||
Key string `json:"key"`
|
||||
User any `json:"user"`
|
||||
Value string `json:"value"`
|
||||
ID string `json:"_id"`
|
||||
Stats Stats `json:"_stats"`
|
||||
}
|
||||
|
||||
func (s *Setting) ToDB(dest **db.Setting) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
setting := &db.Setting{
|
||||
Key: s.Key,
|
||||
Value: s.Value,
|
||||
ID: s.ID,
|
||||
}
|
||||
|
||||
s.Stats.ToDB(&setting.Stats)
|
||||
|
||||
*dest = setting
|
||||
|
||||
return true
|
||||
}
|
||||
108
internal/foundry/models/json/setup.go
Normal file
108
internal/foundry/models/json/setup.go
Normal file
@@ -0,0 +1,108 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type Setup struct {
|
||||
CoreUpdate CoreUpdate `json:"coreUpdate"`
|
||||
FeaturedContent FeaturedContent `json:"featuredContent"`
|
||||
Files Files `json:"files"`
|
||||
IsAdmin bool `json:"isAdmin"`
|
||||
IsSetup bool `json:"isSetup"`
|
||||
Languages []*SetupLanguage `json:"languages"`
|
||||
Modules []*Module `json:"modules"`
|
||||
News []*News `json:"news"`
|
||||
Options SetupOptions `json:"options"`
|
||||
PackageWarnings map[string]PackageWarningsData `json:"packageWarnings"`
|
||||
Release Release `json:"release"`
|
||||
Systems []*System `json:"systems"`
|
||||
Worlds []*World `json:"worlds"`
|
||||
}
|
||||
|
||||
func ParseSetup(data []byte) (*Setup, error) {
|
||||
var modelSetup []Setup
|
||||
err := json.Unmarshal(data, &modelSetup)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(modelSetup) > 1 {
|
||||
return nil, ErrorSetupMoreThanOne
|
||||
}
|
||||
return &modelSetup[0], nil
|
||||
}
|
||||
|
||||
func (s *Setup) ToDB(dest *db.Setup) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.IsAdmin = s.IsAdmin
|
||||
dest.IsSetup = s.IsSetup
|
||||
|
||||
s.CoreUpdate.ToDB(&dest.CoreUpdate)
|
||||
s.FeaturedContent.ToDB(&dest.FeaturedContent)
|
||||
s.Files.ToDB(&dest.Files)
|
||||
s.Options.ToDB(&dest.Options)
|
||||
s.Release.ToDB(&dest.Release)
|
||||
|
||||
PackageWarningsToDB(&dest.PackageWarnings, s.PackageWarnings)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
CopySliceToDBParallel(&wg, &dest.Languages, s.Languages)
|
||||
CopySliceToDBParallel(&wg, &dest.Modules, s.Modules)
|
||||
CopySliceToDBParallel(&wg, &dest.News, s.News)
|
||||
CopySliceToDBParallel(&wg, &dest.Systems, s.Systems)
|
||||
CopySliceToDBParallel(&wg, &dest.Worlds, s.Worlds)
|
||||
wg.Wait()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type FeaturedContent struct {
|
||||
Title string `json:"title"`
|
||||
Caption string `json:"caption"`
|
||||
URL string `json:"url"`
|
||||
Image string `json:"image"`
|
||||
}
|
||||
|
||||
func (f *FeaturedContent) ToDB(dest *db.FeaturedContent) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Title = f.Title
|
||||
dest.Caption = f.Caption
|
||||
dest.URL = f.URL
|
||||
dest.Image = f.Image
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type News struct {
|
||||
Title string `json:"title"`
|
||||
Caption string `json:"caption"`
|
||||
URL string `json:"url"`
|
||||
Image string `json:"image"`
|
||||
}
|
||||
|
||||
func (n *News) ToDB(dest **db.News) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
news := &db.News{
|
||||
Title: n.Title,
|
||||
Caption: n.Caption,
|
||||
URL: n.Caption,
|
||||
Image: n.Image,
|
||||
}
|
||||
|
||||
*dest = news
|
||||
|
||||
return true
|
||||
}
|
||||
28
internal/foundry/models/json/stats.go
Normal file
28
internal/foundry/models/json/stats.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Stats struct {
|
||||
CoreVersion string `json:"coreVersion"`
|
||||
SystemID string `json:"systemId"`
|
||||
SystemVersion string `json:"systemVersion"`
|
||||
LastModifiedBy string `json:"lastModifiedBy"`
|
||||
ModifiedTime int64 `json:"modifiedTime"`
|
||||
// CompendiumSource string `json:"compendiumSource,omitempty"`
|
||||
// DuplicateSource string `json:"duplicateSource,omitempty"`
|
||||
// ExportSource string `json:"exportSource,omitempty"`
|
||||
}
|
||||
|
||||
func (s *Stats) ToDB(dest *db.Stats) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.CoreVersion = s.CoreVersion
|
||||
dest.SystemID = s.SystemID
|
||||
dest.SystemVersion = s.SystemVersion
|
||||
dest.LastModifiedBy = s.LastModifiedBy
|
||||
dest.ModifiedTime = s.ModifiedTime
|
||||
|
||||
return true
|
||||
}
|
||||
21
internal/foundry/models/json/style.go
Normal file
21
internal/foundry/models/json/style.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Style struct {
|
||||
Src string `json:"src"`
|
||||
}
|
||||
|
||||
func (s *Style) ToDB(dest **db.Style) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
style := &db.Style{
|
||||
Src: s.Src,
|
||||
}
|
||||
|
||||
*dest = style
|
||||
|
||||
return true
|
||||
}
|
||||
98
internal/foundry/models/json/system.go
Normal file
98
internal/foundry/models/json/system.go
Normal file
@@ -0,0 +1,98 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type System struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Authors []*Author `json:"authors"`
|
||||
URL string `json:"url"`
|
||||
License string `json:"license"`
|
||||
Bugs string `json:"bugs"`
|
||||
Changelog string `json:"changelog"`
|
||||
Media []*Media `json:"media"`
|
||||
Version string `json:"version"`
|
||||
Compatibility Compatibility `json:"compatibility"`
|
||||
Scripts []string `json:"scripts"`
|
||||
Esmodules []string `json:"esmodules"`
|
||||
Packs []*Pack `json:"packs"`
|
||||
Styles []*Style `json:"styles"`
|
||||
Languages []*Language `json:"languages"`
|
||||
PackFolders []*Folder `json:"packFolders"`
|
||||
Relationships Relationships `json:"relationships"`
|
||||
Socket bool `json:"socket"`
|
||||
Manifest string `json:"manifest"`
|
||||
Download string `json:"download"`
|
||||
Protected bool `json:"protected"`
|
||||
Exclusive bool `json:"exclusive"`
|
||||
PersistentStorage bool `json:"persistentStorage"`
|
||||
DocumentTypes DocumentTypes `json:"documentTypes"`
|
||||
Background string `json:"background"`
|
||||
Grid Grid `json:"grid"`
|
||||
PrimaryTokenAttribute string `json:"primaryTokenAttribute"`
|
||||
Availability int `json:"availability"`
|
||||
Locked bool `json:"locked"`
|
||||
Owned bool `json:"owned"`
|
||||
Tags []string `json:"tags"`
|
||||
HasStorage bool `json:"hasStorage"`
|
||||
// SystemFlags SystemFlags `json:"flags"`
|
||||
}
|
||||
|
||||
func (s *System) ToDB(dest **db.System) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
system := &db.System{
|
||||
ID: s.ID,
|
||||
Title: s.Title,
|
||||
Description: s.Description,
|
||||
URL: s.URL,
|
||||
License: s.License,
|
||||
Bugs: s.Bugs,
|
||||
Changelog: s.Changelog,
|
||||
Version: s.Version,
|
||||
Socket: s.Socket,
|
||||
Manifest: s.Manifest,
|
||||
Download: s.Download,
|
||||
Protected: s.Protected,
|
||||
Exclusive: s.Exclusive,
|
||||
PersistentStorage: s.PersistentStorage,
|
||||
Background: s.Background,
|
||||
PrimaryTokenAttribute: s.PrimaryTokenAttribute,
|
||||
Availability: s.Availability,
|
||||
Locked: s.Locked,
|
||||
Owned: s.Owned,
|
||||
HasStorage: s.HasStorage,
|
||||
}
|
||||
|
||||
system.Scripts = make([]string, len(s.Scripts))
|
||||
copy(system.Scripts, s.Scripts)
|
||||
system.Esmodules = make([]string, len(s.Esmodules))
|
||||
copy(system.Esmodules, s.Esmodules)
|
||||
system.Tags = make([]string, len(s.Tags))
|
||||
copy(system.Tags, s.Tags)
|
||||
|
||||
s.Compatibility.ToDB(&system.Compatibility)
|
||||
s.Relationships.ToDB(&system.Relationships)
|
||||
s.DocumentTypes.ToDB(&system.DocumentTypes)
|
||||
s.Grid.ToDB(&system.Grid)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
CopySliceToDBParallel(&wg, &system.Authors, s.Authors)
|
||||
CopySliceToDBParallel(&wg, &system.Media, s.Media)
|
||||
CopySliceToDBParallel(&wg, &system.Styles, s.Styles)
|
||||
CopySliceToDBParallel(&wg, &system.Languages, s.Languages)
|
||||
CopySliceToDBParallel(&wg, &system.Packs, s.Packs)
|
||||
CopySliceToDBParallel(&wg, &system.PackFolders, s.PackFolders)
|
||||
wg.Wait()
|
||||
|
||||
*dest = system
|
||||
|
||||
return true
|
||||
}
|
||||
85
internal/foundry/models/json/table.go
Normal file
85
internal/foundry/models/json/table.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/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
|
||||
}
|
||||
|
||||
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(&table.Stats)
|
||||
|
||||
OwnershipToDB(&table.Ownership, t.Ownership)
|
||||
|
||||
CopySliceToDB(&table.Results, t.Results)
|
||||
|
||||
*dest = table
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
tableResult := &db.TableResult{
|
||||
Type: t.Type,
|
||||
Weight: t.Weight,
|
||||
Drawn: t.Drawn,
|
||||
ID: t.ID,
|
||||
Img: t.Img,
|
||||
Description: t.Description,
|
||||
Name: t.Name,
|
||||
}
|
||||
|
||||
tableResult.Range = make([]int, len(t.Range))
|
||||
copy(tableResult.Range, t.Range)
|
||||
|
||||
t.Stats.ToDB(&tableResult.Stats)
|
||||
|
||||
*dest = tableResult
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
package json
|
||||
|
||||
import "time"
|
||||
|
||||
type DataTemplate struct {
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Authors []DataAuthor `json:"authors,omitempty"`
|
||||
Url string `json:"url,omitempty"`
|
||||
Flags Flags `json:"flags,omitempty"`
|
||||
License string `json:"license,omitempty"`
|
||||
Readme string `json:"readme,omitempty"`
|
||||
Bugs string `json:"bugs,omitempty"`
|
||||
Changelog string `json:"changelog,omitempty"`
|
||||
Media []DataMedia `json:"media,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
Compatibility Compatibility `json:"compatibility,omitempty"`
|
||||
Scripts []string `json:"scripts"`
|
||||
Esmodules []string `json:"esmodules"`
|
||||
Styles []struct {
|
||||
Src string `json:"src,omitempty"`
|
||||
} `json:"styles,omitempty"`
|
||||
Languages []DataLanguage `json:"languages,omitempty"`
|
||||
Packs []DataPack `json:"packs,omitempty"`
|
||||
PackFolder []DataPackFolder `json:"packFolder,omitempty"`
|
||||
Relationships Relationship `json:"relationships,omitempty"`
|
||||
Socket bool `json:"socket,omitempty"`
|
||||
Manifest string `json:"manifest,omitempty"`
|
||||
Download string `json:"download,omitempty"`
|
||||
Protected bool `json:"protected,omitempty"`
|
||||
Exclusive bool `json:"exclusive,omitempty"`
|
||||
PersistentStorage bool `json:"persistentStorage,omitempty"`
|
||||
Availability int `json:"availability,omitempty"`
|
||||
Locked bool `json:"locked,omitempty"`
|
||||
Owned bool `json:"owned,omitempty"`
|
||||
HasStorage bool `json:"hasStorage,omitempty"`
|
||||
|
||||
//module
|
||||
CoreTranslation bool `json:"coreTranslation,omitempty"`
|
||||
Library bool `json:"library,omitempty"`
|
||||
|
||||
//system
|
||||
Background string `json:"background,omitempty"`
|
||||
Grid DataGrid `json:"grid,omitempty"`
|
||||
PrimaryTokenAttribute string `json:"primaryTokenAttribute,omitempty"`
|
||||
|
||||
//world
|
||||
System string `json:"system,omitempty"`
|
||||
JoinTheme string `json:"joinTheme,omitempty"`
|
||||
CoreVersion string `json:"coreVersion,omitempty"`
|
||||
SystemVersion string `json:"systemVersion,omitempty"`
|
||||
LastPlayed string `json:"lastPlayed,omitempty"`
|
||||
PlayTime int64 `json:"playTime,omitempty"`
|
||||
NextSession time.Time `json:"nextSession,omitempty"`
|
||||
}
|
||||
|
||||
type DataAuthor struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Url string `json:"url,omitempty"`
|
||||
Discord string `json:"discord,omitempty"`
|
||||
flags struct{} `json:"-"`
|
||||
}
|
||||
|
||||
type DataMedia struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Url string `json:"url,omitempty"`
|
||||
Loop bool `json:"loop,omitempty"`
|
||||
flags struct{} `json:"-"`
|
||||
}
|
||||
|
||||
type DataLanguage struct {
|
||||
Lang string `json:"lang,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Flags struct{} `json:"-"`
|
||||
}
|
||||
|
||||
type DataPack struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Label string `json:"label,omitempty"`
|
||||
Banner string `json:"banner,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
System string `json:"system,omitempty"`
|
||||
Ownership map[string]string `json:"ownership,omitempty"`
|
||||
flags struct{} `json:"-"`
|
||||
}
|
||||
|
||||
type DataPackFolder struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Sorting string `json:"sorting,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
Packs []string `json:"packs,omitempty"`
|
||||
Folders []DataPackFolder `json:"folders,omitempty"`
|
||||
}
|
||||
|
||||
type DataGrid struct {
|
||||
Type int `json:"type,omitempty"`
|
||||
Distance int `json:"distance,omitempty"`
|
||||
Units string `json:"units,omitempty"`
|
||||
Diagonals int `json:"diagonals,omitempty"`
|
||||
}
|
||||
|
||||
type Compatibility struct {
|
||||
Minimum string `json:"minimum,omitempty"`
|
||||
Verified string `json:"verified,omitempty"`
|
||||
Maximum string `json:"maximum,omitempty"`
|
||||
}
|
||||
|
||||
type Flags struct {
|
||||
HotReload FlagsHotReload `json:"hotReload"`
|
||||
Styles []string `json:"styles"`
|
||||
}
|
||||
|
||||
type FlagsHotReload struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Extensions []string `json:"extensions"`
|
||||
Paths []string `json:"paths"`
|
||||
}
|
||||
|
||||
type Relationship struct {
|
||||
systems []struct{} `json:"-"`
|
||||
requires []struct{} `json:"-"`
|
||||
Recommends []struct {
|
||||
Id string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
compatibility struct{} `json:"-"`
|
||||
} `json:"recommends"`
|
||||
conflicts []struct{} `json:"-"`
|
||||
flags struct{} `json:"-"`
|
||||
}
|
||||
181
internal/foundry/models/json/token.go
Normal file
181
internal/foundry/models/json/token.go
Normal file
@@ -0,0 +1,181 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Token struct {
|
||||
DisplayName int `json:"displayName"`
|
||||
DisplayBars int `json:"displayBars"`
|
||||
Disposition int `json:"disposition"`
|
||||
Sight TokenSight `json:"sight"`
|
||||
Name string `json:"name"`
|
||||
ActorLink bool `json:"actorLink"`
|
||||
AppendNumber bool `json:"appendNumber"`
|
||||
PrependAdjective bool `json:"prependAdjective"`
|
||||
Texture TokenTexture `json:"texture"`
|
||||
Width float64 `json:"width"`
|
||||
Height float64 `json:"height"`
|
||||
LockRotation bool `json:"lockRotation"`
|
||||
Rotation int `json:"rotation"`
|
||||
Alpha int `json:"alpha"`
|
||||
Bar1 TokenBar `json:"bar1"`
|
||||
Bar2 TokenBar `json:"bar2"`
|
||||
Light Light `json:"light"`
|
||||
RandomImg bool `json:"randomImg"`
|
||||
Occludable TokenOccludable `json:"occludable"`
|
||||
Ring Ring `json:"ring"`
|
||||
TurnMarker TokenTurnMarker `json:"turnMarker"`
|
||||
MovementAction any `json:"movementAction"`
|
||||
// Flags any `json:"flags"`
|
||||
// DetectionModes []any `json:"detectionModes"`
|
||||
}
|
||||
|
||||
func (t *Token) ToDB(dest **db.Token) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
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(&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
|
||||
}
|
||||
|
||||
type TokenTexture struct {
|
||||
Src string `json:"src"`
|
||||
ScaleX float64 `json:"scaleX"`
|
||||
ScaleY float64 `json:"scaleY"`
|
||||
OffsetX float64 `json:"offsetX"`
|
||||
OffsetY float64 `json:"offsetY"`
|
||||
Rotation float64 `json:"rotation"`
|
||||
AnchorX float64 `json:"anchorX"`
|
||||
AnchorY float64 `json:"anchorY"`
|
||||
Fit string `json:"fit"`
|
||||
Tint string `json:"tint"`
|
||||
AlphaThreshold float64 `json:"alphaThreshold"`
|
||||
}
|
||||
|
||||
func (t *TokenTexture) ToDB(dest **db.TokenTexture) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
type TokenSight struct {
|
||||
Color string
|
||||
Enabled bool
|
||||
Range int
|
||||
Angle int
|
||||
VisionMode string
|
||||
Attenuation float64
|
||||
Brightness float64
|
||||
}
|
||||
|
||||
func (t *TokenSight) ToDB(dest **db.TokenSight) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
type TokenBar struct {
|
||||
Attribute string `json:"attribute"`
|
||||
}
|
||||
|
||||
func (t *TokenBar) ToDB(dest *db.TokenBar) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Attribute = t.Attribute
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type TokenOccludable struct {
|
||||
Radius int `json:"radius"`
|
||||
}
|
||||
|
||||
func (t *TokenOccludable) ToDB(dest *db.TokenOccludable) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Radius = t.Radius
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type TokenTurnMarker struct {
|
||||
Mode int `json:"mode"`
|
||||
Animation string `json:"animation"`
|
||||
Src string `json:"src"`
|
||||
Disposition bool `json:"disposition"`
|
||||
}
|
||||
|
||||
func (t *TokenTurnMarker) ToDB(dest *db.TokenTurnMarker) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Mode = t.Mode
|
||||
dest.Animation = t.Animation
|
||||
dest.Src = t.Src
|
||||
dest.Disposition = t.Disposition
|
||||
|
||||
return true
|
||||
}
|
||||
45
internal/foundry/models/json/update.go
Normal file
45
internal/foundry/models/json/update.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type CoreUpdate struct {
|
||||
HasUpdate bool `json:"hasUpdate"`
|
||||
CanUpdate bool `json:"canUpdate"`
|
||||
CouldReachWebsite bool `json:"couldReachWebsite"`
|
||||
SlowResponse bool `json:"slowResponse"`
|
||||
Version string `json:"version"`
|
||||
Channel string `json:"channel"`
|
||||
WillDisableModules bool `json:"willDisableModules"`
|
||||
}
|
||||
|
||||
func (c *CoreUpdate) ToDB(dest *db.CoreUpdate) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.HasUpdate = c.HasUpdate
|
||||
dest.CanUpdate = c.CanUpdate
|
||||
dest.CouldReachWebsite = c.CouldReachWebsite
|
||||
dest.SlowResponse = c.SlowResponse
|
||||
dest.Version = c.Version
|
||||
dest.Channel = c.Channel
|
||||
dest.WillDisableModules = c.WillDisableModules
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type SystemUpdate struct {
|
||||
HasUpdate bool `json:"hasUpdate"`
|
||||
Version string `json:"version"`
|
||||
}
|
||||
|
||||
func (s *SystemUpdate) ToDB(dest *db.SystemUpdate) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.HasUpdate = s.HasUpdate
|
||||
dest.Version = s.Version
|
||||
|
||||
return true
|
||||
}
|
||||
41
internal/foundry/models/json/user.go
Normal file
41
internal/foundry/models/json/user.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type User struct {
|
||||
Name string `json:"name"`
|
||||
Role int `json:"role"`
|
||||
ID string `json:"_id"`
|
||||
Avatar string `json:"avatar"`
|
||||
Character string `json:"character"`
|
||||
Color string `json:"color"`
|
||||
Pronouns string `json:"pronouns"`
|
||||
Hotbar map[int]string `json:"hotbar,omitempty"`
|
||||
UsersStats Stats `json:"_stats"`
|
||||
// Permissions any `json:"permissions"`
|
||||
// UsersFlags any `json:"flags,omitempty"`
|
||||
}
|
||||
|
||||
func (u *User) ToDB(dest **db.User) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
user := &db.User{
|
||||
Name: u.Name,
|
||||
Role: u.Role,
|
||||
ID: u.ID,
|
||||
Avatar: u.Avatar,
|
||||
Character: u.Character,
|
||||
Color: u.Color,
|
||||
Pronouns: u.Pronouns,
|
||||
}
|
||||
|
||||
u.UsersStats.ToDB(&user.Stats)
|
||||
|
||||
HotbarToDB(&user.Hotbar, u.Hotbar)
|
||||
|
||||
*dest = user
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/json/modules"
|
||||
|
||||
type User struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
Role int `json:"role,omitempty"`
|
||||
Id string `json:"_id,omitempty"`
|
||||
avatar struct{} `json:"-"`
|
||||
Character string `json:"character,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
Pronouns string `json:"pronouns,omitempty"`
|
||||
Hotbar map[string]string `json:"hotbar,omitempty"`
|
||||
permissions struct{} `json:"-"`
|
||||
Flags UserFlags `json:"flags,omitempty"`
|
||||
Stats UserStats `json:"_stats,omitempty"`
|
||||
}
|
||||
|
||||
type UserFlags struct {
|
||||
World map[string]bool `json:"world,omitempty"`
|
||||
Pf2e modules.Pf2eModule `json:"pf2e,omitempty"`
|
||||
DiceStats modules.DiceStats `json:"diceStats,omitempty"`
|
||||
}
|
||||
|
||||
type UserStats struct {
|
||||
compendiumSource struct{} `json:"-"`
|
||||
duplicateSource struct{} `json:"-"`
|
||||
exportSource struct{} `json:"-"`
|
||||
CoreVersion string `json:"coreVersion,omitempty"`
|
||||
SystemId string `json:"systemId,omitempty"`
|
||||
SystemVersion string `json:"systemVersion,omitempty"`
|
||||
CreatedTime int64 `json:"createdTime,omitempty"`
|
||||
ModifiedTime int64 `json:"modifiedTime,omitempty"`
|
||||
LastModifiedBy string `json:"lastModifiedBy,omitempty"`
|
||||
}
|
||||
|
||||
type Users []User
|
||||
|
||||
func (users Users) GetById(id int) *User {
|
||||
return &users[id]
|
||||
}
|
||||
68
internal/foundry/models/json/utils.go
Normal file
68
internal/foundry/models/json/utils.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrorSetupMoreThanOne = errors.New("More than one setup data")
|
||||
)
|
||||
|
||||
func OwnershipToDB(dest *[]db.OwnershipString, src map[string]int) {
|
||||
*dest = make([]db.OwnershipString, len(src))
|
||||
|
||||
i := 0
|
||||
for k, v := range src {
|
||||
(*dest)[i].Key = k
|
||||
(*dest)[i].Value = v
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
func HotbarToDB(dest *[]db.UserHotbar, src map[int]string) {
|
||||
*dest = make([]db.UserHotbar, len(src))
|
||||
|
||||
i := 0
|
||||
for k, v := range src {
|
||||
(*dest)[i].Key = k
|
||||
(*dest)[i].Value = v
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
func PackageWarningsToDB(dest *[]*db.PackageWarning, src map[string]PackageWarningsData) {
|
||||
*dest = make([]*db.PackageWarning, len(src))
|
||||
|
||||
i := 0
|
||||
for k, v := range src {
|
||||
(*dest)[i] = &db.PackageWarning{Key: k}
|
||||
v.ToDB(&(*dest)[i].Value)
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
type CastableToDB[destType any] interface {
|
||||
ToDB(*destType) bool
|
||||
}
|
||||
|
||||
func CopySliceToDB[destType any, srcType CastableToDB[destType]](dest *[]destType, src []srcType) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
*dest = make([]destType, len(src))
|
||||
for i := range src {
|
||||
src[i].ToDB(&(*dest)[i])
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func CopySliceToDBParallel[destType any, srcType CastableToDB[destType]](wg *sync.WaitGroup, dest *[]destType, src []srcType) {
|
||||
wg.Go(func() {
|
||||
CopySliceToDB(dest, src)
|
||||
})
|
||||
}
|
||||
59
internal/foundry/models/json/wall.go
Normal file
59
internal/foundry/models/json/wall.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package json
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
|
||||
type Wall struct {
|
||||
C []int `json:"c"`
|
||||
Light int `json:"light"`
|
||||
Move int `json:"move"`
|
||||
Sight int `json:"sight"`
|
||||
Sound int `json:"sound"`
|
||||
Dir int `json:"dir"`
|
||||
Door int `json:"door"`
|
||||
Ds int `json:"ds"`
|
||||
ID string `json:"_id"`
|
||||
Threshold Threshold `json:"threshold"`
|
||||
Animation any `json:"animation"`
|
||||
// WallsFlags any `json:"flags"`
|
||||
}
|
||||
|
||||
func (w *Wall) ToDB(dest *db.Wall) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Light = w.Light
|
||||
dest.Move = w.Move
|
||||
dest.Sight = w.Sight
|
||||
dest.Sound = w.Sound
|
||||
dest.Dir = w.Dir
|
||||
dest.Door = w.Door
|
||||
dest.Ds = w.Ds
|
||||
dest.ID = w.ID
|
||||
w.Threshold.ToDB(&dest.Threshold)
|
||||
|
||||
dest.C = make([]int, len(w.C))
|
||||
copy(dest.C, w.C)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type Threshold struct {
|
||||
Light int `json:"light"`
|
||||
Sight int `json:"sight"`
|
||||
Sound int `json:"sound"`
|
||||
Attenuation bool `json:"attenuation"`
|
||||
}
|
||||
|
||||
func (t *Threshold) ToDB(dest *db.Threshold) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
dest.Light = t.Light
|
||||
dest.Sight = t.Sight
|
||||
dest.Sound = t.Sound
|
||||
dest.Attenuation = t.Attenuation
|
||||
|
||||
return true
|
||||
}
|
||||
100
internal/foundry/models/json/world.go
Normal file
100
internal/foundry/models/json/world.go
Normal file
@@ -0,0 +1,100 @@
|
||||
package json
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/db"
|
||||
)
|
||||
|
||||
type World struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Authors []*Author `json:"authors"`
|
||||
Media []*Media `json:"media"`
|
||||
Version string `json:"version"`
|
||||
Compatibility Compatibility `json:"compatibility"`
|
||||
Scripts []string `json:"scripts"`
|
||||
Esmodules []string `json:"esmodules"`
|
||||
Styles []*Style `json:"styles"`
|
||||
Languages []*Language `json:"languages"`
|
||||
Packs []*Pack `json:"packs"`
|
||||
PackFolders []*Folder `json:"packFolders"`
|
||||
Relationships Relationships `json:"relationships"`
|
||||
Socket bool `json:"socket"`
|
||||
Protected bool `json:"protected"`
|
||||
Exclusive bool `json:"exclusive"`
|
||||
PersistentStorage bool `json:"persistentStorage"`
|
||||
System string `json:"system"`
|
||||
Background string `json:"background"`
|
||||
JoinTheme string `json:"joinTheme"`
|
||||
CoreVersion string `json:"coreVersion"`
|
||||
SystemVersion string `json:"systemVersion"`
|
||||
LastPlayed string `json:"lastPlayed"`
|
||||
Playtime int `json:"playtime"`
|
||||
NextSession time.Time `json:"nextSession"`
|
||||
Demo Demo `json:"demo"`
|
||||
Availability int `json:"availability"`
|
||||
Locked bool `json:"locked"`
|
||||
Owned bool `json:"owned"`
|
||||
Tags []string `json:"tags"`
|
||||
HasStorage bool `json:"hasStorage"`
|
||||
// Flags any `json:"flags"`
|
||||
}
|
||||
|
||||
func (w *World) ToDB(dest **db.World) bool {
|
||||
if dest == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
world := &db.World{
|
||||
ID: w.ID,
|
||||
Title: w.Title,
|
||||
Description: w.Description,
|
||||
Version: w.Version,
|
||||
Socket: w.Socket,
|
||||
Protected: w.Protected,
|
||||
Exclusive: w.Exclusive,
|
||||
PersistentStorage: w.PersistentStorage,
|
||||
System: w.System,
|
||||
Background: w.Background,
|
||||
JoinTheme: w.JoinTheme,
|
||||
CoreVersion: w.CoreVersion,
|
||||
SystemVersion: w.SystemVersion,
|
||||
LastPlayed: w.LastPlayed,
|
||||
Playtime: w.Playtime,
|
||||
NextSession: w.NextSession,
|
||||
Availability: w.Availability,
|
||||
Locked: w.Locked,
|
||||
Owned: w.Owned,
|
||||
HasStorage: w.HasStorage,
|
||||
}
|
||||
|
||||
world.Scripts = make([]string, len(w.Scripts))
|
||||
copy(world.Scripts, w.Scripts)
|
||||
world.Esmodules = make([]string, len(w.Esmodules))
|
||||
copy(world.Esmodules, w.Esmodules)
|
||||
world.Tags = make([]string, len(w.Tags))
|
||||
copy(world.Tags, w.Tags)
|
||||
|
||||
w.Compatibility.ToDB(&world.Compatibility)
|
||||
w.Relationships.ToDB(&world.Relationships)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
CopySliceToDBParallel(&wg, &world.Authors, w.Authors)
|
||||
CopySliceToDBParallel(&wg, &world.Media, w.Media)
|
||||
CopySliceToDBParallel(&wg, &world.Styles, w.Styles)
|
||||
CopySliceToDBParallel(&wg, &world.Languages, w.Languages)
|
||||
CopySliceToDBParallel(&wg, &world.Packs, w.Packs)
|
||||
CopySliceToDBParallel(&wg, &world.PackFolders, w.PackFolders)
|
||||
wg.Wait()
|
||||
|
||||
*dest = world
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
type Demo struct {
|
||||
SourceZip any `json:"sourceZip"`
|
||||
}
|
||||
Reference in New Issue
Block a user