Last active
February 8, 2024 07:15
-
-
Save dcdunkan/f98cac20c0cc400d9eb4d859218e17cc to your computer and use it in GitHub Desktop.
Resolve Telegram's slot machine dice value (from tdesktop source)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const e = ["🔤", "🫐", "🍋", "7️⃣"]; | |
function computePartValue(value: number, partIndex: number) { | |
return ((value - 1) >> (partIndex * 2)) & 0x03; // 0..3 | |
} | |
function resolve(value: number) { | |
if (value <= 0 && value > 64) return; | |
let text = `${value}:`; | |
for (let i = 0; i < 3; i++) text += ` e[computePartValue(value, i)]`; | |
console.log(text); | |
} | |
const input = Deno.args[0]; | |
if (!input) { | |
console.log("No arguments."); | |
} else if (isNaN(Number(input))) { | |
console.log("Not a number!"); | |
} else { | |
resolve(Number(Deno.args[0])); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment