This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const DrawCard = require('../../drawcard.js'); | ||
const { Players, CardTypes, Locations } = require('../../Constants'); | ||
const AbilityDsl = require('../../abilitydsl'); | ||
|
||
const nitenCaptureParentCost = function() { | ||
return { | ||
action: { name: 'nitenCaptureParentCost', getCostMessage: () => '' }, | ||
canPay: function() { | ||
return true; | ||
}, | ||
resolve: function(context) { | ||
context.costs.nitenCaptureParentCost = context.source.parent; | ||
}, | ||
pay: function() { | ||
} | ||
}; | ||
|
||
}; | ||
|
||
class Niten extends DrawCard { | ||
setupCardAbilities() { | ||
this.attachmentConditions({ | ||
faction: 'dragon' | ||
}); | ||
|
||
this.action({ | ||
title: 'Put an attachment into play', | ||
condition: context => context.source.parent && context.source.parent.isParticipating(), | ||
cost: [ | ||
nitenCaptureParentCost(), | ||
AbilityDsl.costs.returnSelfToHand() | ||
], | ||
target: { | ||
cardType: CardTypes.Attachment, | ||
controller: Players.Self, | ||
location: Locations.Hand, | ||
cardCondition: (card, context) => card.canAttach(context.source.parent, context) || card.canAttach(context.costs.nitenCaptureParentCost, context) | ||
}, | ||
gameAction: AbilityDsl.actions.attach(context => ({ | ||
target: context.costs.nitenCaptureParentCost, | ||
attachment: context.target | ||
})), | ||
max: AbilityDsl.limit.perRound(1) | ||
}); | ||
} | ||
} | ||
|
||
Niten.id = 'niten'; | ||
|
||
module.exports = Niten; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
describe('Niten', function() { | ||
integration(function() { | ||
beforeEach(function() { | ||
this.setupTest({ | ||
phase: 'conflict', | ||
player1: { | ||
inPlay: ['niten-master', 'doji-challenger'], | ||
hand: ['niten', 'force-of-the-river', 'mark-of-shame', 'fine-katana', 'greater-understanding'] | ||
}, | ||
player2: { | ||
inPlay: ['togashi-yokuni'] | ||
} | ||
}); | ||
|
||
this.master = this.player1.findCardByName('niten-master'); | ||
this.challenger = this.player1.findCardByName('doji-challenger'); | ||
this.niten = this.player1.findCardByName('niten'); | ||
this.river = this.player1.findCardByName('force-of-the-river'); | ||
this.shame = this.player1.findCardByName('mark-of-shame'); | ||
this.katana = this.player1.findCardByName('fine-katana'); | ||
this.greater = this.player1.findCardByName('greater-understanding'); | ||
|
||
this.yokuni = this.player2.findCardByName('togashi-yokuni'); | ||
}); | ||
|
||
it('should attach to dragon characters', function() { | ||
this.player1.clickCard(this.niten); | ||
expect(this.player1).toBeAbleToSelect(this.master); | ||
expect(this.player1).not.toBeAbleToSelect(this.challenger); | ||
expect(this.player1).toBeAbleToSelect(this.yokuni); | ||
}); | ||
|
||
it('should not trigger outside of a conflict', function() { | ||
this.player1.clickCard(this.niten); | ||
this.player1.clickCard(this.master); | ||
this.player2.pass(); | ||
this.player1.clickCard(this.niten); | ||
expect(this.player1).toHavePrompt('Action Window'); | ||
}); | ||
|
||
it('should not trigger if parent is not participating', function() { | ||
this.player1.clickCard(this.niten); | ||
this.player1.clickCard(this.master); | ||
|
||
this.noMoreActions(); | ||
this.initiateConflict({ | ||
attackers: [this.challenger], | ||
defenders: [this.yokuni], | ||
type: 'military' | ||
}); | ||
|
||
this.player2.pass(); | ||
this.player1.clickCard(this.niten); | ||
expect(this.player1).toHavePrompt('Conflict Action Window'); | ||
}); | ||
|
||
it('should allow selecting a legal attachment', function() { | ||
this.player1.clickCard(this.niten); | ||
this.player1.clickCard(this.master); | ||
|
||
this.noMoreActions(); | ||
this.initiateConflict({ | ||
attackers: [this.master], | ||
defenders: [this.yokuni], | ||
type: 'military' | ||
}); | ||
|
||
this.player2.pass(); | ||
this.player1.clickCard(this.niten); | ||
expect(this.player1).toHavePrompt('Niten'); | ||
expect(this.player1).not.toBeAbleToSelect(this.river); | ||
expect(this.player1).toBeAbleToSelect(this.katana); | ||
expect(this.player1).toBeAbleToSelect(this.shame); | ||
expect(this.player1).not.toBeAbleToSelect(this.greater); | ||
}); | ||
|
||
it('should put attachment into play', function() { | ||
this.player1.clickCard(this.niten); | ||
this.player1.clickCard(this.master); | ||
|
||
this.noMoreActions(); | ||
this.initiateConflict({ | ||
attackers: [this.master], | ||
defenders: [this.yokuni], | ||
type: 'military' | ||
}); | ||
|
||
this.player2.pass(); | ||
this.player1.clickCard(this.niten); | ||
expect(this.player1).toHavePrompt('Niten'); | ||
this.player1.clickCard(this.katana); | ||
expect(this.niten.location).toBe('hand'); | ||
expect(this.katana.location).toBe('play area'); | ||
expect(this.getChatLogs(3)).toContain('player1 uses Niten, returning Niten to their hand to attach Fine Katana to Niten Master'); | ||
}); | ||
|
||
it('should trigger reactions to attachments being put into play', function() { | ||
this.player1.clickCard(this.niten); | ||
this.player1.clickCard(this.master); | ||
|
||
this.noMoreActions(); | ||
this.initiateConflict({ | ||
attackers: [this.master], | ||
defenders: [this.yokuni], | ||
type: 'military' | ||
}); | ||
|
||
this.master.bowed = true; | ||
this.player2.pass(); | ||
this.player1.clickCard(this.niten); | ||
expect(this.master.bowed).toBe(true); | ||
expect(this.player1).toHavePrompt('Niten'); | ||
this.player1.clickCard(this.katana); | ||
expect(this.niten.location).toBe('hand'); | ||
expect(this.katana.location).toBe('play area'); | ||
expect(this.getChatLogs(1)).toContain('player1 uses Niten, returning Niten to their hand to attach Fine Katana to Niten Master'); | ||
expect(this.player1).toHavePrompt('Triggered Abilities'); | ||
expect(this.player1).toBeAbleToSelect(this.master); | ||
this.player1.clickCard(this.master); | ||
expect(this.master.bowed).toBe(false); | ||
expect(this.getChatLogs(3)).toContain('player1 uses Niten Master to ready Niten Master'); | ||
}); | ||
|
||
it('should not trigger reactions to attachments being played', function() { | ||
this.player1.clickCard(this.niten); | ||
this.player1.clickCard(this.master); | ||
|
||
this.noMoreActions(); | ||
this.initiateConflict({ | ||
attackers: [this.master], | ||
defenders: [this.yokuni], | ||
type: 'military' | ||
}); | ||
|
||
this.player2.pass(); | ||
this.player1.clickCard(this.niten); | ||
expect(this.player1).toHavePrompt('Niten'); | ||
this.player1.clickCard(this.shame); | ||
expect(this.niten.location).toBe('hand'); | ||
expect(this.shame.location).toBe('play area'); | ||
expect(this.getChatLogs(3)).toContain('player1 uses Niten, returning Niten to their hand to attach Mark of Shame to Niten Master'); | ||
expect(this.player1).not.toHavePrompt('Triggered Abilities'); | ||
expect(this.player2).toHavePrompt('Conflict Action Window'); | ||
}); | ||
}); | ||
}); |