summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/solitaire.c75
1 files changed, 30 insertions, 45 deletions
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index 007f80d28b..c30bda9803 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -741,9 +741,9 @@ unsigned char rem;
741/* upper visible card from the remains' stack */ 741/* upper visible card from the remains' stack */
742unsigned char cur_rem; 742unsigned char cur_rem;
743/* number of cards drawn from the remains stack - 1 */ 743/* number of cards drawn from the remains stack - 1 */
744unsigned char count_rem; 744char count_rem;
745/* number of cards per draw of the remains' stack */ 745/* number of cards per draw of the remains' stack */
746int cards_per_draw; 746char cards_per_draw;
747 747
748/* the 7 game columns */ 748/* the 7 game columns */
749unsigned char cols[COL_NUM]; 749unsigned char cols[COL_NUM];
@@ -917,7 +917,6 @@ unsigned char find_last_card( unsigned char col )
917 } 917 }
918 else 918 else
919 { 919 {
920 //c = rem;
921 c = cur_rem; 920 c = cur_rem;
922 } 921 }
923 922
@@ -973,7 +972,8 @@ enum move move_card( unsigned char dest_col, unsigned char src_card )
973 /* this is a winning combination */ 972 /* this is a winning combination */
974 cols[dest_col] = src_card; 973 cols[dest_col] = src_card;
975 } 974 }
976 /* ... or check if the cards follow one another and have same suit */ 975 /* ... or check if the cards follow one another and have
976 * different colorsuit */
977 else if(( deck[dest_card].suit + deck[src_card].suit)%2==1 977 else if(( deck[dest_card].suit + deck[src_card].suit)%2==1
978 && deck[dest_card].num == deck[src_card].num + 1 ) 978 && deck[dest_card].num == deck[src_card].num + 1 )
979 { 979 {
@@ -1012,7 +1012,7 @@ enum move move_card( unsigned char dest_col, unsigned char src_card )
1012 /* ... or, well that's not good news */ 1012 /* ... or, well that's not good news */
1013 else 1013 else
1014 { 1014 {
1015 /* this is not a winnong combination */ 1015 /* this is not a winning combination */
1016 return MOVE_NOT_OK; 1016 return MOVE_NOT_OK;
1017 } 1017 }
1018 } 1018 }
@@ -1031,7 +1031,6 @@ enum move move_card( unsigned char dest_col, unsigned char src_card )
1031 if( src_card_prev == NOT_A_CARD ) 1031 if( src_card_prev == NOT_A_CARD )
1032 { 1032 {
1033 rem = deck[src_card].next; 1033 rem = deck[src_card].next;
1034 //count_rem--;
1035 } 1034 }
1036 /* if src card is not the first card from the stack */ 1035 /* if src card is not the first card from the stack */
1037 else 1036 else
@@ -1260,25 +1259,30 @@ int solitaire( void )
1260 deck[rem].known = true; 1259 deck[rem].known = true;
1261 } 1260 }
1262 1261
1263 if( rem != NOT_A_CARD ) 1262 if( rem != NOT_A_CARD && cur_rem != NOT_A_CARD )
1264 { 1263 {
1265 if( count_rem >= cards_per_draw ) 1264 if( count_rem < 0 )
1266 count_rem = cards_per_draw-1;
1267 if( cur_rem != NOT_A_CARD )
1268 { 1265 {
1269 prevcard = cur_rem; 1266 prevcard = rem;
1270 j = CARD_WIDTH+2*MARGIN+1; 1267 count_rem = 0;
1271 for( i = 0; i < count_rem; i++ ) 1268 while( prevcard != cur_rem && count_rem < cards_per_draw-1 )
1272 prevcard = find_prev_card(prevcard);
1273 for( i = 0; i <= count_rem; i++ )
1274 { 1269 {
1275 draw_card( deck[prevcard], j,
1276 MARGIN, sel_card == prevcard,
1277 cur_card == prevcard, i < count_rem );
1278 prevcard = deck[prevcard].next; 1270 prevcard = deck[prevcard].next;
1279 j += NUMBER_WIDTH+2; 1271 count_rem++;
1280 } 1272 }
1281 } 1273 }
1274 prevcard = cur_rem;
1275 j = CARD_WIDTH+2*MARGIN+1;
1276 for( i = 0; i < count_rem; i++ )
1277 prevcard = find_prev_card(prevcard);
1278 for( i = 0; i <= count_rem; i++ )
1279 {
1280 draw_card( deck[prevcard], j,
1281 MARGIN, sel_card == prevcard,
1282 cur_card == prevcard, i < count_rem );
1283 prevcard = deck[prevcard].next;
1284 j += NUMBER_WIDTH+2;
1285 }
1282 } 1286 }
1283 if( ( cur_rem == NOT_A_CARD || rem == NOT_A_CARD ) 1287 if( ( cur_rem == NOT_A_CARD || rem == NOT_A_CARD )
1284 && cur_col == REM_COL ) 1288 && cur_col == REM_COL )
@@ -1419,11 +1423,7 @@ int solitaire( void )
1419 if( lastbutton != SOL_CUR2STACK_PRE ) 1423 if( lastbutton != SOL_CUR2STACK_PRE )
1420 break; 1424 break;
1421#endif 1425#endif
1422 if( cur_card != NOT_A_CARD ) 1426 move_card( deck[cur_card].suit + STACKS_COL, cur_card );
1423 {
1424 move_card( deck[cur_card].suit + STACKS_COL, cur_card );
1425 sel_card = NOT_A_CARD;
1426 }
1427 break; 1427 break;
1428 1428
1429 /* Move cards arround, Uncover cards, ... */ 1429 /* Move cards arround, Uncover cards, ... */
@@ -1458,20 +1458,17 @@ int solitaire( void )
1458 { 1458 {
1459 /* unselect card or try putting card on 1459 /* unselect card or try putting card on
1460 * one of the 4 stacks */ 1460 * one of the 4 stacks */
1461 move_card( deck[sel_card].suit + COL_NUM, sel_card ); 1461 if( move_card( deck[sel_card].suit + COL_NUM, sel_card )
1462 sel_card = NOT_A_CARD; 1462 == MOVE_OK && cur_col == REM_COL )
1463 if( cur_col == REM_COL )
1464 { 1463 {
1465 cur_card = cur_rem; 1464 cur_card = cur_rem;
1466 } 1465 }
1466 sel_card = NOT_A_CARD;
1467 } 1467 }
1468 else 1468 else
1469 { 1469 {
1470 /* try moving cards */ 1470 /* try moving cards */
1471 if( move_card( cur_col, sel_card ) == MOVE_OK ) 1471 move_card( cur_col, sel_card );
1472 {
1473 sel_card = NOT_A_CARD;
1474 }
1475 } 1472 }
1476 break; 1473 break;
1477 1474
@@ -1482,11 +1479,7 @@ int solitaire( void )
1482 if( lastbutton != SOL_REM2CUR_PRE ) 1479 if( lastbutton != SOL_REM2CUR_PRE )
1483 break; 1480 break;
1484#endif 1481#endif
1485 if( move_card( cur_col, cur_rem ) == MOVE_OK ) 1482 move_card( cur_col, cur_rem );
1486 {
1487 //count_rem--;
1488 sel_card = NOT_A_CARD;
1489 }
1490 break; 1483 break;
1491 1484
1492 /* If the card on top of the remains can be put on one 1485 /* If the card on top of the remains can be put on one
@@ -1496,15 +1489,7 @@ int solitaire( void )
1496 if( lastbutton != SOL_REM2STACK_PRE ) 1489 if( lastbutton != SOL_REM2STACK_PRE )
1497 break; 1490 break;
1498#endif 1491#endif
1499 if( cur_rem != NOT_A_CARD ) 1492 move_card( deck[cur_rem].suit + COL_NUM, cur_rem );
1500 {
1501 if( move_card( deck[cur_rem].suit + COL_NUM, cur_rem )
1502 == MOVE_OK )
1503 {
1504 sel_card = NOT_A_CARD;
1505 //count_rem--;
1506 }
1507 }
1508 break; 1493 break;
1509 1494
1510#ifdef SOL_REM 1495#ifdef SOL_REM