1
0
Fork 0

Fixed equipment price depreciation and displayed stat

This commit is contained in:
Michaël Lemaire 2018-01-02 19:23:12 +01:00
parent 7e20599fce
commit f9859c157e
9 changed files with 48 additions and 25 deletions

View File

@ -64,7 +64,6 @@ Battle
Ships models and equipments
---------------------------
* Smooth the price depreciation in battles, it's too high when first using equipments
* Add permanent effects and actions to ship models
* Add critical hit/miss (or indicate lucky/unlucky throws)
* Add damage over time effect (tricky to make intuitive)
@ -86,6 +85,7 @@ Artificial Intelligence
* Abandon fight if the AI judges there is no hope of victory
* Add combination of random small move and actual maneuver, as producer
* New duel page with producers/evaluators tweaking
* Prototype of evolving AI
Common UI
---------
@ -121,6 +121,7 @@ Postponed
* Secondary story arcs
* Replays
* Multiplayer/co-op
* Puzzle mode
* Formation or deployment phase
* Add ship personality (with icons to identify?), with reaction dialogs
* Hide enemy information (shield, hull, weapons), until they are in play, or until a "spy" effect is used

View File

@ -1,5 +1,5 @@
#!/bin/bash
# Main build/run tool for SpaceTac
# Main build/run tool
# REQUIRES yarn
# If yarn is not found, python3 may be used to create a local node.js environment with yarn in it, and use it
@ -13,7 +13,7 @@ else
dir=$(dirname $0)
test -x "${dir}/.env/bin/nodeenv" || ( virtualenv -p python3 "${dir}/.env" && "${dir}/.env/bin/pip" install --upgrade nodeenv )
test -e "${dir}/.env/node/bin/activate" || "${dir}/.env/bin/nodeenv" --node=6.11.1 --force "${dir}/.env/node"
test -e "${dir}/.env/node/bin/yarn" || "${dir}/.env/node/bin/shim" "${dir}/.env/node/bin/npm" install -g yarn@1.1.0
test -e "${dir}/.env/node/bin/activate" || "${dir}/.env/bin/nodeenv" --node=9.3.0 --force "${dir}/.env/node"
test -e "${dir}/.env/node/bin/yarn" || "${dir}/.env/node/bin/shim" "${dir}/.env/node/bin/npm" install -g yarn@1.3.2
PATH="${dir}/.env/node/bin:${PATH}" yarn "$@"
fi

View File

@ -275,7 +275,7 @@ module TK.SpaceTac {
this.outcome = null;
this.cycle = 1;
this.placeShips();
this.stats.onBattleStart(this.fleets[0], this.fleets[1]);
this.stats.addFleetsValue(this.fleets[0], this.fleets[1]);
this.throwInitiative();
iforeach(this.iships(), ship => ship.restoreInitialState());
this.setPlayingShip(this.play_order[0]);

View File

@ -83,13 +83,13 @@ module TK.SpaceTac.Specs {
let equ2 = TestTools.addEngine(defender, 50);
equ2.price = 1100;
stats.onBattleStart(attacker.fleet, defender.fleet);
stats.addFleetsValue(attacker.fleet, defender.fleet);
check.equals(stats.stats, { "Equipment wear (zotys)": [1000, 1100] });
equ1.price = 500;
equ2.price = 800;
stats.onBattleEnd(attacker.fleet, defender.fleet);
stats.addFleetsValue(attacker.fleet, defender.fleet, false);
check.equals(stats.stats, { "Equipment wear (zotys)": [500, 300] });
})
})

View File

@ -69,19 +69,12 @@ module TK.SpaceTac {
}
/**
* Prepare some stats at the start of battle
* Store the fleets' value, for equipment wear display
*/
onBattleStart(attacker: Fleet, defender: Fleet): void {
this.addStat("Equipment wear (zotys)", this.getFleetValue(attacker), true);
this.addStat("Equipment wear (zotys)", this.getFleetValue(defender), false);
}
/**
* Finalize some stats at the start of battle
*/
onBattleEnd(attacker: Fleet, defender: Fleet): void {
this.addStat("Equipment wear (zotys)", -this.getFleetValue(attacker), true);
this.addStat("Equipment wear (zotys)", -this.getFleetValue(defender), false);
addFleetsValue(attacker: Fleet, defender: Fleet, positive = true): void {
let sgn = positive ? 1 : -1;
this.addStat("Equipment wear (zotys)", sgn * this.getFleetValue(attacker), true);
this.addStat("Equipment wear (zotys)", sgn * this.getFleetValue(defender), false);
}
}
}

View File

@ -87,13 +87,16 @@ module TK.SpaceTac.Specs {
check.equals(equipment.getPrice(), 99);
equipment.addWear(10);
check.equals(equipment.getPrice(), 90);
check.equals(equipment.getPrice(), 97);
equipment.addWear(89);
check.equals(equipment.getPrice(), 50);
check.equals(equipment.getPrice(), 83);
equipment.addWear(400);
check.equals(equipment.getPrice(), 16);
check.equals(equipment.getPrice(), 50);
equipment.addWear(12500);
check.equals(equipment.getPrice(), 3);
});
test.case("builds a full textual description", check => {

View File

@ -116,7 +116,7 @@ module TK.SpaceTac {
* Get the equipment price value.
*/
getPrice(): number {
return Math.floor(this.price * 100 / (100 + this.wear));
return Math.floor(this.price * 500 / (500 + this.wear));
}
/**

View File

@ -1,18 +1,40 @@
module TK.SpaceTac.Specs {
testing("EndBattle", test => {
testing("EndBattleDiff", test => {
test.case("applies and reverts", check => {
let battle = new Battle();
let ship1 = battle.fleets[0].addShip();
let ship2 = battle.fleets[1].addShip();
let equ1 = new Equipment(SlotType.Weapon);
equ1.price = 10000;
ship1.addSlot(SlotType.Weapon).attach(equ1);
let equ2 = new Equipment(SlotType.Weapon);
equ2.price = 20000;
ship2.addSlot(SlotType.Weapon).attach(equ2);
battle.start();
TestTools.diffChain(check, battle, [
new EndBattleDiff(battle.fleets[1], 4)
], [
check => {
check.equals(battle.ended, false, "battle is ongoing");
check.equals(battle.outcome, null, "battle has no outcome");
check.equals(equ1.wear, 0, "equipment1 wear");
check.equals(equ2.wear, 0, "equipment2 wear");
check.equals(battle.stats.getImportant(1), [
{ name: 'Equipment wear (zotys)', attacker: 10000, defender: 20000 }
], "stats stores equipment value");
},
check => {
check.equals(battle.ended, true, "battle is ended");
check.same(nn(battle.outcome).winner, battle.fleets[1], "battle has an outcome");
check.equals(equ1.wear, 4, "equipment1 wear");
check.equals(equ2.wear, 4, "equipment2 wear");
check.equals(battle.stats.getImportant(1), [
{ name: 'Equipment wear (zotys)', attacker: 80, defender: 159 }
], "stats stores equipment wear");
},
]);
});

View File

@ -28,14 +28,18 @@ module TK.SpaceTac {
equipment.addWear(this.cycles);
});
});
battle.stats.addFleetsValue(battle.fleets[0], battle.fleets[1], false);
}
revert(battle: Battle): void {
battle.outcome = null;
battle.stats.addFleetsValue(battle.fleets[0], battle.fleets[1], true);
iforeach(battle.iships(), ship => {
ship.listEquipment().forEach(equipment => {
equipment.addWear(this.cycles);
equipment.addWear(-this.cycles);
});
});
}