-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
125 lines (107 loc) · 6.58 KB
/
index.html
File metadata and controls
125 lines (107 loc) · 6.58 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env bash<!DOCTYPE html> <html lang="id"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Anti-Hangman | Pilih Aplikasi Termux</title> <link rel="stylesheet" href="asciinema-player.css" /> <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> <script>function share() { if (navigator.share) { navigator.share({ title: document.title, url: 'https://luisadha.github.io/anti-hangman/' }); } else { alert("Fitur berbagi tidak didukung di browser ini."); } } </script> <style> body { font-family: monospace; background: #f5f5f5; padding: 1em; } h2, h3 { margin-top: 1.5em; } code { display: block; background: #0b0c0e; color: #f0f0f0; padding: 1em; border-radius: 5px; overflow-x: auto; } .github-fork-ribbon:before { background-color: #0b0c0e; } footer { font-size: 0.75rem; margin-top: 3em; } .share-line { display: flex; align-items: center; gap: 0.5em; flex-wrap: wrap; margin-top: 0.5em; } button { font-family: inherit; font-size: 0.9em; padding: 0.4em 0.8em; border: none; background: #0b0c0e; color: white; border-radius: 4px; cursor: pointer; } button:hover { background: #333; } #player { max-width: 100%; margin-top: 1em; } iframe, .asciinema-player { width: 100% !important; height: auto !important; } .note { font-size: 0.9em; background: #fff9c4; padding: 1em; border-left: 5px solid #fbc02d; margin-top: 1em; } </style> <style> .share { font-weight: bold; position: relative; } .share:before { content: "."; font-size: 2.2em; position: absolute; bottom: -2.5px; left: -4px; } .share:after { content: ":"; font-size: 2em; position: absolute; bottom: -6px; right: -7px; } </style> </head> <body> <!-- Fork ribbon --> <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> <p><a href="https://luisadha.github.io/anti-hangman">Anti-Hangman</a> Is hangman-like games but it's difference, written in Pure Bash</p> <p>— Gunakan self-hosted ini untuk memainkan permainan hangman yang lebih sulit di termux anda.</p> <p> <h3>Preview</h3> <a href="https://asciinema.org/a/704914" target="_blank"> <img src="https://asciinema.org/a/704914.svg" alt="Preview animation" style="max-width: 100%; height: auto;" /> </a> <pre><code class="language-shell"> <!--
#!/data/data/com.termux/files/usr/bin/bash
# anti-hangman (bash compatible)
set -euo pipefail
version="0.21"
# ---------------------------
# Version flag
# ---------------------------
if [[ "${1:-}" == "-v" || "${1:-}" == "--version" ]]; then
echo "anti-hangman v${version}"
exit 0
fi
# ---------------------------
# TTY IO
# ---------------------------
exec 4</dev/tty
exec 5>/dev/tty
cout() {
printf '%s\n' "$*" >&5
}
cin() {
local prompt="$1"
local __var="$2"
printf '%s ' "$prompt" >&5
IFS= read -r ans <&4
printf -v "$__var" '%s' "$ans"
}
# ---------------------------
# Dependency check
# ---------------------------
DEPENDENCIES=(crunch curl awk grep sed shuf sort uniq tr)
for dep in "${DEPENDENCIES[@]}"; do
command -v "$dep" >/dev/null 2>&1 || {
cout "Error: $dep belum terinstal."
exit 1
}
done
# ---------------------------
# Dictionary
# ---------------------------
DICT_DIR="$PREFIX/var/games/anti-hangman"
DICT_FILE="$DICT_DIR/sowpods.txt"
if [[ ! -f "$DICT_FILE" ]]; then
cout "Kamus tidak ditemukan. Unduh? (y/n)"
cin "" CONT
if [[ "$CONT" == "y" ]]; then
mkdir -p "$DICT_DIR"
curl -fsSL \
https://raw.githubusercontent.com/jesstess/Scrabble/master/scrabble/sowpods.txt \
-o "$DICT_FILE"
cout "Download selesai. Jalankan ulang."
exit 0
else
cout "Tidak bisa melanjutkan tanpa kamus."
exit 1
fi
fi
# ---------------------------
# Banner
# ---------------------------
cout "--------------------------------------------------------"
cout "Selamat datang di game Tebak Kata"
cout "anti-hangman v$version"
cout "https://github.com/luisadha/anti-hangman"
cout "ABSOLUTELY NO WARRANTY"
cout "--------------------------------------------------------"
# ---------------------------
# Game loop
# ---------------------------
while true; do
get_phrase="$(shuf -n 1 "$DICT_FILE")"
hangman_simulation="$(
awk '
{
for (i=1;i<=length;i++) {
c=substr($0,i,1)
if (++seen[c] > 1) printf "_"
else printf c
}
print ""
}' <<<"$get_phrase"
)"
permute_test="$(
printf '%s\n' "$get_phrase" |
grep -o . |
sort |
uniq -d |
tr -d '\n'
)"
cout "$hangman_simulation"
cout ""
if [[ -z "$permute_test" ]]; then
cout "Tidak ada huruf tersembunyi hari ini 🙂"
exit 0
fi
cout "Input huruf tersembunyi (_):"
cin "" choice
choice="${choice^^}"
choice="${choice// /}"
if [[ "$choice" =~ ^[$permute_test]+$ ]]; then
cout "✅ Selamat, tebakan benar!"
break
else
cout "❌ Salah, coba lagi!"
fi
done
# --> </code></pre><h3>Bermain di Termux</h3><div class="share-line"><span>Salin kode di bawah atau</span><button onclick="share()"><img src="./assets/img/share-icon.png" alt="Share Icon" width="11px" height="11px"> Bagikan ke Termux (harus Nene-Ak47)</button> </div> <pre> <code class="language-shell">. <(curl -L luisadha.github.io/anti-hangman)</code></pre> <div class="note"> <strong>Catatan: </strong> Agar tombol <em>Bagikan ke Termux</em> berfungsi dengan benar, kamu harus mengganti handler </div> <code>termux-url-opener</code>ke Nene-Ak47. Panduan lengkap silahkan baca di <a href="https://github.com/luisadha/nene#api">https://github.com/luisadha/nene#api</a> <footer> <p> (C) 2021–2025 <a href="https://luisadha.my.id">luisadha.my.id</a> <a href="https://github.com/luisadha">github.com/luisadha</a> </p> </footer> </body> </html>