feat: add common social fireplace

This commit is contained in:
2026-09-05 18:20:49 +05:00
parent 32527ec2ed
commit ca830b00b9
11 changed files with 539 additions and 121 deletions
+31 -1
View File
@@ -108,10 +108,40 @@ export const REST = {
cycleMs: 60_000,
buffMs: 300_000,
maxStacks: 2,
/** Прибавка к добыче за стак (дробные циклы копятся аккумулятором). */
/** Прибавка к добыче за стак при костре 1-го уровня. */
bonusPerStack: 0.2,
} as const;
// ---- кооп-костёр (M4) ----
export const CAMPFIRE = {
/** Прогресс за каждое сожжённое бревно. */
progressPerLog: 10,
cycleMs: 10_000,
/** Очков в минуту сгорает само (декей; копится и за оффлайн). */
decayPerMin: 4,
/** Пороги прогресса для уровней 1..5. */
levelThresholds: [0, 100, 300, 700, 1500],
} as const;
/** Точка, куда встаёт аватар, чтобы подкинуть дров. */
export const CAMPFIRE_SPOT = { x: 1900, y: 505 } as const;
export function campfireLevelFor(progress: number): number {
let level = 1;
for (let l = 2; l <= CAMPFIRE.levelThresholds.length; l++) {
const threshold = CAMPFIRE.levelThresholds[l - 1];
if (threshold === undefined || progress < threshold) break;
level = l;
}
return level;
}
/** Уровень костра усиливает бафф отдыха: +25% к бонусу за уровень. */
export function restBonusFor(fireLevel: number): number {
return REST.bonusPerStack * (1 + (fireLevel - 1) * 0.25);
}
// ---- навыки ----
export const SKILLS = [
+19 -2
View File
@@ -8,7 +8,7 @@
* дельты вместо полных снапшотов, игровые события, серверная камера.
*/
export const PROTOCOL_VERSION = 4;
export const PROTOCOL_VERSION = 5;
export interface ZoneDef {
id: string;
@@ -33,7 +33,7 @@ export interface WorldDef {
props: PropDef[];
}
export type AvatarAction = 'idle' | 'chop' | 'mine' | 'smith' | 'cook' | 'fish' | 'rest';
export type AvatarAction = 'idle' | 'chop' | 'mine' | 'smith' | 'cook' | 'fish' | 'rest' | 'feed';
export interface SkillState {
xp: number;
@@ -105,6 +105,8 @@ export type GameEvent =
| { k: 'fell'; userId: string; name: string; color: string; nodeId: string }
| { k: 'depleted'; userId: string; name: string; color: string; nodeId: string }
| { 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: 'blocked'; userId: string; name: string; color: string; reason: string };
export interface WelcomeMsg {
@@ -115,6 +117,19 @@ export interface WelcomeMsg {
world: WorldDef;
}
export interface CampfireContributor {
name: string;
color: string;
contributed: number;
}
/** Кооп-костёр: общий пул прогресса + топ вкладчиков (ledger на сервере). */
export interface CampfireState {
progress: number;
level: number;
top: CampfireContributor[];
}
export interface SnapshotMsg {
t: 'snapshot';
tick: number;
@@ -123,6 +138,7 @@ export interface SnapshotMsg {
avatars: AvatarState[];
nodes: NodeState[];
stats: ViewerStat[];
campfire: CampfireState;
}
export interface DeltaMsg {
@@ -133,6 +149,7 @@ export interface DeltaMsg {
avatars?: AvatarState[];
nodes?: NodeState[];
stats?: ViewerStat[];
campfire?: CampfireState;
events?: GameEvent[];
}