Just a test for key prototyping

Godot Version

4.2.2

Question

While I know this needs a hosting backend to truly work, how is this local prototype?

extends Node

var activationKey = "" 
var correctActivationKey = ""
var currentQuestionIndex = 0
var attempts = 0
var maxAttempts = 2

var questions = [
    ["What is the third day?", "Wednesday"],
] # Make the days rotate and lead to correct answer first step

var submittedAnswers = []

@onready var rich_text_label = $RichTextLabel
@onready var line_edit = $LineEdit

func _ready():
    generate_activation_key()
    display_question()

func generate_activation_key():
    var system_identifier = Engine.get_identifier()  # Get a unique identifier for the user's system
    var seed = str(system_identifier) + "my_proto_seed"  # Add a seed to make randomness
    activationKey = generate_random_key(seed, 4)
    correctActivationKey = activationKey  # Store the correct activation key
    print("Activation Key:", activationKey)

func generate_random_key(seed, length):
    var rand_gen = RandomNumberGenerator.new()
    rand_gen.randomize()
    rand_gen.set_seed_string(seed)
    var charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
    var key = ""
    for i in range(length):
        key += charset[rand_gen.randi() % charset.length()]
    return key

func display_question():
    var question = questions[currentQuestionIndex][0]
    rich_text_label.text = question

func check_activation_key(playerKey):
    if playerKey.strip_edges().to_lower() == correctActivationKey.to_lower():
        print("Activation successful!")
        rich_text_label.text = "Activation successful! Enjoy the application!"
        line_edit.hide()
    else:
        attempts += 1
        print("Incorrect activation key. Please try again. Attempt " + str(attempts))
    if attempts == 2:
        line_edit.hide()
        rich_text_label.text = "Failed Activation, invalid key." + "\n" + "Restart or purchase valid key"

func check_answer(playerAnswer):
    var correctAnswer = questions[currentQuestionIndex][1].to_lower()  # Convert to lowercase
    playerAnswer = playerAnswer.strip_edges().to_lower()  # Convert to lowercase and remove leading/trailing spaces
    if playerAnswer == correctAnswer:
        print("Correct!")
        currentQuestionIndex += 1
        if currentQuestionIndex < questions.size():
            display_question()
        else:
            print("All questions answered correctly. Now enter the activation key.")
            rich_text_label.text = "Now enter the activation key: " + activationKey
            line_edit.text = ""  # Clear LineEdit text for activation key entry
    else:
        attempts += 1
        print("Incorrect! Try again.")
        if attempts >= maxAttempts:
            print("Maximum attempts reached. Locking out further attempts.")
            rich_text_label.hide()
            line_edit.hide()

    submittedAnswers.append(playerAnswer)

func _on_line_edit_text_submitted(new_text):
    var answer = new_text
    if currentQuestionIndex < questions.size():
        check_answer(answer)  # If questions remain, check answer
    else:
        check_activation_key(answer)  # If all questions answered, check activation key

    submittedAnswers.append(new_text)