我目前有一些东西可以滚动到一个数字但我想要更改它,而不是显示它滚动的数字,它显示该数字分开的名称。我所拥有的片段如下:
function spin(m) {
var x = m.roll;
play_sound("roll");
var order = [1, 14, 2, 13, 3, 12, 4, 0, 11, 5, 10, 6, 9, 7, 8];
var index = 0;
for (var i = 0; i < order.length; i++) {
if (x == order[i]) {
index = i;
break
}
}
var max = 32;
var min = -32;
var w = Math.floor(m.wobble * (max - min + 1) + min);
var dist = index * 70 + 36 + w;
dist += 1050 * 5;
animStart = new Date().getTime();
vi = getVi(dist);
tf = getTf(vi);
isMoving = true;
setTimeout(function() {
finishRoll(m, tf)
}, tf);
render()
}
如你所见,我有1,14,2,13等 我想它如此,如果它滚到1,2,3,4,5,6或7它显示'Group1'而不是它已落地的数字。 同样适用于14,13,12,11,10,9和8,除了我希望它显示'Group2'而不是它已经登陆的数字。 现在为0,我喜欢它,因此当它落在它上面时它显示'绿色'而不是0。 这些是文件中的主要代码段。 1。
function cd(ms, cb) {
$("#counter").finish().css("width", "100%");
$("#counter").animate({
width: "0%"
}, {
"duration": ms * 1000,
"easing": "linear",
progress: function(a, p, r) {
var c = (r / 1000).toFixed(2);
$BANNER.html("Rolling in " + c + "...");
},
complete: cb
});
}
2
function finishRoll(m, tf) {
$BANNER.html("Rolled number " + m.roll + "!");
addHist(m.roll, m.rollid);
play_sound("finish");
for (var i = 0; i < m.nets.length; i++) {
$("#panel" + m.nets[i].lower + "-" + m.nets[i].upper).find(".total").countTo(m.nets[i].swon > 0 ? m.nets[i].swon : -m.nets[i].samount, {
"color": true,
"keep": true
});
}
var cats = [
[0, 0],
[1, 7],
[8, 14]
];
for (var i = 0; i < cats.length; i++) {
var $mytotal = $("#panel" + cats[i][0] + "-" + cats[i][1]).find(".mytotal");
if (m.roll >= cats[i][0] && m.roll <= cats[i][1]) {
$mytotal.countTo(m.won, {
"color": true,
"keep": true
});
} else {
var curr = parseFloat($mytotal.html());
if ($("#settings_dongers").is(":checked")) {
curr *= 1000;
}
$mytotal.countTo(-curr, {
"color": true,
"keep": true
});
}
}
if (m.balance != null) {
$("#balance").countTo(m.balance, {
"color": true
});
checkplus(m.balance);
}
setTimeout(function() {
cd(m.count);
$(".total,.mytotal").removeClass("text-success text-danger").html(0);
$(".betlist li").remove();
snapRender();
$(".betButton").prop("disabled", false);
showbets = true;
}, m.wait * 1000 - tf);
}
3
function snapRender(x, wobble) {
CASEW = $("#case").width();
if (isMoving) return;
else if (typeof x === 'undefined') view(snapX);
else {
var order = [1, 14, 2, 13, 3, 12, 4, 0, 11, 5, 10, 6, 9, 7, 8];
var index = 0;
for (var i = 0; i < order.length; i++) {
if (x == order[i]) {
index = i;
break
}
}
var max = 32;
var min = -32;
var w = Math.floor(wobble * (max - min + 1) + min);
var dist = index * 70 + 36 + w;
dist += 1050 * 5;
snapX = dist;
view(snapX)
}
}
答案 0 :(得分:0)
这个怎么样?
// assumes n is always a number between 0 and 14 (inclusive)
function numberToName(n) {
if (n === 0) {
return "Green";
} else if (n < 8) {
return "Group1";
} else {
return "Group2";
}
}
只需使用所选数字调用此选项,然后根据需要使用返回的文本。