aboutsummaryrefslogtreecommitdiff
path: root/internal/object/object.go
blob: 12e5585b49218c8c6fb08b5187d1354d1fe33f02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package object

import "thehouseoficarus/internal/action"

type UseInteraction struct {
	Item      string             `yaml:"item_id"`
	Condition *action.Condition  `yaml:"condition"`
	Message   string             `yaml:"message"`
	Action    *action.NodeAction `yaml:"action"`
}

type ObjectDef struct {
	ID                string             `yaml:"id"`
	Name              string             `yaml:"name"`
	Color             string             `yaml:"color"`
	Hidden            bool               `yaml:"hidden"`
	InRoomDescription string             `yaml:"inroom_description"`
	RemovalItem       string             `yaml:"removal_item"`
	Description       string             `yaml:"description"`
	UseInteractions   []UseInteraction   `yaml:"use_interactions"`
	StealTable        string             `yaml:"steal_table"`
	StealLevel        int                `yaml:"steal_level"`
	StealXP           int                `yaml:"steal_xp"`
	StealSpeed        float64            `yaml:"steal_speed"`
	GuardMob          string             `yaml:"guard_mob"`

	Gather   *action.GatherConfig `yaml:"gather,omitempty"`
	Talk     *action.TalkConfig   `yaml:"talk,omitempty"`
	Use      *action.UseConfig    `yaml:"use,omitempty"`
	Safespot *SafespotConfig      `yaml:"safespot,omitempty"`
}

type SafespotConfig struct {
	Tier          int             `yaml:"tier"`
	MaxBlockSize  string          `yaml:"max_block_size"`
	MaxOccupants  int             `yaml:"max_occupants"`
	UnsafeChance  float64         `yaml:"unsafe_chance"`
	DecayTicks    float64         `yaml:"decay_ticks"`
	DecayChance   float64         `yaml:"decay_chance"`
	RespawnOnHide bool            `yaml:"respawn_on_hide"`
	RespawnTicks  float64         `yaml:"respawn_ticks"`
	Levels        []SafespotLevel `yaml:"levels"`
}

type SafespotLevel struct {
	Message        string `yaml:"message"`
	DegradeMessage string `yaml:"degrade_message"`
}

func (d *ObjectDef) IsGatherable() bool  { return d.Gather != nil }
func (d *ObjectDef) IsTalkable() bool    { return d.Talk != nil }
func (d *ObjectDef) IsUsable() bool      { return d.Use != nil }
func (d *ObjectDef) IsSafespot() bool    { return d.Safespot != nil }
func (d *ObjectDef) IsInteractable() bool { return d.Gather != nil || d.Talk != nil || d.Use != nil || d.Safespot != nil }

func (d *ObjectDef) BehaviorType() string {
	switch {
	case d.Gather != nil:
		return "gather"
	case d.Talk != nil:
		return "talk"
	case d.Use != nil:
		return "use"
	case d.Safespot != nil:
		return "safespot"
	}
	return ""
}