Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Mirage Market Mystery - Enhanced</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- box-sizing: border-box;
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
- }
- body {
- background: linear-gradient(to bottom, #f5d76e, #d4ac0d, #7d6608);
- color: #3e2723;
- min-height: 100vh;
- overflow-x: hidden;
- padding: 20px;
- }
- .container {
- max-width: 1200px;
- margin: 0 auto;
- padding: 20px;
- }
- header {
- text-align: center;
- margin-bottom: 30px;
- position: relative;
- }
- h1 {
- font-size: 3rem;
- color: #3e2723;
- text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
- margin-bottom: 10px;
- }
- .subtitle {
- font-size: 1.2rem;
- color: #5d4037;
- margin-bottom: 20px;
- }
- .stats {
- display: flex;
- justify-content: center;
- gap: 30px;
- margin-bottom: 20px;
- background: rgba(255, 236, 179, 0.7);
- padding: 15px;
- border-radius: 10px;
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
- }
- .stat-item {
- text-align: center;
- }
- .stat-value {
- font-size: 1.8rem;
- font-weight: bold;
- color: #3e2723;
- }
- .instructions {
- background: rgba(255, 236, 179, 0.9);
- padding: 20px;
- border-radius: 10px;
- margin-bottom: 30px;
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
- }
- .instructions h2 {
- margin-bottom: 10px;
- color: #5d4037;
- }
- .instructions ul {
- list-style-type: none;
- padding-left: 20px;
- }
- .instructions li {
- margin-bottom: 8px;
- position: relative;
- padding-left: 25px;
- }
- .instructions li:before {
- content: "•";
- color: #d4ac0d;
- font-weight: bold;
- position: absolute;
- left: 0;
- font-size: 1.5rem;
- }
- .inventory {
- background: rgba(255, 236, 179, 0.9);
- padding: 20px;
- border-radius: 10px;
- margin-bottom: 30px;
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
- }
- .inventory h2 {
- margin-bottom: 15px;
- color: #5d4037;
- }
- .inventory-slots {
- display: grid;
- grid-template-columns: repeat(6, 1fr);
- gap: 10px;
- }
- .inventory-slot {
- width: 60px;
- height: 60px;
- background: rgba(212, 172, 13, 0.3);
- border: 2px solid #d4ac0d;
- border-radius: 5px;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 1.8rem;
- cursor: pointer;
- position: relative;
- }
- .inventory-slot:hover {
- background: rgba(212, 172, 13, 0.5);
- }
- .sell-tooltip {
- position: fixed;
- background: rgba(255, 236, 179, 0.95);
- padding: 10px;
- border-radius: 5px;
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
- pointer-events: none;
- z-index: 100;
- display: none;
- }
- .market {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
- gap: 25px;
- margin-bottom: 30px;
- perspective: 1000px;
- }
- .stall {
- background: rgba(255, 236, 179, 0.9);
- border-radius: 10px;
- padding: 20px;
- text-align: center;
- box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
- transition: transform 0.5s ease, opacity 0.5s ease;
- position: relative;
- overflow: hidden;
- }
- .stall:before {
- content: "";
- position: absolute;
- top: 0;
- left: -100%;
- width: 100%;
- height: 100%;
- background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
- transition: 0.5s;
- }
- .stall:hover:before {
- left: 100%;
- }
- .stall h3 {
- color: #5d4037;
- margin-bottom: 15px;
- font-size: 1.4rem;
- }
- .item {
- font-size: 3rem;
- margin-bottom: 15px;
- transition: all 0.3s ease;
- }
- .price {
- font-size: 1.2rem;
- color: #3e2723;
- margin-bottom: 15px;
- }
- .timer {
- height: 5px;
- background: #d4ac0d;
- width: 100%;
- margin-bottom: 15px;
- border-radius: 5px;
- overflow: hidden;
- }
- .timer-bar {
- height: 100%;
- background: #ff5722;
- width: 100%;
- transition: width 1s linear;
- }
- .barter-container {
- display: flex;
- justify-content: center;
- align-items: center;
- gap: 10px;
- }
- .barter-btn {
- background: #d4ac0d;
- color: #3e2723;
- border: none;
- width: 30px;
- height: 30px;
- border-radius: 50%;
- cursor: pointer;
- font-weight: bold;
- display: flex;
- justify-content: center;
- align-items: center;
- transition: background 0.3s;
- }
- .barter-btn:hover {
- background: #f5d76e;
- }
- .barter-btn:disabled {
- background: #cccccc;
- cursor: not-allowed;
- }
- .buy-btn {
- background: #d4ac0d;
- color: #3e2723;
- border: none;
- padding: 8px 15px;
- border-radius: 5px;
- cursor: pointer;
- font-weight: bold;
- transition: background 0.3s;
- }
- .buy-btn:hover {
- background: #f5d76e;
- }
- .buy-btn:disabled {
- background: #cccccc;
- cursor: not-allowed;
- }
- .message-box {
- position: fixed;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- background: rgba(255, 236, 179, 0.95);
- padding: 30px;
- border-radius: 10px;
- box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
- text-align: center;
- z-index: 100;
- display: none;
- }
- .message-box h2 {
- margin-bottom: 20px;
- color: #5d4037;
- }
- .message-box p {
- margin-bottom: 20px;
- font-size: 1.2rem;
- }
- .close-btn {
- background: #d4ac0d;
- color: #3e2723;
- border: none;
- padding: 10px 20px;
- border-radius: 5px;
- cursor: pointer;
- font-weight: bold;
- }
- .heat-wave {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- pointer-events: none;
- background: linear-gradient(to bottom, rgba(255, 255, 255, 0.1) 0%, transparent 50%, rgba(255, 255, 255, 0.1) 100%);
- background-size: 100% 5px;
- animation: heatWave 2s infinite linear;
- z-index: 50;
- opacity: 0.6;
- }
- @keyframes heatWave {
- 0% {
- background-position: 0 0;
- }
- 100% {
- background-position: 0 50px;
- }
- }
- .mirage {
- animation: shimmer 3s infinite alternate;
- }
- @keyframes shimmer {
- 0% {
- opacity: 0.7;
- transform: scale(0.95);
- }
- 100% {
- opacity: 1;
- transform: scale(1.05);
- }
- }
- .fade-out {
- animation: fadeOut 1s forwards;
- }
- @keyframes fadeOut {
- to {
- opacity: 0;
- transform: translateY(20px) scale(0.9);
- }
- }
- .artifact {
- position: relative;
- }
- .artifact:after {
- content: "✨";
- position: absolute;
- top: -10px;
- right: -10px;
- font-size: 1.5rem;
- animation: glow 2s infinite alternate;
- }
- @keyframes glow {
- from {
- text-shadow: 0 0 5px #fff, 0 0 10px #fff, 0 0 15px #ffdd00, 0 0 20px #ffdd00;
- }
- to {
- text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #ffdd00, 0 0 40px #ffdd00;
- }
- }
- .shimmer {
- position: relative;
- }
- .shimmer:before {
- content: "";
- position: absolute;
- top: -50%;
- left: -50%;
- width: 200%;
- height: 200%;
- background: linear-gradient(45deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
- transform: rotate(45deg);
- animation: shine 3s infinite;
- }
- @keyframes shine {
- 0% {
- left: -100%;
- }
- 100% {
- left: 100%;
- }
- }
- footer {
- text-align: center;
- margin-top: 30px;
- color: #5d4037;
- font-size: 0.9rem;
- }
- #startScreen {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background: rgba(0,0,0,0.7);
- display: flex;
- justify-content: center;
- align-items: center;
- z-index: 1000;
- }
- @media (max-width: 768px) {
- .market {
- grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
- }
- .inventory-slots {
- grid-template-columns: repeat(4, 1fr);
- }
- h1 {
- font-size: 2.2rem;
- }
- .stat-value {
- font-size: 1.5rem;
- }
- }
- .shake {
- animation: shake 0.5s;
- animation-iteration-count: 1;
- }
- @keyframes shake {
- 0% { transform: translate(1px, 1px) rotate(0deg); }
- 10% { transform: translate(-1px, -2px) rotate(-1deg); }
- 20% { transform: translate(-3px, 0px) rotate(1deg); }
- 30% { transform: translate(3px, 2px) rotate(0deg); }
- 40% { transform: translate(1px, -1px) rotate(1deg); }
- 50% { transform: translate(-1px, 2px) rotate(-1deg); }
- 60% { transform: translate(-3px, 1px) rotate(0deg); }
- 70% { transform: translate(3px, 1px) rotate(-1deg); }
- 80% { transform: translate(-1px, -1px) rotate(1deg); }
- 90% { transform: translate(1px, 2px) rotate(0deg); }
- 100% { transform: translate(1px, -2px) rotate(-1deg); }
- }
- /* New styles for mirage explosion */
- .explode {
- animation: explode 0.8s forwards;
- }
- @keyframes explode {
- 0% { transform: scale(1); opacity: 1; }
- 50% { transform: scale(1.5); opacity: 0.5; }
- 100% { transform: scale(2); opacity: 0; }
- }
- .artifact-chance {
- font-size: 0.9rem;
- color: #5d4037;
- margin-top: 5px;
- height: 20px;
- }
- </style>
- </head>
- <body>
- <div class="heat-wave"></div>
- <div class="sell-tooltip" id="sellTooltip"></div>
- <div id="startScreen">
- <div style="text-align: center; color: white;">
- <h2 style="margin-bottom: 20px;">Mirage Market Mystery</h2>
- <p style="margin-bottom: 30px;">Now with enhanced economy and better artifact chances!</p>
- <button class="close-btn" onclick="startGame()">Start</button>
- </div>
- </div>
- <div class="container">
- <header>
- <h1>Mirage Market Mystery</h1>
- <p class="subtitle">Navigate the shifting sands of the bazaar to uncover rare artifacts</p>
- <div class="stats">
- <div class="stat-item">
- <div class="stat-label">Gold</div>
- <div class="stat-value" id="gold">100</div>
- </div>
- <div class="stat-item">
- <div class="stat-label">Artifacts</div>
- <div class="stat-value" id="artifacts">0</div>
- </div>
- <div class="stat-item">
- <div class="stat-label">Time</div>
- <div class="stat-value" id="timer">120</div>
- </div>
- </div>
- </header>
- <div class="instructions">
- <h2>How to Play</h2>
- <ul>
- <li>Stalls shift positions and goods appear/disappear randomly</li>
- <li>Use + and - to barter - + increases artifact chance, - lowers price but risks</li>
- <li>Buy items before they vanish - but beware of mirages!</li>
- <li>Look for shimmering items - they might be rare artifacts</li>
- <li>Sell items from your inventory by clicking on them</li>
- <li>Manage your gold wisely - mirages will waste your gold</li>
- <li>Find 5 artifacts before time runs out to win!</li>
- </ul>
- </div>
- <div class="inventory">
- <h2>Inventory <span id="inventoryCount">(0/12)</span></h2>
- <div class="inventory-slots" id="inventorySlots">
- <!-- Inventory slots will be generated by JavaScript -->
- </div>
- </div>
- <div class="market" id="market">
- <!-- Stalls will be generated by JavaScript -->
- </div>
- <footer>
- <p>Mirage Market Mystery - Can you master the shifting bazaar?</p>
- </footer>
- </div>
- <div class="message-box" id="messageBox">
- <h2 id="messageTitle">Game Over</h2>
- <p id="messageText">You've run out of gold!</p>
- <button id="messageButton" class="close-btn">Play Again</button>
- </div>
- <script>
- // Game state
- const gameState = {
- gold: 100.0,
- artifacts: 0,
- time: 120,
- stalls: [],
- inventory: new Array(12).fill(null),
- gameInterval: null,
- shiftInterval: null,
- goldInterval: null,
- isGameActive: false,
- globalPriceModifier: 1.0 // Starts at 1, changes with buys/sells
- };
- // Items data with 80% reduced prices
- const items = [
- { name: "Desert Rose", emoji: "🌹", basePrice: 4 },
- { name: "Magic Lamp", emoji: "🪔", basePrice: 8 },
- { name: "Silk Scarf", emoji: "🧣", basePrice: 3 },
- { name: "Sandstone Tablet", emoji: "📜", basePrice: 9 },
- { name: "Pyramid Crystal", emoji: "🔮", basePrice: 14 },
- { name: "Ancient Potion", emoji: "🧪", basePrice: 6 },
- { name: "Golden Scarab", emoji: "🐞", basePrice: 10 },
- { name: "Pharaoh's Mask", emoji: "🎭", basePrice: 12 },
- { name: "Desert Dagger", emoji: "🔪", basePrice: 5 }
- ];
- // Start the game
- function startGame() {
- document.getElementById('startScreen').style.display = 'none';
- initGame();
- }
- // Initialize the game
- function initGame() {
- gameState.gold = 100.0;
- gameState.artifacts = 0;
- gameState.time = 120;
- gameState.inventory = new Array(12).fill(null);
- gameState.isGameActive = true;
- gameState.globalPriceModifier = 1.0;
- updateUI();
- generateStalls();
- initializeInventory();
- // Start game timer
- clearInterval(gameState.gameInterval);
- gameState.gameInterval = setInterval(gameTick, 1000);
- // Start shifting stalls
- clearInterval(gameState.shiftInterval);
- gameState.shiftInterval = setInterval(shiftStalls, 5000);
- // Start gold increase
- clearInterval(gameState.goldInterval);
- gameState.goldInterval = setInterval(() => {
- if (gameState.isGameActive) {
- gameState.gold += (0.5 + Math.random() * 2); // Reduced gold income
- updateUI();
- }
- }, 1000);
- }
- // Main game tick (every second)
- function gameTick() {
- if (gameState.isGameActive) {
- gameState.time--;
- updateUI();
- if (gameState.time <= 0) {
- endGame(`The market gates are closing! You found ${gameState.artifacts} artifacts but needed 5 to prove your expertise as a master collector. The desert sun sets on today's opportunities, but new treasures await tomorrow.`);
- }
- }
- }
- // Initialize inventory slots
- function initializeInventory() {
- const inventorySlots = document.getElementById('inventorySlots');
- inventorySlots.innerHTML = '';
- for (let i = 0; i < 12; i++) {
- const slot = document.createElement('div');
- slot.className = 'inventory-slot';
- slot.dataset.index = i;
- slot.innerHTML = '<div style="opacity: 0.3;">+</div>';
- slot.addEventListener('click', () => sellItem(i));
- slot.addEventListener('mousemove', (e) => showSellTooltip(e, i));
- slot.addEventListener('mouseout', hideSellTooltip);
- inventorySlots.appendChild(slot);
- }
- updateInventoryCount();
- }
- // Show sell tooltip
- function showSellTooltip(e, index) {
- const tooltip = document.getElementById('sellTooltip');
- const item = gameState.inventory[index];
- if (item) {
- let statusHtml = item.isArtifact
- ? '<span style="color: purple;">Status: Artifact</span>'
- : '<span style="color: blue;">Status: Common</span>';
- if (item.isArtifact) {
- tooltip.innerHTML = `${statusHtml}<br>Cannot sell`;
- } else {
- const sellPrice = Math.floor(item.price * 0.5);
- tooltip.innerHTML = `${statusHtml}<br>Sell for ${sellPrice} gold<br>Left-click to sell`;
- }
- tooltip.style.display = 'block';
- tooltip.style.left = (e.pageX + 10) + 'px';
- tooltip.style.top = (e.pageY + 10) + 'px';
- }
- }
- // Hide sell tooltip
- function hideSellTooltip() {
- const tooltip = document.getElementById('sellTooltip');
- tooltip.style.display = 'none';
- }
- // Sell item from inventory
- function sellItem(index) {
- if (!gameState.isGameActive) return;
- const item = gameState.inventory[index];
- if (item) {
- if (item.isArtifact) {
- showMessage("Cannot Sell", "Artifacts cannot be sold!", false);
- return;
- }
- const sellPrice = Math.floor(item.price * 0.5);
- gameState.gold += sellPrice;
- // Update global price modifier slightly on sell
- gameState.globalPriceModifier *= 0.98; // Slight decrease on sell
- // Update inventory
- gameState.inventory[index] = null;
- // Update slot
- const slot = document.querySelector(`.inventory-slot[data-index="${index}"]`);
- slot.innerHTML = '<div style="opacity: 0.3;">+</div>';
- updateUI();
- updateInventoryCount();
- }
- }
- // Update inventory count
- function updateInventoryCount() {
- const count = gameState.inventory.filter(item => item !== null).length;
- document.getElementById('inventoryCount').textContent = `(${count}/12)`;
- }
- // Generate stalls for the market
- function generateStalls() {
- const market = document.getElementById('market');
- market.innerHTML = '';
- gameState.stalls = [];
- const stallCount = 6;
- for (let i = 0; i < stallCount; i++) {
- const stall = document.createElement('div');
- stall.className = 'stall';
- stall.dataset.id = i;
- // Decide shimmer first
- const hasShimmer = Math.random() < 0.2;
- // Base artifact chance (10-20%)
- const baseArtifactChance = 0.1 + (Math.random() * 0.1);
- const item = JSON.parse(JSON.stringify(items[Math.floor(Math.random() * items.length)]));
- // Apply global modifier and shimmer inflation
- item.basePrice = Math.floor(item.basePrice * gameState.globalPriceModifier);
- if (hasShimmer) item.basePrice += 2;
- const timerDuration = 8000 + Math.random() * 7000;
- gameState.stalls.push({
- element: stall,
- item: item,
- hasShimmer: hasShimmer,
- timerDuration: timerDuration,
- timer: null,
- currentPrice: item.basePrice,
- barterCount: 0,
- maxBarter: Math.floor(Math.random() * 3) + 4,
- lockBarter: false,
- artifactChance: baseArtifactChance
- });
- renderStall(i);
- market.appendChild(stall);
- startItemTimer(i, timerDuration);
- }
- }
- // Render a stall
- function renderStall(stallId) {
- const stall = gameState.stalls[stallId];
- const item = stall.item;
- let className = 'item';
- if (stall.hasShimmer) className += ' shimmer';
- stall.element.innerHTML = `
- <h3>${item.name}</h3>
- <div class="${className}">${item.emoji}</div>
- <div class="price">${stall.currentPrice} gold</div>
- <div class="artifact-chance">Artifact chance: ${Math.round(stall.artifactChance * 100)}%</div>
- <div class="timer"><div class="timer-bar" style="width: 100%;"></div></div>
- <div class="barter-container">
- <button class="barter-btn" onclick="barter(${stallId}, -1)" ${stall.lockBarter ? 'disabled' : ''}>-</button>
- <button class="buy-btn" onclick="buyItem(${stallId})">Purchase</button>
- <button class="barter-btn" onclick="barter(${stallId}, 1)" ${stall.lockBarter ? 'disabled' : ''}>+</button>
- </div>
- `;
- }
- // Barter for an item
- function barter(stallId, direction) {
- if (!gameState.isGameActive) return;
- const stall = gameState.stalls[stallId];
- if (stall.lockBarter) return;
- if (stall.barterCount >= stall.maxBarter) {
- showMessage("Barter Failed", "The trader refuses to negotiate further.", false);
- return;
- }
- stall.barterCount++;
- if (direction === -1) { // Decrease price
- // Sometimes increase by 3 and lock
- if (Math.random() < 0.2) {
- stall.currentPrice += 3;
- stall.lockBarter = true;
- stall.element.classList.add('shake');
- setTimeout(() => stall.element.classList.remove('shake'), 500);
- } else {
- stall.currentPrice = Math.max(1, stall.currentPrice - 1);
- // Slight decrease to artifact chance (2-5%)
- stall.artifactChance = Math.max(0.05, stall.artifactChance - (0.02 + Math.random() * 0.03));
- }
- } else { // Increase for +
- stall.currentPrice += 3;
- // Increase artifact chance based on barter count
- if (stall.barterCount === 1) {
- stall.artifactChance = 0.15 + (Math.random() * 0.1); // 15-25%
- } else if (stall.barterCount === 2) {
- stall.artifactChance = 0.2 + (Math.random() * 0.1); // 20-30%
- } else {
- stall.artifactChance = Math.min(0.9, stall.artifactChance + 0.05); // +5% each additional click
- }
- }
- renderStall(stallId);
- if (stall.barterCount >= stall.maxBarter) {
- const barterButtons = stall.element.querySelectorAll('.barter-btn');
- barterButtons.forEach(btn => btn.disabled = true);
- }
- }
- // Start timer for item
- function startItemTimer(stallId, duration) {
- const stall = gameState.stalls[stallId];
- const timerBar = stall.element.querySelector('.timer-bar');
- if (stall.timer) clearTimeout(stall.timer);
- timerBar.style.transition = `width ${duration}ms linear`;
- timerBar.style.width = '0%';
- stall.timer = setTimeout(() => {
- if (stall.element.parentNode) {
- stall.element.classList.add('fade-out');
- setTimeout(() => {
- if (stall.element.parentNode) replaceStallItem(stallId);
- }, 1000);
- }
- }, duration);
- }
- // Replace stall item
- function replaceStallItem(stallId) {
- const stall = gameState.stalls[stallId];
- const hasShimmer = Math.random() < 0.2;
- // Base artifact chance (10-20%)
- const baseArtifactChance = 0.1 + (Math.random() * 0.1);
- const newItem = JSON.parse(JSON.stringify(items[Math.floor(Math.random() * items.length)]));
- newItem.basePrice = Math.floor(newItem.basePrice * gameState.globalPriceModifier);
- if (hasShimmer) newItem.basePrice += 2;
- stall.item = newItem;
- stall.hasShimmer = hasShimmer;
- stall.timerDuration = 8000 + Math.random() * 7000;
- stall.currentPrice = newItem.basePrice;
- stall.barterCount = 0;
- stall.maxBarter = Math.floor(Math.random() * 3) + 4;
- stall.lockBarter = false;
- stall.artifactChance = baseArtifactChance;
- stall.element.classList.remove('fade-out');
- renderStall(stallId);
- startItemTimer(stallId, stall.timerDuration);
- }
- // Shift stalls
- function shiftStalls() {
- if (!gameState.isGameActive) return;
- const market = document.getElementById('market');
- const stalls = Array.from(market.children);
- for (let i = stalls.length - 1; i > 0; i--) {
- const j = Math.floor(Math.random() * (i + 1));
- market.appendChild(stalls[j]);
- }
- stalls.forEach(stall => {
- stall.style.transform = 'translateX(20px)';
- setTimeout(() => stall.style.transform = 'translateX(0)', 300);
- });
- }
- // Buy item
- function buyItem(stallId) {
- if (!gameState.isGameActive) return;
- const stall = gameState.stalls[stallId];
- const price = stall.currentPrice;
- if (gameState.inventory.filter(item => item !== null).length >= 12) {
- showMessage("Inventory Full", "Your inventory is full! Sell some items first.", false);
- return;
- }
- if (gameState.gold >= price) {
- // 10% chance of mirage
- const isMirage = Math.random() < 0.1;
- // Determine if this is actually an artifact based on artifact chance
- const isActuallyArtifact = Math.random() < stall.artifactChance;
- if (isMirage) {
- // Mirage effect - item explodes and disappears
- stall.element.classList.add('explode');
- gameState.gold -= price;
- setTimeout(() => {
- stall.element.classList.remove('explode');
- showMessage("Mirage!", "The item vanished into thin air! You wasted your gold.", false);
- replaceStallItem(stallId);
- }, 800);
- } else {
- gameState.gold -= price;
- // Update global price modifier on buy
- gameState.globalPriceModifier *= 1.02; // Slight increase on buy
- const inventoryIndex = gameState.inventory.findIndex(slot => slot === null);
- if (inventoryIndex !== -1) {
- // Use the same displayed item, but set isArtifact based on chance
- const actualItem = JSON.parse(JSON.stringify(stall.item));
- actualItem.isArtifact = isActuallyArtifact;
- actualItem.price = price;
- gameState.inventory[inventoryIndex] = actualItem;
- const slot = document.querySelector(`.inventory-slot[data-index="${inventoryIndex}"]`);
- let slotClass = actualItem.isArtifact ? 'artifact' : '';
- slot.innerHTML = `<div class="${slotClass}">${actualItem.emoji}</div>`;
- if (actualItem.isArtifact) {
- gameState.artifacts++;
- updateUI(); // Update UI before checking win
- showMessage("Artifact Found!", `You acquired a rare ${actualItem.name}!`, false);
- if (gameState.artifacts >= 5) {
- endGame("Congratulations! You've uncovered 5 rare artifacts and mastered the Mirage Market. With these treasures in hand, venture forth to fence them in shadowy black markets, turning your savvy acquisitions into fortunes beyond imagination—your legend as a bazaar whisperer begins anew!");
- return;
- }
- } else {
- showMessage("Purchase Successful", `You bought a ${actualItem.name}.`, false);
- }
- }
- }
- updateUI();
- updateInventoryCount();
- if (!isMirage) {
- replaceStallItem(stallId);
- }
- if (gameState.gold < 1) {
- endGame("You've run out of gold!");
- }
- } else {
- showMessage("Not Enough Gold", "You don't have enough gold to buy this item.", false);
- }
- }
- // Update UI
- function updateUI() {
- document.getElementById('gold').textContent = Math.round(gameState.gold);
- document.getElementById('artifacts').textContent = gameState.artifacts;
- document.getElementById('timer').textContent = gameState.time;
- }
- // Show message
- function showMessage(title, text, isGameOver = false) {
- const messageBox = document.getElementById('messageBox');
- const messageTitle = document.getElementById('messageTitle');
- const messageText = document.getElementById('messageText');
- const messageButton = document.getElementById('messageButton');
- messageTitle.textContent = title;
- messageText.textContent = text;
- if (isGameOver) {
- messageButton.textContent = 'Play Again';
- messageButton.onclick = resetGame;
- } else {
- messageButton.textContent = 'Close';
- messageButton.onclick = () => messageBox.style.display = 'none';
- }
- messageBox.style.display = 'block';
- }
- // End game
- function endGame(message) {
- gameState.isGameActive = false;
- clearInterval(gameState.gameInterval);
- clearInterval(gameState.shiftInterval);
- clearInterval(gameState.goldInterval);
- showMessage("Game Over", message, true);
- }
- // Reset game
- function resetGame() {
- document.getElementById('messageBox').style.display = 'none';
- document.getElementById('startScreen').style.display = 'flex';
- }
- // On load, show start screen
- window.onload = () => {
- document.getElementById('startScreen').style.display = 'flex';
- };
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment