add actions string array
This commit is contained in:
parent
d2d4927314
commit
3fd28e0cd9
@ -24,6 +24,7 @@ type Fight struct {
|
||||
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"`
|
||||
}
|
||||
@ -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