This repository has been archived on 2024-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
ambition-legacy/frontend/player.go
Abdulmujeeb Raji 9157bfe8a1 feat(frontend): Basic Player Init
Player has health, level, exp (which is gained constantly while online)
and ambition (which affects the rate of exp gain). More stats will be
added later. This is mostly just a test implementation. Will clean up
later.
2023-07-23 09:20:48 +01:00

43 lines
855 B
Go

package main
import (
"math/rand"
)
type Player struct {
health int
level int
exp float32
ambition float32
}
// NOTE(midnadimple): These gates are temporary. We'll decide on real values later
var level_gates = map[int]float32{
1: 100.0,
2: 150.0,
3: 300.0,
}
// TODO(midnadimple): Move player initialization to server upon login
func initPlayer() Player {
return Player{
health: 100,
level: 1,
exp: 0.0,
ambition: (rand.Float32() * 10), // NOTE(midnadimple): In the future this will be affected by player activity
}
}
func (p *Player) update() {
// TODO(midnadimple): update health upon damage
if p.exp >= level_gates[p.level] {
p.exp = 0.0
p.level += 1
}
// NOTE(midnadimple): This formula for exp gain is pretty simple, maybe devraza can think of
// a more practical one
p.exp += 10.0 * (1.0/60.0) * p.ambition
}