Next card position is corrected for the field
This commit is contained in:
parent
a85cc93f67
commit
b318591451
24
card.c
24
card.c
@ -53,7 +53,7 @@ void remove_from_hand(Hand *h, Card *c) {
|
|||||||
h->count--;
|
h->count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_to_hand(Hand *h, Card *c) {
|
int first_open_spot(Hand *h) {
|
||||||
int order_guy[48];
|
int order_guy[48];
|
||||||
int order_guy_count = 0;
|
int order_guy_count = 0;
|
||||||
|
|
||||||
@ -67,14 +67,17 @@ void add_to_hand(Hand *h, Card *c) {
|
|||||||
order_guy_count++;
|
order_guy_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int first_open_spot = h->count;
|
int fos = h->count;
|
||||||
for (int i = 0; i < order_guy_count; i++) {
|
for (int i = 0; i < order_guy_count; i++) {
|
||||||
if (order_guy[i]) continue;
|
if (order_guy[i]) continue;
|
||||||
first_open_spot = i;
|
fos = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
return fos;
|
||||||
|
}
|
||||||
|
|
||||||
c->order = first_open_spot;
|
void add_to_hand(Hand *h, Card *c) {
|
||||||
|
c->order = first_open_spot(h);
|
||||||
h->cards[h->count] = c;
|
h->cards[h->count] = c;
|
||||||
|
|
||||||
c->move.position = &c->position;
|
c->move.position = &c->position;
|
||||||
@ -82,19 +85,19 @@ void add_to_hand(Hand *h, Card *c) {
|
|||||||
c->move.origin.y = c->position.y;
|
c->move.origin.y = c->position.y;
|
||||||
switch (h->display_type) {
|
switch (h->display_type) {
|
||||||
case HAND_DISPLAY_ROW:
|
case HAND_DISPLAY_ROW:
|
||||||
c->move.destination.x = h->position.x + (first_open_spot * (CARD_WIDTH + 10));
|
c->move.destination.x = h->position.x + (c->order * (CARD_WIDTH + 10));
|
||||||
c->move.destination.y = h->position.y;
|
c->move.destination.y = h->position.y;
|
||||||
break;
|
break;
|
||||||
case HAND_DISPLAY_FIELD:
|
case HAND_DISPLAY_FIELD:
|
||||||
c->move.destination.x = h->position.x + ((first_open_spot / 2) * (CARD_WIDTH + 10));
|
c->move.destination.x = h->position.x + ((c->order / 2) * (CARD_WIDTH + 10));
|
||||||
c->move.destination.y = h->position.y + (first_open_spot % 2 * (CARD_HEIGHT + 10));
|
c->move.destination.y = h->position.y + (c->order % 2 * (CARD_HEIGHT + 10));
|
||||||
break;
|
break;
|
||||||
case HAND_DISPLAY_DECK:
|
case HAND_DISPLAY_DECK:
|
||||||
c->move.destination.x = h->position.x;
|
c->move.destination.x = h->position.x;
|
||||||
c->move.destination.y = h->position.y;
|
c->move.destination.y = h->position.y;
|
||||||
break;
|
break;
|
||||||
case HAND_DISPLAY_SCORED:
|
case HAND_DISPLAY_SCORED:
|
||||||
c->move.destination.x = h->position.x + (first_open_spot * (CARD_WIDTH - 10));
|
c->move.destination.x = h->position.x + (c->order * (CARD_WIDTH - 10));
|
||||||
c->move.destination.y = h->position.y;
|
c->move.destination.y = h->position.y;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -119,9 +122,10 @@ void deal(Hand *from, Hand *to, int count, bool up) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rectangle next_card_position(Hand *h) {
|
Rectangle next_card_position(Hand *h) {
|
||||||
|
int i = first_open_spot(h);
|
||||||
return (Rectangle) {
|
return (Rectangle) {
|
||||||
h->position.x + ((h->count / 2) * (CARD_WIDTH + 10)),
|
h->position.x + ((i / 2) * (CARD_WIDTH + 10)),
|
||||||
h->position.y + (h->count % 2 * (CARD_HEIGHT + 10)),
|
h->position.y + (i % 2 * (CARD_HEIGHT + 10)),
|
||||||
CARD_WIDTH,
|
CARD_WIDTH,
|
||||||
CARD_HEIGHT
|
CARD_HEIGHT
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user