rules

package
v0.0.0-...-c6286b5 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(datadir string)

InitRules populates the global var with the data it loads from `datadir`

Types

type ActionStruct

type ActionStruct struct {
	Index       string
	Name        string         `json:"name"`
	Desc        string         `json:"desc"`
	AttackBonus int            `json:"attack_bonus"`
	Damage      []DamageStruct `json:"damage"`
}

type Buff

type Buff struct {
	Index string `json:"index"`

	Class struct {
		Name string `json:"name"`
	} `json:"class"`

	Subclass struct {
		Name string `json:"name"`
	} `json:"subclass"`

	Name   string   `json:"name"`
	Level  int      `json:"level"`
	Desc   []string `json:"desc"`
	Group  string   `json:"group"`
	Choice struct {
		// Mostly ignore all of this
		Choose int `json:"choose"`
	} `json:"choice"`
}

A Buff is a kinda catchall for a class feature or ability, or some other exception to the rules that we want to be aware of.

func (Buff) Description

func (b Buff) Description() string

func (Buff) GetClass

func (b Buff) GetClass() string

func (Buff) GetSubclass

func (b Buff) GetSubclass() string

func (Buff) IsNil

func (b Buff) IsNil() bool

func (Buff) String

func (b Buff) String() string

func (Buff) Summary

func (b Buff) Summary() string

func (Buff) Type

func (b Buff) Type() string

type BuffList

type BuffList map[string]Buff

func (BuffList) ForClass

func (bl BuffList) ForClass(class, subclass string, level int) []Buff

ForClass finds all the buffs that apply for the given character class / subclass / level.

func (BuffList) Lookup

func (bl BuffList) Lookup(namelike string) []Entryer

Implement the lookup interface

func (BuffList) LookupFirst

func (bl BuffList) LookupFirst(namelike string) Entryer

type DamageStruct

type DamageStruct struct {
	DamageDice  string `json:"damage_dice"`
	DamageBonus int    `json:"damage_bonus"`
	DamageType  struct {
		Name string `json:"name"`
	} `json:"damage_type"`
}

Use named struct, since it occurs twice in the data (where two-handed damage differs)

func (DamageStruct) String

func (d DamageStruct) String() string

type Entryer

type Entryer interface {
	Type() string
	Summary() string
	Description() string
}

type EquipmentList

type EquipmentList map[string]Item

EquipmentList simply maps the `Index` of each item to the full object

func (EquipmentList) Lookup

func (el EquipmentList) Lookup(namelike string) []Entryer

Implement the lookup interface

func (EquipmentList) LookupFirst

func (el EquipmentList) LookupFirst(namelike string) Entryer

type Item

type Item struct {
	Index string `json:"index"`
	Name  string `json:"name"`

	Cost struct {
		Quantity int    `json:"quantity"`
		Unit     string `json:"unit"`
	} `json:"cost"`

	EquipmentCategory struct {
		Name string `json:"name"`
	} `json:"equipment_category"`

	// There is also vehicle_category, etc; only parsing weapony fields for now.
	WeaponCategory string `json:"weapon_category"`
	WeaponRange    string `json:"weapon_range"`
	CategoryRange  string `json:"category_range"`

	Damage DamageStruct `json:"damage"`

	Range struct {
		Normal int `json:"normal"`
		Long   int `json:"long"`
	} `json:"range"`

	ArmorCategory string `json:"armor_category"`
	ArmorClass    struct {
		Base     int  `json:"base"`
		DexBonus bool `json:"dex_bonus"`
		MaxBonus int  `json:"max_bonus"`
	} `json:"armor_class"`

	Weight int      `json:"weight"`
	Desc   []string `json:"desc"`

	Properties []struct {
		Name string `json:"name"`
	} `json:"properties"`

	Damage2H DamageStruct `json:"2h_damage"`
}

func (Item) Description

func (i Item) Description() string

func (Item) GetDescriptions

func (i Item) GetDescriptions() string

func (Item) HasProperty

func (i Item) HasProperty(name string) bool

func (Item) IsNil

func (i Item) IsNil() bool

func (Item) String

func (i Item) String() string

func (Item) Summary

func (i Item) Summary() string

func (Item) Type

func (i Item) Type() string

func (Item) WeaponDamageString

func (i Item) WeaponDamageString() string

type Lookuper

type Lookuper interface {
	Lookup(s string) []Entryer
	LookupFirst(s string) Entryer
}

type Monster

type Monster struct {
	Index     string `json:"index"`
	Name      string `json:"name"`
	Size      string `json:"size"`
	Alignment string `json:"alignment"`

	ArmorClass int    `json:"armor_class"`
	HitPoints  int    `json:"hit_points"`
	HitDice    string `json:"hit_dice"`

	Speed struct {
		Walk string `json:"walk"`
		Swim string `json:"swim"`
		Fly  string `json:"fly"`
	} `json:"speed"`

	Str int `json:"strength"`
	Dex int `json:"dexterity"`
	Con int `json:"constitution"`
	Int int `json:"intelligence"`
	Wis int `json:"wisdom"`
	Cha int `json:"charisma"`

	Abilities []struct {
		Name string `json:"name"`
		Desc string `json:"desc"`
	} `json:"special_abilities"`

	Actions []ActionStruct `json:"actions"`
}

func (Monster) Description

func (m Monster) Description() string

func (*Monster) PostLoadFixups

func (m *Monster) PostLoadFixups()

func (Monster) String

func (m Monster) String() string

func (Monster) Summary

func (m Monster) Summary() string

func (Monster) Type

func (m Monster) Type() string

type MonsterList

type MonsterList map[string]Monster

func (MonsterList) Lookup

func (ml MonsterList) Lookup(namelike string) []Entryer

Implement the lookup interface

func (MonsterList) LookupFirst

func (ml MonsterList) LookupFirst(namelike string) Entryer

type Rules

The Rules type wraps up the DnD 5th Edition API objects (see https://www.dnd5eapi.co/docs/#resource-lists, https://github.com/bagelbits/5e-database)

var (
	TheRules Rules // A dumb global var (cf. "singleton" :) to hold all the objects
)

func (Rules) IsAllowedSpell

func (r Rules) IsAllowedSpell(s string, lvl int) bool

IsAllowedSpell verifies that the index-string passed in will lookup a spell at the specified level (and type ?)

func (Rules) IsArmor

func (r Rules) IsArmor(s string) bool

IsArmor verifies that the index-string passed in will lookup a kind of armor

func (Rules) IsSpell

func (r Rules) IsSpell(s string) bool

IsSpell verifies that the index-string passed in will lookup a spell

func (Rules) IsWeapon

func (r Rules) IsWeapon(s string) bool

IsWeapon verifies that the index-string passed in will lookup a weapon

func (Rules) String

func (r Rules) String() string

type Spell

type Spell struct {
	Index       string   `json:"index"`
	Name        string   `json:"name"`
	Desc        []string `json:"desc"`
	Higher      []string `json:"higher_level"`
	Range       string   `json:"range"`
	Duration    string   `json:"duration"`
	CastingTime string   `json:"casting_time"`
	Ritual      bool     `json:"ritual"`
	Level       int      `json:"level"`
	Classes     []struct {
		Name string `json:"name"`
	} `json:"classes"`
	Subclasses []struct {
		Name string `json:"name"`
	} `json:"subclasses"`
}

func (Spell) ClassesString

func (s Spell) ClassesString() string

func (Spell) Description

func (s Spell) Description() string

func (Spell) HasClass

func (s Spell) HasClass(c string) bool

func (Spell) HasSubclass

func (s Spell) HasSubclass(c string) bool

func (Spell) IsNil

func (s Spell) IsNil() bool

func (Spell) ShorterSummary

func (s Spell) ShorterSummary() string

func (Spell) String

func (s Spell) String() string

func (Spell) SubclassesString

func (s Spell) SubclassesString() string

func (Spell) Summary

func (s Spell) Summary() string

func (Spell) Type

func (s Spell) Type() string

type SpellDamage

type SpellDamage struct {
	Index string `json:"index"`

	AttackRoll string `json:"attack_roll"` // {ranged,melee} for spells that require an attack roll; empty otherwise

	Save struct {
		Attribute string  `json:"attribute"` // con,dex etc; or blank if there is no save
		Effect    float64 `json:"effect"`    // Multiplier on the final damage - e.g. 0.5, for half damage
	} `json:"save"`

	Multi struct {
		AllInArea    bool `json:"all_in_area"`   // Affects all named targets once, e.g. NumTargets = 99
		NumInstances int  `json:"num_instances"` // This damage occurs N times, each hitting the same target or different
		NumTargets   int  `json:"num_targets"`   // This damage can apply to N different targets
	} `json:"multi"`

	Damage DamageStruct `json:"damage"`

	PerHigherLevel struct {
		ExtraDamageDice string `json:"extra_damage_dice"` // You get an extra damage dice
		ExtraMulti      bool   `json:"extra_multi"`       // Whatever the multi-instance rules are, you get one more
	} `json:"per_higher_level"`
}

func (SpellDamage) AllowedSave

func (sd SpellDamage) AllowedSave() (string, float64)

Save returns how the tareget cna save (or empty if there is no save), and the multiplier to apply to the final damage (e.g. 0.5)

func (SpellDamage) Count

func (sd SpellDamage) Count(spellLevel, castingLevel int) (int, bool)

Count returns how many times the spell does its thing; the bool indicates whether the effects stack (i.e. multiple ones can apply to the same target). It needs to know both the base level of the spell, and the level it is being cast at

func (SpellDamage) DamageDice

func (sd SpellDamage) DamageDice(spellLevel, castingLevel int) roll.Roll

DamageRoll returns the roll to be made (per instance). It needs to know the base level of the spell, and the level it is being cast at

func (SpellDamage) IsNil

func (sd SpellDamage) IsNil() bool

func (SpellDamage) NeedsAttackRoll

func (sd SpellDamage) NeedsAttackRoll() bool

func (SpellDamage) String

func (sd SpellDamage) String() string

func (SpellDamage) Summary

func (sd SpellDamage) Summary() string

type SpellDamageList

type SpellDamageList map[string]SpellDamage

type SpellList

type SpellList map[string]Spell

SpellList just maps the `Index` of each spell to the spell object

func (SpellList) FindMatching

func (sl SpellList) FindMatching(class, subclass string, level int) []Spell

func (SpellList) Lookup

func (sl SpellList) Lookup(namelike string) []Entryer

Implement the lookup interface

func (SpellList) LookupFirst

func (sl SpellList) LookupFirst(namelike string) Entryer

Jump to

Keyboard shortcuts

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