popper

package
v0.0.0-...-c5055fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadJSONFile

func LoadJSONFile(fpath string, v interface{}) error

LoadJSONFile loads a JSON file from the given path and unmarshals it into the given interface.

Types

type ArmorWrapper

type ArmorWrapper struct {
	ArmorCategory       string `json:"armor_category"`
	StealthDisadvantage bool   `json:"stealth_disadvantage"`
	StrMinimum          int    `json:"str_minimum,omitempty"`
	ArmorClass          struct {
		Base     int  `json:"base"`
		DexBonus bool `json:"dex_bonus"`
		MaxBonus int  `json:"max_bonus,omitempty"`
	} `json:"armor_class"`
}

type ChoiceWrapper

type ChoiceWrapper struct {
	Desc   string                 `json:"desc"`
	Choose int                    `json:"choose"`
	From   map[string]interface{} `json:"from"`
}

type ClassChoiceWrapper

type ClassChoiceWrapper struct {
	Indx               string           `json:"index"`
	ProficiencyChoices []*ChoiceWrapper `json:"proficiency_choices,omitempty"`
}

type CostWrapper

type CostWrapper struct {
	Quantity int    `json:"quantity"`
	Unit     string `json:"unit"`
}

type EquipmentSubWrapper

type EquipmentSubWrapper struct {
	Name              string      `json:"name"`
	Cost              CostWrapper `json:"cost"`
	Weight            float64     `json:"weight"`
	EquipmentCategory IndxWrapper `json:"equipment_category"`
}

type EquipmentWrapper

type EquipmentWrapper struct {
	Indx string `json:"index"`
	EquipmentSubWrapper
	*WeaponWrapper
	*ArmorWrapper
	*GearWrapper
	*ToolWrapper
	*VehicleWrapper
}

type GearWrapper

type GearWrapper struct {
	GearCategory IndxWrapper `json:"gear_category"`
	Quantity     *int        `json:"quantity,omitempty"`
}

type IndxWrapper

type IndxWrapper struct {
	Indx string `json:"index"`
}

type NestedChoice

type NestedChoice struct {
	Options []struct {
		Choice struct {
			Desc   string `json:"desc,omitempty"`
			Choose int    `json:"choose"`
			From   struct {
				Options []struct {
					Item struct {
						Indx string `json:"index"`
					} `json:"item"`
				} `json:"options"`
			} `json:"from"`
		} `json:"choice,omitempty"`
	} `json:"options,omitempty"`
}

type Popper

type Popper struct {
	Client     *ent.Client
	Reader     *ent.Client
	IdToIndx   map[int]string
	IndxToId   map[string]int
	Context    *context.Context
	PathPrefix string
}

Popper is a populator for the ent database.

func NewPopper

func NewPopper(ctx context.Context, client *ent.Client) *Popper

NewPopper creates a new Popper.

func NewTestPopper

func NewTestPopper(ctx context.Context) *Popper

NewTestPopper creates a new Popper for testing.

func (*Popper) BuildChoice

func (p *Popper) BuildChoice(ctx context.Context, c *ChoiceWrapper) (*ent.ProficiencyChoice, error)

buildChoice creates a Choice entity from a JSON struct.

func (*Popper) GetIDsFromIndxs

func (p *Popper) GetIDsFromIndxs(v []byte) []int

func (*Popper) PopulateAbilityScore

func (p *Popper) PopulateAbilityScore(ctx context.Context) ([]*ent.AbilityScore, error)

PopulateAbilityScore populates the AbilityScore entities from the JSON data files.

func (*Popper) PopulateAbilityScoreEdges

func (p *Popper) PopulateAbilityScoreEdges(ctx context.Context, raw []ent.AbilityScore) error

func (*Popper) PopulateAll

func (p *Popper) PopulateAll(ctx context.Context) error

PopulateAll populates all entities generated from the JSON data files.

func (*Popper) PopulateClass

func (p *Popper) PopulateClass(ctx context.Context) ([]*ent.Class, error)

PopulateClass populates the Class entities from the JSON data files.

func (*Popper) PopulateClassEdges

func (p *Popper) PopulateClassEdges(ctx context.Context, raw []ent.Class) error

func (*Popper) PopulateCoin

func (p *Popper) PopulateCoin(ctx context.Context) ([]*ent.Coin, error)

PopulateCoin populates the Coin entities from the JSON data files.

func (*Popper) PopulateCoinEdges

func (p *Popper) PopulateCoinEdges(ctx context.Context, raw []ent.Coin) error

func (*Popper) PopulateDamageType

func (p *Popper) PopulateDamageType(ctx context.Context) ([]*ent.DamageType, error)

PopulateDamageType populates the DamageType entities from the JSON data files.

func (*Popper) PopulateDamageTypeEdges

func (p *Popper) PopulateDamageTypeEdges(ctx context.Context, raw []ent.DamageType) error

func (*Popper) PopulateEquipment

func (p *Popper) PopulateEquipment(ctx context.Context) error

// PopulateEquipment populates the Equipment entities from the JSON data files.

func (*Popper) PopulateEquipmentEdges

func (p *Popper) PopulateEquipmentEdges(ctx context.Context, raw []EquipmentWrapper) error

PopulateEquipmentEdges populates the Equipment edges from the JSON data files.

func (*Popper) PopulateLanguage

func (p *Popper) PopulateLanguage(ctx context.Context) ([]*ent.Language, error)

PopulateLanguage populates the Language entities from the JSON data files.

func (*Popper) PopulateLanguageEdges

func (p *Popper) PopulateLanguageEdges(ctx context.Context, raw []ent.Language) error

func (*Popper) PopulateMagicSchool

func (p *Popper) PopulateMagicSchool(ctx context.Context) ([]*ent.MagicSchool, error)

PopulateMagicSchool populates the MagicSchool entities from the JSON data files.

func (*Popper) PopulateMagicSchoolEdges

func (p *Popper) PopulateMagicSchoolEdges(ctx context.Context, raw []ent.MagicSchool) error

PopulateMagicSchoolEdges populates the MagicSchool edges from the JSON data files.

func (*Popper) PopulateProficiency

func (p *Popper) PopulateProficiency(ctx context.Context) ([]*ent.Proficiency, error)

PopulateProficiency populates the Proficiency entities from the JSON data files.

func (*Popper) PopulateProficiencyChoices

func (p *Popper) PopulateProficiencyChoices(ctx context.Context) ([]*ent.ProficiencyChoice, error)

PopulateProficiencyProficiencyChoices populates the PopulateProficiencyProficiencyChoices edges from the JSON data files.

func (*Popper) PopulateProficiencyEdges

func (p *Popper) PopulateProficiencyEdges(ctx context.Context, raw []*ent.Proficiency, wrap []ProficiencyWrapper) error

PopulateProficiencyEdges populates the Proficiency edges from the JSON data files.

func (*Popper) PopulateRace

func (p *Popper) PopulateRace(ctx context.Context) ([]*ent.Race, error)

PopulateRace populates the Race entities from the JSON data files.

func (*Popper) PopulateRaceEdges

func (p *Popper) PopulateRaceEdges(ctx context.Context, raw []ent.Race) error

func (*Popper) PopulateRule

func (p *Popper) PopulateRule(ctx context.Context) ([]*ent.Rule, error)

PopulateRule populates the Rule entities from the JSON data files.

func (*Popper) PopulateRuleEdges

func (p *Popper) PopulateRuleEdges(ctx context.Context, raw []ent.Rule) error

PopulateRuleEdges populates the Rule edges from the JSON data files.

func (*Popper) PopulateRuleSection

func (p *Popper) PopulateRuleSection(ctx context.Context) ([]*ent.RuleSection, error)

PopulateRuleSection populates the RuleSection entities from the JSON data files.

func (*Popper) PopulateRuleSectionEdges

func (p *Popper) PopulateRuleSectionEdges(ctx context.Context, raw []ent.RuleSection) error

PopulateRuleSectionEdges populates the RuleSection edges from the JSON data files.

func (*Popper) PopulateSkill

func (p *Popper) PopulateSkill(ctx context.Context) ([]*ent.Skill, error)

PopulateSkill populates the Skill entities from the JSON data files.

func (*Popper) PopulateSkillEdges

func (p *Popper) PopulateSkillEdges(ctx context.Context, raw []ent.Skill)

func (*Popper) PopulateStartingProficiencyOptions

func (p *Popper) PopulateStartingProficiencyOptions(ctx context.Context) error

PopulateStartingProficiencyOptions populates the StartingProficiencyOptions edges from the JSON data files.

func (*Popper) PopulateSubrace

func (p *Popper) PopulateSubrace(ctx context.Context) ([]*ent.Subrace, error)

PopulateSubrace populates the Subrace entities from the JSON data files.

func (*Popper) PopulateSubraceEdges

func (p *Popper) PopulateSubraceEdges(ctx context.Context, raw []ent.Subrace) error

PopulateSubraceEdges populates the Subrace edges from the JSON data files.

func (*Popper) PopulateTrait

func (p *Popper) PopulateTrait(ctx context.Context) ([]*ent.Trait, error)

PopulateTrait populates the Trait entities from the JSON data files.

func (*Popper) PopulateTraitEdges

func (p *Popper) PopulateTraitEdges(ctx context.Context, raw []ent.Trait) error

PopulateTraitEdges populates the Trait edges from the JSON data files.

func (*Popper) PopulateWeaponProperty

func (p *Popper) PopulateWeaponProperty(ctx context.Context) ([]*ent.WeaponProperty, error)

PopulateWeaponProperty populates the WeaponProperty entities from the JSON data files.

func (*Popper) PopulateWeaponPropertyEdges

func (p *Popper) PopulateWeaponPropertyEdges(ctx context.Context, raw []ent.WeaponProperty) error

PopulateWeaponPropertyEdges populates the WeaponProperty edges from the JSON data files.

type ProficiencyWrapper

type ProficiencyWrapper struct {
	Indx      string `json:"index"`
	Name      string `json:"name"`
	Reference struct {
		Indx string `json:"index"`
		Url  string `json:"url"`
	} `json:"reference"`
	Classes []*ent.Class `json:"classes"`
	Races   []*ent.Race  `json:"races"`
}

func (*ProficiencyWrapper) ToEnt

func (p *ProficiencyWrapper) ToEnt() *ent.Proficiency

ToEnt converts the ProficiencyWrapper to an ent.Proficiency.

type RaceChoiceWrapper

type RaceChoiceWrapper struct {
	Indx                       string         `json:"index"`
	StartingProficiencyOptions *ChoiceWrapper `json:"starting_proficiency_options,omitempty"`
}

type Range

type Range struct {
	Normal int `json:"normal,omitempty"`
	Long   int `json:"long,omitempty"`
}

type RefChoice

type RefChoice struct {
	Options []struct {
		Item struct {
			Indx string `json:"index"`
		} `json:"item"`
	} `json:"options,omitempty"`
}

type ToolWrapper

type ToolWrapper struct {
	ToolCategory string `json:"tool_category"`
}

type VehicleWrapper

type VehicleWrapper struct {
	VehicleCategory string `json:"vehicle_category"`
}

type WeaponWrapper

type WeaponWrapper struct {
	WeaponCategory string `json:"weapon_category"`
	WeaponRange    string `json:"weapon_range"`
	MeleeRange     Range  `json:"range,omitempty"`
	ThrowRange     Range  `json:"throw_range,omitempty"`
	Damage         struct {
		Dice  string      `json:"damage_dice,omitempty"`
		DType IndxWrapper `json:"damage_type,omitempty"`
	} `json:"damage,omitempty"`
	Properties []IndxWrapper `json:"properties,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL