1
0
Fork 0

Round some displayable attributes to integers

This commit is contained in:
Michaël Lemaire 2017-01-11 18:31:21 +01:00
parent 6c47655472
commit cfaeb8da7a
47 changed files with 49 additions and 61 deletions

View file

@ -20,46 +20,23 @@
height: 1080px;
}
</style>
<!-- build:remove -->
<link rel="stylesheet" href="vendor/jasmine-core/lib/jasmine-core/jasmine.css">
<!-- /build -->
</head>
<body>
<div id="-space-tac" class="game"></div>
<!-- build:remove -->
<script src="http://localhost:35729/livereload.js"></script>
<script src="vendor/deep-diff/releases/deep-diff-0.3.0.min.js"></script>
<!-- /build -->
<!-- build:js all.min.js -->
<script src="vendor/jasmine-core/lib/jasmine-core/jasmine.js"></script>
<script src="vendor/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
<script src="vendor/jasmine-core/lib/jasmine-core/boot.js"></script>
<script src="vendor/phaser/build/phaser.js"></script>
<script src="build.js"></script>
<!-- /build -->
<script>
var currentWindowOnload = window.onload;
window.oncontextmenu = function (e) { e.preventDefault(); };
window.onload = function () {
<!--build:remove-- >
if (currentWindowOnload) {
currentWindowOnload();
}
<!-- /build -->
var queryString = new jasmine.QueryString({
getWindowLocation: function () { return window.location; }
});
if (queryString.getParam('onlytests') || queryString.getParam('spec')) {
document.getElementById("-space-tac").hidden = true;
} else {
new SpaceTac.GameUI();
}
new SpaceTac.GameUI();
};
</script>

19
out/tests.html Normal file
View file

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>SpaceTac - Unit tests</title>
<link rel="stylesheet" href="vendor/jasmine-core/lib/jasmine-core/jasmine.css">
</head>
<body>
<script src="vendor/jasmine-core/lib/jasmine-core/jasmine.js"></script>
<script src="vendor/jasmine-core/lib/jasmine-core/jasmine-html.js"></script>
<script src="vendor/jasmine-core/lib/jasmine-core/boot.js"></script>
<script src="vendor/phaser/build/phaser.js"></script>
<script src="build.js"></script>
</body>
</html>

View file

@ -81,11 +81,6 @@ module SpaceTac.Game {
this.fix();
}
// Get current value
getValue(): number {
return Math.floor(this.current);
}
// Set an absolute value
// Returns true if the value changed
set(value: number): boolean {
@ -104,12 +99,12 @@ module SpaceTac.Game {
return this.current !== old_value;
}
// Fix the value to remain lower than maximal, and positive
// Fix the value to be integer, positive and lower than maximal
private fix(): void {
if (this.maximal !== null && this.current > this.maximal) {
this.current = this.maximal;
}
if (this.current < 0.0001) {
if (this.current < 0) {
this.current = 0;
}
}

View file

@ -1,4 +1,4 @@
/// <reference path="../events/BaseLogEvent.ts"/>
/// <reference path="events/BaseLogEvent.ts"/>
module SpaceTac.Game {
// Check a single game log event

View file

@ -1,3 +1,5 @@
/// <reference path="LootTemplate.ts" />
module SpaceTac.Game.Specs {
class TestTemplate extends LootTemplate {
constructor() {

View file

@ -42,7 +42,7 @@ module SpaceTac.Game {
this.distance = new Range(0, 0);
this.blast = new Range(0, 0);
this.duration = new IntegerRange(0, 0);
this.ap_usage = new Range(0, 0);
this.ap_usage = new IntegerRange(0, 0);
this.min_level = new IntegerRange(0, 0);
this.permanent_effects = [];
this.target_effects = [];
@ -130,21 +130,21 @@ module SpaceTac.Game {
// Convenience function to add a permanent attribute effect on equipment
addPermanentAttributeValueEffect(code: AttributeCode, min: number, max: number = null): void {
var template = new EffectTemplate(new AttributeValueEffect(code, 0));
template.addModifier("value", new Range(min, max));
template.addModifier("value", new IntegerRange(min, max));
this.permanent_effects.push(template);
}
// Convenience function to add a permanent attribute max effect on equipment
addPermanentAttributeMaxEffect(code: AttributeCode, min: number, max: number = null): void {
var template = new EffectTemplate(new AttributeMaxEffect(code, 0));
template.addModifier("value", new Range(min, max));
template.addModifier("value", new IntegerRange(min, max));
this.permanent_effects.push(template);
}
// Convenience function to add a "damage on target" effect
addDamageOnTargetEffect(min: number, max: number = null): void {
var template = new EffectTemplate(new DamageEffect(0));
template.addModifier("value", new Range(min, max));
template.addModifier("value", new IntegerRange(min, max));
this.target_effects.push(template);
}
@ -152,7 +152,7 @@ module SpaceTac.Game {
addTemporaryEffectOnTarget(effect: TemporaryEffect, min_value: number, max_value: number = null,
min_duration: number = 1, max_duration: number = null): void {
var template = new EffectTemplate(effect);
template.addModifier("value", new Range(min_value, max_value));
template.addModifier("value", new IntegerRange(min_value, max_value));
template.addModifier("duration", new IntegerRange(min_duration, max_duration));
this.target_effects.push(template);
}

View file

@ -1,4 +1,4 @@
/// <reference path="../Serializable.ts"/>
/// <reference path="Serializable.ts"/>
module SpaceTac.Game.Specs {
export class SerializableTestObj3 extends Serializable {

View file

@ -8,7 +8,7 @@ module SpaceTac.Game.Equipments {
this.min_level = new IntegerRange(1, 1);
this.distance = new Range(300, 300);
this.ap_usage = new Range(3);
this.ap_usage = new IntegerRange(3);
this.addPermanentAttributeMaxEffect(AttributeCode.Initiative, 1);
}

View file

@ -1,5 +1,3 @@
/// <reference path="../EnergyDepleter.ts"/>
module SpaceTac.Game.Specs {
describe("EnergyDepleter", () => {
it("limits target's AP", () => {

View file

@ -7,7 +7,7 @@ module SpaceTac.Game.Equipments {
this.setRange(200, 300, false);
this.ap_usage = new Range(4, 5);
this.ap_usage = new IntegerRange(4, 5);
this.min_level = new IntegerRange(1, 3);
this.addTemporaryEffectOnTarget(new AttributeLimitEffect(AttributeCode.AP), 4, 3, 1, 2);

View file

@ -7,7 +7,7 @@ module SpaceTac.Game.Equipments {
this.setRange(400, 400, false);
this.ap_usage = new Range(2, 3);
this.ap_usage = new IntegerRange(2, 3);
this.min_level = new IntegerRange(1, 3);
}
}

View file

@ -1,5 +1,3 @@
/// <reference path="../SubMunitionMissile.ts"/>
module SpaceTac.Game.Specs {
describe("SubMunitionMissile", () => {
it("hits several targets in circle", () => {

View file

@ -8,7 +8,7 @@ module SpaceTac.Game.Equipments {
this.setRange(350, 400, true);
this.setBlast(150, 200);
this.ap_usage = new Range(4, 5);
this.ap_usage = new IntegerRange(4, 5);
this.min_level = new IntegerRange(1, 3);
}
}

View file

@ -1,4 +1,4 @@
/// <reference path="../battle/BattleView.ts"/>
/// <reference path="battle/BattleView.ts"/>
module SpaceTac.View.Specs {
// Test game wrapper (use instead of jasmine 'it')

View file

@ -1,4 +1,4 @@
/// <reference path="TestGame.ts"/>
/// <reference path="../TestGame.ts"/>
module SpaceTac.View.Specs {
describe("ActionBar", () => {

View file

@ -37,7 +37,7 @@ module SpaceTac.View {
this.position.set(action.x, action.y + action.height + action.bar.actionpoints.height);
this.main_title.setText(action.action.equipment ? action.action.equipment.name : action.action.name);
this.sub_title.setText(action.action.equipment ? action.action.name : "");
this.cost.setText(action.action.equipment ? `Cost: ${action.action.equipment.ap_usage.toPrecision(3)} power` : "");
this.cost.setText(action.action.equipment ? `Cost: ${action.action.equipment.ap_usage} power` : "");
Animation.fadeIn(this.game, this, 200, 0.9);
} else {

View file

@ -1,5 +1,4 @@
/// <reference path="TestGame.ts"/>
/// <reference path="../battle/BattleView.ts"/>
/// <reference path="../TestGame.ts"/>
module SpaceTac.View.Specs {
describe("BattleView", () => {

View file

@ -1,4 +1,4 @@
/// <reference path="TestGame.ts"/>
/// <reference path="../TestGame.ts"/>
module SpaceTac.View.Specs {
describe("ShipList", () => {

View file

@ -88,15 +88,15 @@ module SpaceTac.View {
// Fill info
this.title.setText(ship.name);
this.attr_hull.setText(ship.hull.getValue().toString());
this.attr_shield.setText(ship.shield.getValue().toString());
this.attr_power.setText(ship.ap_current.getValue().toString());
this.attr_materials.setText(ship.cap_material.getValue().toString());
this.attr_electronics.setText(ship.cap_electronics.getValue().toString());
this.attr_energy.setText(ship.cap_energy.getValue().toString());
this.attr_human.setText(ship.cap_human.getValue().toString());
this.attr_gravity.setText(ship.cap_gravity.getValue().toString());
this.attr_time.setText(ship.cap_time.getValue().toString());
this.attr_hull.setText(ship.hull.current.toString());
this.attr_shield.setText(ship.shield.current.toString());
this.attr_power.setText(ship.ap_current.current.toString());
this.attr_materials.setText(ship.cap_material.current.toString());
this.attr_electronics.setText(ship.cap_electronics.current.toString());
this.attr_energy.setText(ship.cap_energy.current.toString());
this.attr_human.setText(ship.cap_human.current.toString());
this.attr_gravity.setText(ship.cap_gravity.current.toString());
this.attr_time.setText(ship.cap_time.current.toString());
Animation.fadeIn(this.game, this, 200, 0.9);
} else {