MediaWiki:Mitcher.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
const cards = {
0:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/6/6c/Event_Image_Card_813_Back.png/85px-Event_Image_Card_813_Back.png" decoding="async" width="85" height="120" srcset="https://static.miraheze.org/bluearchivewiki/thumb/6/6c/Event_Image_Card_813_Back.png/127px-Event_Image_Card_813_Back.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/6/6c/Event_Image_Card_813_Back.png/169px-Event_Image_Card_813_Back.png 2x">',
1:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/2/27/Event_Image_Card_813_N_01.png/85px-Event_Image_Card_813_N_01.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/2/27/Event_Image_Card_813_N_01.png/127px-Event_Image_Card_813_N_01.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/2/27/Event_Image_Card_813_N_01.png/169px-Event_Image_Card_813_N_01.png 2x">',
2:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/d/d6/Event_Image_Card_813_N_02.png/85px-Event_Image_Card_813_N_02.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/d/d6/Event_Image_Card_813_N_02.png/127px-Event_Image_Card_813_N_02.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/d/d6/Event_Image_Card_813_N_02.png/169px-Event_Image_Card_813_N_02.png 2x">',
3:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/5/5f/Event_Image_Card_813_N_03.png/85px-Event_Image_Card_813_N_03.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/5/5f/Event_Image_Card_813_N_03.png/127px-Event_Image_Card_813_N_03.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/5/5f/Event_Image_Card_813_N_03.png/169px-Event_Image_Card_813_N_03.png 2x">',
4:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/b/b0/Event_Image_Card_813_N_04.png/85px-Event_Image_Card_813_N_04.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/b/b0/Event_Image_Card_813_N_04.png/127px-Event_Image_Card_813_N_04.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/b/b0/Event_Image_Card_813_N_04.png/169px-Event_Image_Card_813_N_04.png 2x">',
5:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/5/59/Event_Image_Card_813_N_05.png/85px-Event_Image_Card_813_N_05.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/5/59/Event_Image_Card_813_N_05.png/127px-Event_Image_Card_813_N_05.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/5/59/Event_Image_Card_813_N_05.png/169px-Event_Image_Card_813_N_05.png 2x">',
6:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/e/ea/Event_Image_Card_813_R_01.png/85px-Event_Image_Card_813_R_01.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/e/ea/Event_Image_Card_813_R_01.png/127px-Event_Image_Card_813_R_01.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/e/ea/Event_Image_Card_813_R_01.png/169px-Event_Image_Card_813_R_01.png 2x">',
7:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/e/e7/Event_Image_Card_813_R_02.png/85px-Event_Image_Card_813_R_02.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/e/e7/Event_Image_Card_813_R_02.png/127px-Event_Image_Card_813_R_02.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/e/e7/Event_Image_Card_813_R_02.png/169px-Event_Image_Card_813_R_02.png 2x">',
8:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/6/6e/Event_Image_Card_813_SR_01.png/85px-Event_Image_Card_813_SR_01.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/6/6e/Event_Image_Card_813_SR_01.png/127px-Event_Image_Card_813_SR_01.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/6/6e/Event_Image_Card_813_SR_01.png/169px-Event_Image_Card_813_SR_01.png 2x">',
9:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/a/aa/Event_Image_Card_813_SR_02.png/85px-Event_Image_Card_813_SR_02.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/a/aa/Event_Image_Card_813_SR_02.png/127px-Event_Image_Card_813_SR_02.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/a/aa/Event_Image_Card_813_SR_02.png/169px-Event_Image_Card_813_SR_02.png 2x">',
10:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/6/67/Event_Image_Card_813_SR_03.png/85px-Event_Image_Card_813_SR_03.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/6/67/Event_Image_Card_813_SR_03.png/127px-Event_Image_Card_813_SR_03.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/6/67/Event_Image_Card_813_SR_03.png/169px-Event_Image_Card_813_SR_03.png 2x">',
11:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/8/80/Event_Image_Card_813_SSR_01.png/85px-Event_Image_Card_813_SSR_01.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/8/80/Event_Image_Card_813_SSR_01.png/127px-Event_Image_Card_813_SSR_01.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/8/80/Event_Image_Card_813_SSR_01.png/169px-Event_Image_Card_813_SSR_01.png 2x">',
12:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/4/42/Event_Image_Card_813_SSR_02.png/85px-Event_Image_Card_813_SSR_02.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/4/42/Event_Image_Card_813_SSR_02.png/127px-Event_Image_Card_813_SSR_02.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/4/42/Event_Image_Card_813_SSR_02.png/169px-Event_Image_Card_813_SSR_02.png 2x">',
13:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/a/a1/Event_Image_Card_813_SSR_03.png/85px-Event_Image_Card_813_SSR_03.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/a/a1/Event_Image_Card_813_SSR_03.png/127px-Event_Image_Card_813_SSR_03.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/a/a1/Event_Image_Card_813_SSR_03.png/169px-Event_Image_Card_813_SSR_03.png 2x">',
14:'<img src="https://static.miraheze.org/bluearchivewiki/thumb/2/2e/Event_Image_Card_813_SSR_04.png/85px-Event_Image_Card_813_SSR_04.png" decoding="async" width="85" height="120" srcset="//static.miraheze.org/bluearchivewiki/thumb/2/2e/Event_Image_Card_813_SSR_04.png/127px-Event_Image_Card_813_SSR_04.png 1.5x, //static.miraheze.org/bluearchivewiki/thumb/2/2e/Event_Image_Card_813_SSR_04.png/169px-Event_Image_Card_813_SSR_04.png 2x">',
};
var draw_count = 0;
var reveal_count = 0
var mitcher_count = 0;
var token_count = 0
var draws = {};
var card_stats = {0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0};
$( document ).ready(function() {
initMitcher();
addMitcherRow();
// for (let index = 1; index < 1000; index++) {
// addMitcherRow();
// }
})
function initMitcher(){
$(".mitchergacha li.onemore").on("click", function(){addMitcherRow();});
}
function revealCard(draw, position){
//console.log('Called for draw '+draw+', position '+position);
var element = $('#mitchergacha li.draw-'+draw+' > div.position-'+position);
if ( draws[draw]['status'][position] == false ) {
element.removeClass('hidden').addClass('revealed');
draws[draw]['status'][position] = true;
reveal_count++
if (draws[draw]['cards'][position] == 11) mitcher_count += 15;
if (draws[draw]['cards'][position] == 12) mitcher_count += 15;
if (draws[draw]['cards'][position] == 13) mitcher_count += 16;
if (draws[draw]['cards'][position] == 14) mitcher_count += 14;
token_count += 190 + 10 * draws[draw]['status'].filter(x => x === true).length;
$("#stats-reveals").html(reveal_count);
$("#stats-tokens").html(token_count);
$("#stats-frags").html(mitcher_count);
}
else {
//already revealed
}
}
function addMitcherRow(){
var has_gold = false;
var mitchergacha = $('#mitchergacha');
var card_list = [];
var card_images = [];
for (let index = 0; index < 4; index++) {
card_id = generateCard();
card_list.push(card_id);
if (card_id >= 8) has_gold = true;
}
if (!has_gold) {
var x = Math.floor((Math.random() * 3));
card_list[x] = generateCard(7865);
//console.log('Draw had no gold card, added '+card_list[x]+' in slot '+x);
}
draw_count ++;
draws[draw_count] = {'cards':card_list, 'status':[false,false,false,false]};
var html = '';
for (let index = 0; index < 4; index++) {
card_stats[card_list[index]] ++;
card_images.push(cards[card_list[index]]);
html += '<div class="hidden draw-'+draw_count+' position-'+index+'" data-position="'+index+'" data-draw="'+draw_count+'">'+cards[card_list[index]]+'</div>';
}
mitchergacha.prepend('<li class="draw-'+draw_count+'" data-draw="'+draw_count+'">'+html+'</li>')
$("#mitchergacha li.draw-"+draw_count+" div").on("click", function(){revealCard($(this).attr('data-draw'), $(this).attr('data-position'))});
$("#stats-draws").html(draw_count);
}
function generateCard(min_rarity){
min_rarity = (typeof min_rarity !== 'undefined') ? min_rarity : 0; //default false, ES5 does not support function defaults
var draw = Math.floor((Math.random() * (10000 - min_rarity)) + min_rarity + 1);
//console.log('Draw is ' + draw);
var card_id = 1;
var chances = [0, 800, 800, 800, 800, 800, 1600, 1600, 665, 665, 670, 200, 200, 200, 200]
var x = 0
for (var index = 0; index < chances.length; index++) {
x += chances[index];
if (draw >= x) card_id = index+1;
}
//console.log('Card id '+card_id)
return card_id;
}