import type { CommandHandler } from '../server/MessageDispatcher.js';
import { handleStart, handleStop, handleRestart, handleStartNewLife, handleSpeed, handleResetSpeed } from './gameControl.js';
import { handleCharacterSetup, handleDeviceToken, handleLiveActivityEnded, handleLiveActivityToken } from './character.js';
import { handleApplyExtracurricular, handleQuitExtracurricular, handleApplyJob, handleQuitJob, handleQuitHabit, handleStopQuitHabit, handleGetExtracurriculars, handleFocusUpdate, handleSetSpendingHabits, handleRetire } from './activities.js';
import { handleConversation, handleRetrievePerson, handleMarkRead } from './conversations.js';
import { handlePurchaseItem, handlePurchaseInAppItem, handlePurchaseEnergyRefill, handlePurchaseTimeSkip, handleGetEnergyTiers, handleGetTimeSkipTiers } from './purchases.js';
import { handleGetAchievements, handleAcknowledgeAchievement, handleGetDailyRewards, handleClaimDailyReward, handleGetDailyRewardState, handleGetDailyQuests, handleClaimQuestReward, handleClaimEvent, handleTutorialStepComplete, handleCompleteOnboarding, handleTooltipSeen } from './retention.js';
import { handleRomance, handleDateNight, handleBreakUp, handleDivorce, handlePartnerGift, handleGetSwipeCharacter, handleSwipeMatch, handlePropose, handleMarry, handleStartDate, handleGetDateIdeas, handleRelationshipEventResponse, handleDateMiniGameResponse } from './romance.js';
import { handleExportData, handleDeleteAccount, handleCancelAccountDeletion, handleGetStatistics } from './data.js';
import { handleQuestionEvent, handleEventResponse, handleGenericEvent } from './events.js';
import { handleDebugSetup, handleDebugGrant } from './debug.js';
import { handlePerformActivity } from './performActivity.js';

export const COMMAND_REGISTRY: Record<string, CommandHandler> = {
  // Game control - WebSocketServer routes {type: "command", message: "start"} directly to 'start'
  'start': handleStart,
  'stop': handleStop,
  'restart': handleRestart,
  'startNewLife': handleStartNewLife,
  'speed': handleSpeed,
  'resetSpeed': handleResetSpeed,

  // Event responses
  'questionEvent': handleQuestionEvent,
  'eventResponse': handleEventResponse,

  // Character
  'characterSetup': handleCharacterSetup,
  'deviceToken': handleDeviceToken,
  'liveActivityToken': handleLiveActivityToken,
  'liveActivityEnded': handleLiveActivityEnded,

  // Activities & Jobs
  'getExtraCurriculars': handleGetExtracurriculars,
  'applyForExtracurricular': handleApplyExtracurricular,
  'quitExtracurricular': handleQuitExtracurricular,
  'focusUpdate': handleFocusUpdate,
  'performActivity': handlePerformActivity,
  'applyForJob': handleApplyJob,
  'quitJob': handleQuitJob,
  'setSpendingHabits': handleSetSpendingHabits,
  'retire': handleRetire,
  'quitHabit': handleQuitHabit,
  'stopQuitHabit': handleStopQuitHabit,
  'conversation': handleConversation,
  'retrievePerson': handleRetrievePerson,
  'markConversationAsRead': handleMarkRead,
  'purchaseItem': handlePurchaseItem,
  'purchaseInAppItem': handlePurchaseInAppItem,
  'purchaseEnergyRefill': handlePurchaseEnergyRefill,
  'purchaseTimeSkip': handlePurchaseTimeSkip,
  'getEnergyRefillTiers': handleGetEnergyTiers,
  'getTimeSkipTiers': handleGetTimeSkipTiers,
  'getAchievements': handleGetAchievements,
  'acknowledgeAchievement': handleAcknowledgeAchievement,
  'getDailyRewards': handleGetDailyRewards,
  'claimDailyReward': handleClaimDailyReward,
  'getDailyRewardState': handleGetDailyRewardState,
  'getDailyQuests': handleGetDailyQuests,
  'claimQuestReward': handleClaimQuestReward,
  'claimEvent': handleClaimEvent,
  'tutorialStepComplete': handleTutorialStepComplete,
  'completeOnboarding': handleCompleteOnboarding,
  'tooltipSeen': handleTooltipSeen,
  'debugSetup': handleDebugSetup,
  'debugGrant': handleDebugGrant,
  'romance': handleRomance,
  'dateNight': handleDateNight,
  'relationshipEventResponse': handleRelationshipEventResponse,
  'dateMiniGameResponse': handleDateMiniGameResponse,
  'startDate': handleStartDate,
  'getDateIdeas': handleGetDateIdeas,
  'breakUp': handleBreakUp,
  'divorce': handleDivorce,
  'propose': handlePropose,
  'marry': handleMarry,
  'partnerGift': handlePartnerGift,
  'getSwipeCharacter': handleGetSwipeCharacter,
  'swipeMatch': handleSwipeMatch,
  'exportData': handleExportData,
  'deleteAccount': handleDeleteAccount,
  'cancelAccountDeletion': handleCancelAccountDeletion,
  'getPlayerStatistics': handleGetStatistics,
};

export { handleGenericEvent };
