KAZIK/src_graphics/native_blackjack_party.inc
Artvasil09 881a0061dc Add native NPC visitors with contracts, Clover slots, Pyramid, and party table scenes
Implement 32x32 BFS visitor navigation and daily contracts system with companion .npc journals; add native assembly scenes for Clover slots, Pyramid cards, Blackjack Party and Russian Party; package animation and sprite packs; add comprehensive offline test suites and rebuild shipping binaries.
2026-10-13 09:47:33 +03:00

357 lines
7.7 KiB
PHP

InitBJParty3D PROC uses edi
invoke LoadAnimPack3D,OFFSET cbPartyRoom3D,OFFSET cbPartyRoomPath3D
cmp cbPartyRoom3D.frames,1
jne bj_party_invalid_room
cmp cbPartyRoom3D.imageWidth,SCREEN_W
jne bj_party_invalid_room
cmp cbPartyRoom3D.height,SCREEN_H
je bj_party_room_ready
bj_party_invalid_room:
invoke FreeAnimPack3D,OFFSET cbPartyRoom3D
bj_party_room_ready:
cmp cbBotCount3D,3
jbe @F
mov cbBotCount3D,0
@@:
mov cbEarlyOutcome3D,-1
mov cbBotsSettled3D,0
mov cbBotTurn3D,0
mov cbBotTimer3D,0
lea edi,cbBots3D
mov ecx,SIZEOF BJBot3D*3/4
xor eax,eax
rep stosd
invoke LoadAnimPack3D,OFFSET cbPartyArt3D,OFFSET cbPartyArtPath3D
cmp cbPartyArt3D.frames,6
jne bj_party_invalid_art
cmp cbPartyArt3D.imageWidth,160
jne bj_party_invalid_art
cmp cbPartyArt3D.height,160
jne bj_party_invalid_art
ret
bj_party_invalid_art:
call FreeBJParty3D
ret
InitBJParty3D ENDP
FreeBJParty3D PROC
invoke FreeAnimPack3D,OFFSET cbPartyArt3D
invoke FreeAnimPack3D,OFFSET cbPartyRoom3D
ret
FreeBJParty3D ENDP
; Round-robin: player, each guest, then dealer. Old solo order is unchanged.
DealBJParty3D PROC uses ebx esi edi
call InitBJParty3D
mov eax,cbBotCount3D
add eax,2
shl eax,1
mov cbInitialFlights3D,eax
mov cbCursor3D,0
xor edi,edi
bj_party_deal_pass:
mov ecx,cbCursor3D
mov eax,cbDeck3D[ecx*4]
mov cbPlayer3D[edi*4],eax
inc cbCursor3D
xor ebx,ebx
bj_party_deal_guest:
cmp ebx,cbBotCount3D
jae bj_party_deal_dealer
mov esi,ebx
imul esi,SIZEOF BJBot3D
add esi,OFFSET cbBots3D
mov ecx,cbCursor3D
mov eax,cbDeck3D[ecx*4]
mov [esi+edi*4].BJBot3D.cards,eax
inc cbCursor3D
mov [esi].BJBot3D.count,2
mov eax,cbBet3D
mov [esi].BJBot3D.stake,eax
inc ebx
jmp bj_party_deal_guest
bj_party_deal_dealer:
mov ecx,cbCursor3D
mov eax,cbDeck3D[ecx*4]
mov cbDealer3D[edi*4],eax
inc cbCursor3D
inc edi
cmp edi,2
jb bj_party_deal_pass
xor ebx,ebx
bj_party_deal_score:
cmp ebx,cbBotCount3D
jae bj_party_deal_done
mov esi,ebx
imul esi,SIZEOF BJBot3D
add esi,OFFSET cbBots3D
invoke NativeBJScore3D,esi,2
mov [esi].BJBot3D.score,eax
inc ebx
jmp bj_party_deal_score
bj_party_deal_done:
ret
DealBJParty3D ENDP
BeginBJDealer3D PROC
mov cbVisible3D,1
mov cbState3D,CB_DEALER
mov cbTimer3D,0
call ClearKeys3D
ret
BeginBJDealer3D ENDP
; Keep the table alive after a player bust/natural so other seats finish.
FinishBJPlayer3D PROC pending:DWORD
mov eax,pending
mov cbEarlyOutcome3D,eax
cmp cbBotCount3D,0
je bj_party_solo_finish
mov cbBotTurn3D,0
mov cbBotTimer3D,0
mov cbState3D,CB_BOTS
call ClearKeys3D
ret
bj_party_solo_finish:
cmp pending,-1
jne @F
call BeginBJDealer3D
ret
@@:
invoke NativeBJSettle3D,pending
ret
FinishBJPlayer3D ENDP
; No hidden dealer card, other hands, future deck cards or RNG are consulted.
BJBotDecision3D PROC uses ebx esi slot:DWORD
cmp slot,3
jae bj_bot_stand
mov esi,slot
imul esi,SIZEOF BJBot3D
add esi,OFFSET cbBots3D
cmp [esi].BJBot3D.count,12
jae bj_bot_stand
mov eax,cbDealer3D
xor edx,edx
mov ecx,13
div ecx
lea ebx,[edx+2]
cmp ebx,11
jbe @F
mov ebx,10
@@:
cmp edx,12
jne @F
mov ebx,11
@@:
mov eax,[esi].BJBot3D.score
cmp eax,21
jae bj_bot_stand
cmp [esi].BJBot3D.count,2
jne bj_bot_threshold
cmp eax,11
jne bj_bot_threshold
cmp ebx,10
jae bj_bot_threshold
mov eax,2
ret
bj_bot_threshold:
mov ecx,17
cmp slot,1
jne @F
mov ecx,19
@@:
cmp slot,2
jne @F
cmp ebx,7
jae @F
mov ecx,13
@@:
cmp eax,ecx
jae bj_bot_stand
mov eax,1
ret
bj_bot_stand:
xor eax,eax
ret
BJBotDecision3D ENDP
UpdateBJParty3D PROC uses ebx esi
mov eax,deltaTime3D
cmp eax,250
jbe @F
mov eax,250
@@:
add cbBotTimer3D,eax
mov ebx,cbBotTurn3D
cmp ebx,cbBotCount3D
jae bj_bot_finish_table
mov esi,ebx
imul esi,SIZEOF BJBot3D
add esi,OFFSET cbBots3D
cmp [esi].BJBot3D.state,BJ_BOT_FLIGHT
je bj_bot_commit
cmp cbBotTimer3D,BJ_PARTY_MS
jb bj_bot_tick_done
invoke BJBotDecision3D,ebx
test eax,eax
jz bj_bot_finish_seat
cmp cbCursor3D,52
jae bj_bot_finish_seat
cmp eax,2
jne @F
shl [esi].BJBot3D.stake,1
@@:
mov ecx,cbCursor3D
mov eax,cbDeck3D[ecx*4]
mov cbBotCard3D,eax
inc cbCursor3D
mov cbBotTimer3D,0
mov [esi].BJBot3D.state,BJ_BOT_FLIGHT
invoke PlayCasinoSound3D,OFFSET soundCards,0,1
ret
bj_bot_commit:
cmp cbBotTimer3D,TABLE_FLIGHT_MS
jb bj_bot_tick_done
mov ecx,[esi].BJBot3D.count
cmp ecx,12
jae bj_bot_finish_seat
mov eax,cbBotCard3D
mov [esi+ecx*4].BJBot3D.cards,eax
inc [esi].BJBot3D.count
invoke NativeBJScore3D,esi,[esi].BJBot3D.count
mov [esi].BJBot3D.score,eax
cmp eax,21
jae bj_bot_finish_seat
mov eax,cbBet3D
cmp [esi].BJBot3D.stake,eax
ja bj_bot_finish_seat
mov [esi].BJBot3D.state,BJ_BOT_WAIT
mov cbBotTimer3D,0
ret
bj_bot_finish_seat:
mov [esi].BJBot3D.state,BJ_BOT_DONE
inc cbBotTurn3D
mov cbBotTimer3D,0
ret
bj_bot_finish_table:
call BeginBJDealer3D
bj_bot_tick_done:
ret
UpdateBJParty3D ENDP
ResolveBJParty3D PROC uses ebx esi
cmp cbBotsSettled3D,0
jne bj_bot_resolve_done
mov cbBotsSettled3D,1
xor ebx,ebx
bj_bot_resolve:
cmp ebx,cbBotCount3D
jae bj_bot_resolve_done
mov esi,ebx
imul esi,SIZEOF BJBot3D
add esi,OFFSET cbBots3D
mov [esi].BJBot3D.state,BJ_BOT_DONE
mov eax,1
mov ecx,[esi].BJBot3D.score
cmp ecx,21
ja bj_bot_result
cmp cbDealerScore3D,21
jne bj_bot_no_dealer_natural
cmp cbDealerCount3D,2
jne bj_bot_no_dealer_natural
cmp ecx,21
jne bj_bot_result
cmp [esi].BJBot3D.count,2
jne bj_bot_result
mov eax,2
jmp bj_bot_result
bj_bot_no_dealer_natural:
cmp ecx,21
jne bj_bot_compare
cmp [esi].BJBot3D.count,2
jne bj_bot_compare
mov eax,3
jmp bj_bot_result
bj_bot_compare:
cmp cbDealerScore3D,21
ja bj_bot_won
cmp ecx,cbDealerScore3D
jb bj_bot_result
je bj_bot_pushed
bj_bot_won:
xor eax,eax
jmp bj_bot_result
bj_bot_pushed:
mov eax,2
bj_bot_result:
mov [esi].BJBot3D.outcome,eax
inc ebx
jmp bj_bot_resolve
bj_bot_resolve_done:
ret
ResolveBJParty3D ENDP
SetBJPartyCount3D PROC count:DWORD
cmp count,3
ja bj_party_count_done
cmp cbState3D,CB_IDLE
je @F
cmp cbState3D,CB_RESULT
jne bj_party_count_done
@@:
mov eax,count
cmp eax,cbBotCount3D
je bj_party_count_done
mov cbBotCount3D,eax
mov cbState3D,CB_IDLE
mov cbPlayerCount3D,0
mov cbDealerCount3D,0
mov cbStake3D,0
mov cbError3D,0
call InitBJParty3D
bj_party_count_done:
ret
SetBJPartyCount3D ENDP
BJPartyInput3D PROC uses ebx
cmp cbState3D,CB_IDLE
je @F
cmp cbState3D,CB_RESULT
jne bj_party_input_done
@@:
xor ebx,ebx
bj_party_key:
lea eax,[ebx+30h]
invoke Pressed3D,eax
test eax,eax
jz @F
invoke SetBJPartyCount3D,ebx
ret
@@:
inc ebx
cmp ebx,4
jb bj_party_key
cmp mouseClick3D,0
je bj_party_input_done
cmp mouseY3D,35
jb bj_party_input_done
cmp mouseY3D,51
jae bj_party_input_done
mov eax,mouseX3D
sub eax,212
jc bj_party_input_done
cmp eax,100
jae bj_party_input_done
xor edx,edx
mov ecx,25
div ecx
cmp edx,22
jae bj_party_input_done
invoke SetBJPartyCount3D,eax
mov mouseClick3D,0
bj_party_input_done:
ret
BJPartyInput3D ENDP
include src_graphics\native_blackjack_party_render.inc