2024-04-03 18:34:17 -04:00
|
|
|
var color = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e","f"]
|
|
|
|
|
var states = ["solid", "liquid", "gas"]
|
|
|
|
|
var total = 0
|
2024-04-03 21:30:44 -04:00
|
|
|
var dangerouselements = ["supernova", "n_explosion", "pn_explosion", "armageddon", "nuke", "h_bomb"]
|
2024-04-03 18:34:17 -04:00
|
|
|
var elementslist = []
|
|
|
|
|
for (elementi in elements){
|
|
|
|
|
elementslist.push(elementi)
|
|
|
|
|
}
|
|
|
|
|
function randomIntFromInterval(min, max) { // min and max included
|
|
|
|
|
return Math.floor(Math.random() * (max - min + 1) + min)
|
|
|
|
|
}
|
|
|
|
|
var randomProperty = function (obj) {
|
|
|
|
|
var keys = Object.keys(obj);
|
|
|
|
|
return obj[keys[ keys.length* Math.random() << 0]];
|
|
|
|
|
};
|
|
|
|
|
for (var i = 1; i <= 10000; i++){
|
|
|
|
|
var f = Math.random() < 0.2
|
|
|
|
|
var co = Math.random() < 0.2
|
|
|
|
|
elements["element_"+i] = {
|
|
|
|
|
color: "#" + color[Math.floor(Math.random()*color.length)] + color[Math.floor(Math.random()*color.length)] + color[Math.floor(Math.random()*color.length)] + color[Math.floor(Math.random()*color.length)] + color[Math.floor(Math.random()*color.length)] + color[Math.floor(Math.random()*color.length)],
|
|
|
|
|
category: "random",
|
|
|
|
|
behavior: randomProperty(behaviors),
|
|
|
|
|
state: states[Math.floor(Math.random()*states.length)],
|
|
|
|
|
reactions: {},
|
|
|
|
|
density: randomIntFromInterval(1, 10000)
|
|
|
|
|
}
|
|
|
|
|
total = i
|
|
|
|
|
if (f){
|
|
|
|
|
elements["element_"+i].tempHigh = 20 + randomIntFromInterval(10, 6000)
|
|
|
|
|
elements["element_"+i].stateHigh = elementslist[Math.floor(Math.random()*elementslist.length)]
|
|
|
|
|
}
|
|
|
|
|
if (co){
|
|
|
|
|
elements["element_"+i].tempLow = 20 - randomIntFromInterval(10, 270)
|
|
|
|
|
elements["element_"+i].stateLow = elementslist[Math.floor(Math.random()*elementslist.length)]
|
|
|
|
|
}
|
|
|
|
|
for (r = 0; r < 10; r++){
|
|
|
|
|
elements["element_"+i].reactions[elementslist[Math.floor(Math.random()*elementslist.length)]] = { elem1: elementslist[Math.floor(Math.random()*elementslist.length)], elem2: elementslist[Math.floor(Math.random()*elementslist.length)]}
|
|
|
|
|
}
|
|
|
|
|
// console.log(i + " is done!")
|
2024-04-03 18:49:51 -04:00
|
|
|
// console.log(i)
|
|
|
|
|
// console.log(elements["element_"+i].behavior)
|
|
|
|
|
if (elements["element_" + i].density == i){
|
2024-04-03 19:40:02 -04:00
|
|
|
console.log(i + "is unique because its density is the same as its id!")
|
|
|
|
|
}
|
|
|
|
|
for (var reaction in elements["element_" + i].reactions){
|
2024-04-03 21:30:44 -04:00
|
|
|
if (dangerouselements.includes(elements["element_" + i].reactions[reaction].elem1)|| dangerouselements.includes(elements["element_" + i].reactions[reaction].elem2)){
|
2024-04-03 19:40:02 -04:00
|
|
|
console.log(i + " is scary due to its reaction with " + reaction)
|
2024-04-03 21:30:44 -04:00
|
|
|
if (!elements["element_"+i].desc){
|
2024-04-03 19:40:02 -04:00
|
|
|
elements["element_" + i].desc = "This is scary! Don't let it touch " + reaction
|
2024-04-03 21:30:44 -04:00
|
|
|
}else(elements["element_"+i].desc += (" or " + reaction))
|
2024-04-03 19:40:02 -04:00
|
|
|
}
|
2024-04-03 18:49:51 -04:00
|
|
|
}
|
2024-04-03 18:34:17 -04:00
|
|
|
}
|