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.
User prompt
2. Oyuncunun (NPC) seçtiği zarlar aşağıda dizilmiyor, sol tarafta diziliyor. Benim mesela (1. Oyuncu) seçtiğim zarlar aşağıda diziliyor fakat 2. Oyuncunun seçtiği zarlar aşağıda dizilmiyor, solda diziliyor.
User prompt
Şu anda NPC'nin (2. Oyuncu) seçtiği zarlar sanki bir anda yok oluyor gibi. NPC (2. Oyuncu) o zarları seçtiği zaman benim seçtiğim zamandaki gibi o seçtiği zarlar aşağıda gözükmeli sonrasında oyuncu TUT ve DEVAM ET ya da TUT ve TURU SONLANDIR butonuna bastığı zaman ona göre değerlendirme yapılmalı. Şu anda 2. Oyuncu (NPC) çok hızlı oynadığı için ben 2. Oyuncunun Seçilen Skor ve Geçici Skor değerlerini tabloda göremeden bir anda Ana Skora ekliyor.
User prompt
2. Oyuncunun seçtiği zarları göremiyorum. 2. Oyuncu (NPC) çok hızlı oynuyor. 2. oyuncu her bir zarı seçerken araya 1 saniyelik bir bekleme süresi koy.
User prompt
Şu anda 2. Oyuncu çok hızlı oynuyor, daha yavaş oynamasını sağla. 2. Oyuncunun Seçilen Skor, Geçici Skor ve Ana Skor gibi skorlarını göremiyorum hep 0 yazıyor.
Code edit (1 edits merged)
Please save this source code
User prompt
NPC'nin her hareketinin arasına 500ms koy lütfen o halde.
Code edit (2 edits merged)
Please save this source code
User prompt
Hala sağda, daha fazla solda olması gerekiyor. Tam ortalanmamış çünkü. 2048'lik ekranı 1024 diye yarıya böldüğümüzü düşün sol ve sağ taraf olarak, senin yaptığında tablodaki yazıların merkezi 1024 değil ekranın sağ tarfında kalan 1024'lük yerine tam merkezi yani total ekrana göre 1536 oluyor.
User prompt
Şu anda daha da sağa doğru kaydı tablo. Neredeyse ekranımda gözükmüyor bile!
/****
* 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 _createForOfIteratorHelper3(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (!t) {
if (Array.isArray(r) || (t = _unsupportedIterableToArray3(r)) || e && r && "number" == typeof r.length) {
t && (r = t);
var _n3 = 0,
F = function F() {};
return {
s: F,
n: function n() {
return _n3 >= r.length ? {
done: !0
} : {
done: !1,
value: r[_n3++]
};
},
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 _unsupportedIterableToArray3(r, a) {
if (r) {
if ("string" == typeof r) {
return _arrayLikeToArray3(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) ? _arrayLikeToArray3(r, a) : void 0;
}
}
function _arrayLikeToArray3(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 _createForOfIteratorHelper2(r, e) {
var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
if (!t) {
if (Array.isArray(r) || (t = _unsupportedIterableToArray2(r)) || e && r && "number" == typeof r.length) {
t && (r = t);
var _n2 = 0,
F = function F() {};
return {
s: F,
n: function n() {
return _n2 >= r.length ? {
done: !0
} : {
done: !1,
value: r[_n2++]
};
},
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 _unsupportedIterableToArray2(r, a) {
if (r) {
if ("string" == typeof r) {
return _arrayLikeToArray2(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) ? _arrayLikeToArray2(r, a) : void 0;
}
}
function _arrayLikeToArray2(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 _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;
var randomize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
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;
var y = H / 2;
for (var i = 0; i < n; i++) {
var d = new Dice();
d.x = startX + i * diceSpacing;
d.y = y;
if (randomize) {
d.setValue(1 + (Math.random() * 6 | 0));
}
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;
});
}
/**** ZAR DÖNDÜRME ANİMASYONU ****/
function animateRoll(onFinish) {
var playSfx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (game._rolling) {
return;
} // Çifte animasyonu engelle
game._rolling = true;
if (playSfx) {
var s = LK.getSound && LK.getSound('tutVeDevamEtSesi');
s === null || s === void 0 || s.play();
}
rollBtn.interactive = bankBtn.interactive = passBtn.interactive = false;
dice.forEach(function (d) {
return d.down = function () {};
}); // Zarlar seçilemesin
var rollDuration = 2000,
step = 60;
var elapsed = 0;
(function tick() {
dice.forEach(function (d) {
if (!d.selected) {
d.setValue(1 + Math.random() * 6 | 0);
}
});
updateDicePositions();
if ((elapsed += step) < rollDuration) {
LK.setTimeout(tick, step);
} else {
game._rolling = false;
rollBtn.interactive = bankBtn.interactive = passBtn.interactive = true;
renumberDice(); // Zarlar yeniden seçilebilir
onFinish === null || onFinish === void 0 || onFinish(); // Animasyon tamam callback
}
})();
}
/***********************************************************
* 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]) {
// --- Zar kombinasyonları ve puan tablosu ---
// Zar assetlerini göstermek için fonksiyon
var createDiceRow = function createDiceRow(diceArr, text, size, gap) {
var row = new Container();
var x = 0;
for (var i = 0; i < diceArr.length; i++) {
var asset = LK.getAsset(diceArr[i], {
anchorX: 0.5,
anchorY: 0.5,
width: size,
height: size
});
asset.x = x;
asset.y = 0;
row.addChild(asset);
x += size + (gap || 10);
}
if (text) {
var txt = new Text2(text, {
size: size * 0.6,
fill: '#fff'
});
txt.anchor.set(0, 0.5);
txt.x = x + 30;
txt.y = 0;
row.addChild(txt);
}
return row;
}; // Tabloyu oluştur
// 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;
var scoreTableContainer = new Container();
scoreTableContainer.x = 0;
scoreTableContainer.y = turnTxt.y + 90;
var rowY = 0;
var rowGap = 70;
var diceSize = 60;
var bigGap = 80;
// 1. satır
var row1a = createDiceRow(['zar1'], "= 100", diceSize);
var row1b = createDiceRow(['zar1', 'zar1', 'zar1', 'zar1'], "= 1000", diceSize);
row1a.x = -350;
row1b.x = 200;
row1a.y = row1b.y = rowY;
scoreTableContainer.addChild(row1a);
scoreTableContainer.addChild(row1b);
rowY += rowGap;
// 2. satır
var row2a = createDiceRow(['zar5'], "= 50", diceSize);
var row2b = createDiceRow(['zar2', 'zar2', 'zar2'], "= 200", diceSize);
row2a.x = -350;
row2b.x = 200;
row2a.y = row2b.y = rowY;
scoreTableContainer.addChild(row2a);
scoreTableContainer.addChild(row2b);
rowY += rowGap;
// 3. satır
var row3a = createDiceRow(['zar1', 'zar2', 'zar3', 'zar4', 'zar5'], "= 500", diceSize);
var row3b = createDiceRow(['zar3', 'zar3', 'zar3'], "= 300", diceSize);
row3a.x = -350;
row3b.x = 200;
row3a.y = row3b.y = rowY;
scoreTableContainer.addChild(row3a);
scoreTableContainer.addChild(row3b);
rowY += rowGap;
// 4. satır
var row4a = createDiceRow(['zar2', 'zar3', 'zar4', 'zar5', 'zar6'], "= 750", diceSize);
var row4b = createDiceRow(['zar4', 'zar4', 'zar4'], "= 400", diceSize);
row4a.x = -350;
row4b.x = 200;
row4a.y = row4b.y = rowY;
scoreTableContainer.addChild(row4a);
scoreTableContainer.addChild(row4b);
rowY += rowGap;
// 5. satır
var row5a = createDiceRow(['zar1', 'zar2', 'zar3', 'zar4', 'zar5', 'zar6'], "= 1500", diceSize);
var row5b = createDiceRow(['zar5', 'zar5', 'zar5'], "= 500", diceSize);
row5a.x = -350;
row5b.x = 200;
row5a.y = row5b.y = rowY;
scoreTableContainer.addChild(row5a);
scoreTableContainer.addChild(row5b);
rowY += rowGap;
// 6. satır
var row6a = createDiceRow(['zar6'], "= Joker", diceSize);
var row6b = createDiceRow(['zar6', 'zar6', 'zar6'], "= 600", diceSize);
row6a.x = -350;
row6b.x = 200;
row6a.y = row6b.y = rowY;
scoreTableContainer.addChild(row6a);
scoreTableContainer.addChild(row6b);
rowY += rowGap;
// Ortala
scoreTableContainer.x = 0;
scoreTableContainer.y = turnTxt.y + 90;
scoreTableContainer.pivot.x = 0;
scoreTableContainer.pivot.y = 0;
scoreTableContainer.anchorX = 0.5;
scoreTableContainer.anchorY = 0;
scoreTableContainer.x = 0;
// GUI'ye ekle (top bölgesine, skor tablosunun altına)
LK.gui.top.addChild(scoreTableContainer);
scoreTableContainer.x = 0;
scoreTableContainer.y = turnTxt.y + 90;
// Tablonun referansını sakla (gerekirse erişmek için)
window._farkleScoreTable = scoreTableContainer;
}
// --- 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)) {
// Kırmızı ekranı daha uzun göster (ör: 1200ms)
LK.effects.flashScreen(0xff0000, 1200);
// "İflas!" yazısı ekle
var iflasTxt = new Text2('İflas!', {
size: 180,
fill: '#fff'
});
iflasTxt.anchor.set(0.5, 0.5);
iflasTxt.x = W / 2;
iflasTxt.y = H / 2;
iflasTxt.alpha = 1;
game.addChild(iflasTxt);
// 1 saniye boyunca göster, sonra yavaşça kaybolsun
LK.setTimeout(function () {
tween(iflasTxt, {
alpha: 0
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
if (iflasTxt && iflasTxt.parent) {
iflasTxt.parent.removeChild(iflasTxt);
}
tempScores[current] = 0;
selectedScores[current] = 0;
turnScore = 0;
updateHUD();
endTurn();
}
});
}, 1000);
}
}
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; // sadece seçimi temizle
});
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, 1200);
var iflasTxt = new Text2('İflas!', {
size: 180,
fill: '#fff'
});
iflasTxt.anchor.set(0.5, 0.5);
iflasTxt.x = W / 2;
iflasTxt.y = H / 2;
iflasTxt.alpha = 1;
game.addChild(iflasTxt);
LK.setTimeout(function () {
tween(iflasTxt, {
alpha: 0
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
if (iflasTxt && iflasTxt.parent) {
iflasTxt.parent.removeChild(iflasTxt);
}
tempScores[current] = 0;
selectedScores[current] = 0;
turnScore = 0;
updateHUD();
endTurn();
}
});
}, 1000);
}
}
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, current === PLAYER);
updateHUD();
if (current === NPC) {
npcTurn(); // hemen animasyon
} else {
animateRoll(); // oyuncu turu başladı
}
}
/* --- NPC Basit AI --- */
function npcTurn() {
// Oyunun bittiğini veya sıranın NPC’de olmadığını kontrol et
if (gameOver || current !== NPC) {
return;
}
/* Önce tüm zarları seçimsiz hâle getir ve güncelle */
var _iterator3 = _createForOfIteratorHelper2(dice),
_step3;
try {
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
var d = _step3.value;
d.selected = false;
}
} catch (err) {
_iterator3.e(err);
} finally {
_iterator3.f();
}
updateDicePositions();
/* 2 sn’lik animasyon → bittikten SONRA 1 sn daha bekle, ondan sonra hamleyi başlat */
animateRoll(function () {
LK.setTimeout(npcThinkAfterRoll, 1000); // 1000 ms = 1 sn
});
}
/**** NPC animasyon sonrası hamle ****/
function npcThinkAfterRoll() {
/* 1) Masa üzerindeki değerlere bakarak en iyi kombini seç */
var vals = dice.map(function (d) {
return d.value;
});
var bestScore = 0,
bestSel = [];
for (var i = 1; i <= vals.length; i++) {
var _iterator2 = _createForOfIteratorHelper3(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();
}
}
/* 2) Hiç puan yoksa bust */
if (bestScore === 0) {
LK.effects.flashScreen(0xff0000, 1200);
var iflasTxt = new Text2('İflas!', {
size: 180,
fill: '#fff'
});
iflasTxt.anchor.set(0.5, 0.5);
iflasTxt.x = W / 2;
iflasTxt.y = H / 2;
iflasTxt.alpha = 1;
game.addChild(iflasTxt);
LK.setTimeout(function () {
tween(iflasTxt, {
alpha: 0
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
if (iflasTxt && iflasTxt.parent) {
iflasTxt.parent.removeChild(iflasTxt);
}
tempScores[NPC] = selectedScores[NPC] = turnScore = 0;
updateHUD();
endTurn();
}
});
}, 1000);
return;
}
/* 3) Zarları adım adım seçip (eski kod) devam et */
var npcSelectOrder = [];
var used = [];
for (var i = 0; i < dice.length; i++) {
var v = dice[i].value;
for (var j = 0; j < bestSel.length; j++) {
if (!used[j] && bestSel[j] === v) {
npcSelectOrder.push(i);
used[j] = true;
break;
}
}
}
var idxSel = 0;
function npcSelectNextDie() {
if (idxSel < npcSelectOrder.length) {
var _ref;
var idx = npcSelectOrder[idxSel++];
dice[idx].selected = !dice[idx].selected;
(_ref = dice[idx].selected ? LK.getSound('zarSecmeSesi') : LK.getSound('zarBirakmaSesi')) === null || _ref === void 0 || _ref.play();
updateDicePositions();
updateHUD();
LK.setTimeout(npcSelectNextDie, 1000);
return;
}
/* --- STRATEJİ (bank / devam) bölümü: eski kodun tamamı --- */
LK.setTimeout(function () {
if (bestScore >= 400 || dice.length - bestSel.length <= 1) {
var _LK$getSound;
(_LK$getSound = LK.getSound('tutVeTuruSonlandirSesi')) === null || _LK$getSound === void 0 || _LK$getSound.play();
selectedScores[NPC] = bestScore;
tempScores[NPC] += bestScore;
scores[NPC] += tempScores[NPC];
tempScores[NPC] = selectedScores[NPC] = 0;
updateHUD();
endTurn();
} else {
var _LK$getSound2;
(_LK$getSound2 = LK.getSound('tutVeDevamEtSesi')) === null || _LK$getSound2 === void 0 || _LK$getSound2.play();
selectedScores[NPC] = bestScore;
tempScores[NPC] += bestScore;
selectedScores[NPC] = 0;
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 leftVals = dice.map(function (d) {
return d.value;
});
if (!canMakeAnyScore(leftVals)) {
LK.effects.flashScreen(0xff0000, 1200);
var iflasTxt = new Text2('İflas!', {
size: 180,
fill: '#fff'
});
iflasTxt.anchor.set(0.5, 0.5);
iflasTxt.x = W / 2;
iflasTxt.y = H / 2;
iflasTxt.alpha = 1;
game.addChild(iflasTxt);
LK.setTimeout(function () {
tween(iflasTxt, {
alpha: 0
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
if (iflasTxt && iflasTxt.parent) {
iflasTxt.parent.removeChild(iflasTxt);
}
tempScores[NPC] = 0;
updateHUD();
endTurn();
}
});
}, 1000);
} else {
npcTurn();
}
}
}, 1000);
}
npcSelectNextDie();
}
/* --- Kazanan ekranı --- */
function showWinner() {
gameOver = true;
var winnerText = current === PLAYER ? 'Kazandın!' : 'NPC Kazandı!';
showGameOverScreen(winnerText);
}
/* --- Buton Olayları --- */
rollBtn.down = function () {
var _LK$getSound3;
if (gameOver || current !== PLAYER) {
return;
}
// sesi zaten burada çalıyoruz
(_LK$getSound3 = LK.getSound('tutVeDevamEtSesi')) === null || _LK$getSound3 === void 0 || _LK$getSound3.play();
/* Zarları döndür, ses O Z A M A N oynatıldı—o yüzden 2. parametre: false */
animateRoll(keepAndContinue, false);
};
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();
animateRoll();
}
// --- 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
@@ -836,9 +836,9 @@
var scoreTableContainer = new Container();
scoreTableContainer.x = 0;
scoreTableContainer.y = turnTxt.y + 90;
var rowY = 0;
- var rowGap = 60;
+ var rowGap = 70;
var diceSize = 60;
var bigGap = 80;
// 1. satır
var row1a = createDiceRow(['zar1'], "= 100", diceSize);
@@ -976,9 +976,11 @@
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
- if (iflasTxt && iflasTxt.parent) iflasTxt.parent.removeChild(iflasTxt);
+ if (iflasTxt && iflasTxt.parent) {
+ iflasTxt.parent.removeChild(iflasTxt);
+ }
tempScores[current] = 0;
selectedScores[current] = 0;
turnScore = 0;
updateHUD();
@@ -1043,9 +1045,11 @@
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
- if (iflasTxt && iflasTxt.parent) iflasTxt.parent.removeChild(iflasTxt);
+ if (iflasTxt && iflasTxt.parent) {
+ iflasTxt.parent.removeChild(iflasTxt);
+ }
tempScores[current] = 0;
selectedScores[current] = 0;
turnScore = 0;
updateHUD();
@@ -1172,9 +1176,11 @@
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
- if (iflasTxt && iflasTxt.parent) iflasTxt.parent.removeChild(iflasTxt);
+ if (iflasTxt && iflasTxt.parent) {
+ iflasTxt.parent.removeChild(iflasTxt);
+ }
tempScores[NPC] = selectedScores[NPC] = turnScore = 0;
updateHUD();
endTurn();
}
@@ -1259,9 +1265,11 @@
}, {
duration: 700,
easing: tween.easeOut,
onFinish: function onFinish() {
- if (iflasTxt && iflasTxt.parent) iflasTxt.parent.removeChild(iflasTxt);
+ if (iflasTxt && iflasTxt.parent) {
+ iflasTxt.parent.removeChild(iflasTxt);
+ }
tempScores[NPC] = 0;
updateHUD();
endTurn();
}
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