NON-PRODUCTION

Inca — tài liệu ghép client

Payline slot 5×3, scatter / wild, free spins pot. Giữa FS không trừ bet; credit chip khi is_finish_free_spin. Trang này chỉ được serve khi ENVIRONMENT != production.

1. Tổng quan

MụcGiá trị
Grid5 cột × 3 hàng · reels[col][row], row 0 = trên
PayPayline. Wild (11) thay thế paying symbol; line có thể tách symbol-win / wild-win
ScatterSymbol 12. Đếm theo cột: number_of_scatter_cols
Scatter pay2 cột → ~2× (theo payline), 3 cột → ~5× — lấy scatter_win_amount, đừng hardcode
FSĐủ scatter cột → is_bonus + number_of_bonus_free_spins
PotMid-FS không debit bet, không credit win; cả pot vào chip khi finish
Base path/api/v1
Session in-memory. Client bắt buộc GET /api/v1/gameplay trước spin. Reconnect giữa FS: restore is_free_spin, free_spins, free_spin_pot.

2. Luồng ghép

  1. Mở game → GET /gameplay. Render board preview, bet, paytable, money, FS nếu đang feature.
  2. User chọn bet chỉ khi is_free_spin = false.
  3. POST /spins body {"bet": ...} (giá trị trong bets).
  4. Highlight từng win_lines[]. Hiện scatter nếu scatter_win_amount > 0.
  5. Nếu is_bonus → popup +N FS từ number_of_bonus_free_spins.
  6. Khi is_free_spin: không trừ bet, tiếp tục /spins tới is_finish_free_spin.
  7. Luôn lấy số dư từ user_money của response vừa nhận.

3. Auth & envelope

Header

Authorization: Bearer <access_token>
Content-Type: application/json

Mọi API dưới /api/v1 cần JWT. Trang docs không cần token.

Envelope

HTTP 200 + code = 0 là thành công. Payload nằm trong msg.

{
  "code": 0,
  "msg": { ... }
}
codeÝ nghĩa
0OK
-1Unknown / thiếu JWT / token invalid
-2Invalid input
69Wrong state — chưa /gameplay, đang FS mà đổi bet
1000Popup i18n

4. Grid & symbol

Board luôn mảng cột. Demo: payline thắng + Wild + Scatter được highlight.

8
11
8
4
12
2
5
12
1
3
0
6
9
7
10

Hàng đầu = row 0. Ô vàng = payline High1 (8) với Wild (11, xanh lá). Ô vàng đậm = Scatter (12) trên 2 cột — đủ scatter pay / tiến tới FS.

idSymbolPay?
0–3Low
4–7Mid
8–10High
11WildThay thế paying; có thể tự pay (wild_win)
12ScatterPay theo số cột + trigger FS

Paytable & line win

Luôn dùng pay_table từ /gameplay. Mỗi win_lines[] tách:

5. GET /api/v1/gameplay

Gọi 1 lần khi vào game. Thiếu bước này thì POST /spins trả code 69.

GET /api/v1/gameplay
FieldTypeClient dùng để
user_moneyint64Chip hiện tại
betint64Bet server đang giữ
betsint64[]Mức hợp lệ — chỉ gửi đúng 1 giá trị
show_betsint64[]Hiển thị UI, cùng index với bets
pay_tablefloat[][]Bảng trả thưởng
is_free_spinboolRestore FS UI, khóa đổi bet
free_spinsintSố lượt còn lại
max_free_spinsintMốc thanh FS
free_spin_potint64Tổng win chưa credit
init_reelsint[5][3]Board preview idle
{
  "code": 0,
  "msg": {
    "user_money": 500000,
    "bet": 1000,
    "bets": [200, 1000, 2000, 10000],
    "show_bets": [200, 1000, 2000, 10000],
    "pay_table": [[1,2,5],[1.5,3,8],[2,4,10],[2.5,5,12],[3,8,15],[4,10,20],[5,12,25],[8,15,40],[10,25,80],[15,40,100],[20,50,150]],
    "is_free_spin": false,
    "free_spins": 0,
    "max_free_spins": 0,
    "free_spin_pot": 0,
    "init_reels": [[8,2,0],[11,5,6],[8,12,9],[4,1,7],[12,3,10]]
  }
}

6. POST /api/v1/spins

POST /api/v1/spins
{ "bet": 1000 }

SpinResult

FieldTypeÝ nghĩa
user_moneyint64Chip sau response
win_amountint64Base: đã credit. FS giữa: win spin (chưa chip). FS xong: cả pot
betint64Bet server dùng
is_bonusboolSpin này award FS
number_of_bonus_free_spinsint+N cho popup
is_free_spinboolSpin vừa rồi nằm trong FS
free_spinsintSource of truth số lượt còn
max_free_spinsintThanh progress
free_spin_potint64Pot sau spin; 0 khi finish
is_finish_free_spinboolCredit pot vào user_money
win_linesWinLine[]Payline thắng
reelsint[5][3]Board sau spin
number_of_scatter_colsintSố cột có ≥1 scatter
scatter_win_amountint64Win scatter (đã gồm trong tổng khi base)

WinLine

FieldÝ nghĩa
lineMảng 5 symbol trên payline
line_numberIndex payline
symbolPaying symbol của line
number_of_symbolsSố ô khớp (kể wild thay)
number_of_wildsSố wild trên line
symbol_win_amountChip thắng symbol
wild_win_amountChip thắng wild-as-line
symbol_win_multiplierHệ số paytable
{
  "code": 0,
  "msg": {
    "user_money": 499000,
    "win_amount": 8500,
    "bet": 1000,
    "is_bonus": true,
    "number_of_bonus_free_spins": 10,
    "is_free_spin": false,
    "free_spins": 10,
    "max_free_spins": 10,
    "free_spin_pot": 0,
    "is_finish_free_spin": false,
    "win_lines": [{
      "line": [8, 11, 8, 4, 12],
      "line_number": 0,
      "symbol": 8,
      "number_of_symbols": 3,
      "number_of_wilds": 1,
      "symbol_win_amount": 8000,
      "wild_win_amount": 0,
      "symbol_win_multiplier": 8
    }],
    "reels": [[8,2,0],[11,5,6],[8,12,9],[4,1,7],[12,3,10]],
    "number_of_scatter_cols": 2,
    "scatter_win_amount": 500
  }
}

Spin trigger FS: is_bonus = true nhưng is_free_spin = false. Win spin này credit ngay (kể scatter). Các spin sau mới là FS.

7. Free spins

Source of truth số lượt là free_spins. Popup +N dùng number_of_bonus_free_spins. Credit chip chỉ khi is_finish_free_spin.
{
  "code": 0,
  "msg": {
    "user_money": 520000, "win_amount": 21000, "bet": 1000,
    "is_bonus": false, "number_of_bonus_free_spins": 0,
    "is_free_spin": true, "free_spins": 0, "max_free_spins": 10,
    "free_spin_pot": 0, "is_finish_free_spin": true,
    "win_lines": [], "reels": [[1,2,3],[4,5,6],[7,8,9],[0,1,2],[3,4,5]],
    "number_of_scatter_cols": 0, "scatter_win_amount": 0
  }
}

8. Animation

  1. Vẽ reels 5×3, row 0 trên cùng.
  2. Lần lượt highlight từng win_lines[] theo line / line_number.
  3. Wild (11): overlay riêng; nếu wild_win_amount > 0 play nhánh wild.
  4. Scatter: đếm cột từ board hoặc tin number_of_scatter_cols. Cộng scatter_win_amount.
  5. is_bonus → popup FS rồi chuyển mode.
  6. FS: counter free_spins / max_free_spins, pot meter. Finish → cộng chip một lần.
Không tự tính win từ paytable. Mọi số chip lấy từ response. Paytable chỉ để vẽ bảng infomation.

9. Cheat (chỉ non-prod / cheater)

{
  "bet": 1000,
  "reels": [
    [8, 2, 0],
    [11, 5, 6],
    [8, 12, 9],
    [4, 1, 7],
    [12, 3, 10]
  ]
}

10. Error & tiền

Tình huốngHành vi client
HTTP 401Token hết hạn / thiếu — relogin
code 69Gọi lại GET /gameplay, sync FS/bet, đừng spam spin
code 1000Hiện popup msg (string i18n)
code -1 khi spinHết tiền hoặc lỗi nội bộ — refresh money qua /gameplay
Spin khi user đang room PvPHTTP 400 body "blocked"

Khi nào chip đổi

EventChip
Base spin−bet ngay; +win_amount (line + scatter) nếu thắng
FS giữa chừngKhông đổi. Chỉ tăng free_spin_pot
FS kết thúc+pot vào user_money

11. Checklist client