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 card Kyuroro DM-06 #255

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
})

}))
}
42 changes: 42 additions & 0 deletions game/cards/dm06/cyber_lord.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,45 @@ 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, ok := ctx.Event.(*match.BreakShieldEvent)
if !ok {
return
}

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 @@ -456,6 +456,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
23 changes: 17 additions & 6 deletions game/match/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,25 +263,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
}

event := &BreakShieldEvent{
Cards: attemptedShields,
Source: source,
}
ctx := NewContext(m, event)
m.HandleFx(ctx)
if ctx.cancel {
return
}
shields := event.Cards

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 @@ -298,7 +309,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 @@ -368,7 +379,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
Loading