Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rodi Gale Night Guardian dm07 + Stealth Mechanic #270

4 changes: 4 additions & 0 deletions api/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ func CreateCardCache() {

for uid, c := range *set {

if c == nil {
continue
}

card := &match.Card{}

c(card)
Expand Down
3 changes: 3 additions & 0 deletions cmd/duel-masters/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func init() {
func main() {
for _, set := range cards.Sets {
for uid, ctor := range *set {
if ctor == nil {
continue
}
match.AddCard(uid, ctor)
}
}
Expand Down
50 changes: 21 additions & 29 deletions game/cards/dm01/armored_wyvern.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,46 +46,38 @@ func ScarletSkyterror(c *match.Card) {
c.ManaCost = 8
c.ManaRequirement = []string{civ.Fire}

c.Use(fx.Creature, func(card *match.Card, ctx *match.Context) {
c.Use(fx.Creature, fx.When(fx.Summoned, func(card *match.Card, ctx *match.Context) {

if event, ok := ctx.Event.(*match.CardMoved); ok {
blockers := make([]*match.Card, 0)

if event.CardID != card.ID || event.To != match.BATTLEZONE {
return
}

blockers := make([]*match.Card, 0)

myBattlezone, err := card.Player.Container(match.BATTLEZONE)
myBattlezone, err := card.Player.Container(match.BATTLEZONE)

if err != nil {
return
}
if err != nil {
return
}

opponentBattlezone, err := ctx.Match.Opponent(card.Player).Container(match.BATTLEZONE)
opponentBattlezone, err := ctx.Match.Opponent(card.Player).Container(match.BATTLEZONE)

if err != nil {
return
}

for _, creature := range myBattlezone {
if creature.HasCondition(cnd.Blocker) {
blockers = append(blockers, creature)
}
}
if err != nil {
return
}

for _, creature := range opponentBattlezone {
if creature.HasCondition(cnd.Blocker) {
blockers = append(blockers, creature)
}
for _, creature := range myBattlezone {
if creature.HasCondition(cnd.Blocker) {
blockers = append(blockers, creature)
}
}

for _, blocker := range blockers {
ctx.Match.Destroy(blocker, card, match.DestroyedByMiscAbility)
for _, creature := range opponentBattlezone {
if creature.HasCondition(cnd.Blocker) {
blockers = append(blockers, creature)
}
}

for _, blocker := range blockers {
ctx.Match.Destroy(blocker, card, match.DestroyedByMiscAbility)
}

})
}))

}
30 changes: 11 additions & 19 deletions game/cards/dm01/armorloid.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,23 @@ func RothusTheTraveler(c *match.Card) {
c.ManaCost = 4
c.ManaRequirement = []string{civ.Fire}

c.Use(fx.Creature, func(card *match.Card, ctx *match.Context) {
c.Use(fx.Creature, fx.When(fx.Summoned, func(card *match.Card, ctx *match.Context) {

if event, ok := ctx.Event.(*match.CardMoved); ok {
creatures := match.Search(card.Player, ctx.Match, card.Player, match.BATTLEZONE, "Rothus, the Traveler: Select 1 creature from your battlezone that will be sent to your graveyard", 1, 1, false)

if event.CardID == card.ID && event.To == match.BATTLEZONE {

creatures := match.Search(card.Player, ctx.Match, card.Player, match.BATTLEZONE, "Rothus, the Traveler: Select 1 creature from your battlezone that will be sent to your graveyard", 1, 1, false)

for _, creature := range creatures {
ctx.Match.Destroy(creature, card, match.DestroyedByMiscAbility)
}

ctx.Match.Wait(card.Player, "Waiting for your opponent to make an action")
defer ctx.Match.EndWait(card.Player)

opponentCreatures := match.Search(ctx.Match.Opponent(card.Player), ctx.Match, ctx.Match.Opponent(card.Player), match.BATTLEZONE, "Rothus, the Traveler: Select 1 creature from your battlezone that will be sent to your graveyard", 1, 1, false)
for _, creature := range creatures {
ctx.Match.Destroy(creature, card, match.DestroyedByMiscAbility)
}

for _, creature := range opponentCreatures {
ctx.Match.Destroy(creature, card, match.DestroyedByMiscAbility)
}
ctx.Match.Wait(card.Player, "Waiting for your opponent to make an action")
defer ctx.Match.EndWait(card.Player)

}
opponentCreatures := match.Search(ctx.Match.Opponent(card.Player), ctx.Match, ctx.Match.Opponent(card.Player), match.BATTLEZONE, "Rothus, the Traveler: Select 1 creature from your battlezone that will be sent to your graveyard", 1, 1, false)

for _, creature := range opponentCreatures {
ctx.Match.Destroy(creature, card, match.DestroyedByMiscAbility)
}

})
}))

}
46 changes: 19 additions & 27 deletions game/cards/dm01/balloon_mushroom.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,37 @@ func PoisonousMushroom(c *match.Card) {
c.ManaCost = 2
c.ManaRequirement = []string{civ.Nature}

c.Use(fx.Creature, func(card *match.Card, ctx *match.Context) {
c.Use(fx.Creature, fx.When(fx.Summoned, func(card *match.Card, ctx *match.Context) {

if event, ok := ctx.Event.(*match.CardMoved); ok {
hand, err := card.Player.Container(match.HAND)

if event.CardID == card.ID && event.To == match.BATTLEZONE {

hand, err := card.Player.Container(match.HAND)

if err != nil {
return
}

ctx.Match.NewAction(card.Player, hand, 1, 1, "Select 1 card from your hand that will be sent to your manazone. Choose close to cancel.", true)

defer ctx.Match.CloseAction(card.Player)
if err != nil {
return
}

for {
ctx.Match.NewAction(card.Player, hand, 1, 1, "Select 1 card from your hand that will be sent to your manazone. Choose close to cancel.", true)

action := <-card.Player.Action
defer ctx.Match.CloseAction(card.Player)

if action.Cancel {
break
}
for {

if len(action.Cards) != 1 || !match.AssertCardsIn(hand, action.Cards...) {
ctx.Match.DefaultActionWarning(card.Player)
continue
}
action := <-card.Player.Action

card.Player.MoveCard(action.Cards[0], match.HAND, match.MANAZONE, card.ID)
if action.Cancel {
break
}

break
if len(action.Cards) != 1 || !match.AssertCardsIn(hand, action.Cards...) {
ctx.Match.DefaultActionWarning(card.Player)
continue
}

}
card.Player.MoveCard(action.Cards[0], match.HAND, match.MANAZONE, card.ID)

}
break

}

})
}))

}
2 changes: 1 addition & 1 deletion game/cards/dm01/beast_folk.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func BronzeArmTribe(c *match.Card) {
c.ManaCost = 3
c.ManaRequirement = []string{civ.Nature}

c.Use(fx.Creature, fx.DrawToMana)
c.Use(fx.Creature, fx.When(fx.Summoned, fx.Draw1ToMana))

}

Expand Down
122 changes: 53 additions & 69 deletions game/cards/dm01/chimera.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,86 +19,78 @@ func Gigaberos(c *match.Card) {
c.ManaCost = 5
c.ManaRequirement = []string{civ.Darkness}

c.Use(fx.Creature, fx.Doublebreaker, func(card *match.Card, ctx *match.Context) {
c.Use(fx.Creature, fx.Doublebreaker, fx.When(fx.Summoned, func(card *match.Card, ctx *match.Context) {

if event, ok := ctx.Event.(*match.CardMoved); ok {
creatures, err := card.Player.Container(match.BATTLEZONE)

if event.CardID == card.ID && event.To == match.BATTLEZONE {

creatures, err := card.Player.Container(match.BATTLEZONE)

if err != nil {
return
}

otherCreatures := make([]*match.Card, 0)
for _, creature := range creatures {
if creature.ID != card.ID {
otherCreatures = append(otherCreatures, creature)
}
}
this := make([]*match.Card, 0)
this = append(this, card)

options := make(map[string][]*match.Card)

options["This creature"] = this
options["Your other creatures"] = otherCreatures

ctx.Match.NewMultipartAction(card.Player, options, 1, 2, "Choose 2 of your other creatures in the battle zone that will be destroyed or destroy this creature", false)
if err != nil {
return
}

defer ctx.Match.CloseAction(card.Player)
otherCreatures := make([]*match.Card, 0)
for _, creature := range creatures {
if creature.ID != card.ID {
otherCreatures = append(otherCreatures, creature)
}
}
this := make([]*match.Card, 0)
this = append(this, card)

for {
options := make(map[string][]*match.Card)

action := <-card.Player.Action
options["This creature"] = this
options["Your other creatures"] = otherCreatures

if len(action.Cards) < 1 || len(action.Cards) > 2 {
ctx.Match.DefaultActionWarning(card.Player)
continue
}
ctx.Match.NewMultipartAction(card.Player, options, 1, 2, "Choose 2 of your other creatures in the battle zone that will be destroyed or destroy this creature", false)

// must be an attempt to destroy this creature
if len(action.Cards) == 1 {
defer ctx.Match.CloseAction(card.Player)

if action.Cards[0] != card.ID {
ctx.Match.DefaultActionWarning(card.Player)
continue
}
for {

ctx.Match.Destroy(card, card, match.DestroyedByMiscAbility)
ctx.InterruptFlow()
action := <-card.Player.Action

break
if len(action.Cards) < 1 || len(action.Cards) > 2 {
ctx.Match.DefaultActionWarning(card.Player)
continue
}

}
// must be an attempt to destroy this creature
if len(action.Cards) == 1 {

if !match.AssertCardsIn(creatures, action.Cards...) {
ctx.Match.DefaultActionWarning(card.Player)
continue
}
if action.Cards[0] != card.ID {
ctx.Match.DefaultActionWarning(card.Player)
continue
}

for _, id := range action.Cards {
ctx.Match.Destroy(card, card, match.DestroyedByMiscAbility)
ctx.InterruptFlow()

creature, err := card.Player.GetCard(id, match.BATTLEZONE)
break

if err != nil {
continue
}
}

ctx.Match.Destroy(creature, card, match.DestroyedByMiscAbility)
if !match.AssertCardsIn(creatures, action.Cards...) {
ctx.Match.DefaultActionWarning(card.Player)
continue
}

}
for _, id := range action.Cards {

break
creature, err := card.Player.GetCard(id, match.BATTLEZONE)

if err != nil {
continue
}

ctx.Match.Destroy(creature, card, match.DestroyedByMiscAbility)

}

break

}

})
}))

}

Expand Down Expand Up @@ -126,23 +118,15 @@ func Gigargon(c *match.Card) {
c.ManaCost = 8
c.ManaRequirement = []string{civ.Darkness}

c.Use(fx.Creature, func(card *match.Card, ctx *match.Context) {
c.Use(fx.Creature, fx.When(fx.Summoned, func(card *match.Card, ctx *match.Context) {

if event, ok := ctx.Event.(*match.CardMoved); ok {

if event.CardID == card.ID && event.To == match.BATTLEZONE {

creatures := match.SearchForCnd(card.Player, ctx.Match, card.Player, match.GRAVEYARD, cnd.Creature, "Gigargon: Select up to 2 cards from your graveyard that will be added to your hand", 1, 2, true)

for _, creature := range creatures {
card.Player.MoveCard(creature.ID, match.GRAVEYARD, match.HAND, card.ID)
ctx.Match.ReportActionInChat(card.Player, fmt.Sprintf("%s was returned to %s's hand from their graveyard", creature.Name, card.Player.Username()))
}

}
creatures := match.SearchForCnd(card.Player, ctx.Match, card.Player, match.GRAVEYARD, cnd.Creature, "Gigargon: Select up to 2 cards from your graveyard that will be added to your hand", 1, 2, true)

for _, creature := range creatures {
card.Player.MoveCard(creature.ID, match.GRAVEYARD, match.HAND, card.ID)
ctx.Match.ReportActionInChat(card.Player, fmt.Sprintf("%s was returned to %s's hand from their graveyard", creature.Name, card.Player.Username()))
}

})
}))

}
Loading
Loading