2018-06-24 14:09:41 +00:00
|
|
|
CheckForLuckyNumberWinners:
|
2017-12-16 01:10:54 +00:00
|
|
|
xor a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2017-12-16 01:10:54 +00:00
|
|
|
ld [wFoundMatchingIDInParty], a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wPartyCount]
|
2017-12-16 01:10:54 +00:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
ld d, a
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMon1ID
|
|
|
|
ld bc, wPartySpecies
|
2017-12-16 01:10:54 +00:00
|
|
|
.PartyLoop:
|
|
|
|
ld a, [bc]
|
|
|
|
inc bc
|
|
|
|
cp EGG
|
|
|
|
call nz, .CompareLuckyNumberToMonID
|
|
|
|
push bc
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec d
|
|
|
|
jr nz, .PartyLoop
|
|
|
|
ld a, BANK(sBox)
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [sBoxCount]
|
|
|
|
and a
|
|
|
|
jr z, .SkipOpenBox
|
|
|
|
ld d, a
|
|
|
|
ld hl, sBoxMon1ID
|
|
|
|
ld bc, sBoxSpecies
|
|
|
|
.OpenBoxLoop:
|
|
|
|
ld a, [bc]
|
|
|
|
inc bc
|
|
|
|
cp EGG
|
|
|
|
jr z, .SkipOpenBoxMon
|
|
|
|
call .CompareLuckyNumberToMonID
|
|
|
|
jr nc, .SkipOpenBoxMon
|
|
|
|
ld a, 1
|
|
|
|
ld [wFoundMatchingIDInParty], a
|
|
|
|
|
|
|
|
.SkipOpenBoxMon:
|
|
|
|
push bc
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec d
|
|
|
|
jr nz, .OpenBoxLoop
|
|
|
|
|
|
|
|
.SkipOpenBox:
|
|
|
|
call CloseSRAM
|
|
|
|
ld c, $0
|
|
|
|
.BoxesLoop:
|
|
|
|
ld a, [wCurBox]
|
|
|
|
and $f
|
|
|
|
cp c
|
|
|
|
jr z, .SkipBox
|
|
|
|
ld hl, .BoxBankAddresses
|
|
|
|
ld b, 0
|
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
|
|
|
add hl, bc
|
|
|
|
ld a, [hli]
|
|
|
|
call GetSRAMBank
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a ; hl now contains the address of the loaded box in SRAM
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jr z, .SkipBox ; no mons in this box
|
|
|
|
push bc
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
inc bc
|
|
|
|
ld de, sBoxMon1ID - sBox
|
|
|
|
add hl, de
|
|
|
|
ld d, a
|
|
|
|
.BoxNLoop:
|
|
|
|
ld a, [bc]
|
|
|
|
inc bc
|
|
|
|
cp EGG
|
|
|
|
jr z, .SkipBoxMon
|
|
|
|
|
2018-01-23 22:39:09 +00:00
|
|
|
call .CompareLuckyNumberToMonID ; sets wScriptVar and wCurPartySpecies appropriately
|
2017-12-16 01:10:54 +00:00
|
|
|
jr nc, .SkipBoxMon
|
|
|
|
ld a, 1
|
|
|
|
ld [wFoundMatchingIDInParty], a
|
|
|
|
|
|
|
|
.SkipBoxMon:
|
|
|
|
push bc
|
|
|
|
ld bc, BOXMON_STRUCT_LENGTH
|
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
dec d
|
|
|
|
jr nz, .BoxNLoop
|
|
|
|
pop bc
|
|
|
|
|
|
|
|
.SkipBox:
|
|
|
|
inc c
|
|
|
|
ld a, c
|
|
|
|
cp NUM_BOXES
|
|
|
|
jr c, .BoxesLoop
|
|
|
|
|
|
|
|
call CloseSRAM
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptVar]
|
2017-12-16 01:10:54 +00:00
|
|
|
and a
|
|
|
|
ret z ; found nothing
|
2018-01-02 19:00:14 +00:00
|
|
|
farcall StubbedTrainerRankings_LuckyNumberShow
|
2017-12-16 01:10:54 +00:00
|
|
|
ld a, [wFoundMatchingIDInParty]
|
|
|
|
and a
|
|
|
|
push af
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wCurPartySpecies]
|
2017-12-16 01:10:54 +00:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
|
|
|
call GetPokemonName
|
|
|
|
ld hl, .FoundPartymonText
|
|
|
|
pop af
|
|
|
|
jr z, .print
|
|
|
|
ld hl, .FoundBoxmonText
|
|
|
|
|
|
|
|
.print
|
|
|
|
jp PrintText
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.CompareLuckyNumberToMonID:
|
2017-12-16 01:10:54 +00:00
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
push hl
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wBuffer1
|
2017-12-16 01:10:54 +00:00
|
|
|
lb bc, PRINTNUM_LEADINGZEROS | 2, 5
|
|
|
|
call PrintNum
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wLuckyNumberDigit1Buffer
|
2017-12-16 01:10:54 +00:00
|
|
|
ld de, wLuckyIDNumber
|
|
|
|
lb bc, PRINTNUM_LEADINGZEROS | 2, 5
|
|
|
|
call PrintNum
|
|
|
|
ld b, 5
|
|
|
|
ld c, 0
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wLuckyNumberDigit5Buffer
|
|
|
|
ld de, wBuffer5
|
2017-12-16 01:10:54 +00:00
|
|
|
.loop
|
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
|
|
|
jr nz, .done
|
|
|
|
dec de
|
|
|
|
dec hl
|
|
|
|
inc c
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
pop hl
|
|
|
|
push hl
|
|
|
|
ld de, -6
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
pop de
|
|
|
|
push af
|
|
|
|
ld a, c
|
|
|
|
ld b, 1
|
|
|
|
cp 5
|
|
|
|
jr z, .okay
|
|
|
|
ld b, 2
|
|
|
|
cp 3
|
|
|
|
jr nc, .okay
|
|
|
|
ld b, 3
|
|
|
|
cp 2
|
|
|
|
jr nz, .nomatch
|
|
|
|
|
|
|
|
.okay
|
|
|
|
inc b
|
2018-01-23 22:39:09 +00:00
|
|
|
ld a, [wScriptVar]
|
2017-12-16 01:10:54 +00:00
|
|
|
and a
|
|
|
|
jr z, .bettermatch
|
|
|
|
cp b
|
|
|
|
jr c, .nomatch
|
|
|
|
|
|
|
|
.bettermatch
|
|
|
|
dec b
|
|
|
|
ld a, b
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wScriptVar], a
|
2017-12-16 01:10:54 +00:00
|
|
|
pop bc
|
|
|
|
ld a, b
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wCurPartySpecies], a
|
2017-12-16 01:10:54 +00:00
|
|
|
pop bc
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.nomatch
|
|
|
|
pop bc
|
|
|
|
pop bc
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.BoxBankAddresses:
|
2017-12-16 01:10:54 +00:00
|
|
|
dba sBox1
|
|
|
|
dba sBox2
|
|
|
|
dba sBox3
|
|
|
|
dba sBox4
|
|
|
|
dba sBox5
|
|
|
|
dba sBox6
|
|
|
|
dba sBox7
|
|
|
|
dba sBox8
|
|
|
|
dba sBox9
|
|
|
|
dba sBox10
|
|
|
|
dba sBox11
|
|
|
|
dba sBox12
|
|
|
|
dba sBox13
|
|
|
|
dba sBox14
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
.FoundPartymonText:
|
2017-12-16 01:10:54 +00:00
|
|
|
; Congratulations! We have a match with the ID number of @ in your party.
|
|
|
|
text_jump UnknownText_0x1c1261
|
|
|
|
db "@"
|
|
|
|
|
2018-06-25 00:10:37 +00:00
|
|
|
.FoundBoxmonText:
|
2017-12-16 01:10:54 +00:00
|
|
|
; Congratulations! We have a match with the ID number of @ in your PC BOX.
|
|
|
|
text_jump UnknownText_0x1c12ae
|
|
|
|
db "@"
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
PrintTodaysLuckyNumber:
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wStringBuffer3
|
2017-12-16 01:10:54 +00:00
|
|
|
ld de, wLuckyIDNumber
|
|
|
|
lb bc, PRINTNUM_LEADINGZEROS | 2, 5
|
|
|
|
call PrintNum
|
|
|
|
ld a, "@"
|
2018-01-23 22:39:09 +00:00
|
|
|
ld [wStringBuffer3 + 5], a
|
2017-12-16 01:10:54 +00:00
|
|
|
ret
|