init
This commit is contained in:
44
internal/foundry/models/data.go
Normal file
44
internal/foundry/models/data.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
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 struct {
|
||||
Language string `json:"language,omitempty"`
|
||||
} `json:"options,omitempty"`
|
||||
|
||||
//coreUpdate struct{}
|
||||
//featuredContent struct{}
|
||||
//files struct{}
|
||||
//news struct{}
|
||||
|
||||
//packageWarnings struct{} think about it
|
||||
}
|
||||
|
||||
func (state FoundryState) GetRelease() Release {
|
||||
return state.Release
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
8
internal/foundry/models/errors.go
Normal file
8
internal/foundry/models/errors.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package models
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
ErrorSetupMoreThanOne = errors.New("Passed more than one setupData")
|
||||
ErrorSetupNotFound = errors.New("Not found setup data from your request")
|
||||
)
|
||||
13
internal/foundry/models/language.go
Normal file
13
internal/foundry/models/language.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package models
|
||||
|
||||
type Language struct {
|
||||
Id string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Modules []LangModule `json:"modules"`
|
||||
}
|
||||
|
||||
type LangModule struct {
|
||||
Id string `json:"id"`
|
||||
Label string `json:"label"`
|
||||
Path string `json:"path"`
|
||||
}
|
||||
49
internal/foundry/models/module.go
Normal file
49
internal/foundry/models/module.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package models
|
||||
|
||||
type Module struct {
|
||||
Id string
|
||||
Title string
|
||||
Description string
|
||||
Url string
|
||||
Version string
|
||||
Compatibility Compatibility
|
||||
Languages []DataLanguage
|
||||
Availability int
|
||||
}
|
||||
|
||||
type Modules []Module
|
||||
|
||||
func (modules Modules) GetById(id int) *Module {
|
||||
return &modules[id]
|
||||
}
|
||||
|
||||
func (state *FoundryState) GetModules() Modules {
|
||||
modulesCopy := make([]Module, 0, 8)
|
||||
for i := range state.Modules {
|
||||
module := &(state.Modules[i])
|
||||
moduleCopy := Module{
|
||||
Id: module.Id,
|
||||
Title: module.Title,
|
||||
Description: module.Description,
|
||||
Compatibility: Compatibility{
|
||||
Minimum: module.Compatibility.Minimum,
|
||||
Maximum: module.Compatibility.Maximum,
|
||||
},
|
||||
Url: module.Url,
|
||||
Version: module.CoreVersion,
|
||||
|
||||
Availability: module.Availability,
|
||||
}
|
||||
for j := range module.Languages {
|
||||
lang := DataLanguage{
|
||||
Lang: module.Languages[j].Lang,
|
||||
Name: module.Languages[j].Name,
|
||||
Path: module.Languages[j].Path,
|
||||
Flags: module.Languages[j].Flags,
|
||||
}
|
||||
moduleCopy.Languages = append(moduleCopy.Languages, lang)
|
||||
}
|
||||
modulesCopy = append(modulesCopy, moduleCopy)
|
||||
}
|
||||
return modulesCopy
|
||||
}
|
||||
59
internal/foundry/models/modules/dice-stats.go
Normal file
59
internal/foundry/models/modules/dice-stats.go
Normal file
@@ -0,0 +1,59 @@
|
||||
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"`
|
||||
}
|
||||
12
internal/foundry/models/modules/pf2e.go
Normal file
12
internal/foundry/models/modules/pf2e.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package modules
|
||||
|
||||
type Pf2eModule struct {
|
||||
settings Pf2eSettings
|
||||
}
|
||||
|
||||
type Pf2eSettings struct {
|
||||
showEffectPanel bool
|
||||
showCheckDialogs bool
|
||||
showDamageDialogs bool
|
||||
monochromeDarkvision bool
|
||||
}
|
||||
11
internal/foundry/models/release.go
Normal file
11
internal/foundry/models/release.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package models
|
||||
|
||||
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:"-"`
|
||||
}
|
||||
11
internal/foundry/models/status.go
Normal file
11
internal/foundry/models/status.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package models
|
||||
|
||||
type Status struct {
|
||||
Active bool `json:"active"`
|
||||
Version string `json:"version"`
|
||||
World string `json:"world,omitempty"`
|
||||
System string `json:"system,omitempty"`
|
||||
SystemVersion string `json:"systemVersion,omitempty"`
|
||||
Users int `json:"users,omitempty"`
|
||||
Uptime int64 `json:"uptime,omitempty"`
|
||||
}
|
||||
36
internal/foundry/models/system.go
Normal file
36
internal/foundry/models/system.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package models
|
||||
|
||||
type System struct {
|
||||
Id string
|
||||
Title string
|
||||
Description string
|
||||
Url string
|
||||
Compatibility Compatibility
|
||||
Download string
|
||||
}
|
||||
|
||||
type Systems []System
|
||||
|
||||
func (systems Systems) GetById(id int) *System {
|
||||
return &systems[id]
|
||||
}
|
||||
|
||||
func (state *FoundryState) GetSystems() Systems {
|
||||
systemsCopy := make([]System, 0, 8)
|
||||
for i := range state.Systems {
|
||||
system := &(state.Systems[i])
|
||||
systemCopy := System{
|
||||
Id: system.Id,
|
||||
Title: system.Title,
|
||||
Description: system.Description,
|
||||
Url: system.Url,
|
||||
Compatibility: Compatibility{
|
||||
Minimum: system.Compatibility.Minimum,
|
||||
Maximum: system.Compatibility.Maximum,
|
||||
},
|
||||
Download: system.Download,
|
||||
}
|
||||
systemsCopy = append(systemsCopy, systemCopy)
|
||||
}
|
||||
return systemsCopy
|
||||
}
|
||||
132
internal/foundry/models/template.go
Normal file
132
internal/foundry/models/template.go
Normal file
@@ -0,0 +1,132 @@
|
||||
package models
|
||||
|
||||
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:"-"`
|
||||
}
|
||||
45
internal/foundry/models/users.go
Normal file
45
internal/foundry/models/users.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package models
|
||||
|
||||
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/models/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]
|
||||
}
|
||||
|
||||
func (state *FoundryState) GetUsers() *Users {
|
||||
return &state.Users
|
||||
}
|
||||
88
internal/foundry/models/world.go
Normal file
88
internal/foundry/models/world.go
Normal file
@@ -0,0 +1,88 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type World struct {
|
||||
Id string
|
||||
Title string
|
||||
Description string
|
||||
Compatibility Compatibility
|
||||
System string
|
||||
CoreVersion string
|
||||
SystemVersion string
|
||||
LastPlayed string
|
||||
PlayTime int64
|
||||
NextSession time.Time
|
||||
}
|
||||
|
||||
type Worlds []World
|
||||
|
||||
func (worlds Worlds) GetById(id int) *World {
|
||||
return &worlds[id]
|
||||
}
|
||||
|
||||
func (state *FoundryState) GetWorld() World {
|
||||
return World{
|
||||
Id: state.World.Id,
|
||||
Title: state.World.Title,
|
||||
Description: state.World.Description,
|
||||
Compatibility: 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() Worlds {
|
||||
worldsCopy := make([]World, 0, 8)
|
||||
for i := range state.Worlds {
|
||||
world := &(state.Worlds[i])
|
||||
worldCopy := World{
|
||||
Id: world.Id,
|
||||
Title: world.Title,
|
||||
Description: world.Description,
|
||||
Compatibility: 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)
|
||||
}
|
||||
return worldsCopy
|
||||
}
|
||||
|
||||
func (worlds Worlds) GetSessionTime(worldName string) (*time.Time, error) {
|
||||
if worldName == "" && len(worlds) != 1 {
|
||||
return nil, ErrorSetupNotFound
|
||||
}
|
||||
|
||||
if worldName == "" {
|
||||
return &worlds.GetById(0).NextSession, nil
|
||||
} else {
|
||||
for i := range worlds {
|
||||
if worlds[i].Id == worldName {
|
||||
return &worlds.GetById(0).NextSession, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, ErrorSetupNotFound
|
||||
}
|
||||
|
||||
func (world World) GetSessionTime() *time.Time {
|
||||
return &world.NextSession
|
||||
}
|
||||
Reference in New Issue
Block a user