noname/extension/cardpile/extension.js

108 lines
1.8 KiB
JavaScript
Raw Normal View History

2024-04-15 16:50:54 +00:00
import { lib, game, ui, get, ai, _status } from "../../noname.js";
game.import("play", function () {
2017-04-15 00:25:50 +00:00
return {
2024-04-15 16:50:54 +00:00
name: "cardpile",
arenaReady: function () {
var data = {
total: 160,
sha: {
diamond: 6,
club: 14,
heart: 3,
spade: 7,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
huosha: {
diamond: 2,
heart: 3,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
leisha: {
spade: 5,
club: 4,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
shan: {
heart: 6,
diamond: 18,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
jiu: {
diamond: 1,
spade: 2,
club: 2,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
tao: {
heart: 9,
diamond: 3,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
wanjian: {
heart: 1,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
nanman: {
spade: 2,
club: 1,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
guohe: {
spade: 3,
club: 2,
heart: 1,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
shunshou: {
spade: 3,
diamond: 2,
2018-04-17 07:32:43 +00:00
},
2024-04-15 16:50:54 +00:00
wuxie: {
heart: 2,
diamond: 1,
spade: 2,
club: 2,
},
tiesuo: {
spade: 2,
club: 4,
2018-04-17 07:32:43 +00:00
},
};
2024-04-15 16:50:54 +00:00
var rand = function () {
return Math.ceil(Math.random() * 13);
2017-04-15 00:25:50 +00:00
};
2024-04-15 16:50:54 +00:00
var getn = function (i, j) {
return Math.round(
data[i][j] *
parseFloat(
lib.config["cardpile_" + i + "_playpackconfig"]
)
);
};
var num = 0;
for (var i in data) {
for (var j in data[i]) {
num += getn(i, j);
2018-04-17 07:32:43 +00:00
}
}
2024-04-15 16:50:54 +00:00
var dn =
(num * (lib.card.list.length - data.total)) /
(data.total - num);
if (dn > 1000) dn = 1000;
if (dn > 0) {
var p = 0;
for (var i in data) {
for (var j in data[i]) {
var n = Math.round((dn * getn(i, j)) / num);
while (n--) {
if (i == "huosha") {
lib.card.list.push([j, rand(), "sha", "fire"]);
} else if (i == "leisha") {
lib.card.list.push([
j,
rand(),
"sha",
"thunder",
]);
} else {
lib.card.list.push([j, rand(), i]);
2018-04-17 07:32:43 +00:00
}
}
}
}
}
2017-04-15 00:25:50 +00:00
},
};
2017-04-14 23:35:56 +00:00
});