Skip to content

Commit

Permalink
Add Kyuroro DM-06
Browse files Browse the repository at this point in the history
  • Loading branch information
DanieloV committed Sep 18, 2024
1 parent 5e2053d commit 17ce84d
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 25 deletions.
2 changes: 1 addition & 1 deletion game/cards/dm05/giant.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func AvalancheGiant(c *match.Card) {
1,
1,
false,
), card.ID)
), card)

ctx.Match.ReportActionInChat(card.Player, fmt.Sprintf("Avalanche Giant broke one of %s's shield", opponent.Username()))

Expand Down
19 changes: 8 additions & 11 deletions game/cards/dm06/armored_dragon.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,20 @@ func BolmeteusSteelDragon(c *match.Card) {
c.ManaCost = 7
c.ManaRequirement = []string{civ.Fire}

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

if card.Zone != match.BATTLEZONE {
event, _ := ctx.Event.(*match.BreakShieldEvent)
if event.Source != card {
return
}

if event, ok := ctx.Event.(*match.ShieldTriggerEvent); ok && event.Source == card.ID {
ctx.InterruptFlow()
}

if event, ok := ctx.Event.(*match.MoveCard); ok && event.From == match.SHIELDZONE && event.To == match.HAND && event.Source == card.ID {
moved, err := ctx.Match.Opponent(card.Player).MoveCard(event.CardID, match.SHIELDZONE, match.GRAVEYARD, card.ID)
ctx.InterruptFlow()
for _, shield := range event.Cards {
moved, err := ctx.Match.Opponent(card.Player).MoveCard(shield.ID, match.SHIELDZONE, match.GRAVEYARD, card.ID)
if err == nil {
ctx.Match.ReportActionInChat(ctx.Match.Opponent(card.Player), fmt.Sprintf("%s was moved to %s's graveyard instead of hand by %s", moved.Name, ctx.Match.Opponent(card.Player).Username(), card.Name))
}

ctx.InterruptFlow()
}
})

}))
}
39 changes: 39 additions & 0 deletions game/cards/dm06/cyber_lord.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,42 @@ func Sopian(c *match.Card) {

c.Use(fx.Creature, fx.TapAbility)
}

func Kyuroro(c *match.Card) {

c.Name = "Kyuroro"
c.Power = 2000
c.Civ = civ.Water
c.Family = []string{family.CyberLord}
c.ManaCost = 6
c.ManaRequirement = []string{civ.Water}

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

event, _ := ctx.Event.(*match.BreakShieldEvent)

if event.Source.Player == card.Player ||
!event.Source.HasCondition(cnd.Creature) ||
len(event.Cards) < 1 {
return
}

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

nrOfShields := len(event.Cards)

newShieldsSelection := fx.SelectBackside(
card.Player,
ctx.Match,
event.Cards[0].Player,
match.SHIELDZONE,
fmt.Sprintf("Kyuroro: choose %d shield(s) that your opponent will break", nrOfShields),
nrOfShields,
nrOfShields,
false,
)

event.Cards = newShieldsSelection
}))
}
2 changes: 1 addition & 1 deletion game/cards/dm06/giant_insect.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func SplinterclawWasp(c *match.Card) {
1,
1,
false,
), card.ID)
), card)

ctx.Match.ReportActionInChat(ctx.Match.Opponent(card.Player), fmt.Sprintf("Splinterclaw Wasp broke one of %s's shield", opponent.Username()))

Expand Down
1 change: 1 addition & 0 deletions game/cards/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,4 +516,5 @@ var DM06 = map[string]match.CardConstructor{
"4121d282-d257-4b3b-8388-83fbb4829dd9": dm06.LavaWalkerExecuto,
"7fd21958-859f-4085-acab-c736de7667ef": dm06.FortMegacluster,
"569c34fc-614a-4aaf-a89b-d4e5dd49426c": dm06.PhantasmalHorrorGigazald,
"4387fa57-6ba9-4628-ad07-12bd02def4cb": dm06.Kyuroro,
}
4 changes: 2 additions & 2 deletions game/fx/creature.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func Creature(card *match.Card, ctx *match.Context) {
ctx.Match.End(card.Player, fmt.Sprintf("%s won the game", ctx.Match.PlayerRef(card.Player).Socket.User.Username))
} else {
// Break n shields
ctx.Match.BreakShields(shieldsAttacked, card.ID)
ctx.Match.BreakShields(shieldsAttacked, card)
}

break
Expand Down Expand Up @@ -317,7 +317,7 @@ func Creature(card *match.Card, ctx *match.Context) {
ctx.Match.End(card.Player, fmt.Sprintf("%s won the game", ctx.Match.PlayerRef(card.Player).Socket.User.Username))
} else {
// Break n shields
ctx.Match.BreakShields(shieldsAttacked, card.ID)
ctx.Match.BreakShields(shieldsAttacked, card)
}

}
Expand Down
12 changes: 12 additions & 0 deletions game/fx/quality_of_life.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,18 @@ func EndOfMyTurn(card *match.Card, ctx *match.Context) bool {
return false
}

// BreakShield returns true if a shield is about to be broken
func BreakShield(card *match.Card, ctx *match.Context) bool {

if card.Zone != match.BATTLEZONE {
return false
}

_, ok := ctx.Event.(*match.BreakShieldEvent)
return ok

}

// ShieldBroken returns true if a shield has been broken
func ShieldBroken(card *match.Card, ctx *match.Context) bool {

Expand Down
4 changes: 2 additions & 2 deletions game/match/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ type ChargeManaEvent struct {

// BreakShieldEvent is fired before the shield is broken
type BreakShieldEvent struct {
CardID string
Source string // the card id that caused the shield to break
Cards []*Card
Source *Card // the card id that caused the shield to break
}

// BrokenShieldEvent is fired right after a shield was broken
Expand Down
25 changes: 17 additions & 8 deletions game/match/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,27 +260,36 @@ func (m *Match) MoveCardToFront(card *Card, destination string, source *Card) {
}

// BreakShields breaks the given shields and handles shieldtriggers
func (m *Match) BreakShields(shields []*Card, source string) {
func (m *Match) BreakShields(attemptedShields []*Card, source *Card) {

if len(shields) < 1 {
if len(attemptedShields) < 1 {
return
}

m.ReportActionInChat(shields[0].Player, fmt.Sprintf("%v of %v's shields were broken", len(shields), m.PlayerRef(shields[0].Player).Socket.User.Username))
event := &BreakShieldEvent{
Cards: attemptedShields,
Source: source,
}
ctx := NewContext(m, event)
m.HandleFx(ctx)
if ctx.cancel {
return
}
shields := event.Cards

var shieldTriggers []*Card
m.ReportActionInChat(shields[0].Player, fmt.Sprintf("%v of %v's shields were broken", len(shields), m.PlayerRef(shields[0].Player).Socket.User.Username))

var shieldTriggers []*Card

for _, shield := range shields {

card, err := shield.Player.MoveCard(shield.ID, SHIELDZONE, HAND, source)
card, err := shield.Player.MoveCard(shield.ID, SHIELDZONE, HAND, source.ID)

if err != nil {
continue
}

m.HandleFx(NewContext(m, &BrokenShieldEvent{CardID: card.ID, Source: source}))
m.HandleFx(NewContext(m, &BrokenShieldEvent{CardID: card.ID, Source: source.ID}))

// Handle shield triggers
if card.HasCondition(cnd.ShieldTrigger) {
Expand All @@ -297,7 +306,7 @@ func (m *Match) BreakShields(shields []*Card, source string) {

event := &ShieldTriggerEvent{
Cards: shieldTriggers,
Source: source,
Source: source.ID,
}
ctx := NewContext(m, event)
m.HandleFx(ctx)
Expand Down Expand Up @@ -367,7 +376,7 @@ func (m *Match) BreakShields(shields []*Card, source string) {

m.HandleFx(NewContext(m, &ShieldTriggerPlayedEvent{
Card: card,
Source: source,
Source: source.ID,
}))

m.CloseAction(card.Player)
Expand Down

0 comments on commit 17ce84d

Please sign in to comment.