Created
October 7, 2024 03:55
-
-
Save crischutu07/634c90173dcb7e99abadc67f3362c616 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* Building blocks with letters: | |
* - [] -> Full block | |
* - L -> Half block | |
* - {} -> Ice | |
* - | -> Fence | |
* - / -> Glass | |
* - i -> Candle | |
* - H -> A neo | |
* - _ -> No block | |
* | |
* => @ashmellow78's Parkour Language (on Twitter/X) | |
* Building blocks with numbers: | |
* 0 = D -> Slime block ZERO (0) | |
* 1 = D^ -> Slime block ONE (1) | |
* 2 = D^^ | |
* ... | |
* 9 = D^^^^^^^^^ -> Slime block NINE (9) | |
* | |
*/ | |
let letters = { | |
'a': '[]____ ', | |
'b': '/_/_ ', | |
'c': '{}__ ', | |
'd': '{}___ ', | |
'e': '[]_ ', | |
'f': '/_//_ ', | |
'g': '|_|_ ', | |
'h': '|__|_ ', | |
'i': '[]___ ', | |
'j': 'H_[]_ ', | |
'k': 'i_ ', | |
'l': '{}_ ', | |
'm': '|_||_ ', | |
'n': 'L__ ', | |
'o': 'L__[]_ ', | |
'p': '||_|_ ', | |
'q': 'HH__ ', | |
'r': 'L_ ', | |
's': '[]__ ', | |
't': 'L_[]_ ', | |
'u': '{}____ ', | |
'v': '/__/_ ', | |
'w': 'i__ ', | |
'x': 'i__[]_ ', | |
'y': '//_/_ ', | |
'z': 'i_[]_ ' | |
}; | |
let num = { | |
'0': 'D', | |
'1': 'D^', | |
'2': 'D^^', | |
'3': 'D^^^', | |
'4': 'D^^^^', | |
'5': 'D^^^^^', | |
'6': 'D^^^^^^', | |
'7': 'D^^^^^^^', | |
'8': 'D^^^^^^^^', | |
'9': 'D^^^^^^^^^' | |
}; | |
let punctuation = { | |
// (), [], {} => Those characters i don't know how to wrap it up | |
// Since the author of this language didn't tell us how to wrap these. | |
'(': '<]_', | |
')': '<]_', | |
'[': '<]__', | |
']': '<]__', | |
'{': '<]___', | |
'}': '<]___', | |
':': '<-]_', | |
';': '<-]__', | |
'-': '<-]___', | |
',': '<--]_', | |
"'": '<--]__', | |
'"': '<--]___', | |
'.': '<<]_', | |
'?': '<<]__', | |
'!': '<<]___' | |
}; | |
const decode = process.argv.includes("--decode") || | |
process.argv.includes("-d"); | |
if (!process.argv[2]) { | |
if (!decode) | |
var input = 'The fox jumps over the lazy dog' | |
else | |
var input = '|__|_ []_ {}_ {}_ L__[]_ * i__ L__[]_ L_ {}_ {}___ <<]_' | |
} else var input = process.argv[2]; | |
console.log(`Input: ${input}`); | |
let output = []; | |
if (decode) { | |
letters = Object.fromEntries(Object.entries(letters).map( | |
([key, value]) => [value.trim(), key] | |
)); | |
num = Object.fromEntries(Object.entries(num).map( | |
([key, value]) => [value, key] | |
)); | |
punctuation = Object.fromEntries(Object.entries(punctuation).map( | |
([key, value]) => [value, key] | |
)); | |
input.split(' ').forEach(char => { | |
if (char === '*') | |
output.push(' '); | |
else if (letters[char]) | |
output.push(letters[char]); | |
else if (num[char]) | |
output.push(num[char]); | |
else if (punctuation[char]) | |
output.push(punctuation[char]); | |
}); | |
output = output.join('') | |
} else { | |
input = input.toLowerCase(); | |
for (let i = 0; i < input.length; i++) { | |
const char = input[i]; | |
if (char === ' '){ | |
if (output[output.length - 1] !== '*') | |
output.push('*'); | |
} else if (letters[char]) | |
output.push(letters[char].trim()); | |
else if (num[char]) | |
output.push(num[char]); | |
else if (punctuation[char]) | |
output.push(punctuation[char]); | |
} | |
output = output.join(' '); | |
} | |
console.log(`Output: ${output}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment