diff --git a/src/game/Equipment.ts b/src/game/Equipment.ts
index ec6f5e6..90312db 100644
--- a/src/game/Equipment.ts
+++ b/src/game/Equipment.ts
@@ -86,7 +86,7 @@ module SpaceTac.Game {
var result: string[] = [];
this.target_effects.forEach(effect => {
let suffix = this.blast ? `on all ships in ${this.blast}km of impact` : "on target";
- if (effect instanceof TemporaryEffect) {
+ if (effect instanceof StickyEffect) {
suffix = `for ${effect.duration} turn${effect.duration > 1 ? "s" : ""} ${suffix}`;
}
result.push("- " + effect.getDescription() + " " + suffix);
diff --git a/src/game/LootTemplate.ts b/src/game/LootTemplate.ts
index dfadab3..4716185 100644
--- a/src/game/LootTemplate.ts
+++ b/src/game/LootTemplate.ts
@@ -149,7 +149,7 @@ module SpaceTac.Game {
}
// Convenience function to add a sticking effect on target
- addTemporaryEffectOnTarget(effect: TemporaryEffect, min_value: number, max_value: number = null,
+ addSticky(effect: StickyEffect, 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 IntegerRange(min_value, max_value));
diff --git a/src/game/Ship.spec.ts b/src/game/Ship.spec.ts
index d495fa2..6543f97 100644
--- a/src/game/Ship.spec.ts
+++ b/src/game/Ship.spec.ts
@@ -119,15 +119,15 @@ module SpaceTac.Game.Specs {
expect(battle.log.events.length).toBe(0);
});
- it("sets and logs temporary effects", function () {
+ it("sets and logs sticky effects", function () {
var ship = new Ship();
var battle = new Battle(ship.fleet);
- var effect = new TemporaryEffect("test", 2);
+ var effect = new StickyEffect("test", 2);
- ship.addTemporaryEffect(effect);
+ ship.addStickyEffect(effect);
- expect(ship.temporary_effects).toEqual([effect]);
+ expect(ship.sticky_effects).toEqual([effect]);
expect(battle.log.events).toEqual([
new EffectAddedEvent(ship, effect)
]);
@@ -136,25 +136,25 @@ module SpaceTac.Game.Specs {
battle.log.clear();
ship.endTurn();
- expect(ship.temporary_effects).toEqual([new TemporaryEffect("test", 1)]);
+ expect(ship.sticky_effects).toEqual([new StickyEffect("test", 1)]);
expect(battle.log.events).toEqual([
- new EffectDurationChangedEvent(ship, new TemporaryEffect("test", 1), 2)
+ new EffectDurationChangedEvent(ship, new StickyEffect("test", 1), 2)
]);
ship.startTurn();
battle.log.clear();
ship.endTurn();
- expect(ship.temporary_effects).toEqual([]);
+ expect(ship.sticky_effects).toEqual([]);
expect(battle.log.events).toEqual([
- new EffectRemovedEvent(ship, new TemporaryEffect("test", 1))
+ new EffectRemovedEvent(ship, new StickyEffect("test", 1))
]);
ship.startTurn();
battle.log.clear();
ship.endTurn();
- expect(ship.temporary_effects).toEqual([]);
+ expect(ship.sticky_effects).toEqual([]);
expect(battle.log.events).toEqual([]);
});
diff --git a/src/game/Ship.ts b/src/game/Ship.ts
index ae4d81a..7d23156 100644
--- a/src/game/Ship.ts
+++ b/src/game/Ship.ts
@@ -43,8 +43,8 @@ module SpaceTac.Game {
// Number of shield points (a shield can absorb some damage to protect the hull)
shield: Attribute;
- // Sticky temporary effects
- temporary_effects: TemporaryEffect[];
+ // Sticky effects that applies a given number of times
+ sticky_effects: StickyEffect[];
// Capabilities level
cap_material: Attribute;
@@ -86,7 +86,7 @@ module SpaceTac.Game {
this.cap_human = this.newAttribute(AttributeCode.Cap_Human);
this.cap_time = this.newAttribute(AttributeCode.Cap_Time);
this.cap_gravity = this.newAttribute(AttributeCode.Cap_Gravity);
- this.temporary_effects = [];
+ this.sticky_effects = [];
this.slots = [];
this.arena_x = 0;
@@ -235,7 +235,7 @@ module SpaceTac.Game {
this.updateAttributes();
// Apply sticky effects
- this.temporary_effects.forEach((effect: TemporaryEffect) => {
+ this.sticky_effects.forEach((effect: StickyEffect) => {
effect.singleApply(this, false);
});
}
@@ -253,7 +253,7 @@ module SpaceTac.Game {
// Decrement sticky effects duration
let removed_effects: EffectRemovedEvent[] = [];
- this.temporary_effects = this.temporary_effects.filter((effect: TemporaryEffect): boolean => {
+ this.sticky_effects = this.sticky_effects.filter((effect: StickyEffect): boolean => {
if (effect.duration <= 1) {
removed_effects.push(new EffectRemovedEvent(this, effect));
return false;
@@ -261,17 +261,17 @@ module SpaceTac.Game {
return true;
}
});
- this.temporary_effects.forEach(effect => {
+ this.sticky_effects.forEach(effect => {
effect.duration -= 1;
this.addBattleEvent(new EffectDurationChangedEvent(this, effect, effect.duration + 1));
});
removed_effects.forEach(effect => this.addBattleEvent(effect));
}
- // Add a temporary effect
+ // Add a sticky effect
// A copy of the effect will be used
- addTemporaryEffect(effect: TemporaryEffect, log: boolean = true): void {
- this.temporary_effects.push(Tools.copyObject(effect));
+ addStickyEffect(effect: StickyEffect, log: boolean = true): void {
+ this.sticky_effects.push(Tools.copyObject(effect));
if (log) {
this.addBattleEvent(new EffectAddedEvent(this, effect));
}
diff --git a/src/game/effects/AttributeLimitEffect.ts b/src/game/effects/AttributeLimitEffect.ts
index 6868b55..acad94e 100644
--- a/src/game/effects/AttributeLimitEffect.ts
+++ b/src/game/effects/AttributeLimitEffect.ts
@@ -1,9 +1,9 @@
-///
+///
module SpaceTac.Game {
// Hard limitation on attribute value
// For example, this could be used to slow a target by limiting its action points
- export class AttributeLimitEffect extends TemporaryEffect {
+ export class AttributeLimitEffect extends StickyEffect {
// Affected attribute
attrcode: AttributeCode;
diff --git a/src/game/effects/BaseEffect.ts b/src/game/effects/BaseEffect.ts
index 6d311a9..91085b4 100644
--- a/src/game/effects/BaseEffect.ts
+++ b/src/game/effects/BaseEffect.ts
@@ -2,7 +2,7 @@
module SpaceTac.Game {
// Base class for effects of actions
- // Effects can be permanent or temporary (for a number of turns)
+ // Effects are typically one shot, but sticky effects can be used to apply effects over a period
export class BaseEffect extends Serializable {
// Identifier code for the type of effect
code: string;
diff --git a/src/game/effects/TemporaryEffect.ts b/src/game/effects/StickyEffect.ts
similarity index 90%
rename from src/game/effects/TemporaryEffect.ts
rename to src/game/effects/StickyEffect.ts
index 6620261..68b4daf 100644
--- a/src/game/effects/TemporaryEffect.ts
+++ b/src/game/effects/StickyEffect.ts
@@ -2,7 +2,7 @@
module SpaceTac.Game {
// Base class for actions that will stick to a target for a number of rounds
- export class TemporaryEffect extends BaseEffect {
+ export class StickyEffect extends BaseEffect {
// Duration, in number of turns
duration: number;
@@ -14,7 +14,7 @@ module SpaceTac.Game {
}
applyOnShip(ship: Ship): boolean {
- ship.addTemporaryEffect(this);
+ ship.addStickyEffect(this);
this.singleApply(ship, true);
return true;
}
diff --git a/src/game/equipments/EnergyDepleter.spec.ts b/src/game/equipments/EnergyDepleter.spec.ts
index bef818f..7238d81 100644
--- a/src/game/equipments/EnergyDepleter.spec.ts
+++ b/src/game/equipments/EnergyDepleter.spec.ts
@@ -10,13 +10,13 @@ module SpaceTac.Game.Specs {
spyOn(equipment.action, "canBeUsed").and.returnValue(true);
expect(target.ap_current.current).toBe(7);
- expect(target.temporary_effects).toEqual([]);
+ expect(target.sticky_effects).toEqual([]);
// Attribute is immediately limited
equipment.action.apply(null, ship, Target.newFromShip(target));
expect(target.ap_current.current).toBe(4);
- expect(target.temporary_effects).toEqual([
+ expect(target.sticky_effects).toEqual([
new AttributeLimitEffect(AttributeCode.AP, 1, 4)
]);
@@ -25,7 +25,7 @@ module SpaceTac.Game.Specs {
target.startTurn();
expect(target.ap_current.current).toBe(4);
- expect(target.temporary_effects).toEqual([
+ expect(target.sticky_effects).toEqual([
new AttributeLimitEffect(AttributeCode.AP, 1, 4)
]);
@@ -33,7 +33,7 @@ module SpaceTac.Game.Specs {
target.endTurn();
expect(target.ap_current.current).toBe(6);
- expect(target.temporary_effects).toEqual([]);
+ expect(target.sticky_effects).toEqual([]);
});
});
}
diff --git a/src/game/equipments/EnergyDepleter.ts b/src/game/equipments/EnergyDepleter.ts
index 8d9c9a8..0f0996f 100644
--- a/src/game/equipments/EnergyDepleter.ts
+++ b/src/game/equipments/EnergyDepleter.ts
@@ -10,7 +10,7 @@ module SpaceTac.Game.Equipments {
this.ap_usage = new IntegerRange(4, 5);
this.min_level = new IntegerRange(1, 3);
- this.addTemporaryEffectOnTarget(new AttributeLimitEffect(AttributeCode.AP), 4, 3, 1, 2);
+ this.addSticky(new AttributeLimitEffect(AttributeCode.AP), 4, 3, 1, 2);
}
}
}
diff --git a/src/game/events/EffectAddedEvent.ts b/src/game/events/EffectAddedEvent.ts
index 1616874..9f1038f 100644
--- a/src/game/events/EffectAddedEvent.ts
+++ b/src/game/events/EffectAddedEvent.ts
@@ -1,12 +1,12 @@
///
module SpaceTac.Game {
- // Event logged when a TemporaryEffect is added to a ship
+ // Event logged when a sticky effect is added to a ship
export class EffectAddedEvent extends BaseLogEvent {
// Pointer to the effect
- effect: TemporaryEffect;
+ effect: StickyEffect;
- constructor(ship: Ship, effect: TemporaryEffect) {
+ constructor(ship: Ship, effect: StickyEffect) {
super("effectadd", ship);
this.effect = effect;
diff --git a/src/game/events/EffectDurationChangedEvent.ts b/src/game/events/EffectDurationChangedEvent.ts
index 9a96223..b40f7f1 100644
--- a/src/game/events/EffectDurationChangedEvent.ts
+++ b/src/game/events/EffectDurationChangedEvent.ts
@@ -1,15 +1,15 @@
///
module SpaceTac.Game {
- // Event logged when a TemporaryEffect is added to a ship
+ // Event logged when a sticky effect is added to a ship
export class EffectDurationChangedEvent extends BaseLogEvent {
// Pointer to the effect
- effect: TemporaryEffect;
+ effect: StickyEffect;
// Previous duration
previous: number;
- constructor(ship: Ship, effect: TemporaryEffect, previous: number) {
+ constructor(ship: Ship, effect: StickyEffect, previous: number) {
super("effectduration", ship);
this.effect = effect;
diff --git a/src/game/events/EffectRemovedEvent.ts b/src/game/events/EffectRemovedEvent.ts
index 53d84e6..f4a0220 100644
--- a/src/game/events/EffectRemovedEvent.ts
+++ b/src/game/events/EffectRemovedEvent.ts
@@ -1,12 +1,12 @@
///
module SpaceTac.Game {
- // Event logged when a TemporaryEffect is removed from a ship
+ // Event logged when a sticky effect is removed from a ship
export class EffectRemovedEvent extends BaseLogEvent {
// Pointer to the effect
- effect: TemporaryEffect;
+ effect: StickyEffect;
- constructor(ship: Ship, effect: TemporaryEffect) {
+ constructor(ship: Ship, effect: StickyEffect) {
super("effectdel", ship);
this.effect = effect;
diff --git a/src/view/battle/LogProcessor.ts b/src/view/battle/LogProcessor.ts
index e774b19..e18a85a 100644
--- a/src/view/battle/LogProcessor.ts
+++ b/src/view/battle/LogProcessor.ts
@@ -142,7 +142,7 @@ module SpaceTac.View {
}
}
- // Temporary effect on ship added, changed or removed
+ // Sticky effect on ship added, changed or removed
private processEffectEvent(event: Game.BaseLogEvent): void {
var item = this.view.ship_list.findItem(event.ship);
if (item) {
diff --git a/src/view/battle/ShipListItem.ts b/src/view/battle/ShipListItem.ts
index d9da103..814f89b 100644
--- a/src/view/battle/ShipListItem.ts
+++ b/src/view/battle/ShipListItem.ts
@@ -71,9 +71,9 @@ module SpaceTac.View {
// Update effects applied on the ship
updateEffects() {
this.active_effects.removeAll(true);
- var count = this.ship.temporary_effects.length;
+ var count = this.ship.sticky_effects.length;
var spacing = (8 * (count - 1) > 72) ? 72 / (count - 1) : 8;
- this.ship.temporary_effects.forEach((effect, index) => {
+ this.ship.sticky_effects.forEach((effect, index) => {
var x = 46 - (count - 1) * spacing / 2 + index * spacing;
var badge = new Phaser.Image(this.game, x, 85, `battle-shiplist-effect-${effect.isBeneficial() ? "good" : "bad"}`);
badge.anchor.set(0.5, 0.5);
diff --git a/src/view/battle/ShipTooltip.ts b/src/view/battle/ShipTooltip.ts
index a05ea76..9b45b18 100644
--- a/src/view/battle/ShipTooltip.ts
+++ b/src/view/battle/ShipTooltip.ts
@@ -102,7 +102,7 @@ module SpaceTac.View {
this.attr_gravity.setText(ship.cap_gravity.current.toString());
this.attr_time.setText(ship.cap_time.current.toString());
this.active_effects.removeAll(true);
- ship.temporary_effects.forEach((effect, index) => {
+ ship.sticky_effects.forEach((effect, index) => {
this.addEffect(effect, index);
});
@@ -112,8 +112,8 @@ module SpaceTac.View {
}
}
- // Add a temporary effect display
- addEffect(effect: Game.TemporaryEffect, index = 0) {
+ // Add a sticky effect display
+ addEffect(effect: Game.StickyEffect, index = 0) {
var effect_group = new Phaser.Image(this.game, 27, 243 + 60 * index, "battle-ship-tooltip-effect");
this.active_effects.addChild(effect_group);
diff --git a/tsconfig.json b/tsconfig.json
index 0f5260f..c6dd0e5 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -14,9 +14,7 @@
"sourceMap": true,
"target": "es5"
},
- "exclude": [
- "out",
- "coverage",
- "node_modules"
+ "include": [
+ "src"
]
}
\ No newline at end of file