add actions string array
This commit is contained in:
parent
d2d4927314
commit
3fd28e0cd9
@ -8,24 +8,25 @@ import (
|
||||
|
||||
// Fight represents a fight, past or present
|
||||
type Fight struct {
|
||||
ID int `json:"id"`
|
||||
UserID int `json:"user_id"`
|
||||
MonsterID int `json:"monster_id"`
|
||||
MonsterHP int `json:"monster_hp"`
|
||||
MonsterMaxHP int `json:"monster_max_hp"`
|
||||
MonsterSleep int `json:"monster_sleep"`
|
||||
MonsterImmune int `json:"monster_immune"`
|
||||
UberDamage int `json:"uber_damage"`
|
||||
UberDefense int `json:"uber_defense"`
|
||||
FirstStrike bool `json:"first_strike"`
|
||||
Turn int `json:"turn"`
|
||||
RanAway bool `json:"ran_away"`
|
||||
Victory bool `json:"victory"`
|
||||
Won bool `json:"won"`
|
||||
RewardGold int `json:"reward_gold"`
|
||||
RewardExp int `json:"reward_exp"`
|
||||
Created int64 `json:"created"`
|
||||
Updated int64 `json:"updated"`
|
||||
ID int `json:"id"`
|
||||
UserID int `json:"user_id"`
|
||||
MonsterID int `json:"monster_id"`
|
||||
MonsterHP int `json:"monster_hp"`
|
||||
MonsterMaxHP int `json:"monster_max_hp"`
|
||||
MonsterSleep int `json:"monster_sleep"`
|
||||
MonsterImmune int `json:"monster_immune"`
|
||||
UberDamage int `json:"uber_damage"`
|
||||
UberDefense int `json:"uber_defense"`
|
||||
FirstStrike bool `json:"first_strike"`
|
||||
Turn int `json:"turn"`
|
||||
RanAway bool `json:"ran_away"`
|
||||
Victory bool `json:"victory"`
|
||||
Won bool `json:"won"`
|
||||
RewardGold int `json:"reward_gold"`
|
||||
RewardExp int `json:"reward_exp"`
|
||||
Actions []string `json:"actions"`
|
||||
Created int64 `json:"created"`
|
||||
Updated int64 `json:"updated"`
|
||||
}
|
||||
|
||||
func (f *Fight) Save() error {
|
||||
@ -56,6 +57,7 @@ func New(userID, monsterID int) *Fight {
|
||||
Won: false,
|
||||
RewardGold: 0,
|
||||
RewardExp: 0,
|
||||
Actions: make([]string, 0),
|
||||
Created: now,
|
||||
Updated: now,
|
||||
}
|
||||
@ -309,3 +311,24 @@ func (f *Fight) DamageMonster(damage int) {
|
||||
}
|
||||
f.Updated = time.Now().Unix()
|
||||
}
|
||||
|
||||
func (f *Fight) AddAction(action string) {
|
||||
f.Actions = append(f.Actions, action)
|
||||
f.Updated = time.Now().Unix()
|
||||
}
|
||||
|
||||
func (f *Fight) GetActions() []string {
|
||||
return f.Actions
|
||||
}
|
||||
|
||||
func (f *Fight) GetLastAction() string {
|
||||
if len(f.Actions) == 0 {
|
||||
return ""
|
||||
}
|
||||
return f.Actions[len(f.Actions)-1]
|
||||
}
|
||||
|
||||
func (f *Fight) ClearActions() {
|
||||
f.Actions = make([]string, 0)
|
||||
f.Updated = time.Now().Unix()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user