mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
fix: trading, machine rewards and claw prizes from the owner's list
- a completed trade no longer plays the failure sound over the success one - a sign over players who are trading, seen by everyone in the room - every item added to a trade list is shown; lists keep up to 200 items - the drink, popcorn and cotton candy machines always hand over what they made (the game sent nothing when it was like the last one it gave), the smoothie machine even when the game it is was not noted down, and the server takes a game's message for a moment after it is left - claw machine, Phantom Invasion and Sky High prizes are the game's own items only: a custom item could be missing from the winner's game
This commit is contained in:
1 parent
22fb7f0fa5
commit
6c273554d7
12 files changed
+2791
-11
No files matched your search
+14
-4
@@ -15,7 +15,7 @@ const TYPE_CLOTHING = 0;
|
||||
const TYPE_DEN_ITEM = 1;
|
||||
const TYPE_PET = 3;
|
||||
|
||||
const MAX_TRADE_ITEMS = 50;
|
||||
const MAX_TRADE_ITEMS = 200; // on a trade list (the game sets no end to it; past this the rest were dropped)
|
||||
const MAX_PETS = 1000; // as in lib/pets.js
|
||||
|
||||
// "ti" request steps (first parameter from the client)
|
||||
@@ -46,7 +46,7 @@ const TRADES_KEPT = 50; // per account, for its page
|
||||
const MAX_WAITING_OFFERS = 50; // offers left on one account
|
||||
const MAX_OFFERS_MADE = 20; // by one account, still waiting
|
||||
|
||||
module.exports = ({findOnline, blocks}) => {
|
||||
module.exports = ({findOnline, blocks, showTrading}) => {
|
||||
// TradeManager.onTradeListReceived: [username, clothingCount, (defId,
|
||||
// invIdx, color)..., denItemCount, (defId, invIdx, version, approved,
|
||||
// imageId, creatorDbId, creatorUuid)..., petCount, (speciesId, invIdx,
|
||||
@@ -138,6 +138,8 @@ module.exports = ({findOnline, blocks}) => {
|
||||
const other = trade.requester === session ? trade.owner : trade.requester;
|
||||
trade.requester.trade = trade.owner.trade = null;
|
||||
other.sendXt("ti", -1, status, session.account.username, USERNAME_SHOWN);
|
||||
showTrading(session);
|
||||
showTrading(other);
|
||||
};
|
||||
|
||||
// moves one entry between accounts. it gets a fresh inventory id, and
|
||||
@@ -209,6 +211,8 @@ module.exports = ({findOnline, blocks}) => {
|
||||
return;
|
||||
}
|
||||
session.trade = owner.trade = {requester: session, owner, wantedType, wanted, offered, accepted: false, confirmed: new Set()};
|
||||
showTrading(session);
|
||||
showTrading(owner);
|
||||
// TradeManager.displayTradeRequested: [0, requesterName, moderatedFlag,
|
||||
// wantedCode, wantedInvIdx, clothingCount, denCount, petCount, ...items]
|
||||
const ofType = type => offered.filter(item => item.type === type);
|
||||
@@ -251,6 +255,8 @@ module.exports = ({findOnline, blocks}) => {
|
||||
}
|
||||
const {requester, owner, wantedType, wanted, offered} = trade;
|
||||
requester.trade = owner.trade = null;
|
||||
showTrading(requester);
|
||||
showTrading(owner);
|
||||
// either side may have recycled or re-traded something while deciding.
|
||||
const stillThere = collectionOf(owner.account, wantedType).includes(wanted)
|
||||
&& offered.every(item => collectionOf(requester.account, item.type).includes(item.entry))
|
||||
@@ -312,8 +318,12 @@ module.exports = ({findOnline, blocks}) => {
|
||||
sendTradeList(session, account);
|
||||
},
|
||||
|
||||
// ["1"/"0"]: busy flag while the trade window is open; nothing to answer.
|
||||
tb() {},
|
||||
// ["1"/"0"]: busy flag while the trade window is open; nothing to
|
||||
// answer. it shows as the trading sign (lib/world.js showTrading).
|
||||
tb(session, roomId, [busy]) {
|
||||
session.tradeBusy = busy === "1";
|
||||
showTrading(session);
|
||||
},
|
||||
|
||||
ti(session, roomId, params) {
|
||||
switch (params[0]) {
|
||||
|
||||
Reference in new issue
Block a user