Header Ads Widget

Responsive Advertisement

igi game

import React, { useState, useCallback } from 'react'; import { Terminal } from './components/Terminal'; import { SatelliteView } from './components/SatelliteView'; import { StatusHUD } from './components/StatusHUD'; import { gameMaster } from './services/gameMaster'; import { GameState, LogEntry } from './types'; import { Radio, Play, Skull, Trophy } from 'lucide-react'; const INITIAL_STATE: GameState = { health: 100, ammo: 150, // High ammo for AK-47 alarmLevel: 0, stealth: false, location: 'Island 3 Approach', missionStatus: 'BRIEFING', inventory: ['AK-47', 'Knife', 'Map'], logs: [], turnCount: 0, enemyStatus: 'CALM', enemiesRemaining: 50 }; const SAMPLE_COMMANDS = [ "Run towards the Camp", "Fire AK-47 burst at guards", "Reload weapon", "Search Lab for Medicine", "Get to the Helicopter" ]; const App: React.FC = () => { const [gameState, setGameState] = useState(INITIAL_STATE); const [inputCommand, setInputCommand] = useState(''); const [isLoading, setIsLoading] = useState(false); const [missionReady, setMissionReady] = useState(false); const addLog = useCallback((source: LogEntry['source'], message: string) => { const newLog: LogEntry = { id: crypto.randomUUID(), source, message, timestamp: new Date().toLocaleTimeString([], { hour12: false, hour: "2-digit", minute: "2-digit", second: "2-digit" }) }; setGameState(prev => ({ ...prev, logs: [...prev.logs, newLog] })); }, []); const initializeMission = async () => { if (isLoading) return; setIsLoading(true); addLog('SYSTEM', 'GPS UPLINK ESTABLISHED...'); await new Promise(r => setTimeout(r, 1000)); const { briefing, location } = await gameMaster.generateMissionBriefing(); setGameState(prev => ({ ...prev, missionStatus: 'ACTIVE', location: location, logs: [] // Clear init logs })); addLog('HQ', `Agent, we're approaching the drop zone. Gear up.`); addLog('HQ', briefing); addLog('SYSTEM', `WEAPON LIVE: AK-47. 50 TANGOS IN AREA.`); setMissionReady(true); setIsLoading(false); }; const handleCommandSubmit = async (e?: React.FormEvent) => { e?.preventDefault(); if (!inputCommand.trim() || isLoading || gameState.missionStatus !== 'ACTIVE') return; const command = inputCommand; setInputCommand(''); setIsLoading(true); addLog('YOU', command); const result = await gameMaster.processTurn(gameState, command); setGameState(prev => { let newHealth = prev.health + result.healthDelta; let newAlarm = Math.max(0, Math.min(100, prev.alarmLevel + result.alarmDelta)); let newAmmo = Math.max(0, prev.ammo + result.ammoDelta); let newEnemies = Math.max(0, prev.enemiesRemaining - (result.enemiesDefeated || 0)); // Cap health newHealth = Math.min(100, newHealth); let newStatus = prev.missionStatus; if (newHealth <= 0) newStatus = 'FAILED'; else if (result.isMissionSuccess) newStatus = 'SUCCESS'; let newInventory = [...prev.inventory]; if (result.narrative.toLowerCase().includes("medicine") && !newInventory.includes("Medicine")) { newInventory.push("Medicine"); } return { ...prev, health: newHealth, ammo: newAmmo, alarmLevel: newAlarm, enemyStatus: result.enemyStatus, location: result.newLocation, missionStatus: newStatus, turnCount: prev.turnCount + 1, enemiesRemaining: newEnemies, inventory: newInventory }; }); addLog('SYSTEM', result.narrative); if (result.healthDelta < 0) { addLog('SYSTEM', `WARNING: ARMOR BREACH DETECTED (${result.healthDelta} HP)`); } if (result.isGameOver || (gameState.health + result.healthDelta) <= 0) { addLog('HQ', 'VITAL SIGNS FLATLINED. AGENT DOWN.'); } if (result.isMissionSuccess) { addLog('HQ', 'Package secured. Excellent work, Agent. Coming in for extraction.'); } setIsLoading(false); }; if (!missionReady) { return (

PROJECT I.G.I.

SEASON 1: ISLAND STRIKE

> TARGET: ISLAND RESEARCH FACILITY

> OBJECTIVE: RETRIEVE MEDICINE

> HOSTILES: 50+ (ARMED WITH AK-47)

> EXTRACTION: HELICOPTER

TACTICAL SIMULATION
); } const isGameOver = gameState.missionStatus === 'FAILED' || gameState.missionStatus === 'SUCCESS'; return (
IGI COMMAND
ISLAND OPS | LIVE COMBAT
TACTICAL OPTIONS
{SAMPLE_COMMANDS.map((cmd, idx) => ( ))}
> setInputCommand(e.target.value)} placeholder={isGameOver ? "SIGNAL LOST" : "What do you do?"} className="flex-1 bg-transparent border-b border-[#33ff33]/50 text-[#33ff33] focus:outline-none focus:border-[#33ff33] py-2 font-mono" autoFocus disabled={isGameOver || isLoading} />
{isGameOver && (
{gameState.missionStatus === 'FAILED' ? (

KIA - MISSION FAILED

You were overwhelmed by enemy fire.

) : (

EXTRACTION SUCCESSFUL

You secured the medicine and neutralized the island.

)}
)}
); }; export default App;

Post a Comment

0 Comments