-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
98 lines (83 loc) · 5.38 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#<!DOCTYPE html><head><link rel="stylesheet" type="text/css" href="asciinema-player.css" /><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Usage</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/github-fork-ribbon-css/0.2.3/gh-fork-ribbon.min.css" /><link rel="stylesheet" href="https://unpkg.com/@highlightjs/cdn-assets@11.5.0/styles/default.min.css"><script src="https://unpkg.com/@highlightjs/cdn-assets@11.5.0/highlight.min.js"></script><script> hljs.initHighlightingOnLoad();</script><style>body { font-family: monospace; background: rgba(245, 245, 245, 1); } footer { font-size: 0.65rem; } a { color: inherit; text-decoration: none; } pre { white-space: pre-wrap; /* Supaya teks wrap otomatis */ word-wrap: break-word; /* Pastikan kata bisa pecah */ overflow-x: auto; /* Tambahkan scroll horizontal kalau tetap kepanjangan */ max-width: 100%; /* Hindari melebihi lebar layar */ } code { display: block; overflow-x: auto; /* Pastikan teks wrap */ border-radius: 4px; font-size: 1.1rem; color: #F0F0F0 !important; background: rgb(11 12 14) !important; } .github-fork-ribbon:before { background-color: rgb(11 12 14); } .hidden-text { white-space: nowrap; margin: 0; padding: 0; visibility: hidden; /* atau display: none; */ } .container { display: flex; flex-direction: column; /* Supaya item dalam satu kolom */ align-items: center; /* Biar rapi di tengah */ width: 100%; /* Hindari elemen terlalu lebar */ max-width: 100vw; /* Batasi sesuai lebar layar */ overflow-x: auto; /* Scroll kalau perlu */ }</style></head><body>: Anti-hangman is Hangman-Like games, written in bash <a class="github-fork-ribbon" href="https://github.com/luisadha/anti-hangman" data-ribbon="Contribute on GitHub" title="Contribute on GitHub">Contribute on GitHub</a> <h2>
#!/usr/bin/env bash </br></h2><span>luisadha.github.io/anti-hangman Use this self-hosted script to Playing Hangman-Like Games on terminal.</span><h3>
### <a name="usage" href="#usage">Bermain di Terminal</a></h2><pre><code code="shell">. <(curl -L luisadha.github.io/anti-hangman)</code></pre><h3><span class="hidden-text">
# Anti-Hangman v.0.03
# - nix-on-droid tested
version="0.04"
# Reference :
# - https://stackoverflow.com/questions/4687722/dynamic-case-statement-in-bash#19771433
# - https://id.bitdegree.org/tutorial/ide-proyek-python
# - https://github.com/jesstess/Scrabble/blob/master/scrabble/sowpods.txt
# Dependend
# - crunch
# - coreutils
# - awk
#
#
#!/data/data/com.termux/files/usr/bin/bash
# Anti-Hangman v.0.04
# Dependensi (pastikan diinstal sebelum menjalankan)
# - crunch
# - coreutils
# - awk
DICT_NAMES="wordlist.txt"
DICTIONARY_PATH="$PREFIX/var/games/anti-hangman/${DICT_NAMES:-sowpods.txt}"
DEPENDENCIES=(crunch curl coreutils find gawk git grep sed)
for DEP in "${DEPENDENCIES[@]}"; do
if ! command -v "$DEP" &>/dev/null; then
echo "Error: $DEP tidak terinstal. Silakan instal sebelum menjalankan skrip."
exit 1
fi
done
if [ ! -f "$DICTIONARY_PATH" ]; then
echo "Data kamus diperlukan, Unduh? (y/n)"
read -r CONT
if [ "$CONT" = "y" ]; then
mkdir -p "$(dirname "$DICTIONARY_PATH")"
curl -fSsl https://raw.githubusercontent.com/jesstess/Scrabble/master/scrabble/sowpods.txt -o "$DICTIONARY_PATH"
if [ $? -eq 0 ]; then
echo "Berhasil download data, silahkan jalankan ulang!"
exit 0
else
echo "Download tidak berhasil"; exit 1;
fi
else
echo "Gagal memulai karena kamus tidak tersedia."; exit 1;
fi
fi
echo -e "--------------------------------------------------------"
echo -e "Selamat datang di game Tebak-tebakan."
echo -e "Uji pengetahuan bahasa inggris umum-mu sekarang juga!"
echo -e "-----[ name: anti-hangman ]-"
echo -e "-----[ version: v$version ]-"
echo -e "-----[ source code: https://github.com/luisadha/anti-hangman ]-"
echo -e " anti-hangman Copyright (C) 2023 Luis Adha
This program comes with ABSOLUTELY NO WARRANTY"
echo -e "--------------------------------------------------------"
while true; do
get_pharse=$(mapfile -t word_arr < $PREFIX/var/games/anti-hangman/sowpods.txt && printf '%s\n' "${word_arr[@]}" |shuf -n 1)
hangman_simulation=$(echo $get_pharse | awk 'BEGIN{FS=""}{for(i=1;i<=NF;i++) if(seen[$i]++) $i="_"}1')
permute_test=$(echo $get_pharse | grep -o . | sort | uniq -d | xargs | tr -d ' ')
# eval echo $get_pharse # Uncomment this if your a noob player
echo $hangman_simulation
# eval echo $permute_test
valid=$(crunch 1 1 -p $permute_test 2>/dev/null | xargs | tr ' ' '|' )
if [[ "$hangman_simulation" =~ ^[[:alpha:]]+$ ]]; then
echo "Tidak ada tebakan hari ini, Kembali lagi nanti :)"
exit 2
fi
echo
read -p "Input hidden letters: " choice
[[ -n $choice ]] || { echo "Apa itu? Coba lagi" >&2; continue; }
eval "case \"$choice\" in
$valid)
echo "Selamat, tebakan anda benar"
break;
;;
*)
echo "Coba lagi!"
continue;
;;
esac" 2>/dev/null
done
#</code></pre><footer>#### Copyright (C) 2021-2025 <a href="https://luisadha.my.id">luisadha.my.id</a> (<a href="https://github.com/luisadha">github.com/luisadha</a>) ####</footer><a href="https://asciinema.org/a/704914" target="_blank"><img src="https://asciinema.org/a/704914.svg" /></a><div id="player"></div><script src="asciinema-player.min.js"></script><script> AsciinemaPlayer.create( '/assets/704914.cast', document.getElementById('player'), { cols: 54, rows: 28 } ); </script></body></html>