Code edit (1 edits merged)
Please save this source code
User prompt
Her butonun kendine özel asseti olsun. TUT ve DEVAM ET butonunun asseti "tutVeDevamEtButonuGorseli" olsun. TUT ve TURU SONLANDIR butonunun asseti "tutVeTuruSonlandırButonuGorseli" olsun. PAS GEÇ butonunun asseti "pasGecButonuGorseli" olsun. Ana Menüye Dön butonunun asseti "anaMenuyeDonButonuGorseli" olsun. Oyunu Başlat butonunun asseti "oyunuBaslatButonuGorseli" olsun.
User prompt
Her butonun kendine özel asseti olsun. TUT ve DEVAM ET butonunun asseti "tutVeDevamEtButonuGorseli" olsun. TUT ve TURU SONLANDIR butonunun asseti "tutVeTuruSonlandırButonuGorseli" olsun. PAS GEÇ butonunun asseti "pasGecButonuGorseli" olsun. Ana Menüye Dön butonunun asseti "anaMenuyeDonButonuGorseli" olsun. Oyunu Başlat butonunun asseti "oyunuBaslatGorseli" olsun.
User prompt
Her butonun kendine özel asseti olsun. TUT ve DEVAM ET butonunun asseti "tutVeDevamEtButonuGorseli" olsun. TUT ve TURU SONLANDIR butonunun asseti "tutVeTuruSonlandırButonuGorseli" olsun. PAS GEÇ butonunun asseti "pasGecButonuGorseli" olsun. Ana Menüye Dön butonunun asseti "anaMenuyeDonButonuGorseli" olsun. Oyunu Başlat butonunun asseti "oyunuBaşlatGorseli" olsun.
Code edit (2 edits merged)
Please save this source code
User prompt
Puan tablosunun da altında gri renkli "3'ten sonraki her ilave zar değerini iki katına çıkarır." yazmasını istiyorum. Ayrıca "var row6a = createDiceRow(['zar6'], "= Joker", diceSize);" kısmında "zar6" asseti yerine "zarJoker" asseti olsun. "zarJoker" asseti ekleyelim.
Code edit (8 edits merged)
Please save this source code
User prompt
Puan tablosunu biraz çok az daha aşağı taşı. Ayrıca biraz daha sola taşı. Ayrıca yataydaki aralarında olan (büyük boşluk) dediğim boşluğu da biraz daha arttır.
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Şu şekilde bir tablo oluşturman gerekiyor: (Oyunun skor tablosunu gösterebilmem için) "zar1 asseti" = 100 (büyük boşluk) "zar1 asseti" "zar1 asseti" "zar1 asseti" = 1000 "zar5 asseti" = 50 (büyük boşluk) "zar2 asseti" "zar2 asseti" "zar2 asseti" = 200 "zar1 asseti" "zar2 asseti" "zar3 asseti" "zar4 asseti" "zar5 asseti" = 500 (büyük boşluk) "zar3 asseti" "zar3 asseti" "zar3 asseti" = 300 "zar2 asseti" "zar3 asseti" "zar4 asseti" "zar5 asseti" "zar6 asseti" = 750 (büyük boşluk) "zar4 asseti" "zar4 asseti" "zar4 asseti" = 400 "zar1 asseti" "zar2 asseti" "zar3 asseti" "zar4 asseti" "zar5 asseti" "zar6 asseti" = 1500 (büyük boşluk) "zar5 asseti" "zar5 asseti" "zar5 asseti" = 500 "zar6 asseti" = Joker (büyük boşluk) "zar6 asseti" "zar6 asseti" "zar6 asseti" = 600 Bu tabloyu skor tablosunun altına koyacağım.
User prompt
Hani şu anda atılan zarların sonucunda hiçbir kombinasyon yapılamadığı zaman kırmızı bir ekran yanıp yavaşça sönüyor ya, bunun süresini uzatabilir miyiz? O kırmızı ekran bittikten sonra çok hızlı geçiyor oyun. O kırmızı ekran geldiği zaman ekranda 1 saniye boyunca beyaz "İflas!" yazısı yazsa ve o da yavaşça kaybolsa ve sonrasında oyun devam etse (sıra diğer oyuncuya geçse) daha güzel olurdu bence. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (3 edits merged)
Please save this source code
User prompt
Ama şu anda zarlar dönüyorken NPC (2. oyuncu) hala zar seçebiliyor! Zarlar dönüyorken (durmamışken) zarlar seçilemez! Zar seçmek için zarlar durmuş olmaları şart.
User prompt
Please fix the bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'selected')' in or related to this line: 'if (dice[idx].selected) {' Line Number: 921
User prompt
Ama şu anda 2. oyuncu (NPC) TUT ve DEVAM ET dediği zaman zarların döndüğünü görmüyorum, zarlar sadece 1. oyuncu TUT ve DEVAM ET dediği zaman dönüyor. Bunu düzelt. Ayrıca zarlar dönerken 2. oyuncu da zar seçemez, zar dönüşünün bitmesini beklemek zorunda. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
TUT ve DEVAM ET butonuna basıldığı zaman zarlar bir anda fırlatılmasın, zarlar rastgele olarak 2 saniye boyunca dönsün (farklı değerler göstersin hızlıca dönüyormuş gibi) sonra dursun. Bu esnada zarlar seçilemez, zarların seçilebilmesi için durması gerekiyor bu hızlıca dönme sürecinin. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Zarların her biri için bir asset kullanmak istiyorum. 1 zarında "zar1", 2 zarında "zar2", 3 zarında "zar3", 4 zarında "zar4", 5 zarında "zar5", 6 zarında "zar6" asseti olsun.
Code edit (2 edits merged)
Please save this source code
User prompt
Zarların boyutunu biraz daha büyült.
Code edit (1 edits merged)
Please save this source code
User prompt
TUT ve TURU SONALNDIR butonunun yanına PAS GEÇ butonu ekle. Bu butona basınca sıram pas geçsin ve tur sırası rakibe (2. Oyuncu) geçsin.
User prompt
Hedef skoru 2000 yerine 5000 yapar mısın? Ayrıca attığım zar sonucunda (sıra bana gelince attığım zar da dahil) eğer hiçbir şekilde kombinasyon yapamıyorsam otomatik olarak tur sıram rakibe geçmeli.
Code edit (5 edits merged)
Please save this source code
User prompt
2. Oyuncunun seçtiği zarlar hala aşağıda dizilmiyor! Şu kısım "/* Seçili zarlar aşağıda (hem PLAYER hem de NPC için) */ var selStart = W / 2 - (sel.length - 1) * 220 / 2; var selY = H / 2 + 250; sel.forEach(function (idx, i) { var d = dice[idx]; d.x = selStart + i * 220; d.y = selY; d.face.alpha = .6; }); /* Diğer zarlar ortada */ var unStart = W / 2 - (unsel.length - 1) * 220 / 2, y = H / 2; unsel.forEach(function (idx, i) { var d = dice[idx]; d.x = unStart + i * 220; d.y = y; d.face.alpha = 1; });" 1. oyuncu için düzgün çalışıyor fakat 2. oyuncu (NPC) için düzgün çalışmıyor. Şimdi de sağda diziliyor. Ayrıca 2. oyuncu (NPC) her zar seçtiğinde "zarSecmeSesi" çalsın 1 kere. 2. oyuncu TUT ve DEVAM ET butonuna basınca "tutVeDevamEtSesi" çalsın 1 kere. 2. oyuncu TUT ve TURU SONLANDIR butonuna basınca "tutVeTuruSonlandirSesi" çalsın 1 kere. 2. oyuncu seçtiği zarı geri bırakırsa "zarBirakmaSesi" çalsın 1 kere.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Initialize Game ****/ // Kanvas boyutları /* --- Oyun nesnesi --- */ var game = new LK.Game({ backgroundColor: 0x1a1a1a }); /**** * Game Code ****/ /* --- Zar sınıfı --- */ /*********************************************************** * 1. KISIM — VARLIKLAR, GENEL TANIMLAR, Dice SINIFI ************************************************************/ // Custom background images for each screen // Music for each screen function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) { throw o; } } } }; } function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) { return _arrayLikeToArray(r, a); } var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) { n[e] = r[e]; } return n; } function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) { return; } f = !1; } else { for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0) { ; } } } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) { return; } } finally { if (o) { throw n; } } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) { return r; } } function _classCallCheck(a, n) { if (!(a instanceof n)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) { return t; } var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) { return i; } throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) { return e; } if (void 0 !== e) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(t); } function _assertThisInitialized(e) { if (void 0 === e) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return e; } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } function _inherits(t, e) { if ("function" != typeof e && null !== e) { throw new TypeError("Super expression must either be null or a function"); } t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } var W = 2048, H = 2732; var Dice = /*#__PURE__*/function (_Container) { function Dice() { var _this; _classCallCheck(this, Dice); _this = _callSuper(this, Dice); /** Zar yüzü (1-6) */ _this.value = 1; /** Seçili mi? */ _this.selected = false; // Zar yüzü asset'i (her değer için ayrı) _this.face = _this.attachAsset('zar1', { anchorX: .5, anchorY: .5 }); _this.updateFace = function () { // Eski asset'i kaldır if (_this.face && _this.face.parent) { _this.face.parent.removeChild(_this.face); } // Yeni asset'i ekle var assetName = 'zar' + _this.value; _this.face = _this.attachAsset(assetName, { anchorX: .5, anchorY: .5 }); }; // Başlangıçta 1 ile başlat _this.value = 1; _this.selected = false; _this.updateFace(); return _this; } /** Değeri ayarla + yüzü güncelle */ _inherits(Dice, _Container); return _createClass(Dice, [{ key: "setValue", value: function setValue(v) { this.value = v; this.updateFace(); } }]); }(Container); /* --- Global durum --- */ var PLAYER = 0, NPC = 1; var scores = [0, 0], turnScore = 0, current = PLAYER, gameOver = false; var dice = []; // Aktif zarlar var selectedDiceIdx = []; // Seçili zar indeksleri var diceGroup = null, selectedDiceGroup = null; /* --- Diziyi yeniden numaralandır + doğru tıklama --- */ function renumberDice() { for (var i = 0; i < dice.length; i++) { var d = dice[i]; d.idx = i; // güncel indis d.down = function () { toggleSelect(this.idx); }; // <— closure sorunu yok } } /*********************************************************** * 2. KISIM — SKOR HESABI ve KOMBİNASYON YARDIMCILARI ************************************************************/ /* Farkle puan tablosu */ function calcScoreFarkle(vals) { var cnt = Array(7).fill(0); vals.forEach(function (v) { return cnt[v]++; }); var score = 0, used = []; /* Full straight 1-6 */ if (vals.length === 6 && [1, 2, 3, 4, 5, 6].every(function (v) { return cnt[v] === 1; })) { return { score: 1500, used: [0, 1, 2, 3, 4, 5] }; } /* Partial straight 1-5 */ if (vals.length === 5 && [1, 2, 3, 4, 5].every(function (v) { return cnt[v]; })) { return { score: 500, used: [0, 1, 2, 3, 4] }; } /* Partial straight 2-6 */ if (vals.length === 5 && [2, 3, 4, 5, 6].every(function (v) { return cnt[v]; })) { return { score: 750, used: [0, 1, 2, 3, 4] }; } /* 3-6 aynı zar kümeleri */ for (var v = 1; v <= 6; v++) { if (cnt[v] >= 3) { var base = v === 1 ? 1000 : v * 100; var factor = [1, 2, 4, 8][cnt[v] - 3]; score += base * factor; var need = cnt[v]; vals.forEach(function (val, i) { if (val === v && need) { used.push(i); need--; } }); cnt[v] = 0; // tekil sayılmasın } } /* Tekil 1 & 5 */ vals.forEach(function (v, i) { if (used.includes(i)) { return; } if (v === 1) { score += 100; used.push(i); } if (v === 5) { score += 50; used.push(i); } }); return { score: score, used: used }; } /* Seçim geçerli mi? */ function isValidSelection(selVals) { var r = calcScoreFarkle(selVals); return r.score > 0 && r.used.length === selVals.length; } /* Belirli uzunlukta kombinasyonları döndür */ function getCombinations(arr, k) { var out = []; (function helper(start, path) { if (path.length === k) { out.push(path.slice()); return; } for (var i = start; i < arr.length; i++) { path.push(arr[i]); helper(i + 1, path); path.pop(); } })(0, []); return out; } /* Kalan zarlarla **hiç** skor yapılabilir mi? */ function canMakeAnyScore(vals) { if (!vals.length) { return false; } for (var i = 1; i <= vals.length; i++) { var combs = getCombinations(vals, i); var _iterator = _createForOfIteratorHelper(combs), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var c = _step.value; if (isValidSelection(c)) { return true; } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } return false; } /*********************************************************** * 3. KISIM — GUI, HUD ve ZAR YÖNETİMİ ************************************************************/ /* --- Butonlar --- */ var rollBtn = new Container(); rollBtn.attachAsset('btnBlue', { anchorX: .5, anchorY: .5 }); var rollTxt = new Text2('TUT ve DEVAM ET', { size: 36, fill: '#fff' }); rollTxt.anchor.set(.5, .5); rollBtn.addChild(rollTxt); LK.gui.bottom.addChild(rollBtn); rollBtn.x = -500; rollBtn.y = -140; var bankBtn = new Container(); bankBtn.attachAsset('btnRed', { anchorX: .5, anchorY: .5 }); var bankTxt = new Text2('TUT ve TURU SONLANDIR', { size: 36, fill: '#fff' }); bankTxt.anchor.set(.5, .5); bankBtn.addChild(bankTxt); LK.gui.bottom.addChild(bankBtn); bankBtn.x = 0; bankBtn.y = -140; // PAS GEÇ butonu ekle var passBtn = new Container(); passBtn.attachAsset('btnBlue', { anchorX: .5, anchorY: .5 }); var passTxt = new Text2('PAS GEÇ', { size: 36, fill: '#fff' }); passTxt.anchor.set(.5, .5); passBtn.addChild(passTxt); LK.gui.bottom.addChild(passBtn); // PAS GEÇ butonunu TUT ve TURU SONLANDIR butonunun sağına yerleştir passBtn.x = 500; passBtn.y = -140; /* --- Reset & Pozisyon --- */ function resetDice() { var n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 6; if (diceGroup) { diceGroup.destroy(); } if (selectedDiceGroup) { selectedDiceGroup.destroy(); } dice = []; selectedDiceIdx = []; diceGroup = new Container(); selectedDiceGroup = new Container(); game.addChild(diceGroup); game.addChild(selectedDiceGroup); var diceSpacing = 280; var startX = W / 2 - (n - 1) * diceSpacing / 2, y = H / 2; for (var i = 0; i < n; i++) { var d = new Dice(); d.x = startX + i * diceSpacing; d.y = y; d.setValue(1 + Math.floor(Math.random() * 6)); diceGroup.addChild(d); dice.push(d); } renumberDice(); updateDicePositions(); updateHUD(); } /* Seç/Aç seçimi */ function toggleSelect(idx) { if (gameOver || current !== PLAYER) { return; } var d = dice[idx]; if (d.selected) { d.selected = false; selectedDiceIdx = selectedDiceIdx.filter(function (i) { return i !== idx; }); // Play zarBirakmaSesi when deselecting var birakmaSesi = LK.getSound && LK.getSound('zarBirakmaSesi'); if (birakmaSesi && birakmaSesi.play) { birakmaSesi.play(); } } else { d.selected = true; if (!selectedDiceIdx.includes(idx)) { selectedDiceIdx.push(idx); } // Play zarSecmeSesi when selecting var secmeSesi = LK.getSound && LK.getSound('zarSecmeSesi'); if (secmeSesi && secmeSesi.play) { secmeSesi.play(); } } updateDicePositions(); updateHUD(); } /* Konumları güncelle */ function updateDicePositions() { if (!diceGroup || !selectedDiceGroup) { return; } diceGroup.removeChildren(); selectedDiceGroup.removeChildren(); // YENİ: her iki oyuncu için d.selected bayrağını kullan var sel = [], unsel = []; for (var i = 0; i < dice.length; i++) { var d = dice[i]; if (!d) { continue; } // güvenlik if (d.selected) { sel.push(i); selectedDiceGroup.addChild(d); } else { unsel.push(i); diceGroup.addChild(d); } } /* Seçili zarlar aşağıda (hem PLAYER hem de NPC için) */ // 2. oyuncu (NPC) için de seçili zarlar aşağıda dizilecek var diceSpacing = 280; var selStart = W / 2 - (sel.length - 1) * diceSpacing / 2; var selY = H / 2 + 280; sel.forEach(function (idx, i) { var d = dice[idx]; d.x = selStart + i * diceSpacing; d.y = selY; d.face.alpha = .6; }); /* Diğer zarlar ortada */ var unStart = W / 2 - (unsel.length - 1) * diceSpacing / 2, y = H / 2; unsel.forEach(function (idx, i) { var d = dice[idx]; d.x = unStart + i * diceSpacing; d.y = y; d.face.alpha = 1; }); } /*********************************************************** * 4. KISIM — OYUN DÖNGÜSÜ, NPC, HUD, BAŞLAT ************************************************************/ /* --- HUD --- */ // Skor tablosu için Text2 objeleri var scoreTableRows = [null, null, null, null]; var turnTxt; var TARGET_SCORE = 5000; // Hedef puan // Geçici ve seçilen skorlar için yeni değişkenler var tempScores = [0, 0]; // Geçici skorlar (her oyuncu için) var selectedScores = [0, 0]; // Seçilen skorlar (her oyuncu için) var turnNumber = 1; // Tur sayısı function updateHUD() { // --- Buton aktifliği --- var selVals = selectedDiceIdx.map(function (i) { return dice[i].value; }); var valid = isValidSelection(selVals); rollBtn.alpha = bankBtn.alpha = valid ? 1 : 0.4; rollBtn.interactive = bankBtn.interactive = valid && current === PLAYER && !gameOver; // --- Skor tablosu ilk kez oluşturuluyorsa ekle --- if (!scoreTableRows[0]) { // 1. satır: başlıklar scoreTableRows[0] = new Text2("1. Oyuncu | Hedef | 2. Oyuncu", { size: 54, fill: '#fff', fontWeight: 'bold' }); scoreTableRows[0].anchor.set(0.5, 0); LK.gui.top.addChild(scoreTableRows[0]); // Skor tablosunu ekranın tam ortasına yerleştir // Tüm satırları ve sıra göstergesini tam ekranın ortasına hizala var centerX = 0; scoreTableRows[0].x = centerX; scoreTableRows[0].y = 80; // 2. satır: ana skorlar ve hedef scoreTableRows[1] = new Text2("", { size: 54, fill: '#fff' }); scoreTableRows[1].anchor.set(0.5, 0); LK.gui.top.addChild(scoreTableRows[1]); scoreTableRows[1].x = centerX; scoreTableRows[1].y = scoreTableRows[0].y + 60; // 3. satır: geçici skorlar ve tur scoreTableRows[2] = new Text2("", { size: 48, fill: '#ffe066' }); scoreTableRows[2].anchor.set(0.5, 0); LK.gui.top.addChild(scoreTableRows[2]); scoreTableRows[2].x = centerX; scoreTableRows[2].y = scoreTableRows[1].y + 54; // 4. satır: seçilen skorlar scoreTableRows[3] = new Text2("", { size: 44, fill: '#b3e6ff' }); scoreTableRows[3].anchor.set(0.5, 0); LK.gui.top.addChild(scoreTableRows[3]); scoreTableRows[3].x = centerX; scoreTableRows[3].y = scoreTableRows[2].y + 48; // Sıra göstergesi turnTxt = new Text2('', { size: 54, fill: '#ffe066', fontWeight: 'bold' }); turnTxt.anchor.set(0.5, 0); LK.gui.top.addChild(turnTxt); turnTxt.x = centerX; turnTxt.y = scoreTableRows[3].y + 60; } // --- Skor tablosunu güncelle --- scoreTableRows[1].setText("Ana Skor: " + scores[PLAYER] + " | " + TARGET_SCORE + " | " + "Ana Skor: " + scores[NPC]); scoreTableRows[2].setText("Geçici Skor: " + tempScores[PLAYER] + " | Tur: " + turnNumber + " | Geçici Skor: " + tempScores[NPC]); // Seçilen Skor'u canlı olarak güncelle (her iki oyuncu için) var liveSelectedScorePlayer = 0; var liveSelectedScoreNPC = 0; if (current === PLAYER && selectedDiceIdx.length > 0) { var selValsLive = selectedDiceIdx.map(function (i) { return dice[i].value; }); if (isValidSelection(selValsLive)) { liveSelectedScorePlayer = calcScoreFarkle(selValsLive).score; } } if (current === NPC && dice.length > 0) { // NPC'nin seçili zarlarını bul var selValsLiveNPC = []; for (var i = 0; i < dice.length; i++) { if (dice[i].selected) { selValsLiveNPC.push(dice[i].value); } } if (selValsLiveNPC.length > 0 && isValidSelection(selValsLiveNPC)) { liveSelectedScoreNPC = calcScoreFarkle(selValsLiveNPC).score; } } scoreTableRows[3].setText("Seçilen Skor: " + (current === PLAYER ? liveSelectedScorePlayer : selectedScores[PLAYER]) + " | Seçilen | Seçilen Skor: " + (current === NPC ? liveSelectedScoreNPC : selectedScores[NPC])); turnTxt.setText(current === PLAYER ? 'Sıra: 1. Oyuncuda' : 'Sıra: 2. Oyuncuda'); } /* --- Tur Aksiyonları --- */ function rollAll() { if (gameOver || current !== PLAYER) { return; } dice.forEach(function (d) { if (!d.selected) { d.setValue(1 + Math.floor(Math.random() * 6)); } }); updateDicePositions(); updateHUD(); var unselVals = dice.filter(function (d) { return !d.selected; }).map(function (d) { return d.value; }); // Eğer oyuncu zar attıktan sonra hiçbir şekilde kombinasyon yapılamıyorsa otomatik olarak turu rakibe geçir if (!canMakeAnyScore(unselVals)) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { tempScores[current] = 0; selectedScores[current] = 0; turnScore = 0; updateHUD(); endTurn(); }, 700); } } function keepAndContinue() { if (gameOver || current !== PLAYER) { return; } var selVals = selectedDiceIdx.map(function (i) { return dice[i].value; }); if (!isValidSelection(selVals)) { return; } // Seçilen skor hesapla ve ekle var selScore = calcScoreFarkle(selVals).score; selectedScores[current] = selScore; tempScores[current] += selectedScores[current]; selectedScores[current] = 0; // Seçilen skor sıfırlanır // turnScore artık kullanılmıyor, backward compatibility için güncelle turnScore = tempScores[current]; // Seçili zarları kaldır dice = dice.filter(function (d, i) { return !selectedDiceIdx.includes(i); }).map(function (d) { return d; }); selectedDiceIdx = []; if (dice.length === 0) { resetDice(6); } else { dice.forEach(function (d) { d.selected = false; d.setValue(1 + Math.floor(Math.random() * 6)); }); renumberDice(); updateDicePositions(); } updateHUD(); var unselVals = dice.map(function (d) { return d.value; }); // Eğer kalan zarlarla hiçbir şekilde kombinasyon yapılamıyorsa otomatik olarak turu rakibe geçir if (!canMakeAnyScore(unselVals)) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { tempScores[current] = 0; selectedScores[current] = 0; turnScore = 0; updateHUD(); endTurn(); }, 700); } } function keepAndEndTurn() { if (gameOver || current !== PLAYER) { return; } var selVals = selectedDiceIdx.map(function (i) { return dice[i].value; }); if (!isValidSelection(selVals)) { return; } // Seçilen skor hesapla ve ekle var selScore = calcScoreFarkle(selVals).score; selectedScores[current] = selScore; // Ana skora ekle: geçici skor + seçilen skor scores[current] += tempScores[current] + selectedScores[current]; // Sıfırla tempScores[current] = 0; selectedScores[current] = 0; turnScore = 0; updateHUD(); endTurn(); } function endTurn() { // Kazanan kontrolü if (scores[current] >= TARGET_SCORE) { showWinner(); return; } // Sırayı değiştir current = current === PLAYER ? NPC : PLAYER; // Yeni oyuncunun geçici ve seçilen skorlarını sıfırla tempScores[current] = 0; selectedScores[current] = 0; turnScore = 0; // Tur sayısını sadece 1. oyuncuya geçerken artır if (current === PLAYER) { turnNumber++; } resetDice(6); updateHUD(); if (current === NPC) { LK.setTimeout(npcTurn, 800); } } /* --- NPC Basit AI --- */ function npcTurn() { if (gameOver || current !== NPC) { return; } // Zarlar dönüyor mu kontrolü için global flag if (typeof game._rolling === "undefined") game._rolling = false; if (game._rolling) return; // Zaten dönüyorsa tekrar başlatma game._rolling = true; // Zarlar dönüyorken seçilemesin for (var i = 0; i < dice.length; i++) { dice[i].down = function () {}; } // 2 saniye boyunca zarları hızlıca döndür var rollDuration = 2000; var rollInterval = 60; // ms var elapsed = 0; var rollTimer = null; function _npcRollingTick() { if (!dice || dice.length === 0) return; for (var i = 0; i < dice.length; i++) { dice[i].selected = false; dice[i].setValue(1 + Math.floor(Math.random() * 6)); } updateDicePositions(); elapsed += rollInterval; if (elapsed < rollDuration) { rollTimer = LK.setTimeout(_npcRollingTick, rollInterval); } else { // Animasyon bitti, tekrar seçilebilir yap game._rolling = false; // Zarlar tekrar seçilebilsin (NPC için, insan oyuncu sırası gelene kadar interaktif olmayacak) renumberDice(); // Devam et: NPC'nin kombinasyon bulma ve oynama kodu _npcAfterRoll(); } } function _npcAfterRoll() { // --- Orijinal kodun devamı --- updateDicePositions(); // En yüksek puanlı kombinasyonu bul var vals = dice.map(function (d) { return d.value; }); var bestScore = 0, bestSel = []; for (var i = 1; i <= vals.length; i++) { var _iterator2 = _createForOfIteratorHelper(getCombinations(vals, i)), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var comb = _step2.value; if (isValidSelection(comb)) { var s = calcScoreFarkle(comb).score; if (s > bestScore) { bestScore = s; bestSel = comb; } } } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } } if (bestScore === 0) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { tempScores[NPC] = 0; selectedScores[NPC] = 0; turnScore = 0; updateHUD(); endTurn(); }, 700); return; } // Zarları adım adım seç ve HUD'da göster, ardından NPC'nin kararını uygula var npcSelectOrder = []; // bestSel'deki değerleri, zarların sırasına göre eşleştir var used = []; for (var i = 0; i < dice.length; i++) { var dval = dice[i].value; // Aynı değerden birden fazla varsa, her biri için bir kez eşleştir for (var j = 0; j < bestSel.length; j++) { if (!used[j] && bestSel[j] === dval) { npcSelectOrder.push(i); used[j] = true; break; } } } var npcSelectIndex = 0; function npcSelectNextDie() { if (npcSelectIndex < npcSelectOrder.length) { // Sıradaki zarı seç var idx = npcSelectOrder[npcSelectIndex]; // Eğer zar zaten seçiliyse (NPC geri bırakıyorsa), bırakma sesi çal if (dice[idx].selected) { var birakmaSesi = LK.getSound && LK.getSound('zarBirakmaSesi'); if (birakmaSesi && birakmaSesi.play) { birakmaSesi.play(); } dice[idx].selected = false; } else { // Zar seçme sesi çal var secmeSesi = LK.getSound && LK.getSound('zarSecmeSesi'); if (secmeSesi && secmeSesi.play) { secmeSesi.play(); } dice[idx].selected = true; } updateDicePositions(); updateHUD(); npcSelectIndex++; LK.setTimeout(npcSelectNextDie, 1000); return; } // Tüm zarlar seçildi, seçili zarlar aşağıda gösteriliyor ve skorlar güncel // Şimdi NPC'nin kararını 1 saniye bekleyip uygula LK.setTimeout(function () { // Strateji: ≥400 puan veya 1 zar kalınca bank if (bestScore >= 400 || dice.length - bestSel.length <= 1) { // TUT ve TURU SONLANDIR sesi çal var tutTuruSonlandirSesi = LK.getSound && LK.getSound('tutVeTuruSonlandirSesi'); if (tutTuruSonlandirSesi && tutTuruSonlandirSesi.play) { tutTuruSonlandirSesi.play(); } // NPC'nin seçilen skorunu ve geçici skorunu güncelle selectedScores[NPC] = bestScore; tempScores[NPC] += selectedScores[NPC]; selectedScores[NPC] = 0; turnScore = tempScores[NPC]; updateHUD(); // Ana skora ekle ve turu bitir scores[NPC] += tempScores[NPC]; tempScores[NPC] = 0; selectedScores[NPC] = 0; turnScore = 0; updateHUD(); endTurn(); } else { // TUT ve DEVAM ET sesi çal var tutDevamSesi = LK.getSound && LK.getSound('tutVeDevamEtSesi'); if (tutDevamSesi && tutDevamSesi.play) { tutDevamSesi.play(); } // NPC'nin seçilen skorunu ve geçici skorunu güncelle selectedScores[NPC] = bestScore; tempScores[NPC] += selectedScores[NPC]; selectedScores[NPC] = 0; turnScore = tempScores[NPC]; updateHUD(); // Seçili zarları kaldır dice = dice.filter(function (d) { return !d.selected; }); selectedDiceIdx = []; renumberDice(); if (dice.length === 0) { resetDice(6); } else { dice.forEach(function (d) { d.selected = false; d.setValue(1 + Math.floor(Math.random() * 6)); }); } updateDicePositions(); updateHUD(); var unselVals = dice.map(function (d) { return d.value; }); if (!canMakeAnyScore(unselVals)) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { tempScores[NPC] = 0; selectedScores[NPC] = 0; turnScore = 0; updateHUD(); endTurn(); }, 700); return; } LK.setTimeout(npcTurn, 1200); // NPC'nin oynama hızını yavaşlat (800 -> 1200) } }, 1000); } npcSelectNextDie(); } _npcRollingTick(); // En yüksek puanlı kombinasyonu bul var vals = dice.map(function (d) { return d.value; }); var bestScore = 0, bestSel = []; for (var i = 1; i <= vals.length; i++) { var _iterator2 = _createForOfIteratorHelper(getCombinations(vals, i)), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var comb = _step2.value; if (isValidSelection(comb)) { var s = calcScoreFarkle(comb).score; if (s > bestScore) { bestScore = s; bestSel = comb; } } } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } } if (bestScore === 0) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { tempScores[NPC] = 0; selectedScores[NPC] = 0; turnScore = 0; updateHUD(); endTurn(); }, 700); return; } // Zarları adım adım seç ve HUD'da göster, ardından NPC'nin kararını uygula var npcSelectOrder = []; // bestSel'deki değerleri, zarların sırasına göre eşleştir var used = []; for (var i = 0; i < dice.length; i++) { var dval = dice[i].value; // Aynı değerden birden fazla varsa, her biri için bir kez eşleştir for (var j = 0; j < bestSel.length; j++) { if (!used[j] && bestSel[j] === dval) { npcSelectOrder.push(i); used[j] = true; break; } } } var npcSelectIndex = 0; function npcSelectNextDie() { if (npcSelectIndex < npcSelectOrder.length) { // Sıradaki zarı seç var idx = npcSelectOrder[npcSelectIndex]; // Eğer zar zaten seçiliyse (NPC geri bırakıyorsa), bırakma sesi çal if (dice[idx].selected) { var birakmaSesi = LK.getSound && LK.getSound('zarBirakmaSesi'); if (birakmaSesi && birakmaSesi.play) { birakmaSesi.play(); } dice[idx].selected = false; } else { // Zar seçme sesi çal var secmeSesi = LK.getSound && LK.getSound('zarSecmeSesi'); if (secmeSesi && secmeSesi.play) { secmeSesi.play(); } dice[idx].selected = true; } updateDicePositions(); updateHUD(); npcSelectIndex++; LK.setTimeout(npcSelectNextDie, 1000); return; } // Tüm zarlar seçildi, seçili zarlar aşağıda gösteriliyor ve skorlar güncel // Şimdi NPC'nin kararını 1 saniye bekleyip uygula LK.setTimeout(function () { // Strateji: ≥400 puan veya 1 zar kalınca bank if (bestScore >= 400 || dice.length - bestSel.length <= 1) { // TUT ve TURU SONLANDIR sesi çal var tutTuruSonlandirSesi = LK.getSound && LK.getSound('tutVeTuruSonlandirSesi'); if (tutTuruSonlandirSesi && tutTuruSonlandirSesi.play) { tutTuruSonlandirSesi.play(); } // NPC'nin seçilen skorunu ve geçici skorunu güncelle selectedScores[NPC] = bestScore; tempScores[NPC] += selectedScores[NPC]; selectedScores[NPC] = 0; turnScore = tempScores[NPC]; updateHUD(); // Ana skora ekle ve turu bitir scores[NPC] += tempScores[NPC]; tempScores[NPC] = 0; selectedScores[NPC] = 0; turnScore = 0; updateHUD(); endTurn(); } else { // TUT ve DEVAM ET sesi çal var tutDevamSesi = LK.getSound && LK.getSound('tutVeDevamEtSesi'); if (tutDevamSesi && tutDevamSesi.play) { tutDevamSesi.play(); } // NPC'nin seçilen skorunu ve geçici skorunu güncelle selectedScores[NPC] = bestScore; tempScores[NPC] += selectedScores[NPC]; selectedScores[NPC] = 0; turnScore = tempScores[NPC]; updateHUD(); // Seçili zarları kaldır dice = dice.filter(function (d) { return !d.selected; }); selectedDiceIdx = []; renumberDice(); if (dice.length === 0) { resetDice(6); } else { dice.forEach(function (d) { d.selected = false; d.setValue(1 + Math.floor(Math.random() * 6)); }); } updateDicePositions(); updateHUD(); var unselVals = dice.map(function (d) { return d.value; }); if (!canMakeAnyScore(unselVals)) { LK.effects.flashScreen(0xff0000, 600); LK.setTimeout(function () { tempScores[NPC] = 0; selectedScores[NPC] = 0; turnScore = 0; updateHUD(); endTurn(); }, 700); return; } LK.setTimeout(npcTurn, 1200); // NPC'nin oynama hızını yavaşlat (800 -> 1200) } }, 1000); } npcSelectNextDie(); } /* --- Kazanan ekranı --- */ function showWinner() { gameOver = true; var winnerText = current === PLAYER ? 'Kazandın!' : 'NPC Kazandı!'; showGameOverScreen(winnerText); } /* --- Buton Olayları --- */ rollBtn.down = function () { if (current === PLAYER) { var _rollingTick = function rollingTick() { if (!dice || dice.length === 0) return; for (var i = 0; i < dice.length; i++) { if (!dice[i].selected) { dice[i].setValue(1 + Math.floor(Math.random() * 6)); } } updateDicePositions(); elapsed += rollInterval; if (elapsed < rollDuration) { rollTimer = LK.setTimeout(_rollingTick, rollInterval); } else { // Animasyon bitti, tekrar tıklanabilir yap game._rolling = false; rollBtn.interactive = true; bankBtn.interactive = true; passBtn.interactive = true; renumberDice(); // Zarları tekrar seçilebilir yap keepAndContinue(); } }; var tutDevamSesi = LK.getSound && LK.getSound('tutVeDevamEtSesi'); if (tutDevamSesi && tutDevamSesi.play) { tutDevamSesi.play(); } // Zarlar dönüyor mu kontrolü için global flag if (typeof game._rolling === "undefined") game._rolling = false; if (game._rolling) return; // Zaten dönüyorsa tekrar başlatma game._rolling = true; // Zarlar dönüyorken tıklanamaz/yok sayılsın rollBtn.interactive = false; bankBtn.interactive = false; passBtn.interactive = false; // Zarlar dönüyorken seçilemesin for (var i = 0; i < dice.length; i++) { dice[i].down = function () {}; } // 2 saniye boyunca zarları hızlıca döndür var rollDuration = 2000; var rollInterval = 60; // ms var elapsed = 0; var rollTimer = null; _rollingTick(); } }; bankBtn.down = function () { if (current === PLAYER) { var tutTuruSonlandirSesi = LK.getSound && LK.getSound('tutVeTuruSonlandirSesi'); if (tutTuruSonlandirSesi && tutTuruSonlandirSesi.play) { tutTuruSonlandirSesi.play(); } keepAndEndTurn(); } }; // PAS GEÇ butonu olayı passBtn.down = function () { if (current === PLAYER && !gameOver) { // Sıramı pas geç, turu rakibe geçir tempScores[current] = 0; selectedScores[current] = 0; turnScore = 0; updateHUD(); endTurn(); } }; /* --- Başlat --- */ function startGame() { scores = [0, 0]; tempScores = [0, 0]; selectedScores = [0, 0]; turnScore = 0; turnNumber = 1; current = PLAYER; gameOver = false; // Set oyunEkraniArkaplani as background if (game._oyunBg) { game._oyunBg.destroy(); game._oyunBg = null; } var oyunBg = LK.getAsset('oyunEkraniArkaplani', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: W, height: H }); game.addChildAt(oyunBg, 0); game._oyunBg = oyunBg; // Müzik sadece loading ekranı kalkınca başlatılacak, burada tekrar başlatılmıyor resetDice(6); updateHUD(); } // --- Ana Menü ve Oyun Sonu Ekranları --- var mainMenuContainer = null; var gameOverContainer = null; // Ana Menü Ekranını Göster function showMainMenu() { // Temizle if (mainMenuContainer) { mainMenuContainer.destroy(); mainMenuContainer = null; } if (gameOverContainer) { gameOverContainer.destroy(); gameOverContainer = null; } // Oyun alanını temizle if (diceGroup) { diceGroup.destroy(); diceGroup = null; } if (selectedDiceGroup) { selectedDiceGroup.destroy(); selectedDiceGroup = null; } dice = []; selectedDiceIdx = []; // Skor tablosunu gizle for (var i = 0; i < scoreTableRows.length; i++) { if (scoreTableRows[i]) { scoreTableRows[i].visible = false; } } if (turnTxt) { turnTxt.visible = false; } // Butonları pasifleştir rollBtn.visible = false; bankBtn.visible = false; if (typeof passBtn !== "undefined") { passBtn.visible = false; } // Remove oyun ekranı arkaplanı if exists if (game._oyunBg) { game._oyunBg.destroy(); game._oyunBg = null; } // Ana Menü Container mainMenuContainer = new Container(); mainMenuContainer.width = W; mainMenuContainer.height = H; // Arkaplan (anaMenuEkraniArkaplani) var bg = LK.getAsset('anaMenuEkraniArkaplani', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: W, height: H }); mainMenuContainer.addChild(bg); // Müzik sadece loading ekranı kalkınca başlatılacak, burada tekrar başlatılmıyor // "Oyunu Başlat" Butonu var startBtn = new Container(); startBtn.attachAsset('btnBlue', { anchorX: 0.5, anchorY: 0.5, width: 600, // Buton genişliğini büyüt height: 180 // Buton yüksekliğini büyüt }); var startTxt = new Text2('Oyunu Başlat', { size: 60, // Yazı boyutunu büyüt fill: '#fff' }); startTxt.anchor.set(0.5, 0.5); startBtn.addChild(startTxt); startBtn.x = W / 2; startBtn.y = H / 2; startBtn.interactive = true; startBtn.down = function () { hideMainMenu(); startGame(); }; mainMenuContainer.addChild(startBtn); game.addChild(mainMenuContainer); } // Ana Menü Ekranını Gizle function hideMainMenu() { if (mainMenuContainer) { mainMenuContainer.destroy(); mainMenuContainer = null; } // Skor tablosunu göster for (var i = 0; i < scoreTableRows.length; i++) { if (scoreTableRows[i]) { scoreTableRows[i].visible = true; } } if (turnTxt) { turnTxt.visible = true; } // Butonları göster rollBtn.visible = true; bankBtn.visible = true; if (typeof passBtn !== "undefined") { passBtn.visible = true; } } // Oyun Sonu Ekranını Göster function showGameOverScreen(winnerText) { // Temizle if (gameOverContainer) { gameOverContainer.destroy(); gameOverContainer = null; } if (mainMenuContainer) { mainMenuContainer.destroy(); mainMenuContainer = null; } // Oyun alanını temizle if (diceGroup) { diceGroup.destroy(); diceGroup = null; } if (selectedDiceGroup) { selectedDiceGroup.destroy(); selectedDiceGroup = null; } dice = []; selectedDiceIdx = []; // Skor tablosunu gizle for (var i = 0; i < scoreTableRows.length; i++) { if (scoreTableRows[i]) { scoreTableRows[i].visible = false; } } if (turnTxt) { turnTxt.visible = false; } // Butonları pasifleştir rollBtn.visible = false; bankBtn.visible = false; if (typeof passBtn !== "undefined") { passBtn.visible = false; } // Remove oyun ekranı arkaplanı if exists if (game._oyunBg) { game._oyunBg.destroy(); game._oyunBg = null; } // Oyun Sonu Container gameOverContainer = new Container(); gameOverContainer.width = W; gameOverContainer.height = H; // Arkaplan (oyunSonuEkraniArkaplani) var bg = LK.getAsset('oyunSonuEkraniArkaplani', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: W, height: H }); gameOverContainer.addChild(bg); // Müzik sadece loading ekranı kalkınca başlatılacak, burada tekrar başlatılmıyor // Kazanan/Kaybeden Metni var resultTxt = new Text2(winnerText || 'Oyun Bitti', { size: 80, fill: '#fff' }); resultTxt.anchor.set(0.5, 0.5); resultTxt.x = W / 2; resultTxt.y = H / 2 - 120; gameOverContainer.addChild(resultTxt); // "Ana Menüye Dön" Butonu var menuBtn = new Container(); menuBtn.attachAsset('btnRed', { anchorX: 0.5, anchorY: 0.5 }); var menuTxt = new Text2('Ana Menüye Dön', { size: 60, fill: '#fff' }); menuTxt.anchor.set(0.5, 0.5); menuBtn.addChild(menuTxt); menuBtn.x = W / 2; menuBtn.y = H / 2 + 60; menuBtn.interactive = true; menuBtn.down = function () { hideGameOverScreen(); showMainMenu(); }; gameOverContainer.addChild(menuBtn); game.addChild(gameOverContainer); } // Oyun Sonu Ekranını Gizle function hideGameOverScreen() { if (gameOverContainer) { gameOverContainer.destroy(); gameOverContainer = null; } // Skor tablosunu göster for (var i = 0; i < scoreTableRows.length; i++) { if (scoreTableRows[i]) { scoreTableRows[i].visible = true; } } if (turnTxt) { turnTxt.visible = true; } // Butonları göster rollBtn.visible = true; bankBtn.visible = true; if (typeof passBtn !== "undefined") { passBtn.visible = true; } } // --- Kazanan ekranı override --- // Yükleme ekranı için sınıf ve gösterme fonksiyonu var loadingContainer = null; var loadingTimeout = null; // Tween plugin import // Yükleme ekranını göster function showLoadingScreen() { // First, create the main menu in the background so resources can load showMainMenu(); // Müzik yükleme ekranında başlamasın, sadece loading kalkınca başlatacağız // (Burada playMusic çağrısı kaldırıldı) // Temizle if (loadingContainer) { loadingContainer.destroy(); loadingContainer = null; } loadingContainer = new Container(); loadingContainer.width = W; loadingContainer.height = H; // Kırmızı arkaplan var bg = LK.getAsset('loadingBgRed', { anchorX: 0, anchorY: 0, x: 0, y: 0, width: W, height: H, color: 0xff0000, shape: 'box' }); loadingContainer.addChild(bg); // Novatek logosu (ortada üstte) var logo = LK.getAsset('novatekLogosu', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1050 }); loadingContainer.addChild(logo); // "Loading..." yazısı var loadingTxt = new Text2('Yükleniyor...', { size: 90, fill: '#fff' }); loadingTxt.anchor.set(0.5, 0.5); loadingTxt.x = 1024; loadingTxt.y = 1366; loadingContainer.addChild(loadingTxt); // Alt açıklama yazısı var infoTxt = new Text2("En iyi oyun deneyimi için lütfen oyunun grafik ve ses kaynakları tamamen yüklenene kadar bekleyin. Unutmayın ki insanların %99'u büyük kazanamadan hemen önce oyunu bırakıyor! %1'e girebilecek misiniz?", { size: 36, fill: '#fff', wordWrap: true, wordWrapWidth: 1800, align: 'center' }); infoTxt.anchor.set(0.5, 0); infoTxt.x = 1024; infoTxt.y = 1460; loadingContainer.addChild(infoTxt); // Dönen yükleme çubuğu var spinner = LK.getAsset('yuklemeCubugu', { anchorX: 0.5, anchorY: 0.5, x: W / 2, y: infoTxt.y + infoTxt.height + 120 }); loadingContainer.addChild(spinner); // Spinner animasyonu (dönme) spinner.rotation = 0; var _spinTween = function spinTween() { tween(spinner, { rotation: spinner.rotation + Math.PI * 2 }, { duration: 1200, easing: tween.linear, onFinish: _spinTween }); }; _spinTween(); // Add loading screen on top of main menu game.addChild(loadingContainer); // 10 saniye sonra loading ekranını kaldır (ana menü zaten gösteriliyor) loadingTimeout = LK.setTimeout(function () { if (loadingContainer) { loadingContainer.destroy(); loadingContainer = null; } // Ana menü zaten gösteriliyor, sadece loading overlay'ini kaldırıyoruz // Müzik burada başlatılır, sadece bir kez ve döngüde LK.playMusic('oyunEkraniMuzigi', { loop: true }); }, 10000); } // Oyun başında yükleme ekranını göster showLoadingScreen(); /* --- Responsive HUD --- */ if (!window._frvr_gui_resize_hooked) { window._frvr_gui_resize_hooked = true; LK.on('resize', function () { var centerX = W / 2; // 2048/2 = 1024, ekranın tam ortası for (var i = 0; i < scoreTableRows.length; i++) { if (scoreTableRows[i]) { scoreTableRows[i].x = centerX; } } if (turnTxt) { turnTxt.x = centerX; } }); }
===================================================================
--- original.js
+++ change.js
@@ -791,13 +791,193 @@
function npcTurn() {
if (gameOver || current !== NPC) {
return;
}
- dice.forEach(function (d) {
- d.selected = false;
- d.setValue(1 + Math.floor(Math.random() * 6));
- });
- updateDicePositions();
+ // Zarlar dönüyor mu kontrolü için global flag
+ if (typeof game._rolling === "undefined") game._rolling = false;
+ if (game._rolling) return; // Zaten dönüyorsa tekrar başlatma
+ game._rolling = true;
+ // Zarlar dönüyorken seçilemesin
+ for (var i = 0; i < dice.length; i++) {
+ dice[i].down = function () {};
+ }
+ // 2 saniye boyunca zarları hızlıca döndür
+ var rollDuration = 2000;
+ var rollInterval = 60; // ms
+ var elapsed = 0;
+ var rollTimer = null;
+ function _npcRollingTick() {
+ if (!dice || dice.length === 0) return;
+ for (var i = 0; i < dice.length; i++) {
+ dice[i].selected = false;
+ dice[i].setValue(1 + Math.floor(Math.random() * 6));
+ }
+ updateDicePositions();
+ elapsed += rollInterval;
+ if (elapsed < rollDuration) {
+ rollTimer = LK.setTimeout(_npcRollingTick, rollInterval);
+ } else {
+ // Animasyon bitti, tekrar seçilebilir yap
+ game._rolling = false;
+ // Zarlar tekrar seçilebilsin (NPC için, insan oyuncu sırası gelene kadar interaktif olmayacak)
+ renumberDice();
+ // Devam et: NPC'nin kombinasyon bulma ve oynama kodu
+ _npcAfterRoll();
+ }
+ }
+ function _npcAfterRoll() {
+ // --- Orijinal kodun devamı ---
+ updateDicePositions();
+ // En yüksek puanlı kombinasyonu bul
+ var vals = dice.map(function (d) {
+ return d.value;
+ });
+ var bestScore = 0,
+ bestSel = [];
+ for (var i = 1; i <= vals.length; i++) {
+ var _iterator2 = _createForOfIteratorHelper(getCombinations(vals, i)),
+ _step2;
+ try {
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
+ var comb = _step2.value;
+ if (isValidSelection(comb)) {
+ var s = calcScoreFarkle(comb).score;
+ if (s > bestScore) {
+ bestScore = s;
+ bestSel = comb;
+ }
+ }
+ }
+ } catch (err) {
+ _iterator2.e(err);
+ } finally {
+ _iterator2.f();
+ }
+ }
+ if (bestScore === 0) {
+ LK.effects.flashScreen(0xff0000, 600);
+ LK.setTimeout(function () {
+ tempScores[NPC] = 0;
+ selectedScores[NPC] = 0;
+ turnScore = 0;
+ updateHUD();
+ endTurn();
+ }, 700);
+ return;
+ }
+ // Zarları adım adım seç ve HUD'da göster, ardından NPC'nin kararını uygula
+ var npcSelectOrder = [];
+ // bestSel'deki değerleri, zarların sırasına göre eşleştir
+ var used = [];
+ for (var i = 0; i < dice.length; i++) {
+ var dval = dice[i].value;
+ // Aynı değerden birden fazla varsa, her biri için bir kez eşleştir
+ for (var j = 0; j < bestSel.length; j++) {
+ if (!used[j] && bestSel[j] === dval) {
+ npcSelectOrder.push(i);
+ used[j] = true;
+ break;
+ }
+ }
+ }
+ var npcSelectIndex = 0;
+ function npcSelectNextDie() {
+ if (npcSelectIndex < npcSelectOrder.length) {
+ // Sıradaki zarı seç
+ var idx = npcSelectOrder[npcSelectIndex];
+ // Eğer zar zaten seçiliyse (NPC geri bırakıyorsa), bırakma sesi çal
+ if (dice[idx].selected) {
+ var birakmaSesi = LK.getSound && LK.getSound('zarBirakmaSesi');
+ if (birakmaSesi && birakmaSesi.play) {
+ birakmaSesi.play();
+ }
+ dice[idx].selected = false;
+ } else {
+ // Zar seçme sesi çal
+ var secmeSesi = LK.getSound && LK.getSound('zarSecmeSesi');
+ if (secmeSesi && secmeSesi.play) {
+ secmeSesi.play();
+ }
+ dice[idx].selected = true;
+ }
+ updateDicePositions();
+ updateHUD();
+ npcSelectIndex++;
+ LK.setTimeout(npcSelectNextDie, 1000);
+ return;
+ }
+ // Tüm zarlar seçildi, seçili zarlar aşağıda gösteriliyor ve skorlar güncel
+ // Şimdi NPC'nin kararını 1 saniye bekleyip uygula
+ LK.setTimeout(function () {
+ // Strateji: ≥400 puan veya 1 zar kalınca bank
+ if (bestScore >= 400 || dice.length - bestSel.length <= 1) {
+ // TUT ve TURU SONLANDIR sesi çal
+ var tutTuruSonlandirSesi = LK.getSound && LK.getSound('tutVeTuruSonlandirSesi');
+ if (tutTuruSonlandirSesi && tutTuruSonlandirSesi.play) {
+ tutTuruSonlandirSesi.play();
+ }
+ // NPC'nin seçilen skorunu ve geçici skorunu güncelle
+ selectedScores[NPC] = bestScore;
+ tempScores[NPC] += selectedScores[NPC];
+ selectedScores[NPC] = 0;
+ turnScore = tempScores[NPC];
+ updateHUD();
+ // Ana skora ekle ve turu bitir
+ scores[NPC] += tempScores[NPC];
+ tempScores[NPC] = 0;
+ selectedScores[NPC] = 0;
+ turnScore = 0;
+ updateHUD();
+ endTurn();
+ } else {
+ // TUT ve DEVAM ET sesi çal
+ var tutDevamSesi = LK.getSound && LK.getSound('tutVeDevamEtSesi');
+ if (tutDevamSesi && tutDevamSesi.play) {
+ tutDevamSesi.play();
+ }
+ // NPC'nin seçilen skorunu ve geçici skorunu güncelle
+ selectedScores[NPC] = bestScore;
+ tempScores[NPC] += selectedScores[NPC];
+ selectedScores[NPC] = 0;
+ turnScore = tempScores[NPC];
+ updateHUD();
+ // Seçili zarları kaldır
+ dice = dice.filter(function (d) {
+ return !d.selected;
+ });
+ selectedDiceIdx = [];
+ renumberDice();
+ if (dice.length === 0) {
+ resetDice(6);
+ } else {
+ dice.forEach(function (d) {
+ d.selected = false;
+ d.setValue(1 + Math.floor(Math.random() * 6));
+ });
+ }
+ updateDicePositions();
+ updateHUD();
+ var unselVals = dice.map(function (d) {
+ return d.value;
+ });
+ if (!canMakeAnyScore(unselVals)) {
+ LK.effects.flashScreen(0xff0000, 600);
+ LK.setTimeout(function () {
+ tempScores[NPC] = 0;
+ selectedScores[NPC] = 0;
+ turnScore = 0;
+ updateHUD();
+ endTurn();
+ }, 700);
+ return;
+ }
+ LK.setTimeout(npcTurn, 1200); // NPC'nin oynama hızını yavaşlat (800 -> 1200)
+ }
+ }, 1000);
+ }
+ npcSelectNextDie();
+ }
+ _npcRollingTick();
// En yüksek puanlı kombinasyonu bul
var vals = dice.map(function (d) {
return d.value;
});
Yeşil casino masa arkaplanı. Dikdörtgen.
Casino oyunum için buton olarak kullanmalık dikdörtgen (köşeleri yumuşatılmış, edge). Yazısız.. In-Game asset. 2d. High contrast. No shadows
Bu sefer zar 1 yerine zar 2 olsun. Delik kırmızı değil siyah olsun.
Zar 2 değil 3 olsun.
Zar 4 olsun. Deliklerinin içi dolu siyah olsun.
Zar 2 değil, zar 5 olsun.
Zar 6 olsun. İçindeki deliklerin içi dolu siyah olsun.
Zar 6 değil, zar joker olsun. Yani zarın üstünde joker sembolü olsun.
Zar 4 değil, zar 1 olsun. İçi siyah değil kırmızı olsun.
Casino tarzında yatay dikdörtgen (köşeleri yumuşatılmış, edge). İçi sarı, dışında kırmızı şerit var. Sol üst köşesinde bir çift zar var. Yazısız.. In-Game asset. 2d. High contrast. No shadows. Casino
oyunEkraniMuzigi
Music
zarBirakmaSesi
Sound effect
zarSecmeSesi
Sound effect
tutVeDevamEtSesi
Sound effect
tutVeTuruSonlandirSesi
Sound effect
ilkSenBasliyorsunSesi
Sound effect
rakibinSirasiSesi
Sound effect
siraSendeSesi
Sound effect
iflasBenSesi
Sound effect
iflasRakipSesi
Sound effect
senKazandinSesi
Sound effect
kaybettinSesi
Sound effect
pasButonuSesi
Sound effect
klavyeTusunaBasmaSesi
Sound effect
oyunuBaslatButonuSesi
Sound effect
anaMenuyeDonButonuSesi
Sound effect
hesabiSifirlaButonuSesi
Sound effect
yuklemeEkraniSesi
Sound effect
ilkRakipBasliyorSesi
Sound effect