mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-20 01:37:50 -05:00
fix(avatars): keep the gem count when an animal is recycled
The animal switcher shows the second field of "ak" as the player's gems; it was always 0, so recycling an animal showed 0 gems until the next login.
This commit is contained in:
1 parent
3770341514
commit
1d9b70f32e
1 file changed
+5
-3
+5
-3
@@ -104,12 +104,12 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// AvatarSwitch.avatarKillResponse: [success, ?]
|
// AvatarSwitch.avatarKillResponse: [success, gems]
|
||||||
ak(session, roomId, [perUserAvId]) {
|
ak(session, roomId, [perUserAvId]) {
|
||||||
const {account} = session;
|
const {account} = session;
|
||||||
const avatar = account.avatars.find(candidate => candidate.perUserAvId === Number(perUserAvId));
|
const avatar = account.avatars.find(candidate => candidate.perUserAvId === Number(perUserAvId));
|
||||||
if (!avatar || avatar === activeAvatar(account) || account.avatars.length < 2) {
|
if (!avatar || avatar === activeAvatar(account) || account.avatars.length < 2) {
|
||||||
session.sendXt("ak", -1, 0, 0);
|
session.sendXt("ak", -1, 0, account.currency.gems);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
account.avatars = account.avatars.filter(candidate => candidate !== avatar);
|
account.avatars = account.avatars.filter(candidate => candidate !== avatar);
|
||||||
@@ -117,7 +117,9 @@ module.exports = ({others, findOnline, findBySfsId, refreshForOthers, petFields}
|
|||||||
item.on = item.on.filter(avInvId => avInvId !== avatar.avInvId);
|
item.on = item.on.filter(avInvId => avInvId !== avatar.avInvId);
|
||||||
}
|
}
|
||||||
accounts.save(account);
|
accounts.save(account);
|
||||||
session.sendXt("ak", -1, 1, 0);
|
// [success, gems]: the animal switcher (AvatarSwitcher.recycleAvatarCallback)
|
||||||
|
// shows the second as the player's gems, so it is their total, unchanged.
|
||||||
|
session.sendXt("ak", -1, 1, account.currency.gems);
|
||||||
},
|
},
|
||||||
|
|
||||||
// AvatarXtCommManager.requestColorChange: [color1, color2, color3, nameBarData]
|
// AvatarXtCommManager.requestColorChange: [color1, color2, color3, nameBarData]
|
||||||
|
|||||||
Reference in new issue
Block a user