feat: economy and polishing

This commit is contained in:
2026-09-05 19:12:28 +05:00
parent ca830b00b9
commit c56ec113cc
18 changed files with 868 additions and 42 deletions
+37
View File
@@ -303,6 +303,43 @@ export function findRecipe(text: string): RecipeDef | undefined {
});
}
// ---- предметы: поиск по названию (для !подарить) ----
export const ITEM_ALIASES: Record<string, string[]> = {
log: ['брёвна', 'бревно', 'дрова', 'дерево'],
copper_ore: ['медная руда'],
iron_ore: ['железная руда'],
copper_bar: ['медный слиток'],
iron_bar: ['железный слиток'],
raw_fish: ['сырая рыба', 'рыбка'],
cooked_fish: ['жареная рыба'],
axe_rusty: ['ржавый топор'],
axe_iron: ['железный топор'],
pick_rusty: ['ржавая кирка'],
pick_iron: ['железная кирка'],
};
/** Все id предметов, чьи слова матчатся запросу (точное совпадение — первым). */
export function itemCandidates(text: string): string[] {
const q = text.trim().toLowerCase().replace(/\s+/g, ' ');
if (!q) return [];
const ids = Object.keys(ITEMS);
const exact = ids.filter((id) => {
const item = ITEMS[id];
return id === q || item?.title === q || (ITEM_ALIASES[id] ?? []).includes(q);
});
if (exact.length > 0) return exact;
const qStems = q.split(' ').map(stem);
return ids.filter((id) => {
const stems = new Set(
[ITEMS[id]?.title ?? '', ...(ITEM_ALIASES[id] ?? [])]
.flatMap((w) => w.split(' '))
.map(stem),
);
return qStems.every((s) => stems.has(s));
});
}
// ---- прочее ----
export const WALK_SPEED = 110; // px/сек
+5 -1
View File
@@ -8,7 +8,7 @@
* дельты вместо полных снапшотов, игровые события, серверная камера.
*/
export const PROTOCOL_VERSION = 5;
export const PROTOCOL_VERSION = 6;
export interface ZoneDef {
id: string;
@@ -107,6 +107,8 @@ export type GameEvent =
| { k: 'rest'; userId: string; name: string; color: string; stacks: number }
| { k: 'fire'; userId: string; name: string; color: string; contributed: number; progress: number; level: number }
| { k: 'firelevel'; level: number }
| { k: 'gift'; userId: string; name: string; color: string; toName: string; item: string; qty: number }
| { k: 'spotlight'; name: string; color: string }
| { k: 'blocked'; userId: string; name: string; color: string; reason: string };
export interface WelcomeMsg {
@@ -151,6 +153,8 @@ export interface DeltaMsg {
stats?: ViewerStat[];
campfire?: CampfireState;
events?: GameEvent[];
/** Аватары, исчезнувшие из мира (сброс зрителя с дашборда). */
removed?: string[];
}
export type ServerMessage = WelcomeMsg | SnapshotMsg | DeltaMsg;