feat: generate dragon code

This commit is contained in:
Gerard Gascón 2025-04-09 01:16:47 +02:00
parent ca4959af32
commit 577926e8fc
5 changed files with 180 additions and 1 deletions

View file

@ -40,5 +40,9 @@ func _on_change_shoes_pressed() -> void:
func _on_create_pressed() -> void:
if dragon_name.text.is_empty():
return
var result: String = CodeGenerator.new(hat_outfits, shirt_outfits, shoes_outfits).encrypt(hat.texture, shirt.texture, shoes.texture, dragon_name.text)
print(result)
var decrypted: Dictionary = CodeGenerator.new(hat_outfits, shirt_outfits, shoes_outfits).descrypt(result)
print(decrypted)
on_create_dragon.emit(hat.texture, shirt.texture, shoes.texture, dragon_name.text)
queue_free()

View file

@ -6,6 +6,28 @@ func _ready() -> void:
func _text_to_upper(new_text: String):
var ascii_map := {
"á":"a", "à":"a", "â":"a", "ä":"a", "ã":"a", "å":"a",
"é":"e", "è":"e", "ê":"e", "ë":"e",
"í":"i", "ì":"i", "î":"i", "ï":"i",
"ó":"o", "ò":"o", "ô":"o", "ö":"o", "õ":"o",
"ú":"u", "ù":"u", "û":"u", "ü":"u",
"ñ":"n", "ç":"c",
"Á":"A", "À":"A", "Â":"A", "Ä":"A", "Ã":"A", "Å":"A",
"É":"E", "È":"E", "Ê":"E", "Ë":"E",
"Í":"I", "Ì":"I", "Î":"I", "Ï":"I",
"Ó":"O", "Ò":"O", "Ô":"O", "Ö":"O", "Õ":"O",
"Ú":"U", "Ù":"U", "Û":"U", "Ü":"U",
"Ñ":"N", "Ç":"C"
}
var filtered_text := ""
for c in new_text:
if ascii_map.has(c):
filtered_text += ascii_map[c]
elif c.unicode_at(0) <= 127:
filtered_text += c
var last_caret_column = caret_column
text = new_text.to_upper()
text = filtered_text.to_upper()
caret_column = last_caret_column