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
|
// Fight represents a fight, past or present
|
||||||
type Fight struct {
|
type Fight struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
UserID int `json:"user_id"`
|
UserID int `json:"user_id"`
|
||||||
MonsterID int `json:"monster_id"`
|
MonsterID int `json:"monster_id"`
|
||||||
MonsterHP int `json:"monster_hp"`
|
MonsterHP int `json:"monster_hp"`
|
||||||
MonsterMaxHP int `json:"monster_max_hp"`
|
MonsterMaxHP int `json:"monster_max_hp"`
|
||||||
MonsterSleep int `json:"monster_sleep"`
|
MonsterSleep int `json:"monster_sleep"`
|
||||||
MonsterImmune int `json:"monster_immune"`
|
MonsterImmune int `json:"monster_immune"`
|
||||||
UberDamage int `json:"uber_damage"`
|
UberDamage int `json:"uber_damage"`
|
||||||
UberDefense int `json:"uber_defense"`
|
UberDefense int `json:"uber_defense"`
|
||||||
FirstStrike bool `json:"first_strike"`
|
FirstStrike bool `json:"first_strike"`
|
||||||
Turn int `json:"turn"`
|
Turn int `json:"turn"`
|
||||||
RanAway bool `json:"ran_away"`
|
RanAway bool `json:"ran_away"`
|
||||||
Victory bool `json:"victory"`
|
Victory bool `json:"victory"`
|
||||||
Won bool `json:"won"`
|
Won bool `json:"won"`
|
||||||
RewardGold int `json:"reward_gold"`
|
RewardGold int `json:"reward_gold"`
|
||||||
RewardExp int `json:"reward_exp"`
|
RewardExp int `json:"reward_exp"`
|
||||||
Created int64 `json:"created"`
|
Actions []string `json:"actions"`
|
||||||
Updated int64 `json:"updated"`
|
Created int64 `json:"created"`
|
||||||
|
Updated int64 `json:"updated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *Fight) Save() error {
|
func (f *Fight) Save() error {
|
||||||
@ -56,6 +57,7 @@ func New(userID, monsterID int) *Fight {
|
|||||||
Won: false,
|
Won: false,
|
||||||
RewardGold: 0,
|
RewardGold: 0,
|
||||||
RewardExp: 0,
|
RewardExp: 0,
|
||||||
|
Actions: make([]string, 0),
|
||||||
Created: now,
|
Created: now,
|
||||||
Updated: now,
|
Updated: now,
|
||||||
}
|
}
|
||||||
@ -309,3 +311,24 @@ func (f *Fight) DamageMonster(damage int) {
|
|||||||
}
|
}
|
||||||
f.Updated = time.Now().Unix()
|
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