Improved distance display for move actions
This commit is contained in:
parent
1f8eb2d86d
commit
8c1bd3c2ea
|
@ -170,7 +170,7 @@ module TS.SpaceTac {
|
||||||
expect(action.getEffectsDescription()).toEqual("Move: 58km per power point (safety: 12km)");
|
expect(action.getEffectsDescription()).toEqual("Move: 58km per power point (safety: 12km)");
|
||||||
|
|
||||||
action = new MoveAction(new Equipment(), 58, 12, 80);
|
action = new MoveAction(new Equipment(), 58, 12, 80);
|
||||||
expect(action.getEffectsDescription()).toEqual("Move: 58km per power point (safety: 12km, maneuvrability influence: 80%)");
|
expect(action.getEffectsDescription()).toEqual("Move: 12-58km per power point (safety: 12km)");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,13 +51,22 @@ module TS.SpaceTac {
|
||||||
return ship.getValue("power") * this.getDistanceByActionPoint(ship);
|
return ship.getValue("power") * this.getDistanceByActionPoint(ship);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the distance range that may be traveled with 1 action point
|
||||||
|
*/
|
||||||
|
getDistanceRangeByActionPoint(): IntegerRange {
|
||||||
|
let min_distance = Math.ceil(this.distance_per_power * (1 - this.maneuvrability_factor * 0.01));
|
||||||
|
return new IntegerRange(min_distance, this.distance_per_power);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the distance that may be traveled with 1 action point
|
* Get the distance that may be traveled with 1 action point
|
||||||
*/
|
*/
|
||||||
getDistanceByActionPoint(ship: Ship): number {
|
getDistanceByActionPoint(ship: Ship): number {
|
||||||
let maneuvrability = Math.max(ship.getAttribute("maneuvrability"), 0);
|
let maneuvrability = Math.max(ship.getAttribute("maneuvrability"), 0);
|
||||||
let factor = maneuvrability / (maneuvrability + 2);
|
let factor = maneuvrability / (maneuvrability + 2);
|
||||||
return Math.ceil(this.distance_per_power * (1 - this.maneuvrability_factor * 0.01 * (1 - factor)));
|
let range = this.getDistanceRangeByActionPoint();
|
||||||
|
return range.getProportional(factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,17 +107,12 @@ module TS.SpaceTac {
|
||||||
}
|
}
|
||||||
|
|
||||||
getEffectsDescription(): string {
|
getEffectsDescription(): string {
|
||||||
let result = `Move: ${this.distance_per_power}km per power point`;
|
let range = this.getDistanceRangeByActionPoint();
|
||||||
|
let rangeinfo = (range.max == range.min) ? `${range.min}` : `${range.min}-${range.max}`;
|
||||||
|
let result = `Move: ${rangeinfo}km per power point`;
|
||||||
|
|
||||||
let precisions = [];
|
|
||||||
if (this.safety_distance) {
|
if (this.safety_distance) {
|
||||||
precisions.push(`safety: ${this.safety_distance}km`);
|
result += ` (safety: ${this.safety_distance}km)`;
|
||||||
}
|
|
||||||
if (this.maneuvrability_factor) {
|
|
||||||
precisions.push(`maneuvrability influence: ${this.maneuvrability_factor}%`);
|
|
||||||
}
|
|
||||||
if (precisions.length) {
|
|
||||||
result += ` (${precisions.join(", ")})`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in a new issue