-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplay.sh
More file actions
executable file
·45 lines (40 loc) · 2.17 KB
/
play.sh
File metadata and controls
executable file
·45 lines (40 loc) · 2.17 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
#!/bin/bash
# LinuxMissions launcher
clear
cd "$(dirname "$0")"
# ─── Reset option ──────────────────────────────────────────────────────────────
if [[ "$1" == "--reset" ]]; then
if [ ! -f "progress.json" ]; then
echo "ℹ️ No progress file found — nothing to reset."
exit 0
fi
read -r -p "⚠️ Reset all progress? This cannot be undone. [y/N] " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
PLAYER=$(python3 -c "import json; d=json.load(open('progress.json')); print(d.get('player_name',''))" 2>/dev/null || echo "")
echo "{\"player_name\":\"$PLAYER\",\"total_xp\":0,\"completed_levels\":[],\"current_module\":\"\",\"current_level\":\"\",\"module_certificates\":[],\"time_per_level\":{},\"level_start_time\":null}" > progress.json
echo "✅ Progress reset. Starting from Module 1 Level 1."
else
echo "Cancelled."
exit 0
fi
fi
# ─── venv guard ────────────────────────────────────────────────────────────────
if [ ! -d "venv" ]; then
echo "❌ Virtual environment not found. Run ./install.sh first."
exit 1
fi
# ─── levels.json guard ─────────────────────────────────────────────────────────
if [ ! -f "levels.json" ]; then
echo "⚙️ levels.json not found — generating..."
venv/bin/python3 scripts/generate_levels.py || { echo "❌ Failed to generate levels.json"; exit 1; }
fi
# ─── Launch ────────────────────────────────────────────────────────────────────
export PYTHONPATH="$(pwd):$PYTHONPATH"
if [ -f "venv/bin/python3" ]; then
venv/bin/python3 -m engine.engine
elif [ -f "venv/Scripts/python.exe" ]; then
venv/Scripts/python.exe -m engine.engine
else
echo "❌ Python interpreter not found inside venv"
exit 1
fi