|
|
| (未显示40个用户的268个中间版本) |
| 第1行: |
第1行: |
| {{/handler}} | | {{/handler}} |
| == 请在这行文字下测试您的编辑 == | | == 请在这行文字下测试您的编辑 == |
| <div class="salt-acquire-wealth-simulator">测试中</div> | | <span style=background:-webkit-linear-gradient(35deg,#c2185b,#1976d2);-webkit-background-clip:text;-webkit-text-fill-color:transparent>※※※ [[U:坑触可|'''坑触可''']] ※※※ [[User talk:坑触可|'''留言''']] ※※※</span> | [[特殊:Random|<span style=color:#202122 title=spEciAL;rANdOm>没事干了,不如随机一下</span>]]test |
| <div class="salt-miner-simulator">测试中</div>
| |
| {{#Widget:SaltMCBBSTools}}
| |
| | |
| <script>
| |
| 'use strict';
| |
| // @author Salt
| |
| // @license CC BY-NC-SA
| |
| (function () {
| |
| let prefix = '[MCBBS小工具]';
| |
| function main() {
| |
| wealthSim();
| |
| mineSim();
| |
| addStyle(MCBBSTOOLSTYLE, 'MCBBSTOOL');
| |
| }
| |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| |
| function wealthSim() {
| |
| let elems = document.querySelectorAll('.salt-acquire-wealth-simulator:not([done])');
| |
| log('开始安装致富卡模拟器');
| |
| if (elems.length < 1) {
| |
| return;
| |
| }
| |
| for (let i = 0; i < elems.length; i++) {
| |
| wealthSimulator(elems[i]);
| |
| }
| |
| }
| |
| function wealthSimulator(el) {
| |
| let simbtn = document.createElement('div');
| |
| simbtn.textContent = '模拟致富';
| |
| simbtn.classList.add('sim');
| |
| let clsbtn = document.createElement('div');
| |
| clsbtn.textContent = '清空';
| |
| clsbtn.classList.add('cls');
| |
| let resshow = document.createElement('div');
| |
| resshow.textContent = '统计数据:';
| |
| resshow.classList.add('resshow');
| |
| let simipt = document.createElement('input');
| |
| simipt.placeholder = '请输入模拟次数,最低为1';
| |
| simipt.classList.add('input');
| |
| let resul = document.createElement('ul');
| |
| resul.classList.add('resul');
| |
| let simres = new wsr(resul), count = 1;
| |
| simipt.addEventListener('change', () => {
| |
| let s = simipt.value;
| |
| if (s.length < 1) {
| |
| count = 1;
| |
| return;
| |
| }
| |
| count = parseInt(s);
| |
| if (isNaN(count) || count < 1) {
| |
| count = 1;
| |
| }
| |
| });
| |
| simbtn.addEventListener('click', () => {
| |
| simres.sim(count);
| |
| resshow.textContent = `统计数据:
| |
| 致富卡: ${simres.res.length}张
| |
| 花费金粒: ${simres.res.length * 500}粒
| |
| 获得金粒: ${simres.totalRes}粒
| |
| 总计盈亏: ${simres.totalWin}粒
| |
| 获利比率: ${Math.round(simres.totalWinChance * 10000) / 100}%
| |
| 平局比率: ${Math.round(simres.totalDrawChance * 10000) / 100}%
| |
| 损失比率: ${Math.round(simres.totalLoseChance * 10000) / 100}%
| |
| `;
| |
| });
| |
| clsbtn.addEventListener('click', () => {
| |
| simres.clear();
| |
| resshow.textContent = '统计数据:';
| |
| });
| |
| el.innerHTML = '';
| |
| el.appendChild(resul);
| |
| el.appendChild(simipt);
| |
| el.appendChild(simbtn);
| |
| el.appendChild(clsbtn);
| |
| el.appendChild(resshow);
| |
| el.setAttribute('done', '');
| |
| log('安装致富卡模拟器...');
| |
| }
| |
| function mineSim() {
| |
| let elems = document.querySelectorAll('.salt-miner-simulator:not([done])');
| |
| log('开始安装挖矿模拟器');
| |
| if (elems.length < 1) {
| |
| return;
| |
| }
| |
| for (let i = 0; i < elems.length; i++) {
| |
| mineSimulator(elems[i]);
| |
| }
| |
| }
| |
| function mineSimulator(el) {
| |
| let simbtn = document.createElement('div');
| |
| simbtn.textContent = '挖矿一次';
| |
| simbtn.classList.add('sim');
| |
| let s10btn = document.createElement('div');
| |
| s10btn.textContent = '挖矿十次';
| |
| s10btn.classList.add('sim');
| |
| let resul = document.createElement('ul');
| |
| resul.classList.add('resul');
| |
| let res = [];
| |
| // simipt.addEventListener('change', () => {
| |
| // let s = simipt.value
| |
| // if (s.length < 1) { count = 1; return }
| |
| // count = parseInt(s)
| |
| // if (isNaN(count) || count < 1) { count = 1 }
| |
| // })
| |
| simbtn.addEventListener('click', () => {
| |
| res = [ore.reward[randReward(ore.chance) || 0]];
| |
| showOre();
| |
| });
| |
| s10btn.addEventListener('click', () => {
| |
| res = [];
| |
| for (let i = 0; i < 10; i++) {
| |
| res.push(ore.reward[randReward(ore.chance) || 0]);
| |
| }
| |
| showOre();
| |
| });
| |
| function showOre() {
| |
| resul.innerHTML = '';
| |
| for (let i = 0; i < res.length; i++) {
| |
| let x = res[i].split('|');
| |
| let src = 'https://attachment.mcbbs.net/common/' + x[0], alt = x[1];
| |
| let li = document.createElement('li'), img = document.createElement('img'), span = document.createElement('span');
| |
| img.src = src;
| |
| img.alt = alt;
| |
| li.appendChild(img);
| |
| span.textContent = alt;
| |
| li.appendChild(span);
| |
| li.classList.add(x[2]);
| |
| resul.appendChild(li);
| |
| }
| |
| }
| |
| el.innerHTML = '';
| |
| el.appendChild(resul);
| |
| el.appendChild(simbtn);
| |
| el.appendChild(s10btn); //; el.appendChild(clsbtn); el.appendChild(resshow)
| |
| el.setAttribute('done', '');
| |
| log('安装挖矿模拟器...');
| |
| }
| |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| |
| // assert: 断言
| |
| // condition: 判断状况; msg?: 报错语句
| |
| function assert(condition, msg = '发生错误') {
| |
| if (!condition) {
| |
| throw new Error(prefix + ': ' + msg);
| |
| }
| |
| }
| |
| function addScript(src, asynchronous = false) {
| |
| let scr = document.createElement('script');
| |
| scr.src = src;
| |
| scr.async = asynchronous;
| |
| document.head.appendChild(scr);
| |
| }
| |
| function addStyle(styleCode = '', styleID = '') {
| |
| let s = document.createElement('style');
| |
| if (styleID.length > 0) {
| |
| if (document.querySelector(`style[${styleID}]`)) {
| |
| return;
| |
| }
| |
| else {
| |
| s.setAttribute(styleID, '');
| |
| }
| |
| }
| |
| s.textContent = styleCode;
| |
| document.head.appendChild(s);
| |
| }
| |
| function log(msg) {
| |
| let t = typeof msg;
| |
| let p = prefix + ': ';
| |
| if (t == 'boolean' || t == 'number' || t == 'string') {
| |
| console.log(p + msg);
| |
| }
| |
| else if (t == 'undefined') {
| |
| console.log(p + 'undefined');
| |
| }
| |
| else if (msg instanceof Array) {
| |
| console.log(p + '[' + msg.join(', ') + ']');
| |
| }
| |
| else {
| |
| console.log(p);
| |
| console.log(msg);
| |
| }
| |
| }
| |
| function randInt(max = 750, min = 0) {
| |
| if (min > max) {
| |
| let temp = max;
| |
| max = min;
| |
| min = temp;
| |
| }
| |
| return Math.floor(Math.random() * (max - min + 1) + min);
| |
| }
| |
| function randReward(arr) {
| |
| var leng = 1;
| |
| for (var i = 0; i < arr.length; i++) {
| |
| leng += arr[i]; //获取总数
| |
| }
| |
| for (var i = 0; i < arr.length; i++) {
| |
| var random = Math.floor(Math.random() * leng); //获取 0-总数 之间的一个随随机整数
| |
| if (random < arr[i]) {
| |
| return i; //如果在当前的概率范围内,得到的就是当前概率
| |
| }
| |
| else {
| |
| leng -= arr[i]; //否则减去当前的概率范围,进入下一轮循环
| |
| }
| |
| }
| |
| }
| |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| |
| class wsr {
| |
| constructor(el, winStandard = 500, bottom = 0, top = 750) {
| |
| this.res = []; // 存放结果
| |
| this.totalRes = 0;
| |
| this.totalWin = 0;
| |
| this.totalWinChance = 0;
| |
| this.totalDrawChance = 0;
| |
| this.totalLoseChance = 0;
| |
| this.bindEl = el;
| |
| this.winStandard = winStandard;
| |
| this.range = [bottom, top];
| |
| this.safeRange = Math.floor(Number.MAX_SAFE_INTEGER / Math.max((bottom + top / 2), winStandard)) - 1;
| |
| }
| |
| cls() {
| |
| this.clear();
| |
| }
| |
| clear() {
| |
| this.res = [];
| |
| this.totalRes = 0;
| |
| this.totalWin = 0;
| |
| this.totalWinChance = 0;
| |
| this.totalDrawChance = 0;
| |
| this.totalLoseChance = 0;
| |
| this.resultShow();
| |
| }
| |
| resultCalc() {
| |
| if (this.res.length == 0) {
| |
| this.cls();
| |
| }
| |
| let r = 0, w = 0, wc = 0, dc = 0, len = this.res.length;
| |
| for (let i = 0; i < len; i++) {
| |
| let x = this.res[i];
| |
| r += x.res;
| |
| w += x.win;
| |
| if (x.win > 0) { // 获利次数
| |
| wc += 1;
| |
| }
| |
| else if (x.win == 0) { // 平局次数
| |
| dc += 1;
| |
| }
| |
| }
| |
| this.totalRes = r;
| |
| this.totalWin = w;
| |
| this.totalWinChance = wc / len;
| |
| this.totalDrawChance = dc / len;
| |
| this.totalLoseChance = 1 - wc / len - dc / len;
| |
| }
| |
| resultShow() {
| |
| if (this.res.length == 0) {
| |
| this.bindEl.innerHTML = '';
| |
| }
| |
| let len = this.res.length, childlen = this.bindEl.children.length, html;
| |
| for (let i = childlen; i < len; i++) {
| |
| let x = this.res[i];
| |
| html = document.createElement('li');
| |
| html.textContent = `模拟结果: ${x.res}; 盈亏: ${x.win}`;
| |
| this.bindEl.appendChild(html);
| |
| }
| |
| }
| |
| sim(times = 1) {
| |
| if (times < 1) {
| |
| return;
| |
| }
| |
| if (times > 65536) {
| |
| times = 65536;
| |
| }
| |
| let temp;
| |
| for (let i = 0; i < times; i++) {
| |
| temp = randInt(this.range[1], this.range[0]);
| |
| this.res.push({ res: temp, win: temp - this.winStandard });
| |
| if (this.res.length >= this.safeRange) {
| |
| break;
| |
| } // 安全区间控制
| |
| }
| |
| this.resultCalc();
| |
| this.resultShow();
| |
| }
| |
| }
| |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| |
| let MCBBSTOOLSTYLE = `
| |
| .salt-acquire-wealth-simulator{width:calc(50% + 5rem);padding:1rem;margin:1.25rem auto;box-shadow:6px 6px 12px #e2dac6,-6px -6px 12px #fffff2;overflow:auto;position:relative}.salt-acquire-wealth-simulator::after{content:"致富卡模拟器";font-size:2rem;color:rgba(128,128,128,0.25);position:absolute;bottom:0;right:1rem;pointer-events:none}.salt-acquire-wealth-simulator::before{content:"@author Salt @license CC BY-NC-SA";font-size:0.2rem;color:rgba(128,128,128,0.15);position:absolute;top:0;left:1rem;pointer-events:none}.salt-acquire-wealth-simulator,.salt-acquire-wealth-simulator>*{box-sizing:border-box;transition:0.3s ease}.salt-acquire-wealth-simulator .resul{width:60%;height:25rem;padding:.375rem;margin:0 0 0 0;float:right;overflow-y:scroll;outline:1px solid #ccc}.salt-acquire-wealth-simulator .resul li{height:1.25rem;margin-left:2.25rem;margin-bottom:0;list-style:decimal;border-bottom:1px solid #ccc;transition:0.25s ease;white-space:pre}.salt-acquire-wealth-simulator .resul li:last-child{border-bottom:none}.salt-acquire-wealth-simulator .resul li:hover{background-color:#fff9}.salt-acquire-wealth-simulator .input{width:calc(40% - 1rem);margin:0 1rem 0 0;float:left}.salt-acquire-wealth-simulator .sim,.salt-acquire-wealth-simulator .cls{width:calc(40% - 1rem);padding:.5rem;margin:1rem 1rem 0 0;border-radius:.2rem;background:#fbf2dc;box-shadow:6px 6px 12px #e2dac6,-6px -6px 12px #fffff2;text-align:center;float:left;transition:0.15s ease;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.salt-acquire-wealth-simulator .sim:hover,.salt-acquire-wealth-simulator .cls:hover{box-shadow:4px 4px 8px #e2dac6,-4px -4px 8px #fffff2,inset 4px 4px 8px #fffff2,inset -4px -4px 8px #e2dac6}.salt-acquire-wealth-simulator .sim:active,.salt-acquire-wealth-simulator .cls:active{box-shadow:0 0 0 transparent,0 0 0 transparent,inset 6px 6px 12px #e2dac6,inset -6px -6px 12px #fffff2}.salt-acquire-wealth-simulator .resshow{width:calc(40% - 1rem);padding:.5rem;margin:1rem 1rem 0 0;border-radius:.2rem;outline:1px solid #ccc;white-space:pre-line;float:left}.salt-miner-simulator{width:calc(50% + 5rem);padding:1rem;margin:1.25rem auto;box-shadow:6px 6px 12px #e2dac6,-6px -6px 12px #fffff2;overflow:auto;position:relative}.salt-miner-simulator::after{content:"挖矿模拟器";font-size:2rem;color:rgba(128,128,128,0.25);position:absolute;bottom:0;right:1rem;pointer-events:none}.salt-miner-simulator::before{content:"@author Salt @license CC BY-NC-SA";font-size:0.2rem;color:rgba(128,128,128,0.15);position:absolute;top:0;left:1rem;pointer-events:none}.salt-miner-simulator,.salt-miner-simulator>*{box-sizing:border-box;transition:0.3s ease}.salt-miner-simulator .resul{width:100%;height:240px;max-height:300px;padding:.375rem;margin:0 0 0 0;display:grid;grid-template-columns:1fr 1fr 1fr 1fr 1fr;grid-template-rows:1fr 1fr;overflow-y:scroll;outline:1px solid #ccc;text-align:center;align-items:center}.salt-miner-simulator .resul li{width:100%;margin:auto;list-style:none;transition:0.25s ease;white-space:pre}.salt-miner-simulator .resul li:hover{background-color:var(--bgcolor, #fff9)}.salt-miner-simulator .resul li.common{--bgcolor:#fff9}.salt-miner-simulator .resul li.rare{--bgcolor:rgba(128,191,255,0.4);filter:drop-shadow(0px 0px 4px #80bfff)}.salt-miner-simulator .resul li.epic{--bgcolor:#df80ff66;filter:drop-shadow(0px 0px 6px #df80ff)}.salt-miner-simulator .resul li.legend{--bgcolor:#ffdf8066;filter:drop-shadow(0px 0px 8px #ffdf80)}.salt-miner-simulator .resul li img,.salt-miner-simulator .resul li span{width:74px;margin:0 auto;display:block;text-align:center}.salt-miner-simulator .resul li span{width:96px}.salt-miner-simulator .sim{width:calc(50% - 1rem);padding:.5rem;margin:1rem .5rem 0 .5rem;border-radius:.2rem;background:#fbf2dc;box-shadow:6px 6px 12px #e2dac6,-6px -6px 12px #fffff2;text-align:center;float:left;transition:0.15s ease;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.salt-miner-simulator .sim:hover{box-shadow:4px 4px 8px #e2dac6,-4px -4px 8px #fffff2,inset 4px 4px 8px #fffff2,inset -4px -4px 8px #e2dac6}.salt-miner-simulator .sim:active{box-shadow:0 0 0 transparent,0 0 0 transparent,inset 6px 6px 12px #e2dac6,inset -6px -6px 12px #fffff2}.salt-miner-simulator .sim:nth-of-type(1)::before{background-image:url(https://patchwiki.biligame.com/images/mc/6/63/58aatekitx9pn6kx9ji0few8cxgx06r.png)}.salt-miner-simulator .sim:nth-of-type(2)::before{background-image:url(https://mcbbs-wiki.cn/images/e/e7/Diamond_Pickaxe_JE3_BE3.png)}.salt-miner-simulator .sim::before{content:"";background-size:cover;display:inline-block;height:1.2em;width:1.2em;line-height:1.2em;vertical-align:sub}@media screen and (max-width: 960px){.salt-acquire-wealth-simulator{width:100%}.salt-acquire-wealth-simulator .resul,.salt-acquire-wealth-simulator .input,.salt-acquire-wealth-simulator .sim,.salt-acquire-wealth-simulator .cls,.salt-acquire-wealth-simulator .resshow{width:100%;white-space:pre}.salt-acquire-wealth-simulator .input{margin-top:.5rem}.salt-acquire-wealth-simulator .resul{height:13.75rem}.salt-miner-simulator{width:100%}.salt-miner-simulator .resul li{padding:0}}
| |
| `;
| |
| let ore = {
| |
| chance: [
| |
| 100, 100, 100, 100, 100,
| |
| 55, 55, 55, 55, 55, 55, 55, 55,
| |
| 10, 10, 10, 10, 10,
| |
| 3, 1, 3, 1, 2,
| |
| ],
| |
| reward: [
| |
| 'e9/common_844_oqkCn6N1.gif|金粒*50|common', '7b/common_993_KRfVHSoZ.gif|钻石*1|common', '19/common_668_k157Q6Mz.gif|钻石*2|common',
| |
| 'a8/common_570_z0VtOyfy.gif|挖掘卡*3|common', '0f/common_646_BgtOeYG5.gif|召集卡*2|common',
| |
| '37/common_152_UW5I364l.gif|金粒*100|rare', '20/common_277_yPMMpS5Q.gif|钻石*4|rare', '17/common_564_qj66q6lL.gif|服务器提升卡*2|rare',
| |
| 'f7/common_266_vnIWiNQZ.gif|提升卡*4|rare', 'b6/common_902_CROjtYxg.gif|变色卡*1|rare', 'f7/common_173_uGGMtJ9g.gif|挖掘卡*5|rare',
| |
| '84/common_199_Uj0JJqJG.gif|改名卡*1|rare', '1f/common_880_XMeN56n5.gif|匿名卡*2|rare',
| |
| 'fb/common_68_ugh1RmB9.gif|金粒*500|epic', '39/common_27_o98F2LiA.gif|钻石*8|epic', '7f/common_724_U57122AA.gif|-20%优惠券|epic',
| |
| '26/common_298_wDRoz0ZH.gif|提升卡*8|epic', 'ca/common_679_uH68111v.gif|服务器提升卡*4|epic',
| |
| '67/common_824_z32g532o.gif|金粒*999|legend', 'e8/common_466_g6864s5s.gif|绿宝石*1|legend', '05/common_744_mG2NgTgj.gif|钻石*20|legend',
| |
| '3d/common_843_A8z942OC.gif|-40%优惠券|legend', 'be/common_662_mkmCA9JM.gif|猪灵勋章|legend',
| |
| ]
| |
| };
| |
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
| |
| main();
| |
| })();
| |
| </script>
| |