NACHWEISLICH FAIR
Das Prinzip der Roulette ist recht einfach: Sobald der 15-Sekunden-Countdown endet, wird eine Zufallszahl zwischen 0 und 14 generiert und das Ergebnis bekannt gegeben. Ist die Zahl 0, entspricht dies Gelb; ist sie gerade, Schwarz; und ist sie ungerade, Pink.
import crypto from "crypto";const serverSeed = "1234";const publicSeed = "abcd";const nonce = 3;const seed = `ROULETTE-${serverSeed}-${publicSeed}:${nonce}`;const roll = getRollValue(seed);console.log("El resultado de la ruleta es", getRollColor(roll));function getRollValue(seed) {const hash = crypto.createHmac("sha256", seed).digest("hex");const h = Number.parseInt(hash.slice(0, 52 / 4), 16);const e = Math.pow(2, 52);return Math.floor(h / e * 15); }function getRollColor(rollValue) {const position = rollValue % 15;if (position === 0) {return 'YELLOW';}else if (position % 2 === 1) {return 'PINK';}else {return 'BLACK';}}