import { useState, useEffect, useRef } from 'react';
export default function TerminalBreach() {
// Game state
const [gameState, setGameState] = useState({
currentNode: 'start',
inventory: [],
flags: {
knowsAboutCEO: false,
hasDecryptionKey: false,
trackedMoney: false,
contactedWhistleblower: false,
hasServerAccess: false,
policeAlerted: false,
foundBackdoor: false,
securityBypassed: false,
identityCompromised: false,
trustLevel: 0, // -10 to 10 scale
},
history: [],
ending: null,
});
const [displayText, setDisplayText] = useState('');
const [isTyping, setIsTyping] = useState(false);
const [showChoices, setShowChoices] = useState(false);
const [gameOver, setGameOver] = useState(false);
const terminalRef = useRef(null);
const typingSpeed = 20; // ms per character
// Sound effects
const playSoundEffect = (type) => {
// In a real implementation, this would play actual sound effects
console.log(`Playing sound: ${type}`);
};
// Scroll to bottom of terminal when content updates
useEffect(() => {
if (terminalRef.current) {
terminalRef.current.scrollTop = terminalRef.current.scrollHeight;
}
}, [displayText, showChoices]);
// Story nodes - this contains all the game content
const storyNodes = {
// Starting point
'start': {
text: "TERMINAL CONNECTION ESTABLISHED\n\n> WELCOME TO THE NETWORK\n> SECURITY CLEARANCE: UNAUTHORIZED\n> INTRUSION DETECTION: BYPASSED\n\nYou've successfully breached the outer firewall of Nexus Dynamics, a multinational tech corporation rumored to be involved in illegal data harvesting. Your anonymous client has hired you to find evidence of their wrongdoing, but warned that powerful people will do anything to keep this hidden.\n\nYour terminal glows in the darkness of your apartment. Where do you begin?",
choices: [
{ text: "Access employee directory to find potential targets", nextNode: 'employee_directory' },
{ text: "Probe for vulnerabilities in their financial database", nextNode: 'financial_database' },
{ text: "Search for information about the company's leadership", nextNode: 'company_leadership' },
{ text: "Attempt to locate internal communication servers", nextNode: 'communication_servers' }
]
},
// Level 1 nodes - First major choices
'employee_directory': {
text: "You navigate through several security layers and access the employee directory. Thousands of names scroll by on your screen. You notice the system is monitoring active searches.\n\nA pattern catches your eye - several employees from the data analytics department have been terminated within the past month. No reason listed.",
choices: [
{ text: "Investigate the terminated employees", nextNode: 'terminated_employees' },
{ text: "Look for employees with highest security clearance", nextNode: 'security_clearance' },
{ text: "Search for IT administrators who might have system access", nextNode: 'it_admins' },
{ text: "Back out and try a different approach", nextNode: 'start' }
]
},
'financial_database': {
text: "The financial database is heavily encrypted, but you manage to find a vulnerability in their authentication protocol. Transaction logs appear on your screen - most seem legitimate, but there's an unusual pattern of transfers to an offshore account labeled only as 'Project Oracle'.\n\nThe transfers occur monthly and are approved directly by the CFO.",
choices: [
{ text: "Track the money trail of Project Oracle", nextNode: 'money_trail', setFlag: { trackedMoney: true } },
{ text: "Look for more information about the CFO", nextNode: 'cfo_investigation' },
{ text: "Try to decrypt more details about Project Oracle", nextNode: 'project_oracle' },
{ text: "This seems too risky - try another approach", nextNode: 'start' }
]
},
'company_leadership': {
text: "You pull up profiles of Nexus Dynamics' executive team. CEO Alexander Mercer founded the company 15 years ago. His public persona is spotless - philanthropist, tech visionary, family man.\n\nAs you dig deeper, you find unusual gaps in his history. Before founding Nexus, there's almost no record of him for a three-year period.",
choices: [
{ text: "Investigate Mercer's missing years", nextNode: 'mercer_past', setFlag: { knowsAboutCEO: true } },
{ text: "Look into Mercer's current projects and communications", nextNode: 'mercer_projects' },
{ text: "Research other executives who might be involved", nextNode: 'other_executives' },
{ text: "This is a dead end - try another approach", nextNode: 'start' }
]
},
'communication_servers': {
text: "You locate the internal communication servers. They're using an enterprise messaging system with end-to-end encryption. However, you notice a potential exploit in their authentication system.\n\nAfter several tense minutes, you're in. Thousands of conversations between employees flow across your screen.",
choices: [
{ text: "Search for messages mentioning 'data harvesting'", nextNode: 'data_harvesting_messages' },
{ text: "Look for disgruntled employees who might be whistleblowers", nextNode: 'potential_whistleblowers' },
{ text: "Monitor executive communications", nextNode: 'executive_comms' },
{ text: "This is too much data - try another approach", nextNode: 'start' }
]
},
// Level 2 nodes - some examples, the full game would have many more
'terminated_employees': {
text: "You dig into the records of the terminated employees. All five worked in data analytics, specifically on something called 'Project Oracle'. Their termination notices cite 'violation of ethics policy' but provide no details.\n\nOne name stands out: Dr. Eliza Chen, former Head of Ethical AI. Her personal files show she was raising concerns about a project just days before her termination.",
choices: [
{ text: "Try to contact Dr. Chen", nextNode: 'contact_chen', setFlag: { contactedWhistleblower: true } },
{ text: "Look deeper into Project Oracle", nextNode: 'project_oracle_deep' },
{ text: "Check if other departments had similar terminations", nextNode: 'other_terminations' },
{ text: "This might trigger alerts - try another approach", nextNode: 'employee_directory' }
]
},
'security_clearance': {
text: "You identify employees with top-level security clearance. Most are executives or senior security personnel, but one name seems out of place: Julian Weiss, a mid-level systems administrator with unexplained access to restricted servers.\n\nHis personnel file shows he was hired directly by CEO Alexander Mercer, bypassing normal HR protocols.",
choices: [
{ text: "Investigate Julian Weiss's background", nextNode: 'weiss_background' },
{ text: "Monitor Weiss's system activities", nextNode: 'weiss_activities' },
{ text: "Look into his connection with CEO Mercer", nextNode: 'weiss_mercer_connection', setFlag: { knowsAboutCEO: true } },
{ text: "This person might detect your intrusion - try another approach", nextNode: 'employee_directory' }
]
},
'money_trail': {
text: "You follow the money trail for Project Oracle. The offshore account connects to a network of shell companies, eventually leading to a research facility in Eastern Europe not listed in any of Nexus's public records.\n\nFinancial documents show massive investments in 'predictive behavioral algorithms' and 'neural response testing'. There's also a recurring expense labeled 'subject compensation'.",
choices: [
{ text: "Hack into the research facility's systems", nextNode: 'research_facility' },
{ text: "Investigate what 'subject compensation' means", nextNode: 'subject_compensation' },
{ text: "Look for connections between this facility and other Nexus projects", nextNode: 'facility_connections' },
{ text: "Download the financial evidence", nextNode: 'download_financial_evidence' }
]
},
'mercer_past': {
text: "Digging into Mercer's past requires breaking into some highly secured archives. After bypassing several security layers, you discover the truth: during those missing years, Mercer worked for a classified government program developing mass surveillance technology.\n\nThe program was officially shut down after ethical concerns were raised, but your findings suggest Mercer may have continued the work privately through Nexus Dynamics.",
choices: [
{ text: "Look for current surveillance projects at Nexus", nextNode: 'surveillance_projects' },
{ text: "Search for other former government colleagues at Nexus", nextNode: 'government_colleagues' },
{ text: "Investigate who shut down the original program", nextNode: 'program_shutdown' },
{ text: "This is explosive information - download the evidence", nextNode: 'download_mercer_evidence' }
]
},
'potential_whistleblowers': {
text: "You search for keywords indicating employee dissatisfaction or ethical concerns. Several conversations emerge, but one thread between junior developers is particularly alarming.\n\nThey discuss a data harvesting system that's been deployed without user consent, collecting psychological profiles from Nexus's consumer products. One developer, Maya Patel, seems particularly troubled by the ethical implications.",
choices: [
{ text: "Contact Maya Patel securely", nextNode: 'contact_maya', setFlag: { contactedWhistleblower: true } },
{ text: "Gather more details about the harvesting system", nextNode: 'harvesting_system' },
{ text: "Check if any employees have reported concerns officially", nextNode: 'official_reports' },
{ text: "This conversation might be monitored - try another approach", nextNode: 'communication_servers' }
]
},
// Some mid-game nodes
'contact_chen': {
text: "Using information from her personnel file, you manage to establish a secure connection to Dr. Chen. She's initially suspicious but opens up when you mention Project Oracle.\n\n\"They're using predictive algorithms to manipulate people's behavior without consent. The technology was originally developed to help people with addiction, but Mercer saw its potential for marketing... and more. I have proof, but they're watching me.\"",
choices: [
{ text: "Offer to help her release the evidence publicly", nextNode: 'public_evidence', modifyFlag: { trustLevel: +2 } },
{ text: "Ask her to send you the proof directly", nextNode: 'request_proof', modifyFlag: { trustLevel: -1 } },
{ text: "Suggest meeting in person to exchange information", nextNode: 'suggest_meeting', modifyFlag: { trustLevel: +1 } },
{ text: "Ask about other employees who might help", nextNode: 'other_allies', modifyFlag: { trustLevel: +1 } }
]
},
'project_oracle_deep': {
text: "You breach the secure servers containing Project Oracle data. What you find is disturbing: Nexus has been harvesting psychological profiles from millions of users through their products, without consent.\n\nThe AI system predicts and influences user behavior through subtle manipulations in their software interfaces. Internal reports boast of a 74% success rate in 'behavior modification targets'.",
choices: [
{ text: "Download the evidence of illegal data harvesting", nextNode: 'download_oracle_evidence' },
{ text: "Look for the names of project leaders", nextNode: 'oracle_leadership' },
{ text: "Check if any government agencies are involved", nextNode: 'government_involvement' },
{ text: "Try to access the actual prediction algorithms", nextNode: 'prediction_algorithms', setFlag: { hasDecryptionKey: true } }
]
},
'research_facility': {
text: "Breaking into the research facility's network is challenging, but you manage to access their security cameras. What you see shocks you: dozens of people in what appear to be testing rooms, using Nexus products while their responses are monitored.\n\nInternal documents refer to them as 'participants', but their restricted movement suggests they might not be there voluntarily.",
choices: [
{ text: "Look for information about the test subjects", nextNode: 'test_subjects' },
{ text: "Check if this testing is legal", nextNode: 'testing_legality' },
{ text: "Try to contact someone inside the facility", nextNode: 'facility_contact', setFlag: { securityBypassed: true } },
{ text: "This is enough evidence - download everything", nextNode: 'download_facility_evidence' }
]
},
// Some late-game nodes
'download_oracle_evidence': {
text: "You begin downloading the Project Oracle files. Progress bar: 67%...\n\nSuddenly, a security alert flashes on your screen. They've detected your intrusion! The system is tracing your connection.\n\nProgress: 89%... 94%... 100%. Download complete, but you need to act fast.",
choices: [
{ text: "Activate your emergency exit protocol", nextNode: 'emergency_exit', setFlag: { hasServerAccess: true } },
{ text: "Plant false trails to confuse the trace", nextNode: 'false_trails', setFlag: { securityBypassed: true } },
{ text: "Attempt to corrupt their security logs", nextNode: 'corrupt_logs' },
{ text: "Shut down immediately and go dark", nextNode: 'go_dark', setFlag: { identityCompromised: false } }
]
},
'surveillance_projects': {
text: "You uncover details about Nexus's current surveillance capabilities. Project Oracle is just the tip of the iceberg. They've developed systems that can predict political leanings, personal crises, and major life decisions with frightening accuracy.\n\nMore concerning, you find a client list - including authoritarian governments who have purchased customized versions of this technology.",
choices: [
{ text: "Download the client list and project details", nextNode: 'download_surveillance_evidence' },
{ text: "Look for technical vulnerabilities in the surveillance systems", nextNode: 'surveillance_vulnerabilities', setFlag: { foundBackdoor: true } },
{ text: "Investigate which governments are involved", nextNode: 'government_clients' },
{ text: "This is too dangerous - exit and anonymously tip off journalists", nextNode: 'journalist_tipoff', setFlag: { policeAlerted: true } }
]
},
'contact_maya': {
text: "You establish a secure connection with Maya Patel. She's terrified but determined to expose what's happening.\n\n\"They're collecting data that goes way beyond what users consented to - emotional responses, psychological triggers, even using device cameras to analyze micro-expressions. I've been documenting everything, but I think they're onto me. Yesterday my apartment was searched while I was at work.\"",
choices: [
{ text: "Offer to help her escape with the evidence", nextNode: 'help_maya_escape', modifyFlag: { trustLevel: +3 } },
{ text: "Ask her to transfer all evidence to you immediately", nextNode: 'transfer_evidence', modifyFlag: { trustLevel: -2 } },
{ text: "Suggest she report this to authorities", nextNode: 'suggest_authorities', modifyFlag: { trustLevel: -1 }, setFlag: { policeAlerted: true } },
{ text: "Create a secure dead drop for information exchange", nextNode: 'create_deaddrop', modifyFlag: { trustLevel: +2 } }
]
},
// Some ending path nodes
'emergency_exit': {
text: "You activate your emergency protocols, severing connections and deploying countermeasures. For now, you've escaped detection, but Nexus will be on high alert.\n\nReviewing the Project Oracle files, you have solid evidence of illegal data harvesting, psychological manipulation, and corporate espionage. Your anonymous client will be pleased, but you wonder if there's more to this story.",
choices: [
{ text: "Contact your client with the evidence", nextNode: gameState.flags.contactedWhistleblower ? 'ending_whistleblower' : 'ending_partial' },
{ text: "Take the evidence public yourself", nextNode: 'public_release', setFlag: { policeAlerted: true } },
{ text: "Dig deeper despite the increased risk", nextNode: 'final_dive' },
{ text: "Sell the information to the highest bidder", nextNode: 'ending_mercenary' }
]
},
'help_maya_escape': {
text: "You work with Maya to create a secure exit strategy. Using your hacking skills, you clear her digital trail and provide her with a new identity. She transfers all her evidence to you - it's even more damning than you expected.\n\nThe files show Nexus has been running psychological experiments on users without consent, developing techniques to influence behavior from purchasing decisions to political views.",
choices: [
{ text: "Release all evidence to journalists and authorities", nextNode: 'ending_hero', setFlag: { policeAlerted: true } },
{ text: "Confront CEO Mercer with the evidence", nextNode: gameState.flags.knowsAboutCEO ? 'mercer_confrontation' : 'ending_trapped' },
{ text: "Keep your involvement anonymous and let Maya be the whistleblower", nextNode: 'ending_shadow' },
{ text: "Use the evidence to blackmail Nexus executives", nextNode: 'ending_blackmail' }
]
},
'final_dive': {
text: "Despite the extreme risk, you dive deeper into Nexus's most secure servers. What you find connects all the pieces: Project Oracle isn't just about consumer manipulation - it's a prototype for a mass social control system.\n\nThe technology is being prepared for deployment through popular social media platforms, with the capability to influence elections, suppress dissent, and shape public opinion on an unprecedented scale.",
choices: [
{ text: "Release everything to the public immediately", nextNode: 'ending_whistleblower', setFlag: { policeAlerted: true } },
{ text: "Sabotage the project from within", nextNode: gameState.flags.hasDecryptionKey ? 'ending_saboteur' : 'ending_caught' },
{ text: "Collect more evidence before going public", nextNode: gameState.flags.identityCompromised ? 'ending_caught' : 'ending_whistleblower' },
{ text: "Disappear with the evidence as insurance", nextNode: 'ending_ghost' }
]
},
'mercer_confrontation': {
text: "You establish direct contact with CEO Alexander Mercer, presenting evidence of his illegal activities. There's a long pause before he responds.\n\n\"I'm impressed. Few have gotten this far. But you don't understand what's at stake. This technology is necessary. Humanity needs guidance. Join me, and you'll have resources beyond imagination. Fight me, and... well, you know too much about me to think that ends well.\"",
choices: [
{ text: "Accept his offer to understand from the inside", nextNode: 'ending_insider' },
{ text: "Reject the offer and release all evidence", nextNode: 'ending_martyr', setFlag: { policeAlerted: true } },
{ text: "Pretend to accept while planning to gather more evidence", nextNode: gameState.flags.securityBypassed ? 'ending_double_agent' : 'ending_caught' },
{ text: "Threaten him with a dead man's switch for your safety", nextNode: gameState.flags.hasServerAccess ? 'ending_standoff' : 'ending_eliminated' }
]
},
// Endings
'ending_whistleblower': {
text: "You release all evidence to journalists, authorities, and online platforms simultaneously. The story explodes globally. Nexus stock plummets, and government investigations are launched in multiple countries.\n\nYour identity remains hidden, but your actions have changed the world. Project Oracle is shut down, and new legislation is drafted to prevent similar abuses. Dr. Chen and other whistleblowers are vindicated.\n\nIn the shadows, you wonder if you've made a difference or just delayed the inevitable in a world increasingly shaped by algorithms and those who control them.",
ending: "THE WHISTLEBLOWER: You exposed the truth to the world.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_caught': {
text: "You miscalculated. Nexus security teams trace your connection and identify you. Within hours, your systems are compromised, your evidence corrupted, and your reputation destroyed through fabricated criminal records.\n\nAs authorities close in on your location, you realize too late that you underestimated the resources at Mercer's disposal. Your last act is to wipe your drives before they breach your door.\n\nProject Oracle continues unimpeded, its security now stronger than ever. Your name becomes a cautionary tale among hackers.",
ending: "CAUGHT IN THE WEB: You underestimated your opponent.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_hero': {
text: "Working with Maya and Dr. Chen, you compile an airtight case against Nexus Dynamics. When the evidence is released, it causes an international sensation. Congressional hearings are called, and Mercer and his executives face criminal charges.\n\nYou reveal your identity, becoming the face of digital ethics in the modern age. It's a dangerous position, but your thorough documentation leaves Nexus no room to discredit you.\n\nYour testimony helps shape new international laws on data privacy and algorithmic transparency. The Oracle Project is dismantled, its technology placed under ethical oversight.",
ending: "THE DIGITAL HERO: You stood in the light for what was right.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_mercenary': {
text: "You approach Nexus's competitors with your findings, starting a bidding war for the intelligence. Eventually, you sell the information to both rival corporations and government agencies interested in the technology.\n\nYour bank accounts swell, and you establish a new identity in a country without extradition. The public never learns the full truth about Project Oracle, but your financial future is secure.\n\nOccasionally, you see news about Nexus's continued success and wonder if you made the right choice. But business is business, and in the digital world, information is just another commodity.",
ending: "THE MERCENARY: You profited from the information.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_saboteur': {
text: "Using your deep access and the decryption keys, you implement a subtle but devastating sabotage of Project Oracle. Rather than shutting it down obviously, you introduce subtle flaws in its predictive algorithms.\n\nOver the following months, the system's accuracy degrades. Nexus's clients lose faith in the technology, and internal investigations can't identify the ingenious corruption in the code.\n\nFrom the shadows, you watch as Project Oracle is eventually abandoned as unreliable. No one knows your name, but you've changed the course of history with a few elegant lines of code.",
ending: "THE SABOTEUR: You destroyed the system from within.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_ghost': {
text: "You take the evidence and disappear completely. Using your hacking skills, you create a new identity and relocate to a remote location, the digital trail behind you erased.\n\nThe evidence becomes your insurance policy. A dead man's switch ensures it will be released if anything happens to you. This knowledge keeps you safe from Nexus's reach.\n\nYears pass. Occasionally you anonymously leak small pieces of information, enough to keep Nexus in check without revealing your full hand. You live in the shadows, the ghost with the power to bring down an empire.",
ending: "THE GHOST: You disappeared with the ultimate insurance policy.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_insider': {
text: "You accept Mercer's offer, curious about seeing Project Oracle from the inside. He welcomes you into the inner circle of Nexus, revealing the full scope of his vision.\n\nThe technology isn't just for profit - it's his solution to humanity's self-destructive tendencies. By subtly guiding human behavior, he believes he can avert climate disaster, prevent wars, and guide society toward a better future.\n\nYears pass, and you become integral to refining the system, adding ethical guardrails while maintaining its power. You're never sure if you've compromised your principles or found a pragmatic middle ground in a complex world.",
ending: "THE INSIDER: You joined the system to change it from within.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_double_agent': {
text: "You pretend to accept Mercer's offer while secretly gathering more evidence. For months, you play the role of the converted hacker, gaining his trust and access to Nexus's most sensitive projects.\n\nWhen you finally have everything, you release it all - not just Project Oracle, but Mercer's entire network of influence, government connections, and future plans.\n\nAs Nexus collapses and Mercer faces prosecution, you disappear. Some say you were eliminated by former Nexus security, others that you live under a new identity. The truth remains known only to you.",
ending: "THE DOUBLE AGENT: You played the long game and won.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_partial': {
text: "You deliver the evidence to your anonymous client as contracted. They thank you and transfer the agreed payment. Your job is done.\n\nWeeks later, you see news about minor regulatory actions against Nexus for data privacy violations. The penalties are insignificant, and Project Oracle continues under a different name.\n\nYou realize your client may have been seeking only leverage for a competitor, not justice. The full truth remains hidden, and you're left wondering what more you could have done with the information you found.",
ending: "THE CONTRACTOR: You completed the job, nothing more.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_eliminated': {
text: "Your threat against Mercer backfires. Without proper safeguards in place, you underestimated his resources and reach.\n\nWithin days, your systems are compromised, your evidence corrupted, and your reputation destroyed through fabricated criminal records. Professional operatives track your location.\n\nYou attempt to flee, but it's too late. Your disappearance is never connected to Nexus Dynamics. Project Oracle continues, now with enhanced security protocols based on analyzing how you breached their systems.",
ending: "ELIMINATED: You threatened the wrong person without proper protection.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_standoff': {
text: "Your dead man's switch is sophisticated and credible. Mercer recognizes he can't move against you without risking exposure.\n\nA tense equilibrium develops. You don't release the evidence, and he doesn't pursue you. Occasionally, you notice subtle changes in Project Oracle's implementation - ethical guardrails being added, the most invasive features scaled back.\n\nYou've reached a stalemate with one of the most powerful people in the world. Neither of you has won, but perhaps humanity has, as the worst potential abuses of the technology are kept in check by your mutual assured destruction.",
ending: "THE STANDOFF: You and Mercer keep each other in check.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_shadow': {
text: "You remain in the shadows, providing Maya with secure channels to release the evidence while keeping your involvement hidden. She becomes the public face of the scandal, while your technical expertise ensures the evidence can't be discredited.\n\nNexus attempts to paint Maya as a disgruntled employee, but the evidence is too solid to dismiss. Government investigations begin, and Project Oracle is suspended pending review.\n\nYou watch from afar, your identity still secure. In hacker forums, your unnamed presence becomes legendary - the shadow who helped bring light to the darkness.",
ending: "THE SHADOW: You enabled others to stand in the light.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_martyr': {
text: "You reject Mercer's offer and immediately release all evidence to the public. The impact is seismic - Nexus stock collapses, and government investigations begin worldwide.\n\nHowever, Mercer's resources are vast. Before authorities can reach him, his security team tracks you down. Your systems are destroyed, and you are forced to flee.\n\nThough you live as a fugitive, your actions have changed the world. Project Oracle is dismantled, and new legislation bears the unofficial name of \"The Hacker's Law\" in underground circles. Your sacrifice was not in vain.",
ending: "THE MARTYR: You sacrificed your freedom for the truth.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_blackmail': {
text: "You approach key Nexus executives with carefully selected evidence, making it clear that you have much more secured away. Your demands are specific: substantial payment, and verifiable changes to Project Oracle's implementation.\n\nTo your surprise, they comply. Money flows into your offshore accounts, and you observe as the most unethical aspects of the project are quietly discontinued. You've found leverage over one of the most powerful corporations in the world.\n\nYou live luxuriously but cautiously, knowing that your insurance files are the only thing keeping you alive. It's not justice, but it's a pragmatic victory in a morally complex digital battlefield.",
ending: "THE BLACKMAILER: You found leverage and used it.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
},
'ending_trapped': {
text: "Your attempt to confront Mercer without understanding his background proves disastrous. He was prepared for threats, and his security team quickly traces your connection.\n\nRather than eliminating you, Mercer offers a choice: join Nexus as a security consultant or face prosecution. With your identity compromised and evidence of your illegal hacking clear, you have little choice.\n\nYou find yourself working for the very corporation you tried to expose, your skills now used to prevent others from discovering what you found. The irony is not lost on you as you strengthen the defenses around Project Oracle.",
ending: "THE CAPTURED HACKER: You became what you fought against.",
choices: [
{ text: "Play Again", nextNode: 'start', reset: true }
]
}
};
// Process a choice selection
const processChoice = (choice) => {
// Play selection sound
playSoundEffect('select');
// Update flags if needed
if (choice.setFlag) {
const newFlags = { ...gameState.flags };
Object.entries(choice.setFlag).forEach(([key, value]) => {
newFlags[key] = value;
});
setGameState(prev => ({ ...prev, flags: newFlags }));
}
// Modify flags if needed
if (choice.modifyFlag) {
const newFlags = { ...gameState.flags };
Object.entries(choice.modifyFlag).forEach(([key, value]) => {
if (typeof newFlags[key] === 'number') {
newFlags[key] += value;
}
});
setGameState(prev => ({ ...prev, flags: newFlags }));
}
// Add current node to history
const updatedHistory = [...gameState.history, gameState.currentNode];
// Reset game if needed
if (choice.reset) {
setGameState({
currentNode: choice.nextNode,
inventory: [],
flags: {
knowsAboutCEO: false,
hasDecryptionKey: false,
trackedMoney: false,
contactedWhistleblower: false,
hasServerAccess: false,
policeAlerted: false,
foundBackdoor: false,
securityBypassed: false,
identityCompromised: false,
trustLevel: 0,
},
history: [],
ending: null,
});
} else {
// Update game state with new node
setGameState(prev => ({
...prev,
currentNode: choice.nextNode,
history: updatedHistory,
ending: storyNodes[choice.nextNode].ending || null,
}));
}
// Check if game is over
if (storyNodes[choice.nextNode].ending) {
setGameOver(true);
playSoundEffect('ending');
}
// Reset display for new text
setDisplayText('');
setShowChoices(false);
// Start typing animation for new text
typeText(storyNodes[choice.nextNode].text);
};
// Typing animation effect
const typeText = (text) => {
setIsTyping(true);
let i = 0;
const typing = setInterval(() => {
setDisplayText(text.substring(0, i));
i++;
if (i > text.length) {
clearInterval(typing);
setIsTyping(false);
setShowChoices(true);
}
}, typingSpeed);
};
// Start the game when component mounts
useEffect(() => {
typeText(storyNodes.start.text);
playSoundEffect('start');
}, []);
return (
{/* Header */}
TERMINAL BREACH
import { useState, useEffect, useRef } from 'react';
export default function GeoGuessrGame() {
// Game state
const [currentRound, setCurrentRound] = useState(1);
const [totalScore, setTotalScore] = useState(0);
const [roundScore, setRoundScore] = useState(null);
const [gamePhase, setGamePhase] = useState('guessing'); // guessing, result, summary
const [selectedLocation, setSelectedLocation] = useState(null);
const [distance, setDistance] = useState(null);
const [gameOver, setGameOver] = useState(false);
const mapRef = useRef(null);
const markerRef = useRef(null);
const actualMarkerRef = useRef(null);
const lineRef = useRef(null);
// Location database with images and coordinates
const locations = [
{
id: 1,
name: "Eiffel Tower, Paris",
image: "https://images.unsplash.com/photo-1543349689-9a4d426bee8e?auto=format&fit=crop&q=80&w=1000",
lat: 48.8584,
lng: 2.2945,
hint: "This iconic iron structure is located in Western Europe"
},
{
id: 2,
name: "Machu Picchu, Peru",
image: "https://images.unsplash.com/photo-1526392060635-9d6019884377?auto=format&fit=crop&q=80&w=1000",
lat: -13.1631,
lng: -72.5450,
hint: "This ancient citadel sits high in the Andes mountains of South America"
},
{
id: 3,
name: "Sydney Opera House, Australia",
image: "https://images.unsplash.com/photo-1624138784614-87fd1b6528f8?auto=format&fit=crop&q=80&w=1000",
lat: -33.8568,
lng: 151.2153,
hint: "This performing arts center features distinctive sail-shaped shells"
},
{
id: 4,
name: "Taj Mahal, India",
image: "https://images.unsplash.com/photo-1564507592333-c60657eea523?auto=format&fit=crop&q=80&w=1000",
lat: 27.1751,
lng: 78.0421,
hint: "This white marble mausoleum is located in South Asia"
},
{
id: 5,
name: "Statue of Liberty, USA",
image: "https://images.unsplash.com/photo-1605130284535-11dd9eedc58a?auto=format&fit=crop&q=80&w=1000",
lat: 40.6892,
lng: -74.0445,
hint: "This copper statue stands on an island in North America"
},
{
id: 6,
name: "Great Wall of China",
image: "https://images.unsplash.com/photo-1508804185872-d7badad00f7d?auto=format&fit=crop&q=80&w=1000",
lat: 40.4319,
lng: 116.5704,
hint: "This ancient fortification stretches thousands of kilometers across East Asia"
},
{
id: 7,
name: "Colosseum, Rome",
image: "https://images.unsplash.com/photo-1552832230-c0197dd311b5?auto=format&fit=crop&q=80&w=1000",
lat: 41.8902,
lng: 12.4922,
hint: "This ancient amphitheater is located in Southern Europe"
},
{
id: 8,
name: "Christ the Redeemer, Brazil",
image: "https://images.unsplash.com/photo-1594387295585-34ba50b0b7a2?auto=format&fit=crop&q=80&w=1000",
lat: -22.9519,
lng: -43.2106,
hint: "This large statue of Jesus Christ overlooks a major South American city"
},
{
id: 9,
name: "Mount Fuji, Japan",
image: "https://images.unsplash.com/photo-1570459027562-4a916cc6113f?auto=format&fit=crop&q=80&w=1000",
lat: 35.3606,
lng: 138.7274,
hint: "This iconic volcano is the highest mountain in an East Asian island nation"
},
{
id: 10,
name: "Pyramids of Giza, Egypt",
image: "https://images.unsplash.com/photo-1503177119275-0aa32b3a9368?auto=format&fit=crop&q=80&w=1000",
lat: 29.9792,
lng: 31.1342,
hint: "These ancient structures are located in North Africa"
}
];
// Current location being guessed
const currentLocation = locations[currentRound - 1];
// Initialize map when component mounts
useEffect(() => {
// This would normally use a real map API like Google Maps or Leaflet
// For this example, we're simulating the map functionality
console.log("Map initialized");
return () => {
// Cleanup map resources
if (markerRef.current) markerRef.current = null;
if (actualMarkerRef.current) actualMarkerRef.current = null;
if (lineRef.current) lineRef.current = null;
};
}, []);
// Calculate distance between two points using Haversine formula
const calculateDistance = (lat1, lon1, lat2, lon2) => {
const R = 6371; // Radius of the earth in km
const dLat = deg2rad(lat2 - lat1);
const dLon = deg2rad(lon2 - lon1);
const a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2);
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
const distance = R * c; // Distance in km
return Math.round(distance);
};
const deg2rad = (deg) => {
return deg * (Math.PI/180);
};
// Calculate score based on distance
const calculateScore = (distance) => {
if (distance < 10) return 5000;
if (distance < 50) return 4000;
if (distance < 200) return 3000;
if (distance < 500) return 2000;
if (distance < 1000) return 1000;
if (distance < 2000) return 500;
return 0;
};
// Handle map click to make a guess
const handleMapClick = (event) => {
if (gamePhase !== 'guessing') return;
// In a real implementation, we would get lat/lng from the map click event
// For this example, we'll simulate a random click within a reasonable range
const lat = event.clientY / window.innerHeight * 180 - 90;
const lng = event.clientX / window.innerWidth * 360 - 180;
setSelectedLocation({ lat, lng });
};
// Submit guess and show result
const submitGuess = () => {
if (!selectedLocation) return;
const dist = calculateDistance(
selectedLocation.lat,
selectedLocation.lng,
currentLocation.lat,
currentLocation.lng
);
const score = calculateScore(dist);
setDistance(dist);
setRoundScore(score);
setTotalScore(totalScore + score);
setGamePhase('result');
};
// Move to next round
const nextRound = () => {
if (currentRound >= locations.length) {
setGameOver(true);
return;
}
setCurrentRound(currentRound + 1);
setSelectedLocation(null);
setDistance(null);
setRoundScore(null);
setGamePhase('guessing');
};
// Restart game
const restartGame = () => {
setCurrentRound(1);
setTotalScore(0);
setSelectedLocation(null);
setDistance(null);
setRoundScore(null);
setGamePhase('guessing');
setGameOver(false);
};
// Get score description
const getScoreDescription = (score) => {
if (score >= 4500) return "Amazing!";
if (score >= 3500) return "Excellent!";
if (score >= 2500) return "Great job!";
if (score >= 1500) return "Good guess!";
if (score >= 500) return "Not bad!";
return "Better luck next time!";
};
return (
{/* Simulated map - in a real implementation, this would be a proper map component */}
{selectedLocation && gamePhase === 'guessing' && (
)}
{gamePhase === 'result' && (
<>
{/* User's guess */}
{/* Actual location */}
{/* Line connecting the points */}
>
)}