Initializing
Liveweave
Web
expand_more
home
Home
data_object
CSS Explorer
arrow_outward
Palette
Color Explorer
arrow_outward
Polyline
Graphics Editor
arrow_outward
outbox_alt
Generative AI
arrow_outward
frame_source
Python Playground
New
arrow_outward
build
Tools
expand_more
restart_alt
Load "Hello Weaver!"
post_add
Generate Lorem ipsum...
code
Format HTML
code_blocks
Format CSS
data_object
Format JavaScript
library_add
Library
expand_more
A
Algolia JS
Animate CSS
Apex Charts JS
B
Bulma CSS
Bootstrap
C
Chart JS
Chartist
Create JS
D
D3
Dojo
F
Foundation
Fullpage JS
G
Granim JS
Google Charts
H
Halfmoon
J
jQuery
M
Materialize
Moment JS
Masonry JS
Milligram CSS
P
Pure CSS
Primer CSS
Popper JS
Pattern CSS
Picnic CSS
R
React JS
Raphael JS
Raisin CSS
S
Semantic UI
Skeleton CSS
Spectre CSS
Tachyons CSS
T
Tailwind
Three JS
U
UI Kit
Vis JS
W
Water CSS
download
Download
expand_more
developer_mode
Download as HTML
folder_zip
Download as .ZIP
cloud_upload
Save
account_circle
Login
settings
Settings
expand_more
14
px
Live mode
Night mode
Line number
Mini map
Word wrap
sync_alt
Reset Settings
smart_display
Run
<!DOCTYPE html> <html> <head> <title>HTML5, CSS3 and JavaScript demo</title> </head> <body> <textarea id="savegame" placeholder="Paste your save game here"></textarea><br> Number of mercs:<br> <input type="text" id="inputMercs"> <button onclick="readSave()">Read save</button> <div id="error"></div> </body> </html>
function readSave() { var txt = document.getElementById("savegame").value; var inputMercs = document.getElementById("inputMercs").value; if (txt.indexOf("Fe12NAfA3R6z4k0z") > -1) { document.getElementById("error").innerHTML = "Decoding..."; var result = txt.split("Fe12NAfA3R6z4k0z"); txt = ""; for (var i = 0; i < result[0].length; i += 2) txt += result[0][i]; var data = JSON.parse(decode64(txt)); mercs(data.mercenaries.mercRoller.seed, inputMercs); } else document.getElementById("error").innerHTML = "Not a valid save, try again."; } function mercs(seed, inputMercs) { var output = ""; var bonusTypes = ["Gold","HS","Rubies","Skills","Success","Recruitment"]; for (var i = 0; i < inputMercs; i++) { seed = randNum(seed); // gender seed = randNum(seed); // name seed = randNum(seed); // death phrase seed = randNum(seed); // rarity var rarity = getRarity(seed); seed = randNum(seed); // bonus type var bonusType = seed % 6; while (bonusType == 4) { seed = randNum(seed); // if bonus type is Success keep trying bonusType = seed % 6; } seed = randNum(seed); // added with nov 24th patch output += i + ': ' + rarity + ' ' + bonusTypes[bonusType] + '<br>'; } document.getElementById("error").innerHTML = output; } function randNum(seed) { return (seed * 16807) % 2147483647; } function getRarity(seed) { var chance = [5000, 2000, 800, 300, 100, 25, 8, 1]; var rarities = ["Common","Uncommon","Rare","Epic","Fabled","Mythical","Legendary","Transcendent"]; var sum = 0; for (var i = 0; i < 8; i++) sum += chance[i]; var rand = seed % sum + 1; sum = 0; for (i in chance) { sum += chance[i]; if (rand <= sum) return rarities[i]; } } function decode64(input) { var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; var output = ""; var chr1, chr2, chr3 = ""; var enc1, enc2, enc3, enc4 = ""; var i = 0; // remove all characters that are not A-Z, a-z, 0-9, +, /, or = var base64test = /[^A-Za-z0-9\+\/\=]/g; if (base64test.exec(input)) { alert("There were invalid base64 characters in the input text.\n" + "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" + "Expect errors in decoding."); } input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); do { enc1 = keyStr.indexOf(input.charAt(i++)); enc2 = keyStr.indexOf(input.charAt(i++)); enc3 = keyStr.indexOf(input.charAt(i++)); enc4 = keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) output = output + String.fromCharCode(chr2); if (enc4 != 64) output = output + String.fromCharCode(chr3); chr1 = chr2 = chr3 = ""; enc1 = enc2 = enc3 = enc4 = ""; } while (i < input.length); return unescape(output); }