40 lines
668 B
Go
40 lines
668 B
Go
package game
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type Effect struct {
|
|
Owner uuid.UUID
|
|
Target uuid.UUID
|
|
ID int
|
|
}
|
|
|
|
func RemoveEffect(source uuid.UUID, c *Card) {
|
|
if c.Type == EmptyValue {
|
|
return
|
|
}
|
|
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) {
|
|
if c.Type == EmptyValue {
|
|
log.Println("Can't add effect to empty card")
|
|
return
|
|
}
|
|
for _, v := range c.Effects {
|
|
if v.Owner == e.Owner && v.ID == e.ID {
|
|
log.Println("can't stack effects")
|
|
return
|
|
}
|
|
}
|
|
log.Printf("applying %v to %v", e, c)
|
|
c.Effects = append(c.Effects, e)
|
|
}
|