mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-18 17:27:50 -05:00
feat: redemption codes, world count, den visitor count and more fixes
- codes made in the admin panel (Messages) give an item, gems or diamonds through the game's Redeem Code window, which was never answered; its "need help?" says what codes are here - the number of worlds is set in the admin panel (Debug), live - a den's owner is told how many are in it: the HUD's count and doorbell - the map counts the player's buddies in each land of their world - gifts whose item no longer exists, or with a nonsense amount, are no gift at all, rather than a window that will not close - custom item pictures are 256 pixels and 100 KB at most - the account page's buddies and den visitors fold away - shops no longer count down "X days left"
This commit is contained in:
1 parent
15f321fb00
commit
7de41ceed5
14 files changed
+707
-27
No files matched your search
+34
-7
@@ -77,8 +77,23 @@ const now = () => Math.floor(Date.now() / 1000);
|
||||
const clean = text => String(text).replace(/[\u0000-\u001f\u007f%]/g, " ").trim().slice(0, MAX_MESSAGE);
|
||||
|
||||
module.exports = ({findOnline, blocks}) => {
|
||||
// a gift the game can show and take: its item still exists (a custom item
|
||||
// may have been deleted since), or an amount that makes sense. any other
|
||||
// left the gift windows stuck; it is treated as no gift at all.
|
||||
const MAX_GIFT_AMOUNT = 10000000;
|
||||
const giftUsable = gift => {
|
||||
if (gift.type === TYPE_CLOTHING) {
|
||||
return Boolean(defpacks.itemDef(gift.def)) && Number.isFinite(Number(gift.color));
|
||||
}
|
||||
if (gift.type === TYPE_DEN_ITEM) {
|
||||
return Boolean(defpacks.denItemDef(gift.def));
|
||||
}
|
||||
const amount = Number(gift.def);
|
||||
return Object.hasOwn(CURRENCY_OF, gift.type) && Number.isInteger(amount) && amount > 0 && amount <= MAX_GIFT_AMOUNT;
|
||||
};
|
||||
|
||||
// A card from the server carrying gems or diamonds: one of the popups.
|
||||
const isRedemption = card => Boolean(card.hq && card.gift && Object.hasOwn(CURRENCY_OF, card.gift.type));
|
||||
const isRedemption = card => Boolean(card.hq && card.gift && giftUsable(card.gift) && Object.hasOwn(CURRENCY_OF, card.gift.type));
|
||||
|
||||
// who sent a card: by account id, and for cards from before ids were
|
||||
// kept by the name on them.
|
||||
@@ -98,9 +113,10 @@ module.exports = ({findOnline, blocks}) => {
|
||||
const sender = card.hq ? null : senderOf(card);
|
||||
const senderType = isRedemption(card) ? FROM_REDEMPTION : card.hq ? FROM_HQ : FROM_PLAYER;
|
||||
const name = card.secret ? "" : senderType === FROM_HQ ? HQ_NAME_STRING : card.hq ? HQ_NAME : card.from;
|
||||
const gift = card.gift && giftUsable(card.gift) ? card.gift : null;
|
||||
return [
|
||||
card.id, name, card.card, card.stamp, card.read ? 1 : 0, card.msg, card.gift ? card.gift.type : TYPE_PLAIN,
|
||||
card.gift ? giftId(card.gift) : 0, card.gift ? card.gift.color : 0, card.gift ? card.gift.name : 0,
|
||||
card.id, name, card.card, card.stamp, card.read ? 1 : 0, card.msg, gift ? gift.type : TYPE_PLAIN,
|
||||
gift ? giftId(gift) : 0, gift ? gift.color : 0, gift ? gift.name : 0,
|
||||
card.hq || card.secret ? MEMBER : sender ? sender.accountType : 0,
|
||||
0, // name bar data
|
||||
0, // secondary type
|
||||
@@ -110,7 +126,7 @@ module.exports = ({findOnline, blocks}) => {
|
||||
// patched client (ECardInbox) can show a custom item as itself (its
|
||||
// own picture and name) and not as the art it was made from. (the
|
||||
// "|" keeps the game from taking it for an HQ gift's own message.)
|
||||
card.gift && card.gift.type === TYPE_CLOTHING ? `item|${card.gift.def}` : "",
|
||||
gift && gift.type === TYPE_CLOTHING ? `item|${gift.def}` : "",
|
||||
card.secret ? SECRET_VALENTINE : 0,
|
||||
];
|
||||
};
|
||||
@@ -163,7 +179,11 @@ module.exports = ({findOnline, blocks}) => {
|
||||
}
|
||||
else {
|
||||
// for these the card's "gift id" and "gift name" are both the amount.
|
||||
attached = {type: gift.kind === "gems" ? TYPE_GEMS : TYPE_DIAMONDS, def: gift.amount, color: 0, name: gift.amount};
|
||||
const amount = Number(gift.amount);
|
||||
if (!Number.isInteger(amount) || amount < 1 || amount > MAX_GIFT_AMOUNT) {
|
||||
return "An amount from 1 to 10,000,000";
|
||||
}
|
||||
attached = {type: gift.kind === "gems" ? TYPE_GEMS : TYPE_DIAMONDS, def: amount, color: 0, name: amount};
|
||||
}
|
||||
// the gift popup takes a message that starts with a number for the id of
|
||||
// a localization string (StartupPopups.setupGiftPopup).
|
||||
@@ -226,8 +246,8 @@ module.exports = ({findOnline, blocks}) => {
|
||||
}
|
||||
else if (Object.hasOwn(CURRENCY_OF, gift.type)) {
|
||||
const currency = CURRENCIES[CURRENCY_OF[gift.type]];
|
||||
account.currency[currency] = (account.currency[currency] || 0) + gift.def;
|
||||
achievements.currencyChanged(account, currency, gift.def);
|
||||
account.currency[currency] = (account.currency[currency] || 0) + Number(gift.def);
|
||||
achievements.currencyChanged(account, currency, Number(gift.def));
|
||||
// ItemXtCommManager.currencyUpdateResponse: [currencyType, newAmount, reason]
|
||||
session.sendXt("cu", -1, CURRENCY_OF[gift.type], account.currency[currency], 0);
|
||||
}
|
||||
@@ -333,6 +353,13 @@ module.exports = ({findOnline, blocks}) => {
|
||||
return;
|
||||
}
|
||||
const {gift} = card;
|
||||
// a gift that cannot be had (above): gone, and the window let go
|
||||
if (!giftUsable(gift)) {
|
||||
card.gift = null;
|
||||
accounts.save(session.account);
|
||||
session.sendXt("eg", -1, msgId, 1);
|
||||
return;
|
||||
}
|
||||
// no room for it: it stays in the card until there is.
|
||||
if (accept === "1" && ((gift.type === TYPE_CLOTHING && !hasRoom(session.account, "items"))
|
||||
|| (gift.type === TYPE_DEN_ITEM && !hasRoom(session.account, "denItems")))) {
|
||||
|
||||
Reference in new issue
Block a user