555 lines
16 KiB
JavaScript
555 lines
16 KiB
JavaScript
/**
|
|
* LAWYER OFFICE SYSTEM - Divorce & Marriage Legal Services
|
|
* Part of: New Town Buildings ("Drama Hub")
|
|
* Created: January 4, 2026
|
|
*
|
|
* Features:
|
|
* - Divorce processing (50,000g + 25% money loss)
|
|
* - Prenuptial agreement system (preventive, 10,000g)
|
|
* - Marriage counseling (alternative to divorce, 5,000g)
|
|
* - Relationship crisis detection
|
|
* - Post-divorce quests
|
|
*/
|
|
|
|
class LawyerOfficeSystem {
|
|
constructor(game) {
|
|
this.game = game;
|
|
this.player = game.player;
|
|
|
|
// Lawyer office status
|
|
this.isUnlocked = false;
|
|
this.lawyer = null;
|
|
|
|
// Divorce costs
|
|
this.divorceCost = 50000;
|
|
this.divorceMoneyLoss = 0.25; // 25% of remaining money
|
|
this.divorceMoneyLossWithPrenup = 0.10; // 10% with prenup
|
|
|
|
// Prenup system
|
|
this.hasPrenup = false;
|
|
this.prenupCost = 10000;
|
|
|
|
// Marriage counseling
|
|
this.counselingCost = 5000;
|
|
this.counselingInProgress = false;
|
|
this.counselingTasksCompleted = 0;
|
|
this.counselingTasksRequired = 3;
|
|
|
|
// Divorce history
|
|
this.divorceHistory = [];
|
|
this.hasEverDivorced = false;
|
|
}
|
|
|
|
/**
|
|
* Auto-unlock lawyer office when marriage is in crisis
|
|
*/
|
|
checkAutoUnlock() {
|
|
// Auto-unlock if married AND relationship ≤ 3 hearts
|
|
if (this.player.isMarried) {
|
|
const spouse = this.game.npcs.getSpouse();
|
|
if (spouse && spouse.relationshipHearts <= 3) {
|
|
this.unlockLawyerOffice();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Unlock lawyer office
|
|
*/
|
|
unlockLawyerOffice() {
|
|
if (this.isUnlocked) return;
|
|
|
|
// Auto-build (15,000g automatically deducted)
|
|
if (this.player.money < 15000) {
|
|
// Build on credit (lawyer is greedy!)
|
|
this.player.money = Math.max(0, this.player.money - 15000);
|
|
this.player.debt = Math.abs(Math.min(0, this.player.money));
|
|
} else {
|
|
this.player.money -= 15000;
|
|
}
|
|
|
|
this.isUnlocked = true;
|
|
|
|
// Spawn lawyer NPC
|
|
this.lawyer = this.game.npcs.spawn('lawyer', {
|
|
name: 'Mr. Sterling',
|
|
position: { x: 1600, y: 1000 },
|
|
appearance: {
|
|
clothing: 'black_suit',
|
|
demeanor: 'cold_professional'
|
|
},
|
|
dialogue: this.getLawyerDialogue()
|
|
});
|
|
|
|
// Trigger ominous quest
|
|
this.game.quests.start('till_death_do_us_part');
|
|
|
|
this.game.showMessage('⚖️ Lawyer Office has been built...');
|
|
|
|
return { success: true };
|
|
}
|
|
|
|
/**
|
|
* Get lawyer dialogue
|
|
*/
|
|
getLawyerDialogue() {
|
|
return {
|
|
greeting: [
|
|
"Marriage is a contract. Divorce is... expensive.",
|
|
"Love is temporary. Legal documents are forever.",
|
|
"Here for business or pleasure? I only deal in business."
|
|
],
|
|
divorce_warning: [
|
|
"Are you ABSOLUTELY sure? This will cost you everything.",
|
|
"Divorce is final. There's no going back.",
|
|
"I've seen many regret this decision. Proceed?"
|
|
],
|
|
prenup: [
|
|
"Smart move. Protect your assets before it's too late.",
|
|
"A prenup? Planning ahead, I see. Wise.",
|
|
"Marriage without a prenup is... optimistic."
|
|
],
|
|
counseling: [
|
|
"There may be another way. Have you tried talking?",
|
|
"Marriage counseling. Less expensive than divorce.",
|
|
"Fix it now or pay later. Your choice."
|
|
],
|
|
post_divorce: [
|
|
"Single again. How does freedom feel?",
|
|
"Expensive lesson learned, I hope.",
|
|
"The papers are filed. You're free to go."
|
|
]
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Purchase prenuptial agreement (BEFORE marriage only!)
|
|
*/
|
|
purchasePrenup() {
|
|
// Can only buy BEFORE getting married
|
|
if (this.player.isMarried) {
|
|
return {
|
|
success: false,
|
|
message: 'Too late! Prenups must be signed BEFORE marriage!'
|
|
};
|
|
}
|
|
|
|
if (this.hasPrenup) {
|
|
return {
|
|
success: false,
|
|
message: 'You already have a prenup!'
|
|
};
|
|
}
|
|
|
|
if (this.player.money < this.prenupCost) {
|
|
return {
|
|
success: false,
|
|
message: `Need ${this.prenupCost}g for a prenup!`
|
|
};
|
|
}
|
|
|
|
// Purchase
|
|
this.player.money -= this.prenupCost;
|
|
this.hasPrenup = true;
|
|
|
|
this.game.showMessage(
|
|
`Prenup signed! Divorce money loss reduced to 10%. ${this.prenupCost}g`
|
|
);
|
|
|
|
return { success: true };
|
|
}
|
|
|
|
/**
|
|
* Initiate divorce process
|
|
*/
|
|
initiateDivorce() {
|
|
// Check if married
|
|
if (!this.player.isMarried) {
|
|
return {
|
|
success: false,
|
|
message: 'You\'re not married!'
|
|
};
|
|
}
|
|
|
|
const spouse = this.game.npcs.getSpouse();
|
|
|
|
// Show divorce confirmation with full consequences
|
|
const moneyLossPercent = this.hasPrenup ? 10 : 25;
|
|
const estimatedLoss = Math.floor(this.player.money * (this.hasPrenup ? 0.10 : 0.25));
|
|
|
|
const divorceInfo = {
|
|
cost: this.divorceCost,
|
|
moneyLoss: estimatedLoss,
|
|
moneyLossPercent: moneyLossPercent,
|
|
spouse: spouse.name,
|
|
consequences: [
|
|
`Divorce fee: ${this.divorceCost}g`,
|
|
`Money loss: ${moneyLossPercent}% (${estimatedLoss}g)`,
|
|
`${spouse.name} relationship reset to 0 hearts`,
|
|
`${spouse.name} moves out of farmhouse`,
|
|
'Lose "married" status benefits',
|
|
'King-size bed reverts to single use'
|
|
]
|
|
};
|
|
|
|
// Emit event for UI to show confirmation dialog
|
|
this.game.emit('divorceConfirmationRequired', divorceInfo);
|
|
|
|
return {
|
|
success: false, // Not completed yet, waiting for confirmation
|
|
requiresConfirmation: true,
|
|
divorceInfo: divorceInfo
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Confirm and process divorce (after player confirms)
|
|
*/
|
|
processDivorce() {
|
|
if (!this.player.isMarried) {
|
|
return { success: false, message: 'Not married!' };
|
|
}
|
|
|
|
const spouse = this.game.npcs.getSpouse();
|
|
|
|
// Calculate total cost
|
|
const divorceFee = this.divorceCost;
|
|
const moneyLossPercent = this.hasPrenup ? this.divorceMoneyLossWithPrenup : this.divorceMoneyLoss;
|
|
|
|
// Check if can afford divorce fee
|
|
if (this.player.money < divorceFee) {
|
|
return {
|
|
success: false,
|
|
message: `Not enough money! Divorce costs ${divorceFee}g!`
|
|
};
|
|
}
|
|
|
|
// Deduct divorce fee
|
|
this.player.money -= divorceFee;
|
|
|
|
// Calculate and deduct money loss
|
|
const moneyLoss = Math.floor(this.player.money * moneyLossPercent);
|
|
this.player.money -= moneyLoss;
|
|
|
|
// Reset relationship
|
|
const previousHearts = spouse.relationshipHearts;
|
|
spouse.relationshipHearts = 0;
|
|
spouse.relationshipPoints = 0;
|
|
|
|
// Spouse moves out
|
|
spouse.homeLocation = spouse.originalHome;
|
|
spouse.isLivingWithPlayer = false;
|
|
|
|
// Remove married status
|
|
this.player.isMarried = false;
|
|
this.player.spouse = null;
|
|
|
|
// Downgrade bed
|
|
if (this.game.sleepSystem) {
|
|
const kingSizeBed = this.game.sleepSystem.bedTypes.KING_SIZE_BED;
|
|
kingSizeBed.spousePresent = false;
|
|
}
|
|
|
|
// Record divorce in history
|
|
this.divorceHistory.push({
|
|
spouse: spouse.name,
|
|
date: this.game.time.currentDate,
|
|
costTotal: divorceFee + moneyLoss,
|
|
heartsLost: previousHearts
|
|
});
|
|
|
|
this.hasEverDivorced = true;
|
|
|
|
// Trigger post-divorce quest
|
|
this.game.quests.start('single_again');
|
|
|
|
// Spouse reaction (they're devastated)
|
|
this.game.showDialogue(
|
|
spouse.name,
|
|
"I can't believe this is happening... Goodbye.",
|
|
{
|
|
mood: 'heartbroken',
|
|
animation: 'crying'
|
|
}
|
|
);
|
|
|
|
// Show final message
|
|
this.game.showMessage(
|
|
`Divorced ${spouse.name}. Total cost: ${divorceFee + moneyLoss}g. You are now single.`
|
|
);
|
|
|
|
// Lawyer's cold response
|
|
setTimeout(() => {
|
|
this.game.showDialogue(
|
|
this.lawyer.name,
|
|
"The papers are filed. You're free to go. That'll be " + divorceFee + "g."
|
|
);
|
|
}, 3000);
|
|
|
|
return {
|
|
success: true,
|
|
totalCost: divorceFee + moneyLoss,
|
|
moneyLoss: moneyLoss,
|
|
spouse: spouse.name
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Start marriage counseling (alternative to divorce)
|
|
*/
|
|
startCounseling() {
|
|
if (!this.player.isMarried) {
|
|
return {
|
|
success: false,
|
|
message: 'You\'re not married!'
|
|
};
|
|
}
|
|
|
|
if (this.counselingInProgress) {
|
|
return {
|
|
success: false,
|
|
message: 'Counseling already in progress!'
|
|
};
|
|
}
|
|
|
|
if (this.player.money < this.counselingCost) {
|
|
return {
|
|
success: false,
|
|
message: `Marriage counseling costs ${this.counselingCost}g!`
|
|
};
|
|
}
|
|
|
|
// Pay for counseling
|
|
this.player.money -= this.counselingCost;
|
|
this.counselingInProgress = true;
|
|
this.counselingTasksCompleted = 0;
|
|
|
|
const spouse = this.game.npcs.getSpouse();
|
|
|
|
// Generate counseling tasks
|
|
this.counselingTasks = this.generateCounselingTasks(spouse);
|
|
|
|
// Start counseling quest
|
|
this.game.quests.start('marriage_counseling', {
|
|
tasks: this.counselingTasks
|
|
});
|
|
|
|
this.game.showMessage(
|
|
`Marriage counseling started! Complete 3 tasks to save your marriage. ${this.counselingCost}g`
|
|
);
|
|
|
|
return {
|
|
success: true,
|
|
tasks: this.counselingTasks
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Generate counseling tasks based on spouse
|
|
*/
|
|
generateCounselingTasks(spouse) {
|
|
const tasks = [
|
|
{
|
|
id: 'gift_favorite',
|
|
description: `Give ${spouse.name} their favorite gift`,
|
|
requirement: {
|
|
type: 'gift',
|
|
item: spouse.favoriteGift,
|
|
target: spouse.id
|
|
},
|
|
completed: false
|
|
},
|
|
{
|
|
id: 'date_night',
|
|
description: `Take ${spouse.name} on a date to their favorite location`,
|
|
requirement: {
|
|
type: 'visit_location',
|
|
location: spouse.favoriteLocation,
|
|
withNPC: spouse.id
|
|
},
|
|
completed: false
|
|
},
|
|
{
|
|
id: 'heart_to_heart',
|
|
description: `Have a deep conversation with ${spouse.name}`,
|
|
requirement: {
|
|
type: 'dialogue',
|
|
dialogueId: 'heart_to_heart',
|
|
target: spouse.id
|
|
},
|
|
completed: false
|
|
}
|
|
];
|
|
|
|
return tasks;
|
|
}
|
|
|
|
/**
|
|
* Complete counseling task
|
|
*/
|
|
completeCounselingTask(taskId) {
|
|
if (!this.counselingInProgress) {
|
|
return { success: false };
|
|
}
|
|
|
|
const task = this.counselingTasks.find(t => t.id === taskId);
|
|
if (!task || task.completed) {
|
|
return { success: false };
|
|
}
|
|
|
|
// Mark task as completed
|
|
task.completed = true;
|
|
this.counselingTasksCompleted++;
|
|
|
|
this.game.showMessage(
|
|
`Counseling task completed! (${this.counselingTasksCompleted}/${this.counselingTasksRequired})`
|
|
);
|
|
|
|
// Check if all tasks done
|
|
if (this.counselingTasksCompleted >= this.counselingTasksRequired) {
|
|
this.finishCounseling(true);
|
|
}
|
|
|
|
return { success: true };
|
|
}
|
|
|
|
/**
|
|
* Finish counseling (success or failure)
|
|
*/
|
|
finishCounseling(success) {
|
|
const spouse = this.game.npcs.getSpouse();
|
|
|
|
if (success) {
|
|
// Restore relationship!
|
|
spouse.addRelationshipPoints(500); // +5 hearts
|
|
|
|
this.game.showDialogue(
|
|
spouse.name,
|
|
"I'm so glad we worked through this. I love you.",
|
|
{
|
|
mood: 'happy',
|
|
animation: 'hug'
|
|
}
|
|
);
|
|
|
|
this.game.showMessage(
|
|
`Marriage saved! ${spouse.name}: +5 ❤️`
|
|
);
|
|
|
|
// Complete quest
|
|
this.game.quests.complete('marriage_counseling');
|
|
|
|
} else {
|
|
// Counseling failed
|
|
this.game.showDialogue(
|
|
spouse.name,
|
|
"This isn't working. Maybe it's time to let go...",
|
|
{
|
|
mood: 'sad'
|
|
}
|
|
);
|
|
|
|
this.game.showMessage(
|
|
'Counseling failed. Relationship worsened.'
|
|
);
|
|
|
|
// Relationship damage
|
|
spouse.addRelationshipPoints(-200); // -2 hearts
|
|
|
|
// Fail quest
|
|
this.game.quests.fail('marriage_counseling');
|
|
}
|
|
|
|
this.counselingInProgress = false;
|
|
this.counselingTasks = [];
|
|
this.counselingTasksCompleted = 0;
|
|
}
|
|
|
|
/**
|
|
* Get relationship crisis warning
|
|
*/
|
|
getRelationshipCrisisWarning() {
|
|
if (!this.player.isMarried) {
|
|
return null;
|
|
}
|
|
|
|
const spouse = this.game.npcs.getSpouse();
|
|
|
|
if (spouse.relationshipHearts <= 3) {
|
|
return {
|
|
severity: 'critical',
|
|
message: `Your relationship with ${spouse.name} is in CRISIS! (${spouse.relationshipHearts} ❤️)`,
|
|
suggestion: 'Visit the Lawyer Office for marriage counseling before it\'s too late!'
|
|
};
|
|
}
|
|
|
|
if (spouse.relationshipHearts <= 5) {
|
|
return {
|
|
severity: 'warning',
|
|
message: `Your relationship with ${spouse.name} is struggling. (${spouse.relationshipHearts} ❤️)`,
|
|
suggestion: 'Spend more time together and give gifts.'
|
|
};
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Check if can remarry after divorce
|
|
*/
|
|
canRemarry() {
|
|
if (this.player.isMarried) {
|
|
return { canRemarry: false, reason: 'Already married!' };
|
|
}
|
|
|
|
if (!this.hasEverDivorced) {
|
|
return { canRemarry: true };
|
|
}
|
|
|
|
// Must wait 28 days (4 weeks) after divorce to remarry
|
|
const lastDivorce = this.divorceHistory[this.divorceHistory.length - 1];
|
|
const daysSinceDivorce = this.game.time.currentDate - lastDivorce.date;
|
|
|
|
if (daysSinceDivorce < 28) {
|
|
return {
|
|
canRemarry: false,
|
|
reason: `Must wait ${28 - daysSinceDivorce} more days after divorce.`
|
|
};
|
|
}
|
|
|
|
return { canRemarry: true };
|
|
}
|
|
|
|
/**
|
|
* Get office UI data
|
|
*/
|
|
getOfficeUIData() {
|
|
return {
|
|
isUnlocked: this.isUnlocked,
|
|
lawyer: this.lawyer,
|
|
isMarried: this.player.isMarried,
|
|
spouse: this.player.isMarried ? this.game.npcs.getSpouse() : null,
|
|
divorceCost: this.divorceCost,
|
|
moneyLossPercent: this.hasPrenup ? 10 : 25,
|
|
hasPrenup: this.hasPrenup,
|
|
prenupCost: this.prenupCost,
|
|
counselingCost: this.counselingCost,
|
|
counselingInProgress: this.counselingInProgress,
|
|
counselingTasks: this.counselingTasks,
|
|
divorceHistory: this.divorceHistory,
|
|
crisisWarning: this.getRelationshipCrisisWarning()
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Update (check for auto-unlock)
|
|
*/
|
|
update() {
|
|
if (!this.isUnlocked) {
|
|
this.checkAutoUnlock();
|
|
}
|
|
}
|
|
}
|
|
|
|
|