1
0
Fork 0

equipment: Added two hulls and two shields

This commit is contained in:
Michaël Lemaire 2017-07-28 01:02:53 +02:00
parent 8530ab88f3
commit 666e3dfc1a
15 changed files with 1253 additions and 87 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 110 KiB

View file

@ -55,6 +55,9 @@
<div id="loot">
<h1>SpaceTac - Loot Generator Samples</h1>
<select id="template">
<option value="---">---</option>
</select>
<input id="level" type="range" value="1" min="1" max="20" step="1" />
<div id="result"></div>
</div>
@ -63,12 +66,17 @@
window.onload = function () {
var generator = new TS.SpaceTac.LootGenerator();
var result = document.getElementById("result");
var current_level = 1;
var current_name = "";
function update(level) {
function update() {
result.innerHTML = "";
generator.templates.forEach(function (template) {
if (template.name != current_name) {
return;
}
TS.iterenum(TS.SpaceTac.EquipmentQuality, function (quality) {
var loot = template.generate(level, quality);
var loot = template.generate(current_level, quality);
let title = document.createElement("h2");
title.textContent = loot.getFullName() + " (Price " + loot.price.toString() + ")";
@ -81,10 +89,24 @@
});
}
update(1);
TS.sortedBy(generator.templates, function (template) {
return template.name;
}).forEach(function (template) {
var opt = document.createElement('option');
opt.value = template.name;
opt.innerHTML = template.name;
document.getElementById("template").appendChild(opt);
});
document.getElementById("level").onchange = function () {
update(this.value);
current_level = this.value;
update();
}
document.getElementById("template").onchange = function () {
current_name = this.value;
update();
}
update();
};
</script>
</body>

View file

@ -187,11 +187,11 @@ module TS.SpaceTac {
// Modifiers applied to "common" equipment to obtain a specific quality
protected quality_modifiers: QualityModifier[]
constructor(slot: SlotType, name: string, description = "") {
constructor(slot: SlotType, name: string, description = "", price_base = 100, price_inflation = 200) {
this.slot = slot;
this.name = name;
this.description = description;
this.price = istep(100, istep(200, irepeat(200)));
this.price = istep(price_base, istep(price_inflation, irepeat(price_inflation)));
this.base_modifiers = [];
this.quality_modifiers = [standardQualityModifier];
}
@ -268,7 +268,7 @@ module TS.SpaceTac {
addAttributeEffect(attribute: keyof ShipAttributes, value: LeveledValue): void {
this.base_modifiers.push((equipment, level) => {
let resolved = resolveForLevel(value, level);
if (resolved > 0) {
if (resolved != 0) {
equipment.effects.push(new AttributeEffect(attribute, resolved));
}
});

View file

@ -1,23 +0,0 @@
module TS.SpaceTac.Equipments {
describe("ForceField", function () {
it("generates equipment based on level", function () {
let template = new ForceField();
let equipment = template.generate(1);
expect(equipment.requirements).toEqual({ "skill_photons": 1 });
expect(equipment.effects).toEqual([new AttributeEffect("shield_capacity", 100)]);
equipment = template.generate(2);
expect(equipment.requirements).toEqual({ "skill_photons": 3 });
expect(equipment.effects).toEqual([new AttributeEffect("shield_capacity", 140)]);
equipment = template.generate(3);
expect(equipment.requirements).toEqual({ "skill_photons": 5 });
expect(equipment.effects).toEqual([new AttributeEffect("shield_capacity", 180)]);
equipment = template.generate(10);
expect(equipment.requirements).toEqual({ "skill_photons": 19 });
expect(equipment.effects).toEqual([new AttributeEffect("shield_capacity", 460)]);
});
});
}

View file

@ -1,12 +0,0 @@
/// <reference path="../LootTemplate.ts"/>
module TS.SpaceTac.Equipments {
export class ForceField extends LootTemplate {
constructor() {
super(SlotType.Shield, "Force Field", "A basic force field, generated by radiating waves of compressed energy");
this.setSkillsRequirements({ "skill_photons": istep(1, irepeat(2)) });
this.addAttributeEffect("shield_capacity", istep(100, irepeat(40)));
}
}
}

View file

@ -0,0 +1,99 @@
module TS.SpaceTac.Equipments {
describe("Hulls", function () {
it("generates IronHull based on level", function () {
let template = new IronHull();
let equipment = template.generate(1);
expect(equipment.requirements).toEqual({ "skill_materials": 1 });
expect(equipment.effects).toEqual([new AttributeEffect("hull_capacity", 200)]);
expect(equipment.price).toEqual(100);
equipment = template.generate(2);
expect(equipment.requirements).toEqual({ "skill_materials": 2 });
expect(equipment.effects).toEqual([new AttributeEffect("hull_capacity", 220)]);
expect(equipment.price).toEqual(300);
equipment = template.generate(3);
expect(equipment.requirements).toEqual({ "skill_materials": 3 });
expect(equipment.effects).toEqual([new AttributeEffect("hull_capacity", 240)]);
expect(equipment.price).toEqual(700);
equipment = template.generate(10);
expect(equipment.requirements).toEqual({ "skill_materials": 10 });
expect(equipment.effects).toEqual([new AttributeEffect("hull_capacity", 380)]);
expect(equipment.price).toEqual(9100);
});
it("generates HardCoatedHull based on level", function () {
let template = new HardCoatedHull();
let equipment = template.generate(1);
expect(equipment.requirements).toEqual({ "skill_materials": 2 });
expect(equipment.effects).toEqual([
new AttributeEffect("hull_capacity", 300),
new AttributeEffect("maneuvrability", -2),
]);
expect(equipment.price).toEqual(120);
equipment = template.generate(2);
expect(equipment.requirements).toEqual({ "skill_materials": 4 });
expect(equipment.effects).toEqual([
new AttributeEffect("hull_capacity", 315),
new AttributeEffect("maneuvrability", -3),
]);
expect(equipment.price).toEqual(330);
equipment = template.generate(3);
expect(equipment.requirements).toEqual({ "skill_materials": 6 });
expect(equipment.effects).toEqual([
new AttributeEffect("hull_capacity", 330),
new AttributeEffect("maneuvrability", -4),
]);
expect(equipment.price).toEqual(750);
equipment = template.generate(10);
expect(equipment.requirements).toEqual({ "skill_materials": 20 });
expect(equipment.effects).toEqual([
new AttributeEffect("hull_capacity", 435),
new AttributeEffect("maneuvrability", -11),
]);
expect(equipment.price).toEqual(9570);
});
it("generates FractalHull based on level", function () {
let template = new FractalHull();
let equipment = template.generate(1);
expect(equipment.requirements).toEqual({ "skill_quantum": 1 });
expect(equipment.effects).toEqual([
new AttributeEffect("hull_capacity", 260),
new AttributeEffect("maneuvrability", -1),
]);
expect(equipment.price).toEqual(250);
equipment = template.generate(2);
expect(equipment.requirements).toEqual({ "skill_quantum": 2 });
expect(equipment.effects).toEqual([
new AttributeEffect("hull_capacity", 270),
new AttributeEffect("maneuvrability", -2),
]);
expect(equipment.price).toEqual(480);
equipment = template.generate(3);
expect(equipment.requirements).toEqual({ "skill_quantum": 3 });
expect(equipment.effects).toEqual([
new AttributeEffect("hull_capacity", 280),
new AttributeEffect("maneuvrability", -2),
]);
expect(equipment.price).toEqual(940);
equipment = template.generate(10);
expect(equipment.requirements).toEqual({ "skill_quantum": 10 });
expect(equipment.effects).toEqual([
new AttributeEffect("hull_capacity", 350),
new AttributeEffect("maneuvrability", -6),
]);
expect(equipment.price).toEqual(10600);
});
});
}

View file

@ -0,0 +1,32 @@
/// <reference path="../LootTemplate.ts"/>
module TS.SpaceTac.Equipments {
export class IronHull extends LootTemplate {
constructor() {
super(SlotType.Hull, "Iron Hull", "Protective hull, based on layered iron alloys");
this.setSkillsRequirements({ "skill_materials": 1 });
this.addAttributeEffect("hull_capacity", istep(200, irepeat(20)));
}
}
export class HardCoatedHull extends LootTemplate {
constructor() {
super(SlotType.Hull, "Hard Coated Hull", "Hardened hull, with titanium coating", 120, 210);
this.setSkillsRequirements({ "skill_materials": 2 });
this.addAttributeEffect("hull_capacity", istep(300, irepeat(15)));
this.addAttributeEffect("maneuvrability", istep(-2, irepeat(-1)));
}
}
export class FractalHull extends LootTemplate {
constructor() {
super(SlotType.Hull, "Fractal Hull", "Hull composed of recursively bound quantum patches", 250, 230);
this.setSkillsRequirements({ "skill_quantum": 1 });
this.addAttributeEffect("hull_capacity", istep(260, irepeat(10)));
this.addAttributeEffect("maneuvrability", istep(-1, irepeat(-0.5)));
}
}
}

View file

@ -1,23 +0,0 @@
module TS.SpaceTac.Equipments {
describe("IronHull", function () {
it("generates equipment based on level", function () {
let template = new IronHull();
let equipment = template.generate(1);
expect(equipment.requirements).toEqual({ "skill_materials": 1 });
expect(equipment.effects).toEqual([new AttributeEffect("hull_capacity", 200)]);
equipment = template.generate(2);
expect(equipment.requirements).toEqual({ "skill_materials": 2 });
expect(equipment.effects).toEqual([new AttributeEffect("hull_capacity", 220)]);
equipment = template.generate(3);
expect(equipment.requirements).toEqual({ "skill_materials": 3 });
expect(equipment.effects).toEqual([new AttributeEffect("hull_capacity", 240)]);
equipment = template.generate(10);
expect(equipment.requirements).toEqual({ "skill_materials": 10 });
expect(equipment.effects).toEqual([new AttributeEffect("hull_capacity", 380)]);
});
});
}

View file

@ -1,12 +0,0 @@
/// <reference path="../LootTemplate.ts"/>
module TS.SpaceTac.Equipments {
export class IronHull extends LootTemplate {
constructor() {
super(SlotType.Hull, "Iron Hull", "Protective hull, based on layered iron alloys");
this.setSkillsRequirements({ "skill_materials": 1 });
this.addAttributeEffect("hull_capacity", istep(200, irepeat(20)));
}
}
}

View file

@ -0,0 +1,99 @@
module TS.SpaceTac.Equipments {
describe("Shields", function () {
it("generates ForceField based on level", function () {
let template = new ForceField();
let equipment = template.generate(1);
expect(equipment.requirements).toEqual({ "skill_photons": 1 });
expect(equipment.effects).toEqual([new AttributeEffect("shield_capacity", 100)]);
expect(equipment.price).toEqual(100);
equipment = template.generate(2);
expect(equipment.requirements).toEqual({ "skill_photons": 3 });
expect(equipment.effects).toEqual([new AttributeEffect("shield_capacity", 140)]);
expect(equipment.price).toEqual(300);
equipment = template.generate(3);
expect(equipment.requirements).toEqual({ "skill_photons": 5 });
expect(equipment.effects).toEqual([new AttributeEffect("shield_capacity", 180)]);
expect(equipment.price).toEqual(700);
equipment = template.generate(10);
expect(equipment.requirements).toEqual({ "skill_photons": 19 });
expect(equipment.effects).toEqual([new AttributeEffect("shield_capacity", 460)]);
expect(equipment.price).toEqual(9100);
});
it("generates GravitShield based on level", function () {
let template = new GravitShield();
let equipment = template.generate(1);
expect(equipment.requirements).toEqual({ "skill_gravity": 2 });
expect(equipment.effects).toEqual([
new AttributeEffect("shield_capacity", 160),
new AttributeEffect("precision", -1),
]);
expect(equipment.price).toEqual(140);
equipment = template.generate(2);
expect(equipment.requirements).toEqual({ "skill_gravity": 5 });
expect(equipment.effects).toEqual([
new AttributeEffect("shield_capacity", 190),
new AttributeEffect("precision", -2),
]);
expect(equipment.price).toEqual(320);
equipment = template.generate(3);
expect(equipment.requirements).toEqual({ "skill_gravity": 8 });
expect(equipment.effects).toEqual([
new AttributeEffect("shield_capacity", 220),
new AttributeEffect("precision", -3),
]);
expect(equipment.price).toEqual(680);
equipment = template.generate(10);
expect(equipment.requirements).toEqual({ "skill_gravity": 29 });
expect(equipment.effects).toEqual([
new AttributeEffect("shield_capacity", 430),
new AttributeEffect("precision", -10),
]);
expect(equipment.price).toEqual(8240);
});
it("generates InverterShield based on level", function () {
let template = new InverterShield();
let equipment = template.generate(1);
expect(equipment.requirements).toEqual({ "skill_antimatter": 2 });
expect(equipment.effects).toEqual([
new AttributeEffect("shield_capacity", 130),
new AttributeEffect("power_generation", -1),
]);
expect(equipment.price).toEqual(300);
equipment = template.generate(2);
expect(equipment.requirements).toEqual({ "skill_antimatter": 4 });
expect(equipment.effects).toEqual([
new AttributeEffect("shield_capacity", 165),
new AttributeEffect("power_generation", -1),
]);
expect(equipment.price).toEqual(460);
equipment = template.generate(3);
expect(equipment.requirements).toEqual({ "skill_antimatter": 6 });
expect(equipment.effects).toEqual([
new AttributeEffect("shield_capacity", 200),
new AttributeEffect("power_generation", -1),
]);
expect(equipment.price).toEqual(780);
equipment = template.generate(10);
expect(equipment.requirements).toEqual({ "skill_antimatter": 20 });
expect(equipment.effects).toEqual([
new AttributeEffect("shield_capacity", 445),
new AttributeEffect("power_generation", -3),
]);
expect(equipment.price).toEqual(7500);
});
});
}

View file

@ -0,0 +1,32 @@
/// <reference path="../LootTemplate.ts"/>
module TS.SpaceTac.Equipments {
export class ForceField extends LootTemplate {
constructor() {
super(SlotType.Shield, "Force Field", "A basic force field, generated by radiating waves of compressed energy");
this.setSkillsRequirements({ "skill_photons": istep(1, irepeat(2)) });
this.addAttributeEffect("shield_capacity", istep(100, irepeat(40)));
}
}
export class GravitShield extends LootTemplate {
constructor() {
super(SlotType.Shield, "Gravit Shield", "A shield with micro-gravity wells to help absorb damage", 140, 180);
this.setSkillsRequirements({ "skill_gravity": istep(2, irepeat(3)) });
this.addAttributeEffect("shield_capacity", istep(160, irepeat(30)));
this.addAttributeEffect("precision", istep(-1, irepeat(-1)));
}
}
export class InverterShield extends LootTemplate {
constructor() {
super(SlotType.Shield, "Inverter Shield", "An antimatter shield that tries to cancel inbound energy", 300, 160);
this.setSkillsRequirements({ "skill_antimatter": istep(2, irepeat(2)) });
this.addAttributeEffect("shield_capacity", istep(130, irepeat(35)));
this.addAttributeEffect("power_generation", istep(-0.2, irepeat(-0.3)));
}
}
}