diff options
Diffstat (limited to 'internal/player')
| -rw-r--r-- | internal/player/player.go | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/internal/player/player.go b/internal/player/player.go index 4b26a84..a970a00 100644 --- a/internal/player/player.go +++ b/internal/player/player.go @@ -1,7 +1,11 @@ package player -import "thehouseoficarus/internal/action" -import "thehouseoficarus/internal/object" +import ( + "sort" + + "thehouseoficarus/internal/action" + "thehouseoficarus/internal/object" +) type SkillName string @@ -173,6 +177,10 @@ type Player struct { MoveDirection string `yaml:"-"` MoveTarget int `yaml:"-"` VisualTickCurrent int `yaml:"-"` + Battery float64 `yaml:"battery"` + ActiveTechs map[string]bool `yaml:"-"` + QuickTech string `yaml:"quick_tech,omitempty"` + TechActivatedSinceTick map[string]bool `yaml:"-"` } func (p *Player) ClearMoveState() { @@ -288,6 +296,7 @@ func New(name string) *Player { } p.Skills[Hitpoints] = XPForLevel(10) p.HP = p.MaxHP() + p.Battery = p.MaxBattery() return p } @@ -375,3 +384,45 @@ func (p *Player) RemoveItem(itemID string, qty int) bool { } return remaining <= 0 } + +func (p *Player) MaxBattery() float64 { + return float64(p.Level(Technology)) +} + +func (p *Player) HasActiveTech(techID string) bool { + if p.ActiveTechs == nil { + return false + } + return p.ActiveTechs[techID] +} + +func (p *Player) ActivateTech(techID string) { + if p.ActiveTechs == nil { + p.ActiveTechs = make(map[string]bool) + } + if p.TechActivatedSinceTick == nil { + p.TechActivatedSinceTick = make(map[string]bool) + } + p.ActiveTechs[techID] = true + p.TechActivatedSinceTick[techID] = true +} + +func (p *Player) DeactivateTech(techID string) { + if p.ActiveTechs != nil { + delete(p.ActiveTechs, techID) + } +} + +func (p *Player) DeactivateAllTechs() { + p.ActiveTechs = nil + p.TechActivatedSinceTick = nil +} + +func (p *Player) ActiveTechList() []string { + var result []string + for id := range p.ActiveTechs { + result = append(result, id) + } + sort.Strings(result) + return result +} |
