; Ludo King bot training/config file (INI style)
; Lines starting with ';' are comments.
; Save your template images inside bot\templates and list them below.

[global]
; Path to adb.exe (relative to bot folder). Use full path if needed.
adb_path=..\adb.exe

; How often to capture screen per device
screenshot_interval_sec=3

; Default template match threshold (0-1). Can override per state.
match_threshold=0.88

; Cooldown to avoid repeated clicks on same state
state_cooldown_sec=2

; Base resolution used for coordinates and regions (will auto-scale)
base_resolution=540,960

; Scale templates to current device resolution
scale_templates=true

; Small delay after each action (seconds)
post_action_delay_sec=0.4

; Where templates live (relative to bot folder)
templates_dir=templates

; Where logs are written (relative to bot folder)
log_dir=logs

; Show status in console (true/false)
debug_console=true

; Backend URLs
backend_url=https://ludoking.gamingserver.win/api/submit_room.php
backend_status_url=https://ludoking.gamingserver.win/api/room_status.php
backend_info_url=https://ludoking.gamingserver.win/api/room_info.php

; Optional API secret shared with backend
backend_secret=botSecret2026LK

; OCR engine: clipboard_then_tesseract | tesseract_only | clipboard_only | none
; Ludo King has no copy button, so we use OCR only
ocr_engine=tesseract_only

; If Tesseract is installed in a custom path, set it here
; tesseract_cmd=C:\\Program Files\\Tesseract-OCR\\tesseract.exe
tesseract_cmd=C:\Program Files\Tesseract-OCR\tesseract.exe

; Regex to validate room code (adjust length/format if needed)
room_code_regex=^[A-Z0-9]{4,8}$

; Prevent sending same room code repeatedly (seconds). 0 = always send
room_code_dedupe_sec=3600

; After a room code is sent, temporarily ignore room_created state (seconds)
room_created_block_sec=300

; After game board back -> when home is detected -> change profile name first.
; This flow is coordinate-based: avatar -> Edit Profile -> white name box -> OK -> Continue
post_match_rename_enabled=true
rename_step_delay_sec=1.1
rename_clear_count=20
rename_prefix=lk
rename_random_length=6
rename_home_avatar_tap=35,35
rename_edit_profile_tap=182,832,176,61
rename_name_field_tap=258,252
rename_name_ok_tap=455,919
rename_continue_tap=182,832,176,61

; Optional: room code region (x,y,w,h) at base_resolution
room_code_region=

[app]
package=com.ludo.king
activity=
open_method=monkey

; ---- States ----
; Each [state.X] describes one screen.
; priority: higher runs first (ads/alerts should be highest)
; templates: comma-separated PNG/JPG files
; action: tap_template | tap | back | keyevent | open_app | force_stop | sleep | copy_room_code | play_if_empty_slots
; cooldown_sec: override global cooldown

[state.app_not_responding]
priority=120
templates=app_not_responding.png
action=sleep
sleep_sec=3

[state.ad_close]
priority=110
templates=ad_close_x.png, ad_close_x2.png, ad_close_x3.png, ad_close_x4.png, ad_close_x5.png, ad_close_x6.png, ad_close_x7.png, ad_close_x8.png, ad_close_x9.png, ad_close_x10.png, ad_close_x11.png, ad_close_x12.png, ad_close_x13.png, ad_close_x14.png
action=tap_template
cooldown_sec=1

[state.ldplayer_home]
priority=100
templates=ld_ludo_icon.png
action=tap_template

[state.home_friends]
priority=90
templates=home_friends.png, home_friends_2_0.png, home_friends_3_0.png
threshold=0.93
action=tap_template
cooldown_sec=3

[state.friends_next]
priority=80
templates=friends_next.png
threshold=0.90
action=tap_template

[state.create_room]
priority=70
templates=create_room.png
threshold=0.90
action=tap_template

[state.room_created]
priority=60
templates=room_code_box.png
threshold=0.85
action=copy_room_code
cooldown_sec=5
room_code_region=241,219,126,28

[state.play_ready]
priority=50
templates=play_button.png
threshold=0.85
action=play_if_empty_slots
empty_slot_template=empty_slot.png
empty_slot_threshold=0.80
empty_slot_suppression=2.0
empty_slot_columns=3
empty_slot_expected=1
cooldown_sec=2

[state.game_board]
priority=40
templates=game_board.png, game_board_2_0.png, game_board_3_0.png, game_board_4_0.png, game_board_5_0.png
threshold=0.80
fallback_threshold=0.74
action=back

[state.confirm_quit_game]
priority=45
templates=confirm_yes_game.png
threshold=0.55
fallback_threshold=0.48
action=tap_template
cooldown_sec=1

[state.confirm_quit]
priority=30
templates=confirm_yes.png
threshold=0.55
fallback_threshold=0.48
action=tap_template

; =============================
; TRAINING COMMANDS (copy/paste)
; Replace DEVICE with your emulator id from "..\adb.exe devices"
; Example: DEVICE=emulator-5556
; Keep LDPlayer resolution same as base_resolution (540x960)
; -----------------------------
; Game board area = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\game_board.png  --fit 900x700
; Game board area 2.0 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\game_board_2_0.png  --fit 900x700
; Game board area 3.0 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\game_board_3_0.png  --fit 900x700
; Game board area 4.0 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\game_board_4_0.png  --fit 900x700
; Game board area 5.0 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\game_board_5_0.png  --fit 900x700
; Home friends 2.0 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\home_friends_2_0.png  --fit 900x700
; Home friends 3.0 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\home_friends_3_0.png  --fit 900x700
; Home avatar coord = py bot\trainer.py --device emulator-5556 --roi --print-coords --base 540x960 --fit 900x700
; Edit Profile coord = py bot\trainer.py --device emulator-5556 --roi --print-coords --base 540x960 --fit 900x700
; White name box coord = py bot\trainer.py --device emulator-5556 --roi --print-coords --base 540x960 --fit 900x700
; OK coord = py bot\trainer.py --device emulator-5556 --roi --print-coords --base 540x960 --fit 900x700
; Continue coord = py bot\trainer.py --device emulator-5556 --roi --print-coords --base 540x960 --fit 900x700
; App not responding dialog = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\app_not_responding.png  --fit 900x700
; Ad close X #1 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x.png  --fit 900x700
; Ad close X #2 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x2.png  --fit 900x700
; Ad close X #3 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x3.png  --fit 900x700
; Ad close X #4 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x4.png  --fit 900x700
; Ad close X #5 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x5.png  --fit 900x700
; Ad close X #6 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x6.png  --fit 900x700
; Ad close X #7 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x7.png  --fit 900x700
; Ad close X #8 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x8.png  --fit 900x700
; Ad close X #9 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x9.png  --fit 900x700
; Ad close X #10 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x10.png  --fit 900x700
; Ad close X #11 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x11.png  --fit 900x700
; Ad close X #12 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x12.png  --fit 900x700
; Ad close X #13 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x13.png  --fit 900x700
; Ad close X #14 = py bot\trainer.py --device emulator-5556 --roi --out bot\templates\ad_close_x14.png  --fit 900x700
; =============================
