Guest User

mess

a guest
Sep 7th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 10.56 KB | None | 0 0
  1. void printBoard()
  2.     {
  3.         //horizontal index
  4.         cout << "   ";
  5.         for(int xCount=0; xCount<xSize; xCount++)
  6.         {
  7.             cout << xCount << " ";
  8.             if(xCount<10)
  9.             {
  10.                 cout << " ";
  11.             }
  12.         }
  13.         cout << endl;
  14.  
  15.         for(int yCount=0; yCount<ySize; yCount++)
  16.         {
  17.             //vertical index
  18.             cout << yCount << " ";
  19.             if(yCount<10)
  20.             {
  21.                 cout << " ";
  22.             }
  23.  
  24.             //actual board
  25.             for(int xCount=0; xCount<xSize; xCount++)
  26.             {
  27.                 //colors the current tile
  28.                 if(myTiles[xCount][yCount].player==0)
  29.                 {
  30.                     SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x07);
  31.                 }
  32.                 else if(myTiles[xCount][yCount].player==1 && myTiles[xCount][yCount].myType==tile::abuilding)
  33.                 {
  34.                     if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.66)
  35.                     {
  36.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x62);
  37.                     }
  38.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.33)
  39.                     {
  40.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x6E);
  41.                     }
  42.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0)
  43.                     {
  44.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x64);
  45.                     }
  46.                 }
  47.                 else if(myTiles[xCount][yCount].player==2 && myTiles[xCount][yCount].myType==tile::abuilding)
  48.                 {
  49.                     if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.66)
  50.                     {
  51.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x72);
  52.                     }
  53.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.33)
  54.                     {
  55.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x7E);
  56.                     }
  57.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0)
  58.                     {
  59.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x74);
  60.                     }
  61.                 }
  62.                 else if(myTiles[xCount][yCount].player==3 && myTiles[xCount][yCount].myType==tile::abuilding)
  63.                 {
  64.                     if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.66)
  65.                     {
  66.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xB2);
  67.                     }
  68.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.33)
  69.                     {
  70.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xBE);
  71.                     }
  72.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0)
  73.                     {
  74.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xB4);
  75.                     }
  76.                 }
  77.                 else if(myTiles[xCount][yCount].player==4 && myTiles[xCount][yCount].myType==tile::abuilding)
  78.                 {
  79.                     if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.66)
  80.                     {
  81.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xC2);
  82.                     }
  83.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.33)
  84.                     {
  85.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xCE);
  86.                     }
  87.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0)
  88.                     {
  89.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xC4);
  90.                     }
  91.                 }
  92.  
  93.                 //prints the tiles
  94.                 cout << myTiles[xCount][yCount].symbol;
  95.  
  96.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x07);
  97.                 cout << "  ";
  98.             }
  99.             cout << endl;
  100.         }
  101.  
  102.         //statistics below the board
  103.         for(int player=1; player<=plCount; player++)
  104.         {
  105.             if(player==1)
  106.             {
  107.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x6F);
  108.             }
  109.             else if(player==2)
  110.             {
  111.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x7F);
  112.             }
  113.             else if(player==3)
  114.             {
  115.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xBF);
  116.             }
  117.             else if(player==4)
  118.             {
  119.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xCF);
  120.             }
  121.        
  122.             cout << "P" << player << endl;
  123.             for(int yCount=0; yCount<ySize; yCount++)
  124.             {
  125.                 for(int xCount=0; xCount<xSize; xCount++)
  126.                 {
  127.                     if(myTiles[xCount][yCount].player==player && myTiles[xCount][yCount].myType==tile::abuilding)
  128.                     {
  129.                         if(myTiles[xCount][yCount].myBuilding.myBuildType==0)
  130.                         {
  131.                             cout << "Base: ";
  132.                         }
  133.                         cout << myTiles[xCount][yCount].myBuilding.health << "/" << myTiles[xCount][yCount].myBuilding.maxHealth << endl;
  134.                     }
  135.                 }
  136.             }
  137.         }
  138.         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x07);
  139.     }
  140.  
  141.     void printBDrop(int player)
  142.     {
  143.         //horizontal index
  144.         cout << "   ";
  145.         for(int xCount=0; xCount<xSize; xCount++)
  146.         {
  147.             cout << xCount << " ";
  148.             if(xCount<10)
  149.             {
  150.                 cout << " ";
  151.             }
  152.         }
  153.         cout << endl;
  154.  
  155.         for(int yCount=0; yCount<ySize; yCount++)
  156.         {
  157.             //vertical index
  158.             cout << yCount << " ";
  159.             if(yCount<10)
  160.             {
  161.                 cout << " ";
  162.             }
  163.  
  164.             //actual board
  165.             for(int xCount=0; xCount<xSize; xCount++)
  166.             {
  167.                 //specific base drop coloring
  168.                 if(plCount==2)
  169.                 {
  170.                     if(player==1)
  171.                     {
  172.                         if(xCount<xSize/2)
  173.                         {
  174.                             SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  175.                         }
  176.                     }
  177.                     else if(player==2)
  178.                     {
  179.                         if(xCount>=xSize/2)
  180.                         {
  181.                             SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  182.                         }
  183.                     }
  184.                 }
  185.                 else if(plCount==4)
  186.                 {
  187.                     if(player==1)
  188.                     {
  189.                         if(xCount<xSize/2 && yCount<ySize/2)
  190.                         {
  191.                             SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  192.                         }
  193.                     }
  194.                     else if(player==2)
  195.                     {
  196.                         if(xCount>=xSize/2 && yCount<ySize/2)
  197.                         {
  198.                             SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  199.                         }
  200.                     }
  201.                     else if(player==3)
  202.                     {
  203.                         if(xCount<xSize/2 && yCount>=ySize/2)
  204.                         {
  205.                             SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  206.                         }
  207.                     }
  208.                     else if(player==4)
  209.                     {
  210.                         if(xCount>=xSize/2 && yCount>=ySize/2)
  211.                         {
  212.                             SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x47);
  213.                         }
  214.                     }
  215.                 }
  216.  
  217.                 //colors the current tile
  218.                 if(myTiles[xCount][yCount].player==1 && myTiles[xCount][yCount].myType==tile::abuilding)
  219.                 {
  220.                     if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.66)
  221.                     {
  222.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x62);
  223.                     }
  224.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.33)
  225.                     {
  226.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x6E);
  227.                     }
  228.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0)
  229.                     {
  230.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x64);
  231.                     }
  232.                 }
  233.                 else if(myTiles[xCount][yCount].player==2 && myTiles[xCount][yCount].myType==tile::abuilding)
  234.                 {
  235.                     if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.66)
  236.                     {
  237.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x72);
  238.                     }
  239.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.33)
  240.                     {
  241.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x7E);
  242.                     }
  243.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0)
  244.                     {
  245.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x74);
  246.                     }
  247.                 }
  248.                 else if(myTiles[xCount][yCount].player==3 && myTiles[xCount][yCount].myType==tile::abuilding)
  249.                 {
  250.                     if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.66)
  251.                     {
  252.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xB2);
  253.                     }
  254.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.33)
  255.                     {
  256.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xBE);
  257.                     }
  258.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0)
  259.                     {
  260.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xB4);
  261.                     }
  262.                 }
  263.                 else if(myTiles[xCount][yCount].player==4 && myTiles[xCount][yCount].myType==tile::abuilding)
  264.                 {
  265.                     if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.66)
  266.                     {
  267.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xC2);
  268.                     }
  269.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0.33)
  270.                     {
  271.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xCE);
  272.                     }
  273.                     else if((double)(myTiles[xCount][yCount].myBuilding.health)/(double)(myTiles[xCount][yCount].myBuilding.maxHealth)>0)
  274.                     {
  275.                         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xC4);
  276.                     }
  277.                 }
  278.  
  279.                 //prints the tiles
  280.                 cout << myTiles[xCount][yCount].symbol;
  281.  
  282.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x07);
  283.                 cout << "  ";
  284.             }
  285.             cout << endl;
  286.         }
  287.  
  288.         //statistics below the board
  289.         for(int player=1; player<=plCount; player++)
  290.         {
  291.             if(player==1)
  292.             {
  293.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x6F);
  294.             }
  295.             else if(player==2)
  296.             {
  297.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x7F);
  298.             }
  299.             else if(player==3)
  300.             {
  301.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xBF);
  302.             }
  303.             else if(player==4)
  304.             {
  305.                 SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0xCF);
  306.             }
  307.        
  308.             cout << "P" << player << endl;
  309.             for(int yCount=0; yCount<ySize; yCount++)
  310.             {
  311.                 for(int xCount=0; xCount<xSize; xCount++)
  312.                 {
  313.                     if(myTiles[xCount][yCount].player==player && myTiles[xCount][yCount].myType==tile::abuilding)
  314.                     {
  315.                         if(myTiles[xCount][yCount].myBuilding.myBuildType==0)
  316.                         {
  317.                             cout << "Base: ";
  318.                         }
  319.                         cout << myTiles[xCount][yCount].myBuilding.health << "/" << myTiles[xCount][yCount].myBuilding.maxHealth << endl;
  320.                     }
  321.                 }
  322.             }
  323.         }
  324.         SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), 0x07);
  325.     }
Advertisement
Add Comment
Please, Sign In to add comment