Damage effects may now be random in a given range
This commit is contained in:
parent
f60bbf6e39
commit
7a7fccfbbb
1
TODO
1
TODO
|
@ -23,7 +23,6 @@
|
|||
* Organize arena objects and information in layers
|
||||
* Prevent arena effects information (eg. "shield -36") to overflow out of the arena
|
||||
* Allow to undo last moves
|
||||
* Effect should be random in a range (eg. "damage target 50-75")
|
||||
* Add critical hit/miss
|
||||
* Add an overheat/cooling system
|
||||
* Add auto-move to attack
|
||||
|
|
|
@ -126,7 +126,8 @@ module TS.SpaceTac {
|
|||
simpleFactor(effect, 'duration');
|
||||
effectFactor(effect.base);
|
||||
} else if (effect instanceof DamageEffect) {
|
||||
simpleFactor(effect, 'value');
|
||||
simpleFactor(effect, 'base');
|
||||
simpleFactor(effect, 'span');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,5 +39,10 @@ module TS.SpaceTac.Specs {
|
|||
expect(shield.wear).toBe(5);
|
||||
expect(ship.alive).toBe(false);
|
||||
});
|
||||
|
||||
it("gets a textual description", function () {
|
||||
expect(new DamageEffect(10).getDescription()).toEqual("do 10 damage");
|
||||
expect(new DamageEffect(10, 5).getDescription()).toEqual("do 10-15 damage");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -8,19 +8,23 @@ module TS.SpaceTac {
|
|||
*/
|
||||
export class DamageEffect extends BaseEffect {
|
||||
// Base damage points
|
||||
value: number;
|
||||
base: number;
|
||||
|
||||
constructor(value: number = 0) {
|
||||
// Range of randomness (effective damage will be between *value* and *value+range*)
|
||||
span: number;
|
||||
|
||||
constructor(value = 0, span = 0) {
|
||||
super("damage");
|
||||
|
||||
this.value = value;
|
||||
this.base = value;
|
||||
this.span = span;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the effective damage done to both shield and hull (in this order)
|
||||
*/
|
||||
getEffectiveDamage(ship: Ship): [number, number] {
|
||||
var damage = this.value;
|
||||
var damage = (this.span > 0) ? RandomGenerator.global.randInt(this.base, this.base + this.span) : this.base;
|
||||
var hull: number;
|
||||
var shield: number;
|
||||
|
||||
|
@ -58,7 +62,11 @@ module TS.SpaceTac {
|
|||
}
|
||||
|
||||
getDescription(): string {
|
||||
return `do ${this.value} damage`;
|
||||
if (this.span > 0) {
|
||||
return `do ${this.base}-${this.base + this.span} damage`;
|
||||
} else {
|
||||
return `do ${this.base} damage`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,19 +5,19 @@ module TS.SpaceTac.Equipments {
|
|||
|
||||
let equipment = template.generate(1);
|
||||
expect(equipment.requirements).toEqual({ "skill_material": 1 });
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 3, 600, 0, [new DamageEffect(50)]));
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 3, 600, 0, [new DamageEffect(30, 20)]));
|
||||
|
||||
equipment = template.generate(2);
|
||||
expect(equipment.requirements).toEqual({ "skill_material": 2 });
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 3, 600, 0, [new DamageEffect(60)]));
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 3, 600, 0, [new DamageEffect(35, 25)]));
|
||||
|
||||
equipment = template.generate(3);
|
||||
expect(equipment.requirements).toEqual({ "skill_material": 3 });
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 3, 600, 0, [new DamageEffect(70)]));
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 3, 600, 0, [new DamageEffect(40, 30)]));
|
||||
|
||||
equipment = template.generate(10);
|
||||
expect(equipment.requirements).toEqual({ "skill_material": 10 });
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 3, 600, 0, [new DamageEffect(140)]));
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 3, 600, 0, [new DamageEffect(75, 65)]));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ module TS.SpaceTac.Equipments {
|
|||
|
||||
this.setSkillsRequirements({ "skill_material": 1 });
|
||||
this.addFireAction(irepeat(3), irepeat(600), 0, [
|
||||
new EffectTemplate(new DamageEffect(), { "value": istep(50, irepeat(10)) })
|
||||
new EffectTemplate(new DamageEffect(), { base: istep(30, irepeat(5)), span: istep(20, irepeat(5)) })
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,19 +5,19 @@ module TS.SpaceTac.Equipments {
|
|||
|
||||
let equipment = template.generate(1);
|
||||
expect(equipment.requirements).toEqual({ "skill_material": 1 });
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 4, 500, 150, [new DamageEffect(30)]));
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 4, 500, 150, [new DamageEffect(30, 2)]));
|
||||
|
||||
equipment = template.generate(2);
|
||||
expect(equipment.requirements).toEqual({ "skill_material": 2 });
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 4, 520, 155, [new DamageEffect(32)]));
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 4, 520, 155, [new DamageEffect(32, 3)]));
|
||||
|
||||
equipment = template.generate(3);
|
||||
expect(equipment.requirements).toEqual({ "skill_material": 3 });
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 4, 540, 160, [new DamageEffect(34)]));
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 4, 540, 160, [new DamageEffect(34, 4)]));
|
||||
|
||||
equipment = template.generate(10);
|
||||
expect(equipment.requirements).toEqual({ "skill_material": 10 });
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 4, 680, 195, [new DamageEffect(48)]));
|
||||
expect(equipment.action).toEqual(new FireWeaponAction(equipment, 4, 680, 195, [new DamageEffect(48, 11)]));
|
||||
});
|
||||
|
||||
it("hits several targets in circle", function () {
|
||||
|
@ -39,7 +39,8 @@ module TS.SpaceTac.Equipments {
|
|||
let action = <FireWeaponAction>equipment.action;
|
||||
action.range = 5;
|
||||
action.blast = 1.5;
|
||||
(<DamageEffect>action.effects[0]).value = 20;
|
||||
(<DamageEffect>action.effects[0]).base = 20;
|
||||
(<DamageEffect>action.effects[0]).span = 0;
|
||||
|
||||
var checkHP = (h1: number, s1: number, h2: number, s2: number, h3: number, s3: number): void => {
|
||||
expect(ship.values.hull.get()).toBe(h1);
|
||||
|
|
|
@ -7,7 +7,7 @@ module TS.SpaceTac.Equipments {
|
|||
|
||||
this.setSkillsRequirements({ "skill_material": 1 });
|
||||
this.addFireAction(irepeat(4), istep(500, irepeat(20)), istep(150, irepeat(5)), [
|
||||
new EffectTemplate(new DamageEffect(), { "value": istep(30, irepeat(2)) })
|
||||
new EffectTemplate(new DamageEffect(), { base: istep(30, irepeat(2)), span: istep(2, irepeat(1)) })
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue