Selaa lähdekoodia

Merge branch '156-level-up-max-lvl-notice' into 'staging'

Fixes #156

See merge request !98
tags/v0.1.3^2
Big Bad Waffle 7 vuotta sitten
vanhempi
commit
d8ab1fa77c
2 muutettua tiedostoa jossa 42 lisäystä ja 24 poistoa
  1. +14
    -5
      src/server/components/notice.js
  2. +28
    -19
      src/server/components/stats.js

+ 14
- 5
src/server/components/notice.js Näytä tiedosto

@@ -69,11 +69,13 @@ define([
}, [obj.serverId]);
},

collisionExit: function(obj) {
if (!obj.player)
return;
else if ((this.maxLevel) && (obj.stats.values.level > this.maxLevel))
return;
collisionExit: function(obj, force) {
if (!force) {
if (!obj.player)
return;
else if ((this.maxLevel) && (obj.stats.values.level > this.maxLevel))
return;
}

this.callAction(obj, 'exit');

@@ -83,6 +85,13 @@ define([
this.syncer.queue('onRemoveDialogue', {
src: this.obj.id
}, [obj.serverId]);
},

events: {
onCellPlayerLevelUp: function(obj) {
if ((this.maxLevel) && (obj.stats.values.level > this.maxLevel))
this.collisionExit(obj, true);
}
}
};
});

+ 28
- 19
src/server/components/stats.js Näytä tiedosto

@@ -156,45 +156,54 @@ define([
},

getXp: function(amount) {
amount = ~~(amount * (1 + (this.values.xpIncrease / 100)));
var obj = this.obj;
var values = this.values;

amount = ~~(amount * (1 + (values.xpIncrease / 100)));

this.values.xpTotal = ~~(this.values.xpTotal + amount);
this.values.xp = ~~(this.values.xp + amount);
values.xpTotal = ~~(values.xpTotal + amount);
values.xp = ~~(values.xp + amount);

this.syncer.queue('onGetDamage', {
id: this.obj.id,
id: obj.id,
event: true,
text: '+' + amount + ' xp'
});

var syncO = {};

var didLevelUp = false;
while (this.values.xp >= this.values.xpMax) {

while (values.xp >= values.xpMax) {
didLevelUp = true;
this.values.xp -= this.values.xpMax;
this.values.level++;
values.xp -= values.xpMax;
values.level++;

this.values.hpMax += 40;
values.hpMax += 40;

this.syncer.queue('onGetDamage', {
id: this.obj.id,
id: obj.id,
event: true,
text: 'level up'
});

this.obj.syncer.setObject(true, 'stats', 'values', 'level', this.values.level);
this.obj.syncer.setObject(true, 'stats', 'values', 'hpMax', this.values.hpMax);
obj.syncer.setObject(true, 'stats', 'values', 'level', values.level);
obj.syncer.setObject(true, 'stats', 'values', 'hpMax', values.hpMax);

syncO.level = this.values.level;
syncO.level = values.level;

this.calcXpMax();
}

if (didLevelUp)
this.obj.auth.doSave();
if (didLevelUp) {
var cellContents = obj.instance.physics.getCell(obj.x, obj.y);
cellContents.forEach(function(c) {
c.fireEvent('onCellPlayerLevelUp', obj);
});

obj.auth.doSave();
}

this.obj.syncer.setObject(true, 'stats', 'values', 'xp', this.values.xp);
obj.syncer.setObject(true, 'stats', 'values', 'xp', this.values.xp);

process.send({
method: 'object',
@@ -237,13 +246,13 @@ define([
var amount = level * 10 * mult;
if (Math.abs(levelDelta) <= 10)
amount = ~~(((sourceLevel + levelDelta) * 10) * Math.pow(1 - (Math.abs(levelDelta) / 10), 2) * mult);
else
else
amount = 0;

a.obj.stats.getXp(amount, this.obj);
}
a.obj.fireEvent('afterKillMob', target);
}



Ladataan…
Peruuta
Tallenna