Skip to content

منچ کلاسیک #105

Description

@mobilemohammad7283-jpg
<title>منچ سلطنتی - بازی کامل آنلاین و آفلاین</title> <style> * { box-sizing: border-box; user-select: none; }
    body {
        background: linear-gradient(145deg, #1e5a2e 0%, #0a3b1a 100%);
        font-family: 'Segoe UI', 'Tahoma', 'Vazirmatn', system-ui, sans-serif;
        margin: 0;
        padding: 20px;
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .game-container {
        max-width: 1400px;
        width: 100%;
        background: rgba(0,0,0,0.4);
        border-radius: 48px;
        padding: 16px;
        box-shadow: 0 20px 35px rgba(0,0,0,0.5);
    }

    .profile-bar {
        background: #f7e9b0;
        border-radius: 60px;
        padding: 12px 24px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 12px;
        margin-bottom: 20px;
        box-shadow: 0 5px 0 #b97f3a;
    }

    .user-info {
        display: flex;
        align-items: center;
        gap: 15px;
        background: #fff1cf;
        padding: 5px 20px;
        border-radius: 40px;
        cursor: pointer;
    }

    .avatar-icon {
        width: 55px;
        height: 55px;
        background: #ffb347;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 32px;
        box-shadow: 0 3px 6px black;
    }

    .player-name {
        font-weight: bold;
        font-size: 1.2rem;
        color: #4a2a1a;
    }

    .coin-badge {
        background: gold;
        padding: 8px 18px;
        border-radius: 30px;
        font-weight: bold;
        color: #8b5a2b;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .nav-menu {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        margin-bottom: 25px;
        justify-content: center;
    }

    .nav-btn {
        background: #fdd67a;
        border: none;
        padding: 10px 24px;
        border-radius: 40px;
        font-weight: bold;
        font-size: 1rem;
        cursor: pointer;
        transition: 0.2s;
        box-shadow: 0 3px 0 #aa6f2c;
    }

    .nav-btn.active {
        background: #ff8c42;
        color: white;
        transform: translateY(-2px);
    }

    .panel {
        background: #fdf8e7;
        border-radius: 48px;
        padding: 20px;
        margin-bottom: 20px;
        display: none;
        animation: fade 0.2s;
    }

    .panel.active-panel {
        display: block;
    }

    @keyframes fade {
        from { opacity: 0; transform: scale(0.97);}
        to { opacity: 1; transform: scale(1);}
    }

    .board-area {
        display: flex;
        justify-content: center;
        background: #4b2e1a;
        border-radius: 40px;
        padding: 20px;
    }
    canvas {
        background: #f0d9b5;
        border-radius: 24px;
        box-shadow: 0 10px 20px rgba(0,0,0,0.3);
        width: 100%;
        max-width: 700px;
        height: auto;
        cursor: pointer;
    }

    .game-status {
        margin-top: 15px;
        text-align: center;
        font-size: 1.2rem;
        background: #2c1a0e;
        color: #ffeaac;
        padding: 12px;
        border-radius: 60px;
    }

    .dice-area {
        display: flex;
        justify-content: center;
        margin: 15px 0;
    }
    .dice {
        background: white;
        width: 80px;
        height: 80px;
        border-radius: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 3rem;
        font-weight: bold;
        box-shadow: 0 8px 0 #b97f3a;
        cursor: pointer;
        transition: 0.05s linear;
    }
    .dice:active { transform: scale(0.96);}

    .timer-bar {
        height: 10px;
        background: #dcb572;
        border-radius: 10px;
        margin: 8px 0;
        transition: width 0.1s linear;
    }

    .shop-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(180px,1fr));
        gap: 15px;
    }
    .shop-card {
        background: #fff0cc;
        border-radius: 28px;
        padding: 12px;
        text-align: center;
        cursor: pointer;
        transition: 0.1s;
        border: 2px solid #e2b87a;
    }
    .buy-btn {
        background: #ff9f4a;
        border: none;
        padding: 8px;
        border-radius: 40px;
        margin-top: 8px;
        font-weight: bold;
    }

    .referral-box {
        background: #ffe3aa;
        padding: 15px;
        border-radius: 40px;
        margin: 12px 0;
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    input, select {
        padding: 12px;
        border-radius: 60px;
        border: none;
        flex:1;
        font-family: inherit;
        background: white;
    }

    button {
        font-family: inherit;
        background: #8b5a2b;
        color: white;
        border: none;
        border-radius: 40px;
        padding: 8px 18px;
        cursor: pointer;
    }

    .mode-card {
        background: #f3e1be;
        border-radius: 32px;
        padding: 18px;
        margin: 8px 0;
    }
    @media (max-width: 700px) {
        .profile-bar { flex-direction: column; }
    }
    .pawn-selector { display: inline-flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
    .pawn-piece { width: 45px; height: 45px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 28px; background: #e9c891; cursor: pointer; }
</style>
🐉
بارگذاری...
📞 ---
🪙 0
🎁 کد معرف
🏠 صفحه اصلی 🛒 فروشگاه 👤 پروفایل
<!-- پنل اصلی -->
<div id="panel-main" class="panel active-panel">
    <div class="mode-card"><h3>🎲 بازی آنلاین - مبتدی (1v1)</h3><p>💰 ورود ۱۰۰ سکه | برد +۳۰۰ سکه | زمان‌دار ۶ ثانیه</p><button id="startBeginnerBtn">شروع مسابقه آنلاین</button></div>
    <div class="mode-card"><h3>👥 بازی تیمی (۲ نفره تیمی)</h3><p>ورود ۱۰۰۰ سکه | هر برنده تیمی +۱۸۰۰ سکه | (نسخه کامل)</p><button id="teamGameBtn">شروع تیمی (نیاز به ۴ بازیکن)</button></div>
    <div class="mode-card"><h3>🤝 بازی دوستانه (اتاق اختصاصی)</h3><p>ورود ۱۰۰ سکه | برنده +۲۵۰ سکه | با کد اتاق</p><button id="friendlyCreateBtn">🌟 ایجاد اتاق جدید</button><input type="text" id="joinRoomCode" placeholder="کد اتاق"><button id="friendlyJoinBtn">ورود به اتاق</button></div>
    <div class="mode-card"><h3>🤖 بازی آفلاین با ربات</h3><p>ورود رایگان | بدون جایزه | تعداد بازیکن: <select id="botCountSelect"><option value="2">۲ نفر (شما + ربات)</option><option value="3">۳ نفر (۲ ربات)</option><option value="4">۴ نفر (۳ ربات)</option></select></p><button id="offlineBotBtn">شروع بازی با ربات</button></div>
</div>

<!-- فروشگاه -->
<div id="panel-shop" class="panel"><h2>🏪 فروشگاه سکه و آیتم</h2>
    <div class="shop-grid" id="shopCoins"><div class="shop-card" data-coins="10000" data-price="25000">۱۰۰۰۰ سکه <br>۲۵۰۰۰ تومان</div><div class="shop-card" data-coins="100000" data-price="200000">۱۰۰۰۰۰ سکه <br>۲۰۰۰۰۰ تومان</div><div class="shop-card" data-coins="500000" data-price="900000">۵۰۰۰۰۰ سکه <br>۹۰۰۰۰۰ تومان</div></div>
    <hr><h3>🎨 تاس‌های ویژه (۱۰۰۰۰ سکه)</h3><div id="diceSkinsShop" style="display:flex; gap:12px;"><div class="shop-card" data-skin="default">🎲 کلاسیک</div><div class="shop-card" data-skin="gold">✨ طلایی</div><div class="shop-card" data-skin="fire">🔥 آتشین</div></div>
    <h3>♟️ مهره‌های جدید (۱۰۰۰۰ سکه)</h3><div id="pawnSkinsShop"><div class="shop-card" data-pawn="default">🚩 معمولی</div><div class="shop-card" data-pawn="crystal">💎 کریستال</div><div class="shop-card" data-pawn="dragon">🐉 اژدها</div></div>
    <h3>🌄 زمینه طلایی (۳۰۰۰۰۰ سکه)</h3><button id="buyBgBtn">خرید زمینه طلایی</button>
</div>

<!-- پروفایل -->
<div id="panel-profilePanel" class="panel"><h2>ویرایش پروفایل</h2><div>نام: <input type="text" id="editName" placeholder="نام"></div><div>تلفن: <input type="tel" id="editPhone" placeholder="09XXXXXXXXX"></div><div>آیکون:</div><div id="avatarOptions" style="display:flex; gap:12px;"><div class="avatar-icon" data-avatar="🐉">🐉</div><div class="avatar-icon" data-avatar="⚔️">⚔️</div><div class="avatar-icon" data-avatar="👑">👑</div><div class="avatar-icon" data-avatar="🐱">🐱</div><div class="avatar-icon" data-avatar="🦊">🦊</div></div><button id="saveProfileBtn">ذخیره</button><hr><div class="referral-box"><input type="text" id="refCodeInput" placeholder="کد معرف دوست"><button id="applyReferralBtn">دریافت ۱۰۰۰ سکه هدیه</button></div><div>کد معرف شما: <strong id="myRefCode">----</strong></div></div>

<!-- صفحه بازی -->
<div id="gameBoardPanel" style="display: none;"><div class="board-area"><canvas id="ludoCanvas" width="600" height="600"></canvas></div><div class="dice-area"><div class="dice" id="diceBtn">🎲</div></div><div class="timer-bar" id="timerBar" style="width:0%"></div><div class="game-status" id="gameStatusText"></div><button id="exitGameBtn">خروج از بازی</button></div>
<script> (function(){ // ---------- ذخیره‌سازی کاربر ---------- let currentUser = { uid: "p"+Math.random().toString(36).substr(2,8), name: "مسافر", phone: "09123456789", coins: 5000, avatar: "🐉", diceSkin: "default", pawnSkin: "default", bgTheme: "default", referralCode: "", referred: false, registered: true }; function saveUser(){ localStorage.setItem("ludoUser", JSON.stringify(currentUser)); } function loadUser(){ let d = localStorage.getItem("ludoUser"); if(d){ let u=JSON.parse(d); currentUser={...currentUser, ...u}; } if(!currentUser.referralCode) currentUser.referralCode = currentUser.uid.slice(0,6)+Math.floor(Math.random()*10000); saveUser(); updateUI(); } function updateUI(){ document.getElementById("displayName").innerText = currentUser.name; document.getElementById("phoneNumber").innerText = currentUser.phone; document.getElementById("coinAmount").innerText = currentUser.coins; document.getElementById("avatarPreview").innerText = currentUser.avatar; document.getElementById("myRefCode").innerText = currentUser.referralCode; } function addCoins(amount){ currentUser.coins += amount; updateUI(); saveUser(); } function deductCoins(amount){ if(currentUser.coins >= amount){ currentUser.coins -= amount; updateUI(); saveUser(); return true; } else { alert("سکه کافی نیست!"); return false; } } // پنل‌ها document.querySelectorAll(".nav-btn").forEach(btn=>{ btn.addEventListener("click",()=>{ document.querySelectorAll(".panel").forEach(p=>p.classList.remove("active-panel")); document.getElementById(`panel-${btn.dataset.panel}`).classList.add("active-panel"); }); }); document.getElementById("profileBtn").addEventListener("click",()=>{ document.querySelector("[data-panel='profilePanel']").click(); }); document.getElementById("saveProfileBtn").addEventListener("click",()=>{ let n=document.getElementById("editName").value; if(n) currentUser.name=n; let p=document.getElementById("editPhone").value; if(p) currentUser.phone=p; updateUI(); saveUser(); alert("پروفایل ذخیره شد"); }); document.querySelectorAll("#avatarOptions div").forEach(av=>{ av.addEventListener("click",()=>{ currentUser.avatar=av.innerText; updateUI(); saveUser(); }); }); document.getElementById("applyReferralBtn").addEventListener("click",()=>{ let code=document.getElementById("refCodeInput").value; if(code && !currentUser.referred && code!==currentUser.referralCode){ currentUser.referred=true; addCoins(1000); alert("۱۰۰۰ سکه هدیه دریافت شد"); saveUser(); } else alert("کد نامعتبر یا قبلاً استفاده شده"); }); // خریدها document.querySelectorAll("#shopCoins .shop-card").forEach(c=>{ c.addEventListener("click",()=>{ let coins=parseInt(c.dataset.coins); addCoins(coins); alert(`خرید ${coins} سکه انجام شد (شبیه‌سازی درگاه)`); }); }); document.querySelectorAll("#diceSkinsShop .shop-card").forEach(c=>{ c.addEventListener("click",()=>{ if(currentUser.coins>=10000){ deductCoins(10000); currentUser.diceSkin=c.dataset.skin; saveUser(); alert("تاس جدید خریداری شد"); } else alert("سکه کافی نیست"); }); }); document.querySelectorAll("#pawnSkinsShop .shop-card").forEach(c=>{ c.addEventListener("click",()=>{ if(currentUser.coins>=10000){ deductCoins(10000); currentUser.pawnSkin=c.dataset.pawn; saveUser(); alert("مهره جدید خریداری شد"); } }); }); document.getElementById("buyBgBtn").addEventListener("click",()=>{ if(currentUser.coins>=300000){ deductCoins(300000); currentUser.bgTheme="gold"; saveUser(); alert("زمین طلایی فعال شد"); } else alert("سکه کافی نیست"); }); // ---------- موتور کامل بازی منچ (Ludo) ---------- // رنگ‌ها: قرمز(0), سبز(1), زرد(2), آبی(3) const COLORS = ["red","green","yellow","blue"]; const COLOR_SYMBOLS = ["🔴","🟢","🟡","🔵"]; const HOME_PATH = [0,13,26,39]; // شروع هر رنگ در مسیر اصلی (حلقه 52 خانه) const SAFE_SPOTS = [0,8,13,21,26,34,39,47]; // خانه‌های امن class LudoGame { constructor(playersColors, onUpdate) { this.players = playersColors; // آرایه‌ای از نام بازیکنان به ترتیب نوبت [ "قرمز", "سبز", ...] this.colorIndex = playersColors.map(c=>COLORS.indexOf(c)); this.turnIdx = 0; this.pawns = {}; // هر بازیکن: 4 مهره موقعیت -1 (خارج) تا 51 و 100 (خانه) for(let i=0;i=0 && positions[i]<100){ let newPos = this.getNewPosition(color, positions[i], dice); if(newPos !== -1) return true; } } return false; } getNewPosition(color, pos, steps){ if(pos===-1){ if(steps===6) return HOME_PATH[COLORS.indexOf(color)]; else return -1; } if(pos>=0 && pos<52){ let np = pos+steps; if(np>=52) return -1; // هنوز نرسیده به خانه‌ها // بررسی برخورد با مهره حریف (ضربه) return np; } return -1; } tryMove(pawnIdx){ if(!this.waitingForMove) return false; let color = this.players[this.turnIdx]; let pos = this.pawns[color][pawnIdx]; let steps = this.diceValue; if(pos===-1 && steps!==6) return false; let newPos = this.getNewPosition(color, pos, steps); if(newPos === -1) return false; // ضربه زدن let hit = false; for(let i=0;i= 52 && newPos < 100){} // فعلاً ignore this.waitingForMove = false; clearInterval(this.timerInterval); // چک برنده let allFinished = true; for(let i=0;i<4;i++) if(this.pawns[color][i] !== 100) allFinished=false; if(allFinished){ this.winner = color; this.finished = true; this.onUpdate(); return true; } if(steps !== 6) this.turnIdx = (this.turnIdx+1)%this.players.length; this.onUpdate(); return true; } startTimer(){ this.timeLeft = 6; if(this.timerInterval) clearInterval(this.timerInterval); this.timerInterval = setInterval(()=>{ if(this.waitingForMove && !this.finished){ this.timeLeft -= 0.1; if(this.timeLeft <= 0){ clearInterval(this.timerInterval); this.endTurn(); } this.onUpdate(); } else clearInterval(this.timerInterval); },100); } endTurn(){ if(this.waitingForMove){ this.waitingForMove = false; clearInterval(this.timerInterval); this.turnIdx = (this.turnIdx+1)%this.players.length; this.onUpdate(); } } getCurrentColor(){ return this.players[this.turnIdx]; } } let activeGame = null; let canvas = null, ctx = null; function drawBoard(){ if(!canvas) return; let w=600, h=600; ctx.fillStyle="#f0d9b5"; ctx.fillRect(0,0,w,h); // رسم ساده مسیر (برای نمایش نمادین) ctx.font="bold 20px sans-serif"; ctx.fillStyle="black"; ctx.fillText("بازی منچ",20,50); if(activeGame){ let players = activeGame.players; for(let i=0;i=0?"♟️":"🏁"); ctx.fillStyle = colorName; ctx.fillText(`${COLOR_SYMBOLS[COLORS.indexOf(colorName)]}${state}`, x+p*30, y); } } ctx.fillStyle = "black"; ctx.fillText(`نوبت: ${COLOR_SYMBOLS[COLORS.indexOf(activeGame.getCurrentColor())]}`, 20, 120); ctx.fillText(`تاس: ${activeGame.diceValue || "🎲"}`, 20, 170); if(activeGame.waitingForMove) ctx.fillText(`زمان: ${activeGame.timeLeft.toFixed(1)}ثانیه`,20,220); if(activeGame.winner) ctx.fillText(`برنده: ${activeGame.winner}`,20,270); } } function renderGame(){ if(activeGame && canvas) drawBoard(); } // شروع بازی با موتور function startGameWithPlayers(playersColors, entryFee, winPrize, isTeam=false, teamCallback=null){ if(entryFee>0 && !deductCoins(entryFee)) return false; activeGame = new LudoGame(playersColors, ()=>{ renderGame(); }); document.querySelector(".panel.active-panel").classList.remove("active-panel"); document.getElementById("gameBoardPanel").style.display = "block"; canvas = document.getElementById("ludoCanvas"); ctx = canvas.getContext("2d"); renderGame(); // رویداد تاس const diceBtn = document.getElementById("diceBtn"); const newRoll = ()=>{ if(activeGame && !activeGame.finished && activeGame.getCurrentColor() === playersColors[0] && !activeGame.waitingForMove){ activeGame.rollDice(); renderGame(); } else if(activeGame && activeGame.finished){ let winnerColor = activeGame.winner; if(winnerColor === playersColors[0]){ addCoins(winPrize); alert(`تبریک! شما برنده شدید و +${winPrize} سکه گرفتید.`); } else alert(`بازنده! ${winnerColor} برنده شد.`); endCurrentGame(); } else if(activeGame && activeGame.waitingForMove){ // انتخاب مهره } }; diceBtn.onclick = newRoll; // انتخاب مهره روی canvas (ساده: کلیک بر روی متن مهره) canvas.onclick = (e)=>{ if(!activeGame || activeGame.finished) return; let rect = canvas.getBoundingClientRect(); let scale = canvas.width/rect.width; let mx = (e.clientX - rect.left)*scale; let my = (e.clientY - rect.top)*scale; // تشخیص تقریبی for(let i=0;i<4;i++){ let x=100 + i*30; let y=500; if(mx > x && mx < x+25 && my > y && my < y+30){ if(activeGame.getCurrentColor() === playersColors[0] && activeGame.waitingForMove){ activeGame.tryMove(i); renderGame(); if(activeGame.finished){ let winnerColor = activeGame.winner; if(winnerColor === playersColors[0]) addCoins(winPrize); else alert(`باختید!`); endCurrentGame(); } } break; } } }; document.getElementById("exitGameBtn").onclick = ()=>{ endCurrentGame(); }; return true; } function endCurrentGame(){ if(activeGame && activeGame.timerInterval) clearInterval(activeGame.timerInterval); activeGame = null; document.getElementById("gameBoardPanel").style.display = "none"; document.getElementById("panel-main").classList.add("active-panel"); } // شروع مودهای مختلف function startOnline1v1(){ startGameWithPlayers([currentUser.avatarToColor?"قرمز":COLORS[0], COLORS[1]], 100, 300); } function startTeamMode(){ if(currentUser.coins>=1000){ deductCoins(1000); alert("بازی تیمی: شما و یک هم‌تیمی (ساختگی) در برابر دو حریف. اگر بردید هر کدام ۱۸۰۰ سکه می‌گیرید."); setTimeout(()=>{ addCoins(1800); alert("تیم شما برد! +۱۸۰۰ سکه"); endCurrentGame(); }, 500); document.getElementById("gameBoardPanel").style.display="block"; setTimeout(()=>endCurrentGame(),2000); } else alert("سکه کافی نیست"); } function createFriendlyRoom(){ let code = Math.random().toString(36).substr(2,6).toUpperCase(); localStorage.setItem("ludoRoom_"+code, JSON.stringify({host:currentUser.uid, players:[currentUser.name], color:"قرمز"})); alert(`کد اتاق: ${code} - دوست شما می‌تواند با همین کد وارد شود. بعد از ورود هر دو، بازی شروع می‌شود.`); // شبیه‌سازی ساده: بعد از 5 ثانیه بازی شروع می‌شود setTimeout(()=>{ if(confirm("بازیکن دوم وارد شد؟ شروع بازی")) startGameWithPlayers([COLORS[0], COLORS[1]], 100, 250); }, 2000); } function joinFriendlyRoom(){ let code = document.getElementById("joinRoomCode").value.trim(); if(code && localStorage.getItem("ludoRoom_"+code)){ startGameWithPlayers([COLORS[0], COLORS[1]], 100, 250); } else alert("اتاق نامعتبر"); } function startOfflineBot(){ let count = parseInt(document.getElementById("botCountSelect").value); let players = [COLORS[0]]; for(let i=1;i

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions