Documentation
¶
Index ¶
- func Init(datadir string)
- type ActionStruct
- type Buff
- type BuffList
- type DamageStruct
- type Entryer
- type EquipmentList
- type Item
- type Lookuper
- type Monster
- type MonsterList
- type Rules
- type Spell
- func (s Spell) ClassesString() string
- func (s Spell) Description() string
- func (s Spell) HasClass(c string) bool
- func (s Spell) HasSubclass(c string) bool
- func (s Spell) IsNil() bool
- func (s Spell) ShorterSummary() string
- func (s Spell) String() string
- func (s Spell) SubclassesString() string
- func (s Spell) Summary() string
- func (s Spell) Type() string
- type SpellDamage
- func (sd SpellDamage) AllowedSave() (string, float64)
- func (sd SpellDamage) Count(spellLevel, castingLevel int) (int, bool)
- func (sd SpellDamage) DamageDice(spellLevel, castingLevel int) roll.Roll
- func (sd SpellDamage) IsNil() bool
- func (sd SpellDamage) NeedsAttackRoll() bool
- func (sd SpellDamage) String() string
- func (sd SpellDamage) Summary() string
- type SpellDamageList
- type SpellList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (Buff) GetSubclass ¶
type BuffList ¶
func (BuffList) ForClass ¶
ForClass finds all the buffs that apply for the given character class / subclass / level.
func (BuffList) LookupFirst ¶
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 EquipmentList ¶
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 (Item) GetDescriptions ¶
func (Item) HasProperty ¶
func (Item) WeaponDamageString ¶
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 (*Monster) PostLoadFixups ¶
func (m *Monster) PostLoadFixups()
type MonsterList ¶
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 ¶
type Rules struct { EquipmentList SpellList MonsterList BuffList SpellDamageList }
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 ¶
IsAllowedSpell verifies that the index-string passed in will lookup a spell at the specified level (and type ?)
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 (Spell) Description ¶
func (Spell) HasSubclass ¶
func (Spell) ShorterSummary ¶
func (Spell) SubclassesString ¶
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 ¶
SpellList just maps the `Index` of each spell to the spell object