Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
computer.c
Go to the documentation of this file.
1/* The fourth object of CARDGAME.PRO (see effect_script.c), from CARDGAME_checkComputerCondition
2 (USA): its rodata starts at 0x80083294, 4 bytes past a multiple of 8. */
3
5
6/* The colour of the last card played */
7static inline s32 lastPlayColor(CardBattle *battle) {
8 CardDrawer drawer;
9 s32 card = battle->record.plays[battle->record.playCount - 1].card;
10
11 initCardDrawer(&drawer);
12 drawer.setCard(battle->cards[card] + 1);
13 return drawer.card->color;
14}
15
16/* Checks the condition id (0x70 to 0x96) of a card for the computer; returns 1 if it holds */
18 s32 result = 0;
19
20 switch (id) {
21 case 0x70:
22 case 0x73:
23 case 0x74:
24 case 0x75:
25 case 0x76:
26 case 0x77:
27 case 0x78:
28 case 0x79:
29 case 0x7A:
30 case 0x7B:
31 case 0x7C:
32 case 0x7D:
33 case 0x7E:
34 result = 1;
35 break;
36 case 0x80:
37 case 0x81:
38 if (CARDGAME_markPileCardsByColor(battle, screen, 1, 4, 0xFF)) {
39 result = 1;
40 }
41 break;
42 case 0x83:
43 if (battle->record.playCount != 0) {
44 result = 1;
45 }
46 break;
47 case 0x84:
48 if (battle->record.playCount != 0) {
49 if (lastPlayColor(battle) == 6) {
50 result = 1;
51 }
52 }
53 break;
54 case 0x72:
55 if (CARDGAME_markPileCardsByColor(battle, screen, 0, 3, 0xFF)) {
56 result = 1;
57 }
58 break;
59 case 0x82:
60 if (CARDGAME_markPileCardsByColor(battle, screen, 1, 3, 0xFF)) {
61 result = 1;
62 }
63 break;
64 case 0x71:
65 if (CARDGAME_markPileCardsByColor(battle, screen, 1, 2, 0xFF)) {
66 result = 1;
67 }
68 break;
69 case 0x7F:
70 if (CARDGAME_markPileCardsByColor(battle, screen, 0, 2, 0xFF)) {
71 result = 1;
72 }
73 break;
74 case 0x96:
75 if (CARDGAME_markPileCardsByColor(battle, screen, 1, 2, 0xFD)) {
76 result = 1;
77 }
78 break;
79 case 0x85:
80 case 0x8E:
81 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x1FC)) {
82 result = 1;
83 }
84 break;
85 case 0x87:
86 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x180)) {
87 result = 1;
88 }
89 break;
90 case 0x88:
91 case 0x8F:
92 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x2FC)) {
93 result = 1;
94 }
95 break;
96 case 0x89:
97 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x2BC)) {
98 result = 1;
99 }
100 break;
101 case 0x8A:
102 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x280)) {
103 result = 1;
104 }
105 break;
106 case 0x8B:
107 case 0x90:
108 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x3FC)) {
109 result = 1;
110 }
111 break;
112 case 0x8C:
113 case 0x95:
114 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x380)) {
115 result = 1;
116 }
117 break;
118 case 0x91:
119 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x3F8)) {
120 result = 1;
121 }
122 break;
123 case 0x92:
124 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x3F4)) {
125 result = 1;
126 }
127 break;
128 case 0x93:
129 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x310)) {
130 result = 1;
131 }
132 break;
133 case 0x94:
134 if (CARDGAME_markSlotsByColor(battle, screen, 1, 0x3DC)) {
135 result = 1;
136 }
137 break;
138 }
139 return result;
140}
141
142/* Scores the cards in a side's slots, counting runs of the same card */
144 CardSortEntry entries[6];
145 CardSortEntry entry;
146 CardDrawer drawer;
147 s32 count;
148 s32 total6;
149 s32 total8;
150 s32 rest6;
151 s32 rest8;
152 s32 sum6;
153 s32 sum8;
154 s32 skip;
155 s32 i;
156 s32 j;
157
158 total6 = 0;
159 rest6 = 0;
160 rest8 = 0;
161 count = battle->players[side].slotCount;
162 initCardDrawer(&drawer);
163 total8 = 0;
164 for (i = 0; i < count; i++) {
165 entries[i].card = battle->cards[battle->players[side].slots[i].card];
166 entries[i].slot = i;
167 }
168 for (i = 0; i < count - 1; i++) {
169 for (j = i + 1; j < count; j++) {
170 if (entries[i].card > entries[j].card) {
171 entry = entries[i];
172 entries[i] = entries[j];
173 entries[j] = entry;
174 }
175 }
176 }
177 j = 0;
178 i = (mask >> entries[0].slot) & 1;
179 sum6 = battle->players[side].slots[entries[0].slot].ap;
180 sum8 = battle->players[side].slots[entries[0].slot].hp;
181 for (skip = 0; i < count - 1; i++, skip = 0) {
182 drawer.setCard(entries[i].card + 1);
183 if ((mask >> entries[i + 1].slot) & 1) {
184 if (i == count - 2) {
185 break;
186 }
187 skip = 1;
188 }
189 if (drawer.card->comboCard != 0 && entries[i].card == entries[i + 1 + skip].card) {
190 j++;
191 sum6 += battle->players[side].slots[entries[i + skip].slot].ap;
192 sum8 += battle->players[side].slots[entries[i + skip].slot].hp;
193 } else if (j < 2) {
194 j = 0;
195 if (i + 1 + skip < count) {
196 sum6 = battle->players[side].slots[entries[i + 1 + skip].slot].ap;
197 sum8 = battle->players[side].slots[entries[i + 1 + skip].slot].hp;
198 } else {
199 sum6 = 0;
200 sum8 = 0;
201 }
202 } else {
203 total6 += sum6;
204 total8 += sum8;
205 if (i + 1 + skip < count) {
206 sum6 = battle->players[side].slots[entries[i + 1 + skip].slot].ap;
207 sum8 = battle->players[side].slots[entries[i + 1 + skip].slot].hp;
208 } else {
209 sum6 = 0;
210 sum8 = 0;
211 }
212 if (j >= 3) {
213 total6 += 20;
214 total8 += 20;
215 j = 0;
216 break;
217 }
218 j = 0;
219 }
220 if (skip) {
221 i++;
222 }
223 }
224 if (j >= 2) {
225 total6 += sum6;
226 total8 += sum8;
227 if (j >= 3) {
228 total6 += 20;
229 total8 += 20;
230 }
231 }
232 for (i = 0; i < count; i++) {
233 if (!((mask >> i) & 1)) {
234 rest6 += battle->players[side].slots[i].ap;
235 rest8 += battle->players[side].slots[i].hp;
236 }
237 }
238 return rest6 + rest8 + total6 + total8;
239}
240
241/* Keeps the flag (effectStep.eligible) only on side's flagged slot that CARDGAME_scoreHand
242 rates lowest */
244 s32 best = 0xFFF;
245 s32 bestIndex = 0;
246 s8 *flags;
247 s32 i;
248 s32 value;
249
250 if (side == 1) {
251 flags = &battle->effectStep.eligible[6];
252 } else {
253 flags = battle->effectStep.eligible;
254 }
255 for (i = 0; i < battle->players[side].slotCount; i++) {
256 if (flags[i] != 0) {
257 value = CARDGAME_scoreHand(battle, side, 1 << i);
258 if (best >= value) {
259 best = value;
260 flags[bestIndex] = 0;
261 bestIndex = i;
262 flags[i] = 1;
263 } else {
264 flags[i] = 0;
265 }
266 }
267 }
268}
269
270/* The next play targets (target) side's first flagged slot; whether
271 there is one */
273 s32 found = 0;
274 s8 *flags;
275 s32 i;
276
277 if (side == 1) {
278 flags = &battle->effectStep.eligible[6];
279 } else {
280 flags = battle->effectStep.eligible;
281 }
282 for (i = 0; i < battle->players[side].slotCount; i++) {
283 if (flags[i] != 0) {
284 found = 1;
285 battle->record.plays[battle->record.playCount].target = battle->players[side].slots[i].order;
286 break;
287 }
288 }
289 return found;
290}
291
292/* CARDGAME_targetFlaggedSlot among side's flagged slots of colour 3 */
294 CardDrawer drawer;
295 s8 *flags;
296 s32 i;
297
298 initCardDrawer(&drawer);
299 flags = battle->effectStep.eligible;
300 if (side == 1) {
301 flags = &battle->effectStep.eligible[6];
302 }
303 for (i = 0; i < battle->players[side].slotCount; i++) {
304 if (flags[i] != 0) {
305 drawer.setCard(battle->cards[battle->players[side].slots[i].card] + 1);
306 if (drawer.card->color != 3) {
307 flags[i] = 0;
308 }
309 }
310 }
311 return CARDGAME_targetFlaggedSlot(battle, side);
312}
313
314/* CARDGAME_targetFlaggedSlot among side's flagged slots of colour 4 */
316 CardDrawer drawer;
317 s8 *flags;
318 s32 i;
319
320 initCardDrawer(&drawer);
321 flags = battle->effectStep.eligible;
322 if (side == 1) {
323 flags = &battle->effectStep.eligible[6];
324 }
325 for (i = 0; i < battle->players[side].slotCount; i++) {
326 if (flags[i] != 0) {
327 drawer.setCard(battle->cards[battle->players[side].slots[i].card] + 1);
328 if (drawer.card->color != 4) {
329 flags[i] = 0;
330 }
331 }
332 }
333 return CARDGAME_targetFlaggedSlot(battle, side);
334}
335
336/* Whether side's slot index is flagged and its hp is at most value */
337s32 CARDGAME_isSlotWithin(CardBattle *battle, s32 side, s32 index, s32 value) {
338 s32 result = 0;
339
340 if (*(index + battle->effectStep.eligible) != 0) {
341 result = value >= battle->players[side].slots[index].hp;
342 }
343 return result;
344}
345
346/* Unflags side's slots whose hp is over value; when none is left, 1 (and
347 the last one flagged again, unless keep) */
348s32 CARDGAME_unflagSlotsOver(CardBattle *battle, s32 side, s32 value, s32 keep) {
349 s32 result = 0;
350 s32 last = 0;
351 s8 *flags;
352 s32 i;
353 s32 any;
354
355 if (side == 1) {
356 flags = &battle->effectStep.eligible[6];
357 } else {
358 flags = battle->effectStep.eligible;
359 }
360 for (i = 0; i < battle->players[side].slotCount; i++) {
361 if (flags[i] != 0) {
362 last = i;
363 if (value < battle->players[side].slots[i].hp) {
364 flags[i] = 0;
365 }
366 }
367 }
368 any = 0;
369 for (i = 0; i < battle->players[side].slotCount; i++) {
370 if (flags[i] != 0) {
371 any = 1;
372 break;
373 }
374 }
375 if (!any) {
376 if (keep == 0) {
377 flags[last] = 1;
378 }
379 result = 1;
380 }
381 return result;
382}
383
384/* Picks the opponent's flagged card with the lowest CardImage.rank, the strongest; 1 if
385 there is one */
387 CardDrawer drawer;
388 s32 lowest = 500;
389 s32 best = lowest;
390 s8 *flags = battle->effectStep.eligible;
391 s32 found;
392 s32 i;
393
394 found = 0;
395 initCardDrawer(&drawer);
396 for (i = 0; i < battle->sides[1].pile.handCount; i++) {
397 if (flags[i] != 0) {
398 drawer.setCard(battle->cards[battle->sides[1].pile.hand[i]] + 1);
399 found = 1;
400 if (drawer.card->rank < lowest) {
401 lowest = drawer.card->rank;
402 best = i;
403 }
404 }
405 }
406 if (found == 1) {
407 battle->record.plays[battle->record.playCount].target = battle->sides[1].pile.hand[best];
408 }
409 return found;
410}
411
412/* The limit card id sets for CARDGAME_compareCards (0 for most) */
414 s32 value = 0;
415
416 switch (id) {
417 case 0x12:
418 value = 60;
419 break;
420 case 0x14:
421 value = 15;
422 break;
423 case 0x38:
424 value = 10;
425 break;
426 case 0x15:
427 case 0x2E:
428 value = 30;
429 break;
430 }
431 return value;
432}
433
434/* The bonus card id gives in CARDGAME_compareCards (0 for most) */
436 s32 value = 0;
437
438 switch (id) {
439 case 2:
440 value = 15;
441 break;
442 case 12:
443 value = 50;
444 break;
445 case 15:
446 value = 20;
447 break;
448 case 3:
449 case 40:
450 value = 30;
451 break;
452 case 58:
453 value = 10;
454 break;
455 }
456 return value;
457}
458
459/* The computer's target for card id: a slot picked by the card's rule; 1 once
460 there is one */
462 s32 done = 0;
463
464 switch (id) {
465 case 0x27:
467 done = 1;
468 }
469 break;
470 case 0x07:
471 case 0x09:
472 case 0x1A:
473 case 0x37:
474 case 0x39:
475 CARDGAME_keepLowestSlot(battle, 0);
476 if (CARDGAME_targetFlaggedSlot(battle, 0)) {
477 done = 1;
478 }
479 break;
480 case 0x15:
481 case 0x2E:
482 CARDGAME_unflagSlotsOver(battle, 0, 30, 0);
483 CARDGAME_keepLowestSlot(battle, 0);
484 if (CARDGAME_targetFlaggedSlot(battle, 0)) {
485 done = 1;
486 }
487 break;
488 case 0x38:
489 CARDGAME_unflagSlotsOver(battle, 0, 10, 0);
490 CARDGAME_keepLowestSlot(battle, 0);
491 if (CARDGAME_targetFlaggedSlot(battle, 0)) {
492 done = 1;
493 }
494 break;
495 case 0x28:
496 if (CARDGAME_targetFlaggedSlot(battle, 1)) {
497 done = 1;
498 }
499 break;
500 case 0x03:
501 case 0x0F:
502 case 0x3A:
503 case 0x3B:
504 if (battle->players[1].slotCount != 0) {
505 battle->record.plays[battle->record.playCount].target = battle->players[1].slots[0].order;
506 done = 1;
507 }
508 break;
509 default:
510 done = 1;
511 break;
512 }
513 return done;
514}
515
516/* Compares two cards by the rule of the current play; returns 1 if the second one wins */
517s32 CARDGAME_compareCards(CardBattle *battle, s32 id1, s32 id2, s32 flip) {
518 s32 index = 0;
519 s32 result = 0;
520 s32 value;
521 s32 bonus;
522 s32 i;
523
524 if (flip == 0) {
525 value = CARDGAME_getCardLimit(battle, id2);
526 bonus = CARDGAME_getCardBonus(battle, id1);
527 } else {
528 value = CARDGAME_getCardLimit(battle, id1);
529 bonus = CARDGAME_getCardBonus(battle, id2);
530 }
531 switch (battle->record.plays[battle->record.playCount - 1].targetKind) {
532 case 0:
533 for (i = 0; i < 12; i++) {
534 if (i < 6) {
535 if (battle->record.plays[battle->record.playCount - 1].target == battle->players[0].slots[i].order) {
536 index = i;
537 break;
538 }
539 } else {
540 if (battle->record.plays[battle->record.playCount - 1].target == battle->players[1].slots[i - 6].order) {
541 index = i - 6;
542 break;
543 }
544 }
545 }
546 if (flip == 0) {
547 if (CARDGAME_isSlotWithin(battle, 0, index, value)) {
548 result = 1;
549 battle->record.plays[battle->record.playCount].target = battle->players[0].slots[index].order;
550 }
551 } else {
552 if (CARDGAME_isSlotWithin(battle, 1, index, value) && !CARDGAME_isSlotWithin(battle, 1, index, value - bonus)) {
553 result = 1;
554 battle->record.plays[battle->record.playCount].target = battle->players[1].slots[index].order;
555 }
556 }
557 break;
558 case 1:
559 if (flip == 0) {
560 CARDGAME_unflagSlotsOver(battle, 0, value, 0);
561 CARDGAME_keepLowestSlot(battle, 0);
562 if (CARDGAME_targetFlaggedSlot(battle, 0)) {
563 result = 1;
564 }
565 }
566 break;
567 case 3:
568 if (flip == 0) {
569 CARDGAME_unflagSlotsOver(battle, 0, value, 0);
570 CARDGAME_keepLowestSlot(battle, 0);
571 if (CARDGAME_targetFlaggedSlot(battle, 0)) {
572 result = 1;
573 }
574 } else {
575 if (CARDGAME_unflagSlotsOver(battle, 1, value, 0) && CARDGAME_targetFlaggedSlot(battle, 1)) {
576 result = 1;
577 }
578 }
579 break;
580 case 6:
581 if (flip == 0) {
582 CARDGAME_unflagSlotsOver(battle, 0, value, 0);
583 CARDGAME_keepLowestSlot(battle, 0);
584 if (CARDGAME_targetColor3Slot(battle, 0)) {
585 result = 1;
586 }
587 }
588 break;
589 case 7:
590 if (flip != 0) {
591 CARDGAME_keepLowestSlot(battle, 1);
592 if (CARDGAME_unflagSlotsOver(battle, 1, value, 0) && CARDGAME_targetColor4Slot(battle, 1)) {
593 result = 1;
594 }
595 }
596 break;
597 }
598 return result;
599}
600
601/* The index of the first card of the opponent's hand of opponentPlans kind (its
602 count when none) */
604 s32 i;
605
606 for (i = 0; i < battle->sides[1].pile.handCount; i++) {
607 if (battle->opponentPlans[battle->sides[1].pile.hand[i] - 40].kind == kind) {
608 break;
609 }
610 }
611 return i;
612}
613
614/* Picks the computer's next card, flagging it in effectStep.marked; returns 1 if one was found */
616 CardDrawer drawer;
617 s32 found = 0;
618 CardImage *prevCard;
619 CardImage *header;
620 s32 prev;
621 s32 listed;
622 s32 kind;
623 s32 flip;
624 s32 start;
625 s32 index;
626 s16 card;
627 s32 playerScore;
628 s32 computerScore;
629 s32 i;
630
631 for (i = 0; i < battle->sides[1].pile.handCount; i++) {
632 battle->effectStep.marked[i] = 0;
633 }
634 if (battle->record.playCount == 0) {
635 if (battle->phase == CARD_PHASE_PLAYS_BEFORE) {
637 kind = 1;
638 } else {
640 playerScore = CARDGAME_scoreHand(battle, 0, 0);
641 computerScore = CARDGAME_scoreHand(battle, 1, 0);
642 kind = 3;
643 if ((battle->keptCount & 1) || playerScore < computerScore) {
644 return 0;
645 }
646 }
647 for (i = start; i < battle->sides[1].pile.handCount; i++) {
648 index = battle->sides[1].pile.hand[i];
649 if (battle->opponentPlans[index - 40].kind == kind && CARDGAME_canPlayCardKind(battle, index)) {
650 card = battle->cards[index];
651 if (CARDGAME_checkComputerCondition(battle, screen, CARDGAME_getEffectField(card, 0, 0)) && CARDGAME_pickComputerTarget(battle, screen, card)) {
652 battle->effectStep.marked[i] = 1;
653 found = 1;
654 break;
655 }
656 }
657 }
658 } else {
659 listed = 0;
660 for (i = 0; battle->counterCards[i] != 0xFF; i++) {
661 if (battle->counterCards[i] == battle->cards[battle->record.plays[battle->record.playCount - 1].card]) {
662 listed = 1;
663 break;
664 }
665 }
666 if (listed) {
667 for (i = CARDGAME_findOpponentHandKind(battle, 4); i < battle->sides[1].pile.handCount; i++) {
668 index = battle->sides[1].pile.hand[i];
669 if (CARDGAME_canPlayCardKind(battle, index)) {
670 card = battle->cards[index];
671 if (CARDGAME_checkComputerCondition(battle, screen, CARDGAME_getEffectField(card, 0, 0)) && CARDGAME_pickComputerTarget(battle, screen, card)) {
672 battle->effectStep.marked[i] = 1;
673 found = 1;
674 break;
675 }
676 }
677 }
678 }
679 if (found == 0) {
680 initCardDrawer(&drawer);
681 prev = battle->record.plays[battle->record.playCount - 1].card;
682 drawer.setCard(battle->cards[prev] + 1);
683 prevCard = drawer.card;
684 if (prevCard->kind == 3 || prevCard->kind == 9) {
686 kind = 3;
687 for (i = start; i < battle->sides[1].pile.handCount; i++) {
688 index = battle->sides[1].pile.hand[i];
689 if ((battle->opponentPlans[index - 40].kind == kind || battle->opponentPlans[index - 40].kind == 4) && battle->opponentPlans[index - 40].flagged != 0) {
690 drawer.setCard(battle->cards[index] + 1);
691 header = drawer.card;
692 if (prevCard->kind == 3) {
693 if (header->kind != 9) {
694 continue;
695 }
696 flip = 0;
697 } else {
698 if (header->kind != 3) {
699 continue;
700 }
701 flip = 1;
702 }
703 if (CARDGAME_canPlayCardKind(battle, index) && CARDGAME_checkComputerCondition(battle, screen, CARDGAME_getEffectField(battle->cards[index], 0, 0)) && CARDGAME_compareCards(battle, prev, index, flip)) {
704 battle->effectStep.marked[i] = 1;
705 found = 1;
706 break;
707 }
708 }
709 }
710 }
711 }
712 }
713 return found;
714}
CARDGAME.PRO: the card battle (mode 0x700).
void initCardDrawer(CardDrawer *obj)
Clears a card drawer, gives it its methods and binds it.
@ CARD_PHASE_PLAYS_BEFORE
plays before the cards are put out: kind 2 cards only
Definition battle.h:84
signed int s32
Definition common.h:11
signed char s8
Definition common.h:7
signed short s16
Definition common.h:9
s32 CARDGAME_getCardLimit(CardBattle *battle, s32 id)
The limit card id sets for CARDGAME_compareCards (0 for most)
Definition computer.c:413
s32 CARDGAME_isSlotWithin(CardBattle *battle, s32 side, s32 index, s32 value)
Whether side's slot index is flagged and its hp is at most value.
Definition computer.c:337
static s32 lastPlayColor(CardBattle *battle)
The colour of the last card played.
Definition computer.c:7
s32 CARDGAME_pickComputerTarget(CardBattle *battle, CardScreen *screen, s32 id)
The computer's target for card id: a slot picked by the card's rule; 1 once there is one.
Definition computer.c:461
s32 CARDGAME_targetFlaggedSlot(CardBattle *battle, s32 side)
The next play targets (target) side's first flagged slot; whether there is one.
Definition computer.c:272
s32 CARDGAME_scoreHand(CardBattle *battle, s32 side, s32 mask)
Scores the cards in a side's slots, counting runs of the same card.
Definition computer.c:143
s32 CARDGAME_findOpponentHandKind(CardBattle *battle, s32 kind)
The index of the first card of the opponent's hand of opponentPlans kind (its count when none)
Definition computer.c:603
s32 CARDGAME_pickLowestOpponentCard(CardBattle *battle)
Picks the opponent's flagged card with the lowest CardImage.rank, the strongest; 1 if there is one.
Definition computer.c:386
s32 CARDGAME_compareCards(CardBattle *battle, s32 id1, s32 id2, s32 flip)
Compares two cards by the rule of the current play; returns 1 if the second one wins.
Definition computer.c:517
s32 CARDGAME_pickComputerCard(CardBattle *battle, CardScreen *screen)
Picks the computer's next card, flagging it in effectStep.marked; returns 1 if one was found.
Definition computer.c:615
s32 CARDGAME_targetColor3Slot(CardBattle *battle, s32 side)
CARDGAME_targetFlaggedSlot among side's flagged slots of colour 3.
Definition computer.c:293
s32 CARDGAME_checkComputerCondition(CardBattle *battle, CardScreen *screen, s32 id)
Checks the condition id (0x70 to 0x96) of a card for the computer; returns 1 if it holds.
Definition computer.c:17
void CARDGAME_keepLowestSlot(CardBattle *battle, s32 side)
Keeps the flag (effectStep.eligible) only on side's flagged slot that CARDGAME_scoreHand rates lowest...
Definition computer.c:243
s32 CARDGAME_getCardBonus(CardBattle *battle, s32 id)
The bonus card id gives in CARDGAME_compareCards (0 for most)
Definition computer.c:435
s32 CARDGAME_targetColor4Slot(CardBattle *battle, s32 side)
CARDGAME_targetFlaggedSlot among side's flagged slots of colour 4.
Definition computer.c:315
s32 CARDGAME_unflagSlotsOver(CardBattle *battle, s32 side, s32 value, s32 keep)
Unflags side's slots whose hp is over value; when none is left, 1 (and the last one flagged again,...
Definition computer.c:348
s32 CARDGAME_getEffectField(s32 index, u32 field, s32 offset)
One field of card effect index (CardEffect): 0 its condition, 1 its play condition,...
s32 CARDGAME_canPlayCardKind(CardBattle *battle, s32 index)
Whether card index can be played in this phase by its kind: any kind but 0 in CARD_PHASE_PLAYS_AFTER,...
Definition play_checks.c:39
s32 CARDGAME_markSlotsByColor(CardBattle *battle, CardScreen *screen, s32 side, s32 flags)
Marks in effectStep.eligible the slots of the sides flags picks (0x100 side's own,...
s32 CARDGAME_markPileCardsByColor(CardBattle *battle, CardScreen *screen, s32 side, s32 kind, s32 flags)
Marks in effectStep.eligible the cards of a side's hand (kind 2), deck (3) or discards (4) whose colo...
Task * start(void)
The mode's entry point (MODE_ENTRY_POINTS): starts its root task (update_scene.inc....
Definition start.inc.c:3
The card battle (CARDGAME_createBattle).
Definition battle.h:226
CardPlayer players[2]
Definition battle.h:275
CardRecord record
Definition battle.h:273
s16 cards[250]
card ids, minus one (CARDGAME_loadCardImages)
Definition battle.h:228
u8 keptCount
and how many times
Definition battle.h:250
CardPlan opponentPlans[40]
one per card of side 1 (40-79)
Definition battle.h:257
u8 phase
a CARD_PHASE_*
Definition battle.h:242
CardStep effectStep
Definition battle.h:262
u8 counterCards[0x1B]
the cards the computer answers with a kind 4 card, up to an 0xFF
Definition battle.h:259
CardSide sides[2]
Definition battle.h:274
Draws the cards' images (CardImage), from files 0x7E7-0x7EB.
Definition gfx.h:193
void(* setCard)()
(id)
Definition gfx.h:205
CardImage * card
Definition gfx.h:194
A card's image (CardDrawer.card): 64 to a file, a 12-byte header and a 32x32 8-bit TIM.
Definition gfx.h:172
s16 comboCard
the card (from 1) that three or more of it make (CARDGAME_findCardSet), 0 for none
Definition gfx.h:183
u8 color
from 1
Definition gfx.h:173
u8 kind
an index in CARD_KINDS
Definition gfx.h:176
s16 rank
by strength, from 1 the strongest (0 on the two blank cards)
Definition gfx.h:182
s16 handCount
Definition battle.h:114
s16 hand[10]
handCount in use
Definition battle.h:119
u8 kind
1-7 (CardDeckCard.kind)
Definition battle.h:64
u8 flagged
bit 15 of the card in the opponent's deck
Definition battle.h:65
s16 card
the index in the battle's card list
Definition battle.h:44
u8 targetKind
its effect's (CardEffect.target)
Definition battle.h:47
u8 target
the slot's order, or the card, it was played on
Definition battle.h:48
CardSlot slots[8]
Definition battle.h:39
u8 slotCount
Definition battle.h:38
s8 playCount
the plays in use
Definition battle.h:130
CardPlay plays[3]
the cards played this turn, up to three
Definition battle.h:137
The battle screen (created by CARDGAME_createScreen): the two panels, the cards on the table and the ...
Definition screen.h:263
CardPile pile
Definition battle.h:160
s16 hp
its hit points, 0 to 99: at 0 it is lost
Definition battle.h:24
s16 ap
its attack points, 0 to 99
Definition battle.h:23
s16 card
the index in the battle's card list
Definition battle.h:20
u8 order
CardBattle.slotCount when it was added.
Definition battle.h:27
A slot's card, sorted by id (CARDGAME_findCardSet)
Definition battle.h:31
s16 card
its id, minus one
Definition battle.h:33
s8 eligible[0x29]
the cards or slots that can be picked
Definition battle.h:154
s8 marked[40]
the cards or slots picked
Definition battle.h:155