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)
|
||||||
|
}
|
||||||
|
11
player.go
11
player.go
@ -1,9 +1,10 @@
|
|||||||
package tome_lib
|
package tome_lib
|
||||||
|
|
||||||
type Player struct {
|
type Player struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Id int `json:"id"`
|
Id int `json:"id"`
|
||||||
Hand []*Card `json:"hand"`
|
Hand []*Card `json:"hand"`
|
||||||
Life int `json:"life"`
|
Life int `json:"life"`
|
||||||
Ready bool `json:"ready"`
|
Ready bool `json:"ready"`
|
||||||
|
Effects []*Effect
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user