From 5d667a599f6778cc96b10e3b6d2e885102c9ab70 Mon Sep 17 00:00:00 2001 From: Diego Alonso Ojeda Medina Date: Wed, 28 Jun 2023 14:50:09 -0500 Subject: [PATCH 1/3] Create KonamiCode.php Reto 25 usando PHP --- .../PHP/KonamiCode.php" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/PHP/KonamiCode.php" diff --git "a/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/PHP/KonamiCode.php" "b/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/PHP/KonamiCode.php" new file mode 100644 index 0000000000..35b43e8586 --- /dev/null +++ "b/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/PHP/KonamiCode.php" @@ -0,0 +1,56 @@ + "", Interceptor::KEY_DOWN => "", + Interceptor::KEY_LEFT => "", Interceptor::KEY_RIGHT => "", + 98 => "b", 97 => "a", +]; + +$keys = Interceptor::I(); +echo "\033[31m\e[1mKonami Code \e[32m presione q para salir \n"; + +if ($keys->init()) { + while (true) { + $key = $keys->intercept(); + if (in_array($key, [113, 81])) { + Interceptor::eprintln("\e[7;34;40mSalida registrada\e[0m"); + exit(0); + } + if (!on_press($key)) { + exit(0); + } + } +} + +function on_press($key) +{ + global $key_position, $last_key, $KONAMI_CODE, $ICONS; + echo (in_array($key, $KONAMI_CODE)) ? "$ICONS[$key]" : chr($key); + if ($key == $KONAMI_CODE[$key_position]) { + $key_position += 1; + } elseif ($key == $KONAMI_CODE[0]) { + $key_position = ($last_key == $KONAMI_CODE[0]) ? 2 : 1; + } else { + $key_position = 0; + } + + if ($key_position == count($KONAMI_CODE)) { + echo "\n\e[39m"; + echo "\e[41m╦╔═╔═╗╔╗╔╔═╗╔╦╗╦ ╔═╗╔═╗╔╦╗╔═╗\n"; + echo "\e[41m╠╩╗║ ║║║║╠═╣║║║║ ║ ║ ║ ║║║╣ \n"; + echo "\e[41m╩ ╩╚═╝╝╚╝╩ ╩╩ ╩╩ ╚═╝╚═╝═╩╝╚═╝\n"; + echo "\e[0m"; + return false; + } + $last_key = $key; + return true; +} From a630ebd84e0c5ef627c982339f93be0df9bd4497 Mon Sep 17 00:00:00 2001 From: Diego Alonso Ojeda Medina Date: Wed, 28 Jun 2023 14:57:08 -0500 Subject: [PATCH 2/3] Comentario como ejecutarlo --- .../php/KonamiCode.php" | 4 ++++ 1 file changed, 4 insertions(+) rename "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/PHP/KonamiCode.php" => "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/KonamiCode.php" (94%) diff --git "a/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/PHP/KonamiCode.php" "b/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/KonamiCode.php" similarity index 94% rename from "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/PHP/KonamiCode.php" rename to "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/KonamiCode.php" index 35b43e8586..9761c1044b 100644 --- "a/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/PHP/KonamiCode.php" +++ "b/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/KonamiCode.php" @@ -1,4 +1,8 @@ Date: Thu, 29 Jun 2023 04:06:48 -0500 Subject: [PATCH 3/3] Rename KonamiCode.php to daom89.php Chage name file --- .../Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/daom89.php" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/KonamiCode.php" => "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/daom89.php" (100%) diff --git "a/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/KonamiCode.php" "b/Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/daom89.php" similarity index 100% rename from "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/KonamiCode.php" rename to "Retos/Reto #25 - EL C\303\223DIGO KONAMI [Media]/php/daom89.php"