chore: client/server guards

This commit is contained in:
cha0s 2019-04-23 15:28:03 -05:00
parent 0e5a03336c
commit 49813a5edc

View File

@ -211,24 +211,28 @@ export class Vulnerable extends Trait {
} }
tick(elapsed) { tick(elapsed) {
for (let i = 0; i < this.tookDamageActions.length; ++i) { if (AVOCADO_CLIENT) {
const {context, actions} = this.tookDamageActions[i]; for (let i = 0; i < this.tookDamageActions.length; ++i) {
actions.tick(context, elapsed); const {context, actions} = this.tookDamageActions[i];
} actions.tick(context, elapsed);
if (Object.keys(this.damageList).length > 0) {
this.state = this.state.set('damageList', I.Map(this.damageList));
this.isDirty = true;
this.damageList = {};
}
const keys = Array.from(this.locks.keys());
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
const remaining = this.locks.get(key) - elapsed;
if (remaining <= 0) {
this.locks.delete(key);
} }
else { }
this.locks.set(key, remaining); if (AVOCADO_SERVER) {
if (Object.keys(this.damageList).length > 0) {
this.state = this.state.set('damageList', I.Map(this.damageList));
this.isDirty = true;
this.damageList = {};
}
const keys = Array.from(this.locks.keys());
for (let i = 0; i < keys.length; ++i) {
const key = keys[i];
const remaining = this.locks.get(key) - elapsed;
if (remaining <= 0) {
this.locks.delete(key);
}
else {
this.locks.set(key, remaining);
}
} }
} }
} }