Abandoned Crate 
A secure crate that requires a unique code to unlock. Contains randomized loot.
This crate uses a bulls-and-cows guessing game. Incorrect attempts may cause an explosion.
Vars | |
| attempts | Remaining attempts to input the correct code |
|---|---|
| code | Secret code required to unlock the crate |
| code_length | Length of the generated code (number of digits) |
| possible_loot | Weighted list of possible loot items. Format: list(list(typepath = probability) = group_weight). Total probability = ((probability in sublist * group weight) / 100) |
| previous_attempts | List of previous attempts in format: list("attempt" = "1234", "bulls" = 1, "cows" = 2) |
| qdel_on_open | Whether to delete the crate after opening |
| spawned_loot | Whether loot has already been spawned inside the crate |
Procs | |
| bulls_and_cows | Implements bulls and cows algorithm |
| generate_code | Generates a random code of specified length with no repeating digits |
| spawn_loot | Spawns loot inside the crate |
| validate_input | Validates user input for code attempts |
Var Details
attempts 
Remaining attempts to input the correct code
code 
Secret code required to unlock the crate
code_length 
Length of the generated code (number of digits)
possible_loot 
Weighted list of possible loot items. Format: list(list(typepath = probability) = group_weight). Total probability = ((probability in sublist * group weight) / 100)
previous_attempts 
List of previous attempts in format: list("attempt" = "1234", "bulls" = 1, "cows" = 2)
qdel_on_open 
Whether to delete the crate after opening
spawned_loot 
Whether loot has already been spawned inside the crate
Proc Details
bulls_and_cows
Implements bulls and cows algorithm
Compares the guess against the actual code. Bulls = correct digit in correct position. Cows = correct digit in wrong position.
Arguments:
- guess - The user's guess string
Returns:
- list - Contains attempt, bulls count, and cows count
generate_code
Generates a random code of specified length with no repeating digits
spawn_loot
Spawns loot inside the crate
Selects a random loot item from the weighted possible_loot list. Marks the crate as having spawned loot.
validate_input
Validates user input for code attempts
Checks if input is the correct length, contains only digits, and has no repeating digits.
Arguments:
- input - The user's guess attempt
Returns:
- boolean - TRUE if input is valid, FALSE otherwise