Widget:Summon Simulator/20180318

<!doctype html> FFBE Gacha Simulator - exviuswiki.com     /**		 * FFBE Gacha Simulator v2.4 *		 * https://exviuswiki.com */

var banner_rate = [ ['3', 78],			['4', 19],			['5', 3]		];

var guarantee_rate = [ ['4', 95],			['5', 5]		];

var units = [ { name: 'Ayaka',				base: 5, featured: false }, { name: 'Veritas of the Light',				base: 5, featured: false }, { name: 'Lunera',				base: 5, featured: false }, { name: 'Rem',				base: 5, featured: false }, { name: 'Marie',				base: 5, featured: false }, { name: 'Queen',				base: 5, featured: false }, { name: 'Cedona',				base: 4, featured: false }, { name: 'Drace',				base: 4, featured: false }, { name: 'Kaede',				base: 4, featured: false }, { name: 'Aura',				base: 4, featured: false }, { name: 'Mystea',				base: 4, featured: false }, { name: 'Chloe',				base: 4, featured: false }, { name: 'Crowe',				base: 4, featured: false }, { name: 'Silvia',				base: 4, featured: false }, { name: 'Aria',				base: 4, featured: false }, { name: 'Veritas of the Waters',				base: 4, featured: false }, { name: 'Victoria',				base: 4, featured: false }, { name: 'Meliadoul',				base: 4, featured: false }, { name: 'Helena',				base: 4, featured: false }, { name: 'Ashe',				base: 4, featured: false }, { name: 'Rikku',				base: 4, featured: false }, { name: 'Beach Time Fina',				base: 4, featured: false }, { name: 'Amelia',				base: 4, featured: false }, { name: 'Grace',				base: 4, featured: false }, { name: 'Soleil',				base: 4, featured: false }, { name: 'Shine',				base: 4, featured: false }, { name: 'Rosa',					base: 4, featured: false }, { name: 'Vanille',				base: 4, featured: false }, { name: 'Agrias',				base: 4, featured: false }, { name: 'Garnet',				base: 4, featured: false }, { name: 'Chizuru',				base: 4, featured: false }, { name: 'Luka',					base: 4, featured: false }, { name: 'Mercedes',				base: 4, featured: false }, { name: 'Refia',				base: 4, featured: false }, { name: 'Seven',				base: 4, featured: false }, { name: 'Otogiri',				base: 3, featured: false }, { name: 'Charie',				base: 3, featured: false }, { name: 'Iris',				base: 3, featured: false }, { name: 'Amy',				base: 3, featured: false }, { name: 'Yuri',				base: 3, featured: false }, { name: 'Kupipi',				base: 3, featured: false }, { name: 'Sara',				base: 3, featured: false }, { name: 'Summer Lid',				base: 3, featured: false }, { name: 'Camille',				base: 3, featured: false }, { name: 'Jean',				base: 3, featured: false }, { name: 'Sice',				base: 3, featured: false }, { name: 'Ulrica',				base: 3, featured: false }, { name: 'Ovelia',				base: 3, featured: false }, { name: 'Cinque',				base: 3, featured: false }, { name: 'Terra',				base: 3, featured: false }, { name: 'Faris',				base: 3, featured: false }, { name: 'Fang',					base: 3, featured: false }, { name: 'Alma',					base: 3, featured: false }, { name: 'Ludmille',				base: 3, featured: false }, { name: 'Charlotte',			base: 3, featured: false }, { name: 'Freya',				base: 3, featured: false }, { name: 'Rakshasa',				base: 3, featured: false }, { name: 'Lenna',				base: 3, featured: false }, { name: 'Celes',				base: 3, featured: false }, { name: 'Xiao',					base: 3, featured: false }, { name: 'Miyuki',				base: 3, featured: false }, { name: 'Roselia',				base: 3, featured: false }, { name: 'Cerius',				base: 3, featured: false }, { name: 'Cloud of Darkness',	base: 3, featured: false }, { name: 'Lani',					base: 3, featured: false }, { name: 'Luna',					base: 3, featured: false }, { name: 'Rydia',				base: 3, featured: false }, { name: 'Shantotto',			base: 3, featured: false }, { name: 'Fran',					base: 3, featured: false }, { name: 'Krile',				base: 3, featured: false }, { name: 'Maria',				base: 3, featured: false }, { name: 'Penelo',				base: 3, featured: false } ];

function arrayColumn(arr, n) { return arr.map(x=> x[n]); }

function summon(num) { $('.gacha-result').text("");

$('.loading img').attr("src", "").attr("src", $('.loading img').data("src")); $('.loading').show;

var wikiresult = ""; var total_5 = 0; var total_4 = 0; var total_3 = 0;

for (i = 1; i <= num; i++) { // randomize base var random;

if (num == 11 && i == 1) { // guarantee pull random = chance.weighted(arrayColumn(guarantee_rate, 0), arrayColumn(guarantee_rate, 1)); }				else{ random = chance.weighted(arrayColumn(banner_rate, 0), arrayColumn(banner_rate, 1)); }

var banner = random.split("_"); var rarity = parseInt(banner[0]); var featured = banner[1] == 'ft' ? true : false;

if (rarity == 5) { total_5++; }				else if (rarity == 4) { total_4++; }				else if (rarity == 3) { total_3++; }

// randomize selection within pool var pool = _.where(units, {base: rarity, featured: featured});

var result = chance.integer({min: 0, max: pool.length - 1}); var name = pool[result]['name'];

if (i == 1) { wikiresult += ' ' + name + ' ' + rarity + '_star '; wikiresult += ' '; }				else if (i % 2 == 0) { wikiresult += ''; wikiresult += ' ' + name + ' ' + rarity + '_star '; }				else if (i % 2 == 1){ wikiresult += ' ' + name + ' ' + rarity + '_star '; wikiresult += ' '; }			}			var bold = document.createElement('b'); bold.setAttribute('style', 'font-size:24px') bold.innerText = total_5; var wikitext = ' ';

$.ajax({				url: "//exvius.gamepedia.com/api.php?action=parse&format=json&prop=text&contentmodel=wikitext&text=" + wikitext,				dataType: "json"			}) .done(function( data ) {				result = data.parse.text["*"];				result = result.replace(/3_star/g, " &#9733;&#9733;&#9733;  ");				result = result.replace(/4_star/g, "  &#9733;&#9733;&#9733;&#9733;  ");				result = result.replace(/5_star/g, "  &#9733; &#9733; &#9733; &#9733; &#9733;  ");				$('.gacha-result').html(result);

$('.loading img').attr("src", ""); $('.loading').hide; });		}		function varSummon {			$('.gacha-result').text("");

$('.loading img').attr("src", "").attr("src", $('.loading img').data("src")); $('.loading').show;

var obtained_5 = []; var obtained_4 = []; var obtained_3 = []; var varSummonValue = $("#var_summon").val; if (varSummonValue >= 99999) { varSummonValue = 99999; }			else if (varSummonValue <= 0) { varSummonValue = 1; }

for (i = 1; i <= varSummonValue; i++) { // randomize base var random = chance.weighted(arrayColumn(banner_rate, 0), arrayColumn(banner_rate, 1));

var banner = random.split("_"); var rarity = parseInt(banner[0]); var featured = banner[1] == 'ft' ? true : false;

// randomize selection within pool var pool = _.where(units, {base: rarity, featured: featured});

var result = chance.integer({min: 0, max: pool.length - 1}); var name = pool[result]['name'];

if (rarity == 5) { obtained_5.push(name); trigger = true; }				else if (rarity == 4) { obtained_4.push(name); }				else if (rarity == 3) { obtained_3.push(name); }			}

result = 'Summon = ' + varSummonValue + ' '; result += '5&#9733; (' + obtained_5.length + ') = '; for (i = 0; i < obtained_5.length; i++) { result += obtained_5[i] + (i != obtained_5.length - 1 ? ', ' : ''); }			result += ' '; result += '4&#9733; (' + obtained_4.length + ') = '; for (i = 0; i < obtained_4.length; i++) { result += obtained_4[i] + (i != obtained_4.length - 1 ? ', ' : ''); }			result += ' '; result += '3&#9733; (' + obtained_3.length + ') = '; for (i = 0; i < obtained_3.length; i++) { result += obtained_3[i] + (i != obtained_3.length - 1 ? ', ' : ''); }

$('.gacha-result').html(result);

$('.loading img').attr("src", ""); $('.loading').hide; }		function guaranteedSummon { $('.gacha-result').text("");

$('.loading img').attr("src", "").attr("src", $('.loading img').data("src")); $('.loading').show;

var obtained_5 = []; var obtained_4 = []; var varSummonValue = $("#guaranteed_summon").val; if (varSummonValue >= 99999) { varSummonValue = 99999; }			else if (varSummonValue <= 0) { varSummonValue = 1; }

for (i = 1; i <= varSummonValue; i++) { // randomize base var random = chance.weighted(arrayColumn(guarantee_rate, 0), arrayColumn(guarantee_rate, 1));

var banner = random.split("_"); var rarity = parseInt(banner[0]); var featured = banner[1] == 'ft' ? true : false;

// randomize selection within pool var pool = _.where(units, {base: rarity, featured: featured});

var result = chance.integer({min: 0, max: pool.length - 1}); var name = pool[result]['name'];

if (rarity == 5) { obtained_5.push(name); trigger = true; }				else if (rarity == 4) { obtained_4.push(name); }			}

result = '4★+ Summon = ' + varSummonValue + ' '; result += '5&#9733; (' + obtained_5.length + ') = '; for (i = 0; i < obtained_5.length; i++) { result += obtained_5[i] + (i != obtained_5.length - 1 ? ', ' : ''); }			result += ' '; result += '4&#9733; (' + obtained_4.length + ') = '; for (i = 0; i < obtained_4.length; i++) { result += obtained_4[i] + (i != obtained_4.length - 1 ? ', ' : ''); }

$('.gacha-result').html(result);

$('.loading img').attr("src", ""); $('.loading').hide; }

function repeatSummon { $('.gacha-result').text("");

$('.loading img').attr("src", "").attr("src", $('.loading img').data("src")); $('.loading').show;

var obtained_5 = []; var obtained_4 = []; var obtained_3 = []; var lapis = 0;

var trigger = false;

while (trigger == false) { lapis += 5000;

for (i = 1; i <= 11; i++) { // randomize base var random;

if (i == 1) { // guarantee pull random = chance.weighted(arrayColumn(guarantee_rate, 0), arrayColumn(guarantee_rate, 1)); }					else{ random = chance.weighted(arrayColumn(banner_rate, 0), arrayColumn(banner_rate, 1)); }

var banner = random.split("_"); var rarity = parseInt(banner[0]); var featured = banner[1] == 'ft' ? true : false;

// randomize selection within pool var pool = _.where(units, {base: rarity, featured: featured});

var result = chance.integer({min: 0, max: pool.length - 1}); var name = pool[result]['name'];

if (rarity == 5) { obtained_5.push(name); trigger = true; }					else if (rarity == 4) { obtained_4.push(name); }					else if (rarity == 3) { obtained_3.push(name); }				}			}

result = 'Attempts = ' + lapis / 5000 + ' '; result += 'Lapis used = ' + lapis + ' '; result += '5&#9733; (' + obtained_5.length + ') = '; for (i = 0; i < obtained_5.length; i++) { result += obtained_5[i] + (i != obtained_5.length - 1 ? ', ' : ''); }			result += ' '; result += '4&#9733; (' + obtained_4.length + ') = '; for (i = 0; i < obtained_4.length; i++) { result += obtained_4[i] + (i != obtained_4.length - 1 ? ', ' : ''); }			result += ' '; result += '3&#9733; (' + obtained_3.length + ') = '; for (i = 0; i < obtained_3.length; i++) { result += obtained_3[i] + (i != obtained_3.length - 1 ? ', ' : ''); }

$('.gacha-result').html(result);

$('.loading img').attr("src", ""); $('.loading').hide; }		Summon (1) Summon (10+1) Summon  4★+ Summon  Repeat 10+1 until one or more 5★ is found  Loading...