Added battle experience
This commit is contained in:
parent
27302267b9
commit
d68f295f2d
1
TODO
1
TODO
|
@ -10,7 +10,6 @@
|
|||
* Find incentives to move from starting position
|
||||
* Fix targetting not resetting when using action shortcuts
|
||||
* Add battle statistics and/or critics in outcome dialog
|
||||
* Add battle experience
|
||||
* Ensure that tweens and particle emitters get destroyed once animation is done (or view changes)
|
||||
* Highlight ships that will be included as target of current action
|
||||
* Controls: Do not focus on ship while targetting for area effects (dissociate hover and target)
|
||||
|
|
|
@ -573,11 +573,11 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.70000001"
|
||||
inkscape:cx="290.06665"
|
||||
inkscape:cy="536.461"
|
||||
inkscape:zoom="7.919596"
|
||||
inkscape:cx="577.1487"
|
||||
inkscape:cy="39.46876"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer3"
|
||||
inkscape:current-layer="layer2"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1037"
|
||||
|
@ -1290,6 +1290,15 @@
|
|||
x="169.983"
|
||||
id="tspan6629"
|
||||
sodipodi:role="line">2</tspan></text>
|
||||
<path
|
||||
style="display:inline;opacity:1;fill:#d7d07d;fill-opacity:1;stroke:none;stroke-width:0.58238131;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter9551)"
|
||||
d="m 517.54102,1067.4453 -0.96875,7.6934 h 72.14257 l -0.96875,-7.6934 z"
|
||||
transform="matrix(0.26458334,0,0,0.26458334,26.987511,0)"
|
||||
id="path4776"
|
||||
inkscape:connector-curvature="0"
|
||||
inkscape:export-filename="/home/michael/workspace/perso/spacetac/out/assets/images/character/experience.png"
|
||||
inkscape:export-xdpi="96"
|
||||
inkscape:export-ydpi="96" />
|
||||
</g>
|
||||
<g
|
||||
id="g6064"
|
||||
|
|
Before Width: | Height: | Size: 69 KiB After Width: | Height: | Size: 69 KiB |
BIN
out/assets/images/character/experience.png
Normal file
BIN
out/assets/images/character/experience.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 323 B |
|
@ -1 +1 @@
|
|||
Subproject commit bc39ed78ef474e42cb20b3dbfc3dffa80c07ffe7
|
||||
Subproject commit e3c03f16d3d1e953c1e1faffd2e28cba2c7c518c
|
|
@ -132,6 +132,12 @@ module TS.SpaceTac {
|
|||
* Ends a battle and sets the outcome
|
||||
*/
|
||||
endBattle(winner: Fleet | null, log = true) {
|
||||
this.ended = true;
|
||||
this.outcome = new BattleOutcome(winner);
|
||||
|
||||
// Apply experience
|
||||
this.outcome.grantExperience(this.fleets);
|
||||
|
||||
// Wear down equipment
|
||||
iforeach(this.iships(), ship => {
|
||||
ship.listEquipment().forEach(equipment => {
|
||||
|
@ -139,9 +145,7 @@ module TS.SpaceTac {
|
|||
});
|
||||
});
|
||||
|
||||
// Prepare broadcast
|
||||
this.ended = true;
|
||||
this.outcome = new BattleOutcome(winner);
|
||||
// Broadcast
|
||||
if (log && this.log) {
|
||||
this.log.add(new EndBattleEvent(this.outcome));
|
||||
}
|
||||
|
|
|
@ -55,5 +55,38 @@ module TS.SpaceTac.Specs {
|
|||
expect(outcome.loot[2].quality).toBe(EquipmentQuality.PREMIUM);
|
||||
expect(outcome.loot[2].requirements).toEqual({ "skill_energy": 9 });
|
||||
});
|
||||
|
||||
it("grants experience", function () {
|
||||
let fleet1 = new Fleet();
|
||||
let ship1a = fleet1.addShip(new Ship());
|
||||
ship1a.level.forceLevel(3);
|
||||
let ship1b = fleet1.addShip(new Ship());
|
||||
ship1b.level.forceLevel(4);
|
||||
let fleet2 = new Fleet();
|
||||
let ship2a = fleet2.addShip(new Ship());
|
||||
ship2a.level.forceLevel(6);
|
||||
let ship2b = fleet2.addShip(new Ship());
|
||||
ship2b.level.forceLevel(8);
|
||||
expect(ship1a.level.getExperience()).toEqual(300);
|
||||
expect(ship1b.level.getExperience()).toEqual(600);
|
||||
expect(ship2a.level.getExperience()).toEqual(1500);
|
||||
expect(ship2b.level.getExperience()).toEqual(2800);
|
||||
|
||||
// draw
|
||||
let outcome = new BattleOutcome(null);
|
||||
outcome.grantExperience([fleet1, fleet2]);
|
||||
expect(ship1a.level.getExperience()).toEqual(345);
|
||||
expect(ship1b.level.getExperience()).toEqual(645);
|
||||
expect(ship2a.level.getExperience()).toEqual(1511);
|
||||
expect(ship2b.level.getExperience()).toEqual(2811);
|
||||
|
||||
// win/lose
|
||||
outcome = new BattleOutcome(fleet1);
|
||||
outcome.grantExperience([fleet1, fleet2]);
|
||||
expect(ship1a.level.getExperience()).toEqual(480);
|
||||
expect(ship1b.level.getExperience()).toEqual(780);
|
||||
expect(ship2a.level.getExperience()).toEqual(1518);
|
||||
expect(ship2b.level.getExperience()).toEqual(2818);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -49,6 +49,21 @@ module TS.SpaceTac {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Grant experience to participating fleets
|
||||
*/
|
||||
grantExperience(fleets: Fleet[]) {
|
||||
fleets.forEach(fleet => {
|
||||
let winfactor = (fleet == this.winner) ? 0.03 : (this.draw ? 0.01 : 0.005);
|
||||
let enemies = flatten(fleets.filter(f => f !== fleet).map(f => f.ships));
|
||||
let difficulty = sum(enemies.map(enemy => 100 + enemy.level.getExperience()));
|
||||
fleet.ships.forEach(ship => {
|
||||
ship.level.addExperience(Math.floor(difficulty * winfactor));
|
||||
ship.level.checkLevelUp();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a loot generator for lucky finds
|
||||
*/
|
||||
|
|
|
@ -77,6 +77,9 @@ module TS.SpaceTac {
|
|||
let battle = this.getBattle();
|
||||
|
||||
if (battle && battle.ended) {
|
||||
// Generate experience
|
||||
battle.outcome.grantExperience(battle.fleets);
|
||||
|
||||
if (battle.outcome.winner == this.player.fleet) {
|
||||
// In case of victory, generate loot
|
||||
battle.outcome.createLoot(battle);
|
||||
|
|
|
@ -13,6 +13,13 @@ module TS.SpaceTac {
|
|||
return this.level;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current experience points
|
||||
*/
|
||||
getExperience(): number {
|
||||
return this.experience;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next experience goal to reach, to gain one level
|
||||
*/
|
||||
|
|
|
@ -108,6 +108,7 @@ module TS.SpaceTac.UI {
|
|||
this.loadImage("character/slot-weapon.png");
|
||||
this.loadImage("character/upgrade-available.png");
|
||||
this.loadImage("character/price-tag.png");
|
||||
this.loadImage("character/experience.png");
|
||||
this.loadImage("equipment/ironhull.png");
|
||||
this.loadImage("equipment/forcefield.png");
|
||||
this.loadImage("equipment/nuclearreactor.png");
|
||||
|
|
|
@ -26,6 +26,7 @@ module TS.SpaceTac.UI {
|
|||
|
||||
// Ship level
|
||||
ship_level: Phaser.Text;
|
||||
ship_experience: ValueBar;
|
||||
|
||||
// Ship skill upgrade
|
||||
ship_upgrade_points: Phaser.Text;
|
||||
|
@ -85,6 +86,10 @@ module TS.SpaceTac.UI {
|
|||
this.ship_level.anchor.set(0.5, 0.5);
|
||||
this.addChild(this.ship_level);
|
||||
|
||||
this.ship_experience = new ValueBar(this.game, 516, 1067, "common-transparent");
|
||||
this.ship_experience.setBarImage("character-experience");
|
||||
this.addChild(this.ship_experience);
|
||||
|
||||
this.ship_upgrade_points = new Phaser.Text(this.game, 1066, 1054, "", { align: "center", font: "30pt Arial", fill: "#FFFFFF" });
|
||||
this.ship_upgrade_points.anchor.set(0.5, 0.5);
|
||||
this.addChild(this.ship_upgrade_points);
|
||||
|
@ -204,6 +209,7 @@ module TS.SpaceTac.UI {
|
|||
|
||||
this.ship_name.setText(ship.name);
|
||||
this.ship_level.setText(ship.level.get().toString());
|
||||
this.ship_experience.setValue(ship.level.getExperience(), ship.level.getNextGoal());
|
||||
this.ship_upgrade_points.setText(upgrade_points.toString());
|
||||
this.ship_upgrades.visible = upgrade_points > 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue