-
Notifications
You must be signed in to change notification settings - Fork 0
/
item.go
48 lines (38 loc) · 861 Bytes
/
item.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package retro
import (
"time"
"github.com/kralamoure/retro/retrotyp"
)
type Item struct {
Id int
TemplateId int
Quantity int
Effects []retrotyp.Effect
}
func (item Item) DisplayEffects() []retrotyp.Effect {
effects := make([]retrotyp.Effect, len(item.Effects))
copy(effects, item.Effects)
for _, v := range effects {
if v.Id == 995 {
validity := time.Unix(int64(v.DiceSide/1000), 0)
if !validity.Before(time.Now()) {
dur := validity.Sub(time.Now())
days := int(dur.Hours()) / 24
hours := int(dur.Hours()) % 24
minutes := int(dur.Minutes()) % 60
effects = append(effects, retrotyp.Effect{
Id: 998,
DiceNum: days,
DiceSide: hours,
Value: minutes,
})
} else {
effects = append(effects, retrotyp.Effect{
Id: 994,
})
}
break
}
}
return effects
}