Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
DoR - Siege Warfare (#3691)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcsoiferman-cm authored and The-Outcast committed Nov 22, 2019
1 parent 9fa9b58 commit 624a2cc
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 0 deletions.
23 changes: 23 additions & 0 deletions server/game/cards/11-DoR/SiegeWarfare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const DrawCard = require('../../drawcard.js');
const { Locations } = require('../../Constants');
const AbilityDsl = require('../../abilitydsl');

class SiegeWarfare extends DrawCard {
setupCardAbilities() {
this.action({
title: 'Give attacked province -2 strength',
condition: context => context.player.isAttackingPlayer() && context.player.getNumberOfHoldingsInPlay() > 0 && this.game.currentConflict.conflictProvince.getStrength() > 0,
gameAction: AbilityDsl.actions.cardLastingEffect(() => ({
targetLocation: Locations.Provinces,
target: this.game.currentConflict.conflictProvince,
effect: AbilityDsl.effects.modifyProvinceStrength(-2)
})),
effect: 'reduce the province strength of {1} by 2',
effectArgs: () => this.game.currentConflict.conflictProvince.name
});
}
}

SiegeWarfare.id = 'siege-warfare';

module.exports = SiegeWarfare;
86 changes: 86 additions & 0 deletions test/server/cards/11-DoR/SiegeWarfare.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
describe('Siege Warfare', function() {
integration(function() {
describe('Siege Warfare Ability', function() {
beforeEach(function () {
this.setupTest({
phase: 'conflict',
player1: {
inPlay: ['doji-kuwanan'],
hand: ['siege-warfare'],
dynastyDiscard: ['imperial-storehouse']
},
player2: {
hand: ['siege-warfare'],
dynastyDiscard: ['imperial-storehouse']
}
});

this.kuwanan = this.player1.findCardByName('doji-kuwanan');
this.siegeWarfare = this.player1.findCardByName('siege-warfare');
this.p2siege = this.player2.findCardByName('siege-warfare');
this.storehouse = this.player1.placeCardInProvince('imperial-storehouse', 'province 3');
this.player2.placeCardInProvince('imperial-storehouse', 'province 3');

this.p1 = this.player2.findCardByName('shameful-display', 'province 1');

this.noMoreActions();
this.initiateConflict({
type: 'military',
attackers: [this.kuwanan],
defenders: [],
province: this.p1
});
});

it('should reduce the strength of the attacked province by 2', function () {
let strength = this.p1.getStrength();
this.player2.pass();
this.player1.clickCard(this.siegeWarfare);
expect(this.p1.getStrength()).toBe(strength - 2);
expect(this.getChatLogs(3)).toContain('player1 plays Siege Warfare to reduce the province strength of Shameful Display by 2');
});

it('should not reduce the strength of the attacked province below 0', function () {
let strength = this.p1.getStrength();
this.player2.pass();
this.player1.clickCard(this.siegeWarfare);
expect(this.p1.getStrength()).toBe(strength - 2);
this.player1.moveCard(this.siegeWarfare, 'hand');
this.player2.pass();
this.player1.clickCard(this.siegeWarfare);
expect(this.p1.getStrength()).toBe(0);
});

it('should not be playable if the province strength is already 0', function () {
let strength = this.p1.getStrength();
this.player2.pass();
this.player1.clickCard(this.siegeWarfare);
expect(this.p1.getStrength()).toBe(strength - 2);
this.player1.moveCard(this.siegeWarfare, 'hand');
this.player2.pass();
this.player1.clickCard(this.siegeWarfare);
expect(this.p1.getStrength()).toBe(0);
this.player1.moveCard(this.siegeWarfare, 'hand');
this.player2.pass();
this.player1.clickCard(this.siegeWarfare);
expect(this.player1).toHavePrompt('Conflict Action Window');
});

it('should not be playable on defense', function () {
let strength = this.p1.getStrength();
this.player2.clickCard(this.p2siege);
expect(this.p1.getStrength()).toBe(strength);
expect(this.player2).toHavePrompt('Conflict Action Window');
});

it('should not be playable without a holding', function () {
let strength = this.p1.getStrength();
this.player1.moveCard(this.storehouse, 'dynasty discard pile');
this.player2.pass();
this.player1.clickCard(this.siegeWarfare);
expect(this.p1.getStrength()).toBe(strength);
expect(this.player1).toHavePrompt('Conflict Action Window');
});
});
});
});

0 comments on commit 624a2cc

Please sign in to comment.