|
| 1 | +const techPrefixes = [ |
| 2 | + "Monolito", |
| 3 | + "Cloud", |
| 4 | + "Data", |
| 5 | + "AI", |
| 6 | + "Crypto", |
| 7 | + "Serverless", |
| 8 | + "DevOps", |
| 9 | + "Kube", |
| 10 | + "Token", |
| 11 | + "Mainframe", |
| 12 | + "PHP", |
| 13 | + "Wordpress", |
| 14 | + "API", |
| 15 | + "CI", |
| 16 | + "Deploy", |
| 17 | + "Git", |
| 18 | + "Scrum", |
| 19 | + "Clave", |
| 20 | + "Front", |
| 21 | + "JS", |
| 22 | +]; |
| 23 | + |
| 24 | +const argentineSuffixes = [ |
| 25 | + "ify", |
| 26 | + "App", |
| 27 | + "Tech", |
| 28 | + "AR", |
| 29 | + "Plus", |
| 30 | + "Max", |
| 31 | + "Soft", |
| 32 | + "verse", |
| 33 | + "Go", |
| 34 | + "pe", |
| 35 | + "udo", |
| 36 | + "ear", |
| 37 | + "izar", |
| 38 | + "ocha", |
| 39 | + "ardo", |
| 40 | + "ucha", |
| 41 | + "ón", |
| 42 | + ".ar", |
| 43 | +]; |
| 44 | + |
| 45 | +const argentineWords = [ |
| 46 | + "Choreo", |
| 47 | + "Curro", |
| 48 | + "Chamuyo", |
| 49 | + "Quilombo", |
| 50 | + "Asado", |
| 51 | + "Birra", |
| 52 | + "Mate", |
| 53 | + "Bondi", |
| 54 | + "Laburo", |
| 55 | + "Pibe", |
| 56 | + "Verso", |
| 57 | + "Factura", |
| 58 | + "AFIP", |
| 59 | + "CUIL", |
| 60 | + "Impuesto", |
| 61 | + "Tango", |
| 62 | + "Token", |
| 63 | +]; |
| 64 | + |
| 65 | + |
| 66 | +// DOM elements |
| 67 | +const generateBtn = document.getElementById('generate-btn'); |
| 68 | +const startupNameEl = document.getElementById('startup-name'); |
| 69 | +const timerDisplay = document.getElementById('timer-display'); |
| 70 | +const countdownNumber = document.getElementById('countdown-number'); |
| 71 | +const gameOverDisplay = document.getElementById('game-over'); |
| 72 | + |
| 73 | +// Game state |
| 74 | +let gameState = 'ready'; // 'ready', 'pitching', 'finished' |
| 75 | +let countdownInterval; |
| 76 | +let currentStartupName = ''; |
| 77 | +let usedNames = new Set(); |
| 78 | + |
| 79 | +// Utility functions |
| 80 | +const getRandomElement = (array) => { |
| 81 | + return array[Math.floor(Math.random() * array.length)]; |
| 82 | +}; |
| 83 | + |
| 84 | +const capitalizeFirst = (str) => { |
| 85 | + return str.charAt(0).toUpperCase() + str.slice(1); |
| 86 | +}; |
| 87 | + |
| 88 | +const generateUniqueStartupName = () => { |
| 89 | + let attempts = 0; |
| 90 | + let name; |
| 91 | + |
| 92 | + do { |
| 93 | + const prefix = getRandomElement(techPrefixes); |
| 94 | + const suffix = getRandomElement([...argentineSuffixes, ...argentineWords]); |
| 95 | + |
| 96 | + name = `${prefix}${suffix}`; |
| 97 | + |
| 98 | + attempts++; |
| 99 | + |
| 100 | + // Prevent infinite loop |
| 101 | + if (attempts > 100) { |
| 102 | + usedNames.clear(); |
| 103 | + break; |
| 104 | + } |
| 105 | + } while (usedNames.has(name)); |
| 106 | + |
| 107 | + usedNames.add(name); |
| 108 | + return name; |
| 109 | +}; |
| 110 | + |
| 111 | +const displayStartupName = (name) => { |
| 112 | + startupNameEl.innerHTML = `<p>${name}</p>`; |
| 113 | + startupNameEl.classList.add('active', 'fade-in'); |
| 114 | + |
| 115 | + // Remove animation class after animation completes |
| 116 | + setTimeout(() => { |
| 117 | + startupNameEl.classList.remove('fade-in'); |
| 118 | + }, 500); |
| 119 | +}; |
| 120 | + |
| 121 | +const resetDisplay = () => { |
| 122 | + startupNameEl.innerHTML = '<p>- - - - -</p>'; |
| 123 | + startupNameEl.classList.remove('active'); |
| 124 | + timerDisplay.classList.add('hidden'); |
| 125 | + gameOverDisplay.classList.add('hidden'); |
| 126 | + generateBtn.disabled = false; |
| 127 | + generateBtn.textContent = 'Generar Startup'; |
| 128 | +}; |
| 129 | + |
| 130 | +const startCountdown = () => { |
| 131 | + let timeLeft = 22; |
| 132 | + countdownNumber.textContent = timeLeft; |
| 133 | + timerDisplay.classList.remove('hidden'); |
| 134 | + |
| 135 | + const timerCircle = document.querySelector('.timer-circle'); |
| 136 | + timerCircle.classList.add('pulse'); |
| 137 | + |
| 138 | + countdownInterval = setInterval(() => { |
| 139 | + timeLeft--; |
| 140 | + countdownNumber.textContent = timeLeft; |
| 141 | + |
| 142 | + // Add urgency animation in last 10 seconds |
| 143 | + if (timeLeft <= 10) { |
| 144 | + timerCircle.style.background = 'linear-gradient(45deg, #ff4757, #ff6b6b)'; |
| 145 | + } |
| 146 | + |
| 147 | + // Add final countdown animation in last 5 seconds |
| 148 | + if (timeLeft <= 5) { |
| 149 | + timerCircle.classList.add('pulse'); |
| 150 | + countdownNumber.style.color = '#ff4757'; |
| 151 | + } |
| 152 | + |
| 153 | + if (timeLeft <= 0) { |
| 154 | + clearInterval(countdownInterval); |
| 155 | + endGame(); |
| 156 | + } |
| 157 | + }, 1000); |
| 158 | +}; |
| 159 | + |
| 160 | +const endGame = () => { |
| 161 | + gameState = 'finished'; |
| 162 | + timerDisplay.classList.add('hidden'); |
| 163 | + gameOverDisplay.classList.remove('hidden'); |
| 164 | + generateBtn.disabled = false; |
| 165 | + generateBtn.textContent = 'Generar nueva startup'; |
| 166 | + |
| 167 | + // Reset timer circle styles |
| 168 | + const timerCircle = document.querySelector('.timer-circle'); |
| 169 | + timerCircle.classList.remove('pulse'); |
| 170 | + timerCircle.style.background = 'linear-gradient(45deg, #ff6b6b, #ff8e8e)'; |
| 171 | + countdownNumber.style.color = '#ff6b6b'; |
| 172 | +}; |
| 173 | + |
| 174 | +const startGame = () => { |
| 175 | + if (gameState === 'ready' || gameState === 'finished') { |
| 176 | + // Reset everything |
| 177 | + resetDisplay(); |
| 178 | + |
| 179 | + // Generate and display new startup name |
| 180 | + currentStartupName = generateUniqueStartupName(); |
| 181 | + displayStartupName(currentStartupName); |
| 182 | + |
| 183 | + // Start countdown |
| 184 | + gameState = 'pitching'; |
| 185 | + generateBtn.disabled = true; |
| 186 | + generateBtn.textContent = 'Pitching...'; |
| 187 | + |
| 188 | + setTimeout(() => { |
| 189 | + startCountdown(); |
| 190 | + }, 1000); // Wait 1 second before starting countdown |
| 191 | + } |
| 192 | +}; |
| 193 | + |
| 194 | +// Event listeners |
| 195 | +generateBtn.addEventListener('click', startGame); |
0 commit comments