MC/website/web/app.js

13 lines
4.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const houses={
fremen:{name:'Fremen',world:'ARRAKIS / THE DESERT WORLD',lore:'The desert is home. Its secrets are survival.',detail:'Harvest two spice units per deposit and keep moving with an Arrakis speed bonus. The orange stillsuit is your first line of defense.',status:'Arrakis has the complete gameplay guide: spice, shelter, sandworms, missions and Imperial rights.',image:'arrakis',alt:'Illustrated block-built Arrakis desert'},
atreides:{name:'Atreides',world:'CALADAN / WATER & GREEN LANDS',lore:'From ocean horizons to the dunes of destiny.',detail:'Choose the blue stillsuit and an Atreides movement-speed bonus. Caladan’s released terrain profile brings jungle, greenery and water to your homeworld.',status:'Caladan terrain is implemented. Its manual chapter reserves space for future planet-specific gameplay.',image:'caladan',alt:'Illustrated block-built green Caladan mountains and water'},
harkonnen:{name:'Harkonnen',world:'GIEDI PRIME / INDUSTRIAL SHADOWS',lore:'Power casts a long shadow.',detail:'The red Harkonnen stillsuit accompanies increased melee damage. Giedi Prime uses a swamp biome and a dark blackstone terrain palette.',status:'Giedi Prime terrain is implemented. The illustrated factories are concept scenery, not generated plugin structures.',image:'giedi',alt:'Illustrated dark voxel citadels on Giedi Prime'},
corrino:{name:'Corrino',world:'KAITAIN / THE IMPERIAL HORIZON',lore:'The throne watches every grain of spice.',detail:'Wear the purple stillsuit and gain the Corrino armor bonus. Kaitain’s released profile includes plains, flowers and configured ore deposits.',status:'Kaitain terrain is implemented. Imperial palace architecture is concept artwork; local quests are reserved for future expansion.',image:'kaitain',alt:'Illustrated Minecraft-influenced Imperial golden palace on Kaitain'},
ordos:{name:'Ordos',world:'SIGMA DRACONIS IV / COLD HORIZONS',lore:'A quiet step. A calculated advantage.',detail:'The green stillsuit carries your allegiance. Use the Ordos Shadow Step and configure an optional Wind Charge ability; explore the snowy homeworld profile.',status:'Sigma Draconis IV terrain is implemented. Its reserved chapter documents the current profile without promising new settlements.',image:'sigma',alt:'Illustrated block-built snowy Sigma Draconis IV landscape'}
};
const tabs=[...document.querySelectorAll('[data-house]')];
function selectHouse(key){const h=houses[key];if(!h)return;tabs.forEach(t=>{const active=t.dataset.house===key;t.setAttribute('aria-selected',String(active));t.tabIndex=active?0:-1});for(const [id,value] of [['house-world',h.world],['house-name',h.name],['house-lore',h.lore],['house-detail',h.detail],['house-status',h.status]])document.getElementById(id).textContent=value;const img=document.getElementById('house-image');img.src=`assets/${h.image}.webp`;img.alt=h.alt;const command=document.getElementById('house-command');command.dataset.copy=`/dune choose ${key}`;command.replaceChildren(document.createTextNode(command.dataset.copy+' '));const span=document.createElement('span');span.textContent='Copy ⧉';command.append(span);document.getElementById('house-panel').setAttribute('aria-labelledby',`tab-${key}`)}
tabs.forEach((tab,index)=>{tab.addEventListener('click',()=>selectHouse(tab.dataset.house));tab.addEventListener('keydown',e=>{let next=index;if(e.key==='ArrowRight')next=(index+1)%tabs.length;else if(e.key==='ArrowLeft')next=(index-1+tabs.length)%tabs.length;else if(e.key==='Home')next=0;else if(e.key==='End')next=tabs.length-1;else return;e.preventDefault();selectHouse(tabs[next].dataset.house);tabs[next].focus()})});
const toggle=document.querySelector('.menu-toggle'),nav=document.querySelector('nav');toggle.addEventListener('click',()=>{const open=nav.classList.toggle('open');toggle.setAttribute('aria-expanded',String(open));toggle.setAttribute('aria-label',open?'Close navigation':'Open navigation')});nav.querySelectorAll('a').forEach(a=>a.addEventListener('click',()=>{nav.classList.remove('open');toggle.setAttribute('aria-expanded','false');toggle.setAttribute('aria-label','Open navigation')}));
let toastTimer;function notify(message){const toast=document.querySelector('.toast');toast.textContent=message;toast.classList.add('visible');clearTimeout(toastTimer);toastTimer=setTimeout(()=>toast.classList.remove('visible'),2800)}
document.querySelectorAll('[data-copy]').forEach(button=>button.addEventListener('click',async()=>{try{await navigator.clipboard.writeText(button.dataset.copy);notify('Command copied. Paste it in Minecraft.')}catch{notify('Copy this command: '+button.dataset.copy)}}));