Skip to content
Draft
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
36 changes: 36 additions & 0 deletions test/cases/specific/shd.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { cards } from '../../utils/cards';
import { Gameplay } from '../../utils/gameplay';
import { GameState } from '../../utils/gamestate';
import {
com, p,
Expand Down Expand Up @@ -165,5 +166,40 @@ export const SpecificSHDCases = {
await browser.assert.elementPresent(com.EnemySpaceUnit(1));
await browser.assert.elementPresent(com.EnemyGroundUnit(1));
await browser.assert.not.elementPresent(com.EnemyGroundUnit(2));
},
'Jetpack: break the temporary shield of a shielded unit': async function() {
//arrange
const gameState = new GameState(gameName);
await gameState.LoadGameStateLinesAsync();
await gameState.ResetGameStateLines()
.AddBase(1, cards.SHD.JabbasPalace)
.AddBase(2, cards.SOR.ECL)
.AddLeader(1, cards.SOR.SabineLeader)
.AddLeader(2, cards.SOR.SabineLeader)
.FillResources(1, cards.SOR.CraftySmuggler, 8)
.FillResources(2, cards.SOR.CraftySmuggler, 8)
.AddCardToHand(1, cards.SHD.Jetpack)
.AddCardToHand(1, cards.SHD.Jetpack)
.AddCardToHand(1, cards.SHD.Jetpack)
.AddCardToHand(1, cards.SHD.Jetpack)
.AddUnit(1, cards.SHD.L337, true, 0, gameState.SubcardBuilder().AddShield(1, 1).Build())
.AddUnit(1, cards.SHD.L337, true, 0, gameState.SubcardBuilder().AddShield(1, 1).Build())
.AddUnit(1, cards.SHD.L337, true, 0, gameState.SubcardBuilder().AddShield(1, 1).Build())
.AddUnit(2, cards.SOR.BFMarine, true)
.AddUnit(2, cards.SOR.BFMarine, true)
.AddUnit(2, cards.SOR.BFMarine, true)
.FlushAsync(com.BeginTestCallback)
;

//act
await Gameplay.Start()
.PlayFromHand(1)
.Debug()
.End();

//assert
// await browser.assert.elementPresent(com.EnemySpaceUnit(1));
// await browser.assert.elementPresent(com.EnemyGroundUnit(1));
// await browser.assert.not.elementPresent(com.EnemyGroundUnit(2));
}
}
2 changes: 2 additions & 0 deletions test/utils/cards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ export const cards = {
Finalizer: '9752523457',
CartelTurncoat: '9108611319',
LomPyke: '5632569775',
L337: '9552605383',
PoeDameron: '5966087637',
//upgrades
TopTarget: '4282425335',
Darksaber: '3141660491',
VambraceFlameThrower: '6471336466',
MandosRifle: '0754286363',
LegalAuthority: '8877249477',
Jetpack: '6117103324',
//events
TimelyIntervention: '6847268098',
NoBargain: '7354795397',
Expand Down
145 changes: 145 additions & 0 deletions test/utils/gameplay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import { Awaitable, NightwatchAPI } from "nightwatch";
import { Arena, com, p, player1Window, player2Window, Zone } from "./util";

export class Gameplay {
private asyncBrowser: Awaitable<NightwatchAPI, undefined>;
private currentPlayer: number;

private constructor(player: number) {
this.currentPlayer = 1;
this.asyncBrowser = browser.waitForElementPresent(com.MyHand).moveToElement(com.GameChat, 0, 0).pause(p.Move);
this.WithPlayer(player);
}

public static Start(player: number = 1) {
return new Gameplay(player);
}

public WithPlayer(player: number) {
if (player !== this.currentPlayer) {
this.asyncBrowser.window
.switchTo(player === 1 ? player1Window : player2Window)
.refresh()
.moveToElement(com.GameChat, 0, 0)
.pause(p.WaitToChooseTarget);
this.currentPlayer = player;
}
return this;
}

public async End() {
return await this.asyncBrowser;
}

public Debug() {
this.asyncBrowser.pause(p.Debug);
return this;
}

public Pass() {
this.asyncBrowser.click(com.PassButton).pause(p.ButtonPress);
return this;
}

public Claim() {
this.asyncBrowser.click(com.ClaimButton).pause(p.ButtonPress);
return this;
}

public Attack(attacker: number, target: number, arena: Arena) {
const attackerEl = arena === Arena.ground ? com.AllyGroundUnit(attacker) : com.AllySpaceUnit(attacker);
const targetEl = arena === Arena.ground ? com.EnemyGroundUnit(target) : com.EnemySpaceUnit(target);

this.asyncBrowser
.click(attackerEl)
.moveToElement(com.GameChat, 0, 0)
.pause(p.WaitToChooseTarget)
.click(targetEl)
.moveToElement(com.GameChat, 0, 0)
.pause(p.WaitForEffect);

return this;
}

public AttackWithGround(attacker: number, target: number) {
return this.Attack(attacker, target, Arena.ground);
}

public AttackWithSpace(attacker: number, target: number) {
return this.Attack(attacker, target, Arena.space);
}

public Play(index: number, zone: Zone) {
switch (zone) {
case Zone.hand:
this.asyncBrowser.click(com.HandCard(index));
break;
case Zone.resources:
// TODO - implement resources
break;
case Zone.discard:
// TODO - implement discard
break;
}

this.asyncBrowser.moveToElement(com.GameChat, 0, 0).pause(p.WaitToChooseTarget);
return this;
}

public PlayFromHand(index: number) {
return this.Play(index, Zone.hand);
}

public PlayFromResources(index: number) {
return this.Play(index, Zone.resources);
}

public PlayFromDiscard(index: number) {
return this.Play(index, Zone.discard);
}

public ChooseTopBottom(index: number, choice: number) {
this.asyncBrowser
.click(com.InHandTopBottom(index, choice))
.moveToElement(com.GameChat, 0, 0)
.pause(p.ButtonPress);
return this;
}

public ChooseTop(index: number) {
return this.ChooseTopBottom(index, 1);
}

public ChooseBottom(index: number) {
return this.ChooseTopBottom(index, 2);
}

public ChooseMultiChoice(index: number) {
this.asyncBrowser.click(com.ButtonMultiChoice(index)).moveToElement(com.GameChat, 0, 0).pause(p.ButtonPress);
return this;
}

public ChooseYesNo(choice: "YES" | "NO") {
this.asyncBrowser.click(com.YesNoButton(choice)).moveToElement(com.GameChat, 0, 0).pause(p.ButtonPress);
return this;
}

public ChooseYes() {
return this.ChooseYesNo("YES");
}

public ChooseNo() {
return this.ChooseYesNo("NO");
}

public ActivateLeader() {
this.asyncBrowser
.click(com.Leader(1))
.moveToElement(com.GameChat, 0, 0)
.pause(p.Move)
.click(com.ButtonMultiChoice(1))
.moveToElement(com.GameChat, 0, 0)
.pause(p.ButtonPress);
return this;
}
}
11 changes: 11 additions & 0 deletions test/utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,14 @@ export const cs = {//copied from Constants.php
NumBountyHuntersPlayed: 73,
NumPilotsPlayed: 74,
}

export enum Arena {
ground,
space,
}

export enum Zone {
hand,
resources,
discard,
}