snengame/internal/game/effect.go

33 lines
529 B
Go
Raw Normal View History

2021-07-25 15:33:47 -04:00
package game
import "github.com/google/uuid"
type Effect struct {
Owner uuid.UUID
Target uuid.UUID
ID int
}
func RemoveEffect(source uuid.UUID, c *Card) {
2021-07-25 17:23:12 -04:00
if c.Type == EmptyValue {
return
}
2021-07-25 15:33:47 -04:00
for i, e := range c.Effects {
if e.Owner == source {
c.Effects = append(c.Effects[:i], c.Effects[i+1:]...)
}
}
}
func AddEffect(c *Card, e Effect) {
2021-07-25 17:23:12 -04:00
if c.Type == EmptyValue {
return
}
2021-07-25 15:33:47 -04:00
for _, v := range c.Effects {
if v.Owner == e.Owner && v.ID == e.ID {
return
}
}
c.Effects = append(c.Effects, e)
}