95 lines
2.8 KiB
JavaScript
95 lines
2.8 KiB
JavaScript
export class Reputation {
|
|
constructor(game) {
|
|
this.game = game;
|
|
this.value = 0; // -100 to +100
|
|
}
|
|
|
|
change(amount) {
|
|
const prevLevel = this.getLevel();
|
|
this.value = Math.max(-100, Math.min(100, this.value + amount));
|
|
const newLevel = this.getLevel();
|
|
|
|
if (newLevel !== prevLevel) {
|
|
if (amount > 0) {
|
|
this.game.notify(`Репутация: ${newLevel}`, 'good');
|
|
} else {
|
|
this.game.notify(`Репутация: ${newLevel}`, 'bad');
|
|
}
|
|
// Квест на репутацию
|
|
if (this.value >= 50) {
|
|
this.game.questSystem.onEvent('reputation_level');
|
|
}
|
|
}
|
|
}
|
|
|
|
getLevel() {
|
|
if (this.value <= -50) return 'Изгой';
|
|
if (this.value <= -20) return 'Подозрительный';
|
|
if (this.value < 20) return 'Незнакомец';
|
|
if (this.value < 50) return 'Знакомый';
|
|
if (this.value < 80) return 'Уважаемый';
|
|
return 'Свой человек';
|
|
}
|
|
|
|
getColor() {
|
|
if (this.value <= -50) return '#f44336';
|
|
if (this.value <= -20) return '#ff9800';
|
|
if (this.value < 20) return '#aaa';
|
|
if (this.value < 50) return '#8bc34a';
|
|
if (this.value < 80) return '#4caf50';
|
|
return '#ffd740';
|
|
}
|
|
|
|
// Модификатор для попрошайничества
|
|
getBegModifier() {
|
|
let mod = 1;
|
|
if (this.value >= 50) mod = 1.5;
|
|
else if (this.value >= 20) mod = 1.2;
|
|
else if (this.value <= -50) mod = 0.5;
|
|
else if (this.value <= -20) mod = 0.7;
|
|
|
|
// Низкая гигиена — прохожие брезгуют
|
|
if (this.game.player && this.game.player.stats.hygiene < 30) {
|
|
mod *= 0.7;
|
|
}
|
|
return mod;
|
|
}
|
|
|
|
// Модификатор оплаты за работу
|
|
getJobPayModifier() {
|
|
if (this.value >= 80) return 1.3;
|
|
if (this.value >= 50) return 1.15;
|
|
if (this.value >= 20) return 1.05;
|
|
return 1;
|
|
}
|
|
|
|
// Модификатор цен в магазине
|
|
getShopModifier() {
|
|
if (this.value >= 80) return 0.85;
|
|
if (this.value >= 50) return 0.92;
|
|
if (this.value <= -50) return 1.2;
|
|
return 1;
|
|
}
|
|
|
|
// Модификатор опасности (чаще нападают при низкой репутации)
|
|
getDangerModifier() {
|
|
if (this.value >= 50) return 0.5;
|
|
if (this.value >= 20) return 0.8;
|
|
if (this.value <= -50) return 1.5;
|
|
if (this.value <= -20) return 1.3;
|
|
return 1;
|
|
}
|
|
|
|
getSaveData() {
|
|
return { value: this.value };
|
|
}
|
|
|
|
loadSaveData(data) {
|
|
if (data) this.value = data.value || 0;
|
|
}
|
|
|
|
reset() {
|
|
this.value = 0;
|
|
}
|
|
}
|