164 for (i = 0; i < count; i++) {
168 for (i = 0; i < count - 1; i++) {
169 for (j = i + 1; j < count; j++) {
170 if (entries[i].card > entries[j].card) {
172 entries[i] = entries[j];
178 i = (mask >> entries[0].
slot) & 1;
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) {
195 if (i + 1 + skip < count) {
205 if (i + 1 + skip < count) {
232 for (i = 0; i < count; i++) {
233 if (!((mask >> i) & 1)) {
238 return rest6 + rest8 + total6 + total8;
260 flags[bestIndex] = 0;
363 if (value < battle->players[side].slots[i].hp) {
533 for (i = 0; i < 12; i++) {
643 if ((battle->
keptCount & 1) || playerScore < computerScore) {
650 card = battle->
cards[index];
670 card = battle->
cards[index];
683 prevCard = drawer.
card;
684 if (prevCard->
kind == 3 || prevCard->
kind == 9) {
691 header = drawer.
card;
692 if (prevCard->
kind == 3) {
693 if (header->
kind != 9) {
698 if (header->
kind != 3) {
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
s32 CARDGAME_getCardLimit(CardBattle *battle, s32 id)
The limit card id sets for CARDGAME_compareCards (0 for most)
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.
static s32 lastPlayColor(CardBattle *battle)
The colour of the last card played.
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.
s32 CARDGAME_targetFlaggedSlot(CardBattle *battle, s32 side)
The next play targets (target) side's first flagged slot; whether there is one.
s32 CARDGAME_scoreHand(CardBattle *battle, s32 side, s32 mask)
Scores the cards in a side's slots, counting runs of the same card.
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)
s32 CARDGAME_pickLowestOpponentCard(CardBattle *battle)
Picks the opponent's flagged card with the lowest CardImage.rank, the strongest; 1 if there is one.
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.
s32 CARDGAME_pickComputerCard(CardBattle *battle, CardScreen *screen)
Picks the computer's next card, flagging it in effectStep.marked; returns 1 if one was found.
s32 CARDGAME_targetColor3Slot(CardBattle *battle, s32 side)
CARDGAME_targetFlaggedSlot among side's flagged slots of colour 3.
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.
void CARDGAME_keepLowestSlot(CardBattle *battle, s32 side)
Keeps the flag (effectStep.eligible) only on side's flagged slot that CARDGAME_scoreHand rates lowest...
s32 CARDGAME_getCardBonus(CardBattle *battle, s32 id)
The bonus card id gives in CARDGAME_compareCards (0 for most)
s32 CARDGAME_targetColor4Slot(CardBattle *battle, s32 side)
CARDGAME_targetFlaggedSlot among side's flagged slots of colour 4.
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,...
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,...
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....
The card battle (CARDGAME_createBattle).
s16 cards[250]
card ids, minus one (CARDGAME_loadCardImages)
u8 keptCount
and how many times
CardPlan opponentPlans[40]
one per card of side 1 (40-79)
u8 counterCards[0x1B]
the cards the computer answers with a kind 4 card, up to an 0xFF
Draws the cards' images (CardImage), from files 0x7E7-0x7EB.
A card's image (CardDrawer.card): 64 to a file, a 12-byte header and a 32x32 8-bit TIM.
s16 comboCard
the card (from 1) that three or more of it make (CARDGAME_findCardSet), 0 for none
u8 kind
an index in CARD_KINDS
s16 rank
by strength, from 1 the strongest (0 on the two blank cards)
s16 hand[10]
handCount in use
u8 kind
1-7 (CardDeckCard.kind)
u8 flagged
bit 15 of the card in the opponent's deck
s16 card
the index in the battle's card list
u8 targetKind
its effect's (CardEffect.target)
u8 target
the slot's order, or the card, it was played on
s8 playCount
the plays in use
CardPlay plays[3]
the cards played this turn, up to three
The battle screen (created by CARDGAME_createScreen): the two panels, the cards on the table and the ...
s16 hp
its hit points, 0 to 99: at 0 it is lost
s16 ap
its attack points, 0 to 99
s16 card
the index in the battle's card list
u8 order
CardBattle.slotCount when it was added.
A slot's card, sorted by id (CARDGAME_findCardSet)
s16 card
its id, minus one
s8 eligible[0x29]
the cards or slots that can be picked
s8 marked[40]
the cards or slots picked