add player effects, initial support for arbitrary scrying
This commit is contained in:
parent
bfd48cb069
commit
59cfb71a5e
30
effect.go
30
effect.go
@ -23,7 +23,16 @@ func RemoveEffect(source uuid.UUID, c *Card) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func RemovePlayerEffect(source uuid.UUID, p *Player) {
|
||||||
|
if p == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for i, e := range p.Effects {
|
||||||
|
if e.Owner == source {
|
||||||
|
p.Effects = append(p.Effects[:i], p.Effects[i+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
func AddEffect(c *Card, e *Effect) {
|
func AddEffect(c *Card, e *Effect) {
|
||||||
if c.Type == EmptyValue {
|
if c.Type == EmptyValue {
|
||||||
//can't apply effect to empty card
|
//can't apply effect to empty card
|
||||||
@ -46,3 +55,22 @@ func AddEffect(c *Card, e *Effect) {
|
|||||||
log.Printf("applying %v to %v", e, c)
|
log.Printf("applying %v to %v", e, c)
|
||||||
c.Effects = append(c.Effects, e)
|
c.Effects = append(c.Effects, e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AddPlayerEffect(p *Player, e *Effect) {
|
||||||
|
if p == nil || e == nil {
|
||||||
|
log.Println("adding nil player efect")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if e.Target != uuid.Nil {
|
||||||
|
log.Println("trying to apply targeted effect to player set")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for _, v := range p.Effects {
|
||||||
|
if v.Owner == e.Owner && v.ID == e.ID {
|
||||||
|
//can't stack effects
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Printf("applying %v to player %v", e, p)
|
||||||
|
p.Effects = append(p.Effects, e)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user