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
+13
-3
@@ -6,6 +6,7 @@ const defpacks = require("./defpacks.js");
|
||||
const buddyGames = require("./buddygames.js");
|
||||
const masterpieces = require("./masterpieces.js");
|
||||
const dens = require("./dens.js");
|
||||
const customItems = require("./customitems.js");
|
||||
const limits = require("./limits.js");
|
||||
const {activeAvatar, addClothing, sendClothingAdded} = require("./player.js");
|
||||
|
||||
@@ -42,6 +43,7 @@ const {activeAvatar, addClothing, sendClothingAdded} = require("./player.js");
|
||||
|
||||
const games = new Map(require("./games.json").map(game => [game.id, game]));
|
||||
|
||||
const GAME_AFTERGLOW_MS = 15000; // how long a game's room id is still taken after leaving it (leave)
|
||||
const IN_ROOM = 0;
|
||||
const MAX_GEMS_PER_AWARD = 5000;
|
||||
const MAX_MASTERY_PER_AWARD = 100;
|
||||
@@ -234,6 +236,10 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
return;
|
||||
}
|
||||
session.game = null;
|
||||
// an in-room game may say it is done just before it hands over what it
|
||||
// made (the Juice Bar's smoothie, the Cocoa Hut's drink: an attachment,
|
||||
// lib/world.js pubMsg), labelled with the game's room
|
||||
session.lastGame = {roomId: game.roomId, until: Date.now() + GAME_AFTERGLOW_MS};
|
||||
if (session.bubbleOffOwed) {
|
||||
bubbleOff(session);
|
||||
}
|
||||
@@ -408,8 +414,12 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
// den items a claw machine can drop: the plushies, of the machine's own
|
||||
// animal when it is named for one ("The Wolf Claw").
|
||||
let plushies = null;
|
||||
// the game's own den items only: a custom item (and a player's own, which
|
||||
// is nobody else's to win) may be missing from the winner's game, whose
|
||||
// prize popup then threw (DenItem.initShopItem) and left the game frozen.
|
||||
const gameOwnDenItemIds = () => defpacks.denItemIds().filter(id => id < customItems.FIRST_ID);
|
||||
const clawPrizes = game => {
|
||||
plushies = plushies || defpacks.denItemIds().filter(id => /plush/i.test(defpacks.denItemDef(id).abbrName));
|
||||
plushies = plushies || gameOwnDenItemIds().filter(id => /plush/i.test(defpacks.denItemDef(id).abbrName));
|
||||
const item = defpacks.denItemIds().map(id => defpacks.denItemDef(id)).find(def => Number(def.gameDefId) === game.id);
|
||||
const animal = item ? /^ArcCraneGame(.+)$/.exec(item.abbrName) : null;
|
||||
const own = animal ? plushies.filter(id => defpacks.denItemDef(id).abbrName.toLowerCase().includes(animal[1].toLowerCase())) : [];
|
||||
@@ -420,7 +430,7 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
// machines aside.
|
||||
let phantomItems = null;
|
||||
const invasionPrizes = () => {
|
||||
phantomItems = phantomItems || defpacks.denItemIds().filter(id => /phantom/i.test(defpacks.denItemDef(id).abbrName)
|
||||
phantomItems = phantomItems || gameOwnDenItemIds().filter(id => /phantom/i.test(defpacks.denItemDef(id).abbrName)
|
||||
&& !/^Arc/.test(defpacks.denItemDef(id).abbrName) && defpacks.string(defpacks.denItemDef(id).nameStrId));
|
||||
return phantomItems.length ? phantomItems : defpacks.denItemIds().slice(0, 1);
|
||||
};
|
||||
@@ -550,7 +560,7 @@ module.exports = ({tell, leaveRoom, findOnline, blocks, watchers}) => {
|
||||
WindRider: {
|
||||
go() {},
|
||||
gw(session, game, params, reply) {
|
||||
const ids = defpacks.clothingIds();
|
||||
const ids = defpacks.clothingIds().filter(id => id < customItems.FIRST_ID);
|
||||
const def = Math.random() < SKY_HIGH_PRIZE_CHANCE ? defpacks.itemDef(ids[Math.floor(Math.random() * ids.length)]) : null;
|
||||
session.gamePrize = def ? {def: Number(def.id), color: Number(String(def.colors).split(",")[0])} : null;
|
||||
reply("gw", def ? "1" : "0", def ? def.id : 0, 0, def ? session.gamePrize.color : 0);
|
||||
|
||||
Reference in new issue
Block a user