Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. void computerTurn()
  2. {
  3.     turn='C';
  4.     if(setCount==0)
  5.     {
  6.         for(int i=0;i<6;i++)
  7.         {
  8.             set[i].suit=100;
  9.             set[i].lorn=100;
  10.             reset[i].suit=100;
  11.             reset[i].lorn=100;
  12.         }
  13.     }
  14.     int minimalLorn=8, numb=100, numbAvLorn=0;
  15.     ScanArrays();
  16.     if(setCount==0)
  17.     {
  18.         for(int i=0;i<computerCount;i++)
  19.         {
  20.             if(computer[i].lorn<=minimalLorn)
  21.             {
  22.                 if(computer[i].suit!=trump.suit)
  23.                 {
  24.                     minimalLorn=computer[i].lorn;
  25.                     numb=i;
  26.                 }
  27.                 if(minimalLorn==0) break;
  28.             }
  29.         }
  30.     }
  31.     else
  32.     {
  33.         numbAvLorn=findAvailableLorns();
  34.         for(int i=0;i<computerCount;i++)
  35.         {
  36.             for(int q=0;q<numbAvLorn;q++)
  37.             {
  38.                 if(computer[i].lorn==availableLorns[q])
  39.                 {
  40.                     if(computer[i].suit!=trump.suit)
  41.                     {
  42.                         numb=i;
  43.                         break;
  44.                     }
  45.                 }
  46.             }
  47.             if(numb!=100) break;
  48.         }
  49.     }
  50.     numbAvLorn=0;
  51.     if(numb==100)
  52.     {
  53.         if(setCount==0)
  54.         {
  55.             for(int i=0;i<computerCount;i++)
  56.             {
  57.                 if(computer[i].lorn<=minimalLorn&&minimalLorn<8)
  58.                 {
  59.                     minimalLorn=computer[i].lorn;
  60.                     numb=i;
  61.                 }
  62.                 if(minimalLorn==0) break;
  63.             }
  64.         }
  65.         else if(pileCount==0)
  66.         {
  67.             numbAvLorn=findAvailableLorns();
  68.             for(int i=0;i<computerCount;i++)
  69.             {
  70.                 for(int q=0;q<numbAvLorn;q++)
  71.                 {
  72.                     if(computer[i].lorn==availableLorns[q])
  73.                     {
  74.                             numb=i;
  75.                             break;
  76.                     }
  77.                 }
  78.                 if(numb!=100) break;
  79.             }
  80.         }
  81.     }
  82.     if(numb==100&&setCount!=0)
  83.     {
  84.         for(int i=0;i<6;i++)
  85.         {
  86.             set[i].suit=100;
  87.             set[i].lorn=100;
  88.             reset[i].suit=100;
  89.             reset[i].lorn=100;
  90.         }
  91.         for(int i=0;i<36;i++)
  92.         {
  93.             if(pile[i].description=='S')
  94.             {
  95.                 pile[i].description='O';
  96.             }
  97.         }
  98.         setCount=0;
  99.         resetCount=0;
  100.         wait=1;
  101.         turn='P';
  102.         dealCard();
  103.         ScanArrays();
  104.         return;
  105.     }
  106.     else
  107.     {
  108.         set[setCount]=computer[numb];
  109.         for (int i = 0; i < 36; i++)
  110.         {
  111.             if(pile[i].lorn==computer[numb].lorn&&pile[i].suit==computer[numb].suit) pile[i].description='S';
  112.         }
  113.         computerCount--;
  114.         setCount++;
  115.         wait=1;
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement