1
0
Fork 0

Updated display of turn start/end

This commit is contained in:
Michaël Lemaire 2019-05-20 18:35:59 +02:00
parent 6f1dbf6f4f
commit 6e319cc1ed
16 changed files with 113 additions and 254 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

View file

@ -15,7 +15,7 @@
viewBox="0 0 128 128"
version="1.1"
id="svg6044"
inkscape:version="0.92.3 (3ce5693, 2018-03-11)"
inkscape:version="0.92.4 (33fec40, 2019-01-16)"
sodipodi:docname="awaiter.svg"
inkscape:export-filename="/home/michael/workspace/spacetac/data/stage1/image/common/awaiter.png"
inkscape:export-xdpi="96"
@ -24,28 +24,28 @@
<defs
id="defs6038">
<linearGradient
inkscape:collect="always"
id="linearGradient4299">
id="linearGradient935"
inkscape:collect="always">
<stop
style="stop-color:#c09058;stop-opacity:1;"
id="stop925"
offset="0"
id="stop4295" />
style="stop-color:#425780;stop-opacity:1" />
<stop
id="stop4305"
style="stop-color:#425780;stop-opacity:1"
offset="0.66959655"
style="stop-color:#c09058;stop-opacity:1;" />
id="stop927" />
<stop
id="stop4303"
style="stop-color:#a5b7da;stop-opacity:1"
offset="0.73259044"
style="stop-color:#e9c79f;stop-opacity:1" />
id="stop929" />
<stop
style="stop-color:#c09058;stop-opacity:1;"
id="stop931"
offset="0.78740031"
id="stop4307" />
style="stop-color:#425780;stop-opacity:1" />
<stop
style="stop-color:#c09058;stop-opacity:1"
id="stop933"
offset="1"
id="stop4297" />
style="stop-color:#425780;stop-opacity:1" />
</linearGradient>
<mask
maskUnits="userSpaceOnUse"
@ -122,7 +122,7 @@
</filter>
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4299"
xlink:href="#linearGradient935"
id="linearGradient4301"
x1="65.841492"
y1="1000.924"
@ -131,7 +131,7 @@
gradientUnits="userSpaceOnUse" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4299"
xlink:href="#linearGradient935"
id="linearGradient4323"
gradientUnits="userSpaceOnUse"
x1="65.841492"
@ -160,8 +160,8 @@
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="5.6"
inkscape:cx="63.943429"
inkscape:cy="47.118486"
inkscape:cx="62.680229"
inkscape:cy="80.407176"
inkscape:document-units="px"
inkscape:current-layer="g4293"
showgrid="false"
@ -176,7 +176,7 @@
inkscape:snap-global="false"
inkscape:snap-others="false"
inkscape:window-width="1920"
inkscape:window-height="1037"
inkscape:window-height="1058"
inkscape:window-x="0"
inkscape:window-y="20"
inkscape:window-maximized="0">
@ -200,7 +200,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
@ -216,7 +216,7 @@
inkscape:export-ydpi="96"
transform="rotate(90,67.88396,1031.1339)">
<path
style="opacity:0.34599998;fill:url(#linearGradient4301);fill-opacity:1;stroke:none;stroke-width:6;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4280)"
style="opacity:0.441;fill:url(#linearGradient4301);fill-opacity:1;stroke:none;stroke-width:6;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4280)"
d="m 19.446431,1010.375 h 89.107139 l -13.035716,49.2858 H 32.482145 Z"
id="path4258"
inkscape:connector-curvature="0"
@ -227,21 +227,21 @@
inkscape:connector-curvature="0"
id="rect4255"
d="m 19.046721,1013.2403 h 89.906559 l -13.152665,24.0038 H 32.199384 Z"
style="opacity:1;fill:#ffd09a;fill-opacity:1;stroke:none;stroke-width:5.72441339;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
style="opacity:1;fill:#6f83ac;fill-opacity:1;stroke:none;stroke-width:5.72441339;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
inkscape:connector-curvature="0"
id="path4284"
d="m 34.718151,1033.6347 c 19.521233,0 39.042465,0 58.563698,0 3.065671,-5.595 6.131341,-11.19 9.197011,-16.785 -25.652573,0 -51.305147,0 -76.957721,0 3.065671,5.595 6.131341,11.19 9.197012,16.785 z"
style="opacity:1;fill:#ffdfba;fill-opacity:1;stroke:#000000;stroke-width:2.8622067;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.22985074" />
style="opacity:1;fill:#dde6f9;fill-opacity:1;stroke:#000000;stroke-width:2.8622067;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.22985074" />
<path
transform="matrix(0.39332006,0,0,0.31488355,38.470373,744.91136)"
sodipodi:nodetypes="ccccc"
inkscape:connector-curvature="0"
id="path4321"
d="m 19.446431,1010.375 h 89.107139 l -13.035716,49.2858 H 32.482145 Z"
style="opacity:0.46700003;fill:url(#linearGradient4323);fill-opacity:1;stroke:none;stroke-width:6;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4341)" />
style="opacity:0.675;fill:url(#linearGradient4323);fill-opacity:1;stroke:none;stroke-width:6;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter4341)" />
<path
style="opacity:1;fill:#775227;fill-opacity:1;stroke:#000000;stroke-width:1.80977798;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.22985074"
style="opacity:1;fill:#1f2f4f;fill-opacity:1;stroke:#000000;stroke-width:1.80977798;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.22985074"
d="m 49.787984,1037.2441 h 28.424033 l -4.158226,-7.5888 H 53.946209 Z"
id="path4345"
inkscape:connector-curvature="0"

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 9.5 KiB

View file

@ -19,7 +19,7 @@ module TK.SpaceTac {
ships: RObjectContainer<Ship>
// Current battle turn count
cycle = 0
turncount = 0
// List of deployed drones
drones = new RObjectContainer<Drone>()
@ -144,7 +144,7 @@ module TK.SpaceTac {
* Ends the battle and sets the outcome
*/
endBattle(winner: Fleet | null) {
this.applyDiffs([new EndBattleDiff(winner, this.cycle)]);
this.applyDiffs([new EndBattleDiff(winner, this.turncount)]);
}
/**
@ -165,7 +165,7 @@ module TK.SpaceTac {
*/
start(): void {
this.outcome = null;
this.cycle = 1;
this.turncount = 1;
this.placeShips();
iforeach(this.iships(), ship => ship.restoreInitialState());
}

View file

@ -7,7 +7,7 @@ module TK.SpaceTac.Specs {
let checks = new BattleChecks(battle);
check.equals(checks.checkVictory(), [], "no victory");
battle.cycle = 5;
battle.turncount = 5;
ship1.setDead();
check.equals(checks.checkVictory(), [new EndBattleDiff(battle.fleets[1], 5)], "victory");
})

View file

@ -83,7 +83,7 @@ module TK.SpaceTac {
let fleets = this.battle.fleets;
if (any(fleets, fleet => !fleet.isAlive())) {
const winner = first(fleets, fleet => fleet.isAlive());
return [new EndBattleDiff(winner, this.battle.cycle)];
return [new EndBattleDiff(winner, this.battle.turncount)];
} else {
return [];
}

View file

@ -64,7 +64,7 @@ namespace TK.SpaceTac {
* Log a turn end diff
*/
logEnd(): void {
this.battle.applyDiffs([new TurnEndDiff()]);
this.battle.applyDiffs([new TurnEndDiff(this.battle.turncount)]);
}
}
}

View file

@ -0,0 +1,23 @@
module TK.SpaceTac.Specs {
testing("TurnEndDiff", test => {
test.case("applies and reverts", check => {
const battle = new Battle();
battle.start();
TestTools.diffChain(check, battle, [
new TurnEndDiff(1),
new TurnEndDiff(2),
], [
check => {
check.equals(battle.turncount, 1);
},
check => {
check.equals(battle.turncount, 2);
},
check => {
check.equals(battle.turncount, 3);
},
]);
});
});
}

View file

@ -5,5 +5,16 @@ module TK.SpaceTac {
* A turn has ended
*/
export class TurnEndDiff extends BaseBattleDiff {
constructor(readonly turncount: number) {
super();
}
apply(battle: Battle): void {
battle.turncount = this.turncount + 1;
}
revert(battle: Battle): void {
battle.turncount = this.turncount;
}
}
}

View file

@ -1,81 +0,0 @@
module TK.SpaceTac.UI.Specs {
testing("ActionBar", test => {
let testgame = setupBattleview(test);
test.case("lists available actions for selected ship", check => {
var bar = testgame.view.action_bar;
// Ship not owned by current battleview player
var ship = new Ship();
bar.setShip(ship);
check.equals(bar.action_icons.length, 0);
// Ship with no equipment
let player = new Player();
ship.fleet.setPlayer(player);
testgame.view.player = player;
bar.setShip(ship);
check.equals(bar.action_icons.length, 0);
// Add an engine, with move action
TestTools.addEngine(ship, 50);
bar.setShip(ship);
check.equals(bar.action_icons.length, 1);
check.equals(bar.action_icons[0].action.code, "move");
// Add a weapon, with fire action
TestTools.addWeapon(ship, 10, 1, 100);
bar.setShip(ship);
check.equals(bar.action_icons.length, 2);
check.equals(bar.action_icons[1].action.code, "weapon");
});
test.case("updates power points display", check => {
let bar = testgame.view.action_bar;
function checkpoints(desc: string, available = 0, using = 0, used = 0) {
check.in(desc, check => {
check.same(bar.power_icons.length, available + using + used, "icon count");
bar.power_icons.list.forEach((child, idx) => {
if (check.instance(child, UIImage, `${idx} icon should be an image`)) {
if (idx < available) {
check.equals(child.name, "battle-actionbar-power-available", `icon ${idx}`);
} else if (idx < available + using) {
check.equals(child.name, "battle-actionbar-power-move", `icon ${idx}`);
} else {
check.equals(child.name, "battle-actionbar-power-used", `icon ${idx}`);
}
}
});
});
}
// not owned ship
let ship = new Ship();
TestTools.setShipModel(ship, 100, 0, 8);
bar.setShip(ship);
checkpoints("not owned ship");
// owned ship
testgame.view.player.fleet.addShip(ship);
testgame.view.battle.ships.add(duplicate(ship, TK.SpaceTac));
testgame.view.actual_battle.ships.add(ship);
bar.setShip(ship);
checkpoints("owned ship", 8);
// used points
testgame.view.actual_battle.applyDiffs(ship.getValueDiffs("power", 6));
testgame.view.log_processor.processPending();
checkpoints("2 points used", 6, 0, 2);
// using points
bar.updatePower(5);
checkpoints("5 points in targetting", 1, 5, 2);
// decrease
testgame.view.actual_battle.applyDiffs([new ShipAttributeDiff(ship, "power_capacity", { limit: 3 }, {})]);
testgame.view.log_processor.processPending();
checkpoints("limit to 3", 3);
});
});
}

View file

@ -12,13 +12,6 @@ module TK.SpaceTac.UI {
actions: UIContainer
action_icons: ActionIcon[]
// Power indicator
power: UIContainer
power_icons!: UIContainer
// Indicator of interaction disabled
icon_waiting: UIAwaiter
// Current ship, whose actions are displayed
ship: Ship | null
@ -37,29 +30,10 @@ module TK.SpaceTac.UI {
let builder = new UIBuilder(battleview, this);
// Background
let base = builder.image("battle-actionbar-background");
// Group for actions
this.actions = builder.container("actions", 86, 6);
builder.in(this.actions).image("battle-actionbar-actions-background");
// Power bar
this.power = builder.container("power", 1466, 0);
builder.in(this.power, builder => {
builder.image("battle-actionbar-power-background", 0, 6);
this.power_icons = builder.container("power icons", 50, 14);
});
// Playing ship
builder.image("battle-actionbar-ship", 1735);
// Waiting icon
this.icon_waiting = builder.awaiter(base.width / 2, base.height / 2, true, 0.5);
// Options button
builder.button("battle-actionbar-button-menu", 0, 0, () => battleview.showOptions(), "Game options");
// Log processing
battleview.log_processor.register(diff => {
if (!(diff instanceof BaseBattleShipDiff) || !this.ship || !this.ship.is(diff.ship_id)) {
@ -69,14 +43,9 @@ module TK.SpaceTac.UI {
if (diff instanceof ShipValueDiff && diff.code == "power") {
return {
background: async () => {
this.updatePower();
this.action_icons.forEach(action => action.refresh());
}
}
} else if (diff instanceof ShipAttributeDiff && diff.code == "power_capacity") {
return {
background: async () => this.updatePower()
}
} else if (diff instanceof ShipActionUsedDiff || diff instanceof ShipActionToggleDiff) {
return {
background: async () => this.action_icons.forEach(action => action.refresh())
@ -109,9 +78,6 @@ module TK.SpaceTac.UI {
setInteractivity(interactive: boolean) {
if (this.interactive != interactive) {
this.interactive = interactive;
this.battleview.animations.setVisible(this.icon_waiting, !this.interactive, 100);
this.battleview.animations.setVisible(this.power, interactive, 100, 1, 0.3);
this.battleview.animations.setVisible(this.actions, interactive, 100, 1, 0.3);
}
}
@ -148,64 +114,6 @@ module TK.SpaceTac.UI {
return icon;
}
/**
* Update the power indicator
*/
updatePower(move_power = 0, fire_power = 0): void {
let power_capacity = this.ship ? this.ship.getAttribute("power_capacity") : 0;
let power_value = this.ship ? this.ship.getValue("power") : 0;
let current_power = this.power_icons.length;
if (current_power > power_capacity) {
destroyChildren(this.power_icons, power_capacity, current_power);
} else if (power_capacity > current_power) {
range(power_capacity - current_power).forEach(i => {
let x = (current_power + i) % 5;
let y = ((current_power + i) - x) / 5;
let image = new UIBuilder(this.battleview, this.power_icons).image("battle-actionbar-power-used", x * 43, y * 22);
});
}
let remaining_power = power_value - move_power - fire_power;
this.power_icons.list.forEach((obj, idx) => {
let img = <UIImage>obj;
if (idx < remaining_power) {
this.battleview.changeImage(img, "battle-actionbar-power-available");
} else if (idx < remaining_power + move_power) {
this.battleview.changeImage(img, "battle-actionbar-power-move");
} else if (idx < power_value) {
this.battleview.changeImage(img, "battle-actionbar-power-fire");
} else {
this.battleview.changeImage(img, "battle-actionbar-power-used");
}
});
}
/**
* Temporarily set current action power usage.
*
* When an action is selected, this will fade the icons not available after the action would be done.
* This will also highlight power usage in the power bar.
*
* *move_power* and *fire_power* is the consumption of currently selected action/target.
*/
updateSelectedActionPower(move_power: number, fire_power: number, action: BaseAction): void {
this.action_icons.forEach(icon => icon.refresh(action, move_power + fire_power));
this.updatePower(move_power, fire_power);
}
/**
* Temporarily set power status for a given move-fire simulation
*/
updateFromSimulation(action: BaseAction, simulation: MoveFireResult) {
if (simulation.complete) {
this.updateSelectedActionPower(simulation.total_move_ap, simulation.total_fire_ap, action);
} else {
this.updateSelectedActionPower(0, 0, action);
}
}
/**
* Set the bar to display a given ship
*/
@ -218,8 +126,6 @@ module TK.SpaceTac.UI {
} else {
this.ship = null;
}
this.updatePower();
}
// Called by an action icon when the action is selected
@ -229,8 +135,6 @@ module TK.SpaceTac.UI {
// Called by an action icon when the action has been applied
actionEnded(): void {
this.battleview.exitTargettingMode();
this.updatePower();
this.action_icons.forEach(action => action.refresh());
}
}

View file

@ -90,7 +90,7 @@ module TK.SpaceTac.UI {
this.updateEffectsRadius();
// Set location
if (this.battleview.battle.cycle == 1) {
if (this.battleview.battle.turncount == 1) {
this.setPosition(ship.arena_x - 500 * Math.cos(ship.arena_angle), ship.arena_y - 500 * Math.sin(ship.arena_angle));
this.moveToArenaLocation(ship.arena_x, ship.arena_y, ship.arena_angle, 1);
} else {

View file

@ -11,6 +11,10 @@ module TK.SpaceTac.UI.Specs {
bar.setPhase(3, BattleInfoBarPhase.PLANNING);
expect(collectTexts(parent)).toEqual(["Planning phase", "Ready", "Turn 3"]);
bar.setPhase(3, BattleInfoBarPhase.END);
expect(collectTexts(parent)).toEqual(["End"]);
});
});
}

View file

@ -5,7 +5,9 @@ module TK.SpaceTac.UI {
}
export enum BattleInfoBarPhase {
PLANNING
PLANNING,
RESOLUTION,
END,
}
/**
@ -15,6 +17,7 @@ module TK.SpaceTac.UI {
private container: UIContainer
private title: UIText
private planning: BattleInfoBarPlanning
private awaiter: UIAwaiter
constructor(private builder: UIBuilder, private config: Partial<BattleInfoBarConfig> = {}) {
this.container = builder.container("infobar", 960, 1030);
@ -26,6 +29,8 @@ module TK.SpaceTac.UI {
this.title = builder.in(this.container).text("Battle", 0, 0, { center: true, size: 30, shadow: true, color: "#dbeff9" });
this.awaiter = builder.in(this.container).awaiter(474, 0, false, 0.3);
this.planning = new BattleInfoBarPlanning(this.container, config.startResolution);
}
@ -33,10 +38,18 @@ module TK.SpaceTac.UI {
switch (phase) {
case BattleInfoBarPhase.PLANNING:
this.container.getBuilder().change(this.title, "Planning phase");
break;
case BattleInfoBarPhase.RESOLUTION:
this.container.getBuilder().change(this.title, "Resolution phase");
break;
case BattleInfoBarPhase.END:
this.container.getBuilder().change(this.title, "End");
}
this.planning.setCurrentTurn(turn);
this.planning.setVisible(phase == BattleInfoBarPhase.PLANNING);
this.awaiter.setVisible(phase == BattleInfoBarPhase.RESOLUTION);
}
}

View file

@ -64,29 +64,6 @@ module TK.SpaceTac.UI.Specs {
check.same(battleview.ship_hovered, ship);
});
test.case("allows to choose an action and a target with shortcut keys", check => {
let battleview = testgame.view;
battleview.setInteractionEnabled(true);
battleview.setShipSelected(battleview.battle.fleets[0].ships[0]);
let action_icon = battleview.action_bar.action_icons[0];
check.equals(battleview.targetting.active, false);
check.equals(battleview.action_bar.hasActionSelected(), false);
battleview.numberPressed(battleview.action_bar.action_icons.indexOf(action_icon) + 1);
check.equals(battleview.action_bar.hasActionSelected(), true);
check.equals(battleview.targetting.active, true);
check.same(battleview.targetting.action, action_icon.action);
check.equals(battleview.targetting.target, action_icon.action.getDefaultTarget(action_icon.ship));
battleview.numberPressed(3);
check.equals(battleview.targetting.active, true);
check.same(battleview.targetting.action, action_icon.action);
check.equals(battleview.targetting.target, Target.newFromShip(battleview.battle.ships.list()[2]));
battleview.numberPressed(4);
check.equals(battleview.targetting.active, true);
check.same(battleview.targetting.action, action_icon.action);
check.equals(battleview.targetting.target, Target.newFromShip(battleview.battle.ships.list()[3]));
});
test.case("adds player actions to plan", check => {
let battleview = testgame.view;
check.equals(battleview.turn_plannings.length, 2);
@ -108,6 +85,7 @@ module TK.SpaceTac.UI.Specs {
test.case("disables player interaction while resolution is playing", check => {
const battleview = testgame.view;
const ship = battleview.actual_battle.fleets[0].ships[0];
const mockSetPhase = check.patch(battleview.infobar, "setPhase");
battleview.setShipSelected(ship);
check.in("initial", check => {
check.equals(battleview.interacting, true);
@ -118,22 +96,26 @@ module TK.SpaceTac.UI.Specs {
check.in("start 1", check => {
check.equals(battleview.interacting, false);
check.equals(battleview.ship_selected, null);
check.called(mockSetPhase, [[1, BattleInfoBarPhase.RESOLUTION]]);
});
battleview.actual_battle.applyDiffs([new TurnEndDiff()]);
battleview.actual_battle.applyDiffs([new TurnEndDiff(1)]);
battleview.log_processor.processPending();
check.in("end 1", check => {
check.equals(battleview.interacting, true);
check.called(mockSetPhase, [[2, BattleInfoBarPhase.PLANNING]]);
});
battleview.actual_battle.endBattle(null);
battleview.battle.applyDiffs([new TurnStartDiff([])]);
battleview.actual_battle.applyDiffs([new TurnStartDiff([])]);
battleview.log_processor.processPending();
check.in("start 2", check => {
check.equals(battleview.interacting, false);
check.called(mockSetPhase, [[2, BattleInfoBarPhase.RESOLUTION]]);
});
battleview.actual_battle.applyDiffs([new TurnEndDiff()]);
battleview.actual_battle.endBattle(null);
battleview.actual_battle.applyDiffs([new TurnEndDiff(2)]);
battleview.log_processor.processPending();
check.in("end 2", check => {
check.equals(battleview.interacting, false);
check.called(mockSetPhase, [[3, BattleInfoBarPhase.END]]);
});
});
});

View file

@ -82,7 +82,7 @@ module TK.SpaceTac.UI {
this.player = data.player;
this.actual_battle = data.battle;
this.battle = duplicate(data.battle, <any>TK.SpaceTac);
this.turn_plannings = this.battle.fleets.map(fleet => new TurnPlanning(this.battle, fleet.player));
this.turn_plannings = [];
this.ship_hovered = null;
this.ship_selected = null;
this.background = null;
@ -124,7 +124,7 @@ module TK.SpaceTac.UI {
showOptions: bound(this, "showOptions"),
startResolution: bound(this, "startResolution"),
});
this.infobar.setPhase(1, BattleInfoBarPhase.PLANNING);
this.infobar.setPhase(this.battle.turncount, BattleInfoBarPhase.PLANNING);
this.ship_tooltip = new ShipTooltip(this);
this.character_sheet = new CharacterSheet(this, CharacterSheetMode.DISPLAY);
this.character_sheet.moveToLayer(this.layer_sheets);
@ -158,11 +158,18 @@ module TK.SpaceTac.UI {
return {
foreground: async () => {
this.setInteractionEnabled(false);
this.resetPlannings();
this.infobar.setPhase(this.battle.turncount, BattleInfoBarPhase.RESOLUTION);
}
};
} else if (diff instanceof TurnEndDiff) {
return {
foreground: async () => this.setInteractionEnabled(true)
foreground: async () => {
this.setInteractionEnabled(true);
this.infobar.setPhase(this.battle.turncount,
this.battle.ended ? BattleInfoBarPhase.END : BattleInfoBarPhase.PLANNING
);
}
};
} else {
return {};
@ -187,6 +194,8 @@ module TK.SpaceTac.UI {
// TODO handle errors or timeout
this.multi.setup(this, this.actual_battle, this.gameui.session_token, false);
}
this.resetPlannings();
}
shutdown() {
@ -249,6 +258,14 @@ module TK.SpaceTac.UI {
}
}
/**
* Reset all plannings for a new turn
*/
resetPlannings(): void {
this.turn_plannings = this.battle.fleets.map(fleet => new TurnPlanning(this.battle, fleet.player));
this.planningsChanged();
}
/**
* Start the turn resolution
*/
@ -274,20 +291,9 @@ module TK.SpaceTac.UI {
/**
* Handle the pressing of a number key
*
* It may first be used to select an action to play, then to select a target
*/
numberPressed(num: number): void {
if (this.interacting) {
if (this.targetting.active) {
const ship = this.battle.ships.list()[num - 1];
if (ship) {
this.targetting.setTarget(Target.newFromShip(ship));
}
} else {
this.action_bar.keyActionPressed(num - 1);
}
}
// TODO Helper for action selection and targetting ?
}
/**

View file

@ -394,9 +394,6 @@ module TK.SpaceTac.UI {
setTarget(target: Target | null): void {
this.target = target;
this.update();
if (this.action) {
this.actionbar.updateFromSimulation(this.action, this.simulation);
}
}
/**