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

Implementing Sly Moore Secretive Advisor #426

Merged
merged 3 commits into from
Jan 10, 2025
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
41 changes: 41 additions & 0 deletions server/game/cards/03_TWI/units/SlyMooreSecretiveAdvisor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import AbilityHelper from '../../../AbilityHelper';
import { NonLeaderUnitCard } from '../../../core/card/NonLeaderUnitCard';
import { CardType, PhaseName, RelativePlayer } from '../../../core/Constants';

export default class SlyMooreSecretiveAdvisor extends NonLeaderUnitCard {
protected override getImplementationId () {
return {
id: '7732981122',
internalName: 'sly-moore#secretive-advisor',
};
}

public override setupCardAbilities () {
this.addWhenPlayedAbility({
title: 'Take control of an enemy token unit and ready it. At the start of the regroup phase, that token unit\'s owner takes control of it.',
targetResolver: {
cardTypeFilter: CardType.TokenUnit,
controller: RelativePlayer.Opponent,
immediateEffect: AbilityHelper.immediateEffects.sequential([
AbilityHelper.immediateEffects.takeControlOfUnit((context) => ({
newController: context.source.controller
})),
AbilityHelper.immediateEffects.ready((context) => ({
target: context.target
})),
AbilityHelper.immediateEffects.delayedCardEffect((context) => ({
title: 'Owner takes control',
when: {
onPhaseStarted: (context) => context.phase === PhaseName.Regroup
},
immediateEffect: AbilityHelper.immediateEffects.takeControlOfUnit({
newController: context.target.owner
})
}))
])
}
});
}
}

SlyMooreSecretiveAdvisor.implemented = true;
52 changes: 52 additions & 0 deletions test/server/cards/03_TWI/units/SlyMooreSecretiveAdvisor.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
describe('Sly Moore Secretive Advisor', function() {
integration(function(contextRef) {
describe('Sly Moore\'s ability', function() {
beforeEach(function () {
contextRef.setupTest({
phase: 'action',
player1: {
hand: ['sly-moore#secretive-advisor'],
groundArena: ['battle-droid'],
spaceArena: ['cartel-spacer']
},
player2: {
groundArena: [{ card: 'clone-trooper', exhausted: true }, 'advanced-recon-commando']
}
});
});

it('should take control of an enemy token unit and ready it. At the start of the regroup phase, the owner should take control.', function () {
const { context } = contextRef;

context.player1.clickCard(context.slyMoore);
expect(context.player1).toBeAbleToSelectExactly([context.cloneTrooper]);

context.player1.clickCard(context.cloneTrooper);
expect(context.cloneTrooper).toBeInZone('groundArena', context.player1);
expect(context.cloneTrooper.exhausted).toBeFalse();
supercodepoet marked this conversation as resolved.
Show resolved Hide resolved
expect(context.player2).toBeActivePlayer();

context.moveToRegroupPhase();
expect(context.cloneTrooper).toBeInZone('groundArena', context.player2);
});

it('should take control of an enemy token unit and ready it. At the start of the regroup phase, the owner should not take control if the unit is defeated.', function () {
const { context } = contextRef;

context.player1.clickCard(context.slyMoore);
expect(context.player1).toBeAbleToSelectExactly([context.cloneTrooper]);

context.player1.clickCard(context.cloneTrooper);
expect(context.cloneTrooper).toBeInZone('groundArena', context.player1);
expect(context.cloneTrooper.exhausted).toBeFalse();
expect(context.player2).toBeActivePlayer();

context.player2.clickCard(context.advancedReconCommando);
context.player2.clickCard(context.cloneTrooper);

context.moveToRegroupPhase();
expect(context.cloneTrooper).toBeInZone('outsideTheGame', context.player2);
});
});
});
});
Loading