parent
2d670cd009
commit
85ae45f25b
|
|
@ -45,7 +45,7 @@ const nounTemperatures = {
|
||||||
gas: ["#ffffff", "#eeeeee", "#dddddd", "#cccccc", "#bbbbbb"],
|
gas: ["#ffffff", "#eeeeee", "#dddddd", "#cccccc", "#bbbbbb"],
|
||||||
plasma: ["#ff9966", "#ffaa77", "#ffbb88", "#ffcc99", "#ffddaa"],
|
plasma: ["#ff9966", "#ffaa77", "#ffbb88", "#ffcc99", "#ffddaa"],
|
||||||
slime: ["#88cc88", "#99dd99", "#aaddaa", "#bbeebb", "#ccffcc"],
|
slime: ["#88cc88", "#99dd99", "#aaddaa", "#bbeebb", "#ccffcc"],
|
||||||
sand: ["#cccccc", "#dddddd", "#eeeeee", "#ffffff", "#eeeeee"],
|
sand: ["#D2B48C", "#E8D5A9", "#F0E3C4", "#DCD0BF", "#EBE4D6"],
|
||||||
dust: ["#aaaaaa", "#bbbbbb", "#cccccc", "#dddddd", "#eeeeee"],
|
dust: ["#aaaaaa", "#bbbbbb", "#cccccc", "#dddddd", "#eeeeee"],
|
||||||
rock: ["#777777", "#888888", "#999999", "#aaaaaa", "#bbbbbb"],
|
rock: ["#777777", "#888888", "#999999", "#aaaaaa", "#bbbbbb"],
|
||||||
lava: ["#ff4400", "#ff5511", "#ff6622", "#ff7733", "#ff8844"],
|
lava: ["#ff4400", "#ff5511", "#ff6622", "#ff7733", "#ff8844"],
|
||||||
|
|
@ -57,26 +57,24 @@ const nounTemperatures = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const adjectiveStates = {
|
const nounStates = {
|
||||||
shiny: "solid",
|
metal: "solid",
|
||||||
glowing: "gas",
|
crystal: "solid",
|
||||||
dark: "solid",
|
stone: "solid",
|
||||||
bright: "gas",
|
powder: "liquid",
|
||||||
heavy: "solid",
|
liquid: "liquid",
|
||||||
light: "gas",
|
gas: "gas",
|
||||||
hot: "solid",
|
plasma: "gas",
|
||||||
cold: "solid",
|
slime: "liquid",
|
||||||
hard: "solid",
|
sand: "liquid",
|
||||||
soft: "liquid",
|
dust: "liquid",
|
||||||
smooth: "liquid",
|
rock: "solid",
|
||||||
rough: "solid",
|
lava: "liquid",
|
||||||
round: "liquid",
|
ice: "solid",
|
||||||
sharp: "solid",
|
vapor: "gas",
|
||||||
sweet: "liquid",
|
ash: "liquid",
|
||||||
sour: "liquid",
|
soot: "liquid",
|
||||||
bitter: "liquid",
|
sludge: "liquid"
|
||||||
salty: "solid",
|
|
||||||
savory: "liquid"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Map noun to behavior
|
// Map noun to behavior
|
||||||
|
|
@ -100,12 +98,29 @@ const nounBehaviors = {
|
||||||
sludge: behaviors.LIQUID
|
sludge: behaviors.LIQUID
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const adjectiveBreakInto = {
|
||||||
|
sweet: "sugar",
|
||||||
|
salty: "salt",
|
||||||
|
};
|
||||||
|
|
||||||
|
const nounBreakInto = {
|
||||||
|
crystal: "glass_shard",
|
||||||
|
ice: "snow",
|
||||||
|
rock: ["sand", "gravel"],
|
||||||
|
};
|
||||||
|
|
||||||
|
const adjectiveColorModifiers = {
|
||||||
|
dark: 0.8, // darker
|
||||||
|
shiny: 1.2, // brighter
|
||||||
|
glowing: 1.5 // brightest
|
||||||
|
};
|
||||||
|
|
||||||
// Generate elements
|
// Generate elements
|
||||||
for (const name of elementNames) {
|
for (const name of elementNames) {
|
||||||
|
|
||||||
const [adjective, noun] = name.split("_");
|
const [adjective, noun] = name.split("_");
|
||||||
|
|
||||||
const baseColor = nounColors[noun];
|
let baseColor = nounColors[noun];
|
||||||
|
|
||||||
const {tempLow, tempHigh} = nounTemperatures[noun];
|
const {tempLow, tempHigh} = nounTemperatures[noun];
|
||||||
|
|
||||||
|
|
@ -117,14 +132,69 @@ for (const name of elementNames) {
|
||||||
temp /= 2;
|
temp /= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (adjective in adjectiveColorModifiers) {
|
||||||
|
const modifier = adjectiveColorModifiers[adjective];
|
||||||
|
baseColor = modifyColor(baseColor, modifier);
|
||||||
|
}
|
||||||
|
|
||||||
elements[name] = {
|
elements[name] = {
|
||||||
color: baseColor,
|
color: baseColor,
|
||||||
behavior: nounBehaviors[noun],
|
behavior: nounBehaviors[noun],
|
||||||
category: "random elements",
|
category: "random elements",
|
||||||
state: adjectiveStates[adjective],
|
state: nounStates[noun],
|
||||||
temp: temp,
|
temp: temp,
|
||||||
|
breakInto: adjectiveBreakInto[adjective] || nounBreakInto[noun],
|
||||||
density: Math.random() * 100,
|
density: Math.random() * 100,
|
||||||
viscosity: Math.random() * 100
|
viscosity: Math.random() * 100
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function modifyColor(color, modifier) {
|
||||||
|
if (color[0] === '#') {
|
||||||
|
color = color.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
color = String(color);
|
||||||
|
|
||||||
|
// Check for '#'
|
||||||
|
const match = color.match(/^#?(.*)$/);
|
||||||
|
if (match) {
|
||||||
|
color = match[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to RGB
|
||||||
|
let [r, g, b] = color.match(/.{1,2}/g).map(x => parseInt(x, 16));
|
||||||
|
|
||||||
|
// Apply modifier
|
||||||
|
r = Math.round(r * modifier);
|
||||||
|
g = Math.round(g * modifier);
|
||||||
|
b = Math.round(b * modifier);
|
||||||
|
|
||||||
|
// Constrain RGB values to 0-255
|
||||||
|
r = Math.max(0, Math.min(255, r));
|
||||||
|
g = Math.max(0, Math.min(255, g));
|
||||||
|
b = Math.max(0, Math.min(255, b));
|
||||||
|
|
||||||
|
// Convert back to hex
|
||||||
|
return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
changelog only count importtant stuff and not the small details
|
||||||
|
|
||||||
|
0.1
|
||||||
|
added the mod
|
||||||
|
|
||||||
|
0.2
|
||||||
|
elements have breakInto's
|
||||||
|
elements with the adjectives "dark, shiny and glowing" are darker or brighter
|
||||||
|
elements with the nouns "crystal, ice, rock" can break into other elements like "glass_shard, snow, sand"
|
||||||
|
fixed some elements having wrong states
|
||||||
|
|
||||||
|
todo:
|
||||||
|
elements have reactions
|
||||||
|
gases dont have breakintos
|
||||||
|
|
||||||
|
what a silly little changelog! i made it literally right here!!
|
||||||
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue