DonJabone

CardWarsFix

Nov 28th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7.  
  8. namespace _03.WarCards
  9. {
  10.     class WarCards
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             BigInteger numberOfGames = BigInteger.Parse(Console.ReadLine());
  15.            
  16.  
  17.             BigInteger scorePlayerOne = 0;
  18.             BigInteger scorePlayerTwo = 0;
  19.             BigInteger temp = 0;
  20.             BigInteger temp1 = 0;
  21.  
  22.            
  23.  
  24.             BigInteger gamesWon1 = 0;
  25.             BigInteger gamesWon2 = 0;
  26.  
  27.             for (int i = 0; i < numberOfGames; i++)
  28.             {
  29.                 int cardOne = 0;
  30.                 int cardTwo = 0;
  31.                 int cardThree = 0;
  32.                 BigInteger xCounter1 = 0;
  33.                 BigInteger xCounter2 = 0;
  34.  
  35.                 string[] arr = new string[3];
  36.                 arr[0] = Console.ReadLine();
  37.                 arr[1] = Console.ReadLine();
  38.                 arr[2] = Console.ReadLine();
  39.  
  40.                 if (arr[0] == "2")
  41.                 {
  42.                     cardOne = 10;
  43.                 }
  44.                 if (arr[0] == "3")
  45.                 {
  46.                     cardOne = 9;
  47.                 }
  48.                 if (arr[0] == "4")
  49.                 {
  50.                     cardOne = 8;
  51.                 }
  52.                 if (arr[0] == "5")
  53.                 {
  54.                     cardOne = 7;
  55.                 }
  56.                 if (arr[0] == "6")
  57.                 {
  58.                     cardOne = 6;
  59.                 }
  60.                 if (arr[0] == "7")
  61.                 {
  62.                     cardOne = 5;
  63.                 }
  64.                 if (arr[0] == "8")
  65.                 {
  66.                     cardOne = 4;
  67.                 }
  68.                 if (arr[0] == "9")
  69.                 {
  70.                     cardOne = 3;
  71.                 }
  72.                 if (arr[0] == "10")
  73.                 {
  74.                     cardOne = 2;
  75.                 }
  76.                 if (arr[0] == "A")
  77.                 {
  78.                     cardOne = 1;
  79.                 }
  80.                 if (arr[0] == "J")
  81.                 {
  82.                     cardOne = 11;
  83.                 }
  84.                 if (arr[0] == "Q")
  85.                 {
  86.                     cardOne = 12;
  87.                 }
  88.                 if (arr[0] == "K")
  89.                 {
  90.                     cardOne = 13;
  91.                 }
  92.                 if (arr[0] == "X")
  93.                 {
  94.                     xCounter1++;
  95.                     temp = 0;
  96.                 }
  97.                 if (arr[0] == "Y")
  98.                 {
  99.                     scorePlayerOne = scorePlayerOne - 200;
  100.                     temp = 0;
  101.                 }
  102.                 if (arr[0] == "Z")
  103.                 {
  104.                     scorePlayerOne = scorePlayerOne * 2;
  105.                     temp = 0;
  106.                 }
  107.  
  108.                 if (arr[1] == "2")
  109.                 {
  110.                     cardTwo = 10;
  111.                 }
  112.                 if (arr[1] == "3")
  113.                 {
  114.                     cardTwo = 9;
  115.                 }
  116.                 if (arr[1] == "4")
  117.                 {
  118.                     cardTwo = 8;
  119.                 }
  120.                 if (arr[1] == "5")
  121.                 {
  122.                     cardTwo = 7;
  123.                 }
  124.                 if (arr[1] == "6")
  125.                 {
  126.                     cardTwo = 6;
  127.                 }
  128.                 if (arr[1] == "7")
  129.                 {
  130.                     cardTwo = 5;
  131.                 }
  132.                 if (arr[1] == "8")
  133.                 {
  134.                     cardTwo = 4;
  135.                 }
  136.                 if (arr[1] == "9")
  137.                 {
  138.                     cardTwo = 3;
  139.                 }
  140.                 if (arr[1] == "10")
  141.                 {
  142.                     cardTwo = 2;
  143.                 }
  144.                 if (arr[1] == "A")
  145.                 {
  146.                     cardTwo = 1;
  147.                 }
  148.                 if (arr[1] == "J")
  149.                 {
  150.                     cardTwo = 11;
  151.                 }
  152.                 if (arr[1] == "Q")
  153.                 {
  154.                     cardTwo = 12;
  155.                 }
  156.                 if (arr[1] == "K")
  157.                 {
  158.                     cardTwo = 13;
  159.                 }
  160.                 if (arr[1] == "X")
  161.                 {
  162.                     xCounter1++;
  163.                     temp = 0;
  164.                 }
  165.                 if (arr[1] == "Y")
  166.                 {
  167.                     scorePlayerOne = scorePlayerOne - 200;
  168.                     temp = 0;
  169.                 }
  170.                 if (arr[1] == "Z")
  171.                 {
  172.                     scorePlayerOne = scorePlayerOne * 2;
  173.                     temp = 0;
  174.                 }
  175.  
  176.                 if (arr[2] == "2")
  177.                 {
  178.                     cardThree = 10;
  179.                 }
  180.                 if (arr[2] == "3")
  181.                 {
  182.                     cardThree = 9;
  183.                 }
  184.                 if (arr[2] == "4")
  185.                 {
  186.                     cardThree = 8;
  187.                 }
  188.                 if (arr[2] == "5")
  189.                 {
  190.                     cardThree = 7;
  191.                 }
  192.                 if (arr[2] == "6")
  193.                 {
  194.                     cardThree = 6;
  195.                 }
  196.                 if (arr[2] == "7")
  197.                 {
  198.                     cardThree = 5;
  199.                 }
  200.                 if (arr[2] == "8")
  201.                 {
  202.                     cardThree = 4;
  203.                 }
  204.                 if (arr[2] == "9")
  205.                 {
  206.                     cardThree = 3;
  207.                 }
  208.                 if (arr[2] == "10")
  209.                 {
  210.                     cardThree = 2;
  211.                 }
  212.                 if (arr[2] == "A")
  213.                 {
  214.                     cardThree = 1;
  215.                 }
  216.                 if (arr[2] == "J")
  217.                 {
  218.                     cardThree = 11;
  219.                 }
  220.                 if (arr[2] == "Q")
  221.                 {
  222.                     cardThree = 12;
  223.                 }
  224.                 if (arr[2] == "K")
  225.                 {
  226.                     cardThree = 13;
  227.                 }
  228.                 if (arr[2] == "X")
  229.                 {
  230.                     xCounter1++;
  231.                     temp = 0;
  232.                 }
  233.                 if (arr[2] == "Y")
  234.                 {
  235.                     scorePlayerOne = scorePlayerOne - 200;
  236.                     temp = 0;
  237.                 }
  238.                 if (arr[2] == "Z")
  239.                 {
  240.                     scorePlayerOne = scorePlayerOne * 2;
  241.                     temp = 0;
  242.                 }
  243.                 int sum = cardOne + cardTwo + cardThree;
  244.                 temp = sum;
  245.                 cardOne = 0;
  246.                 cardTwo = 0;
  247.                 cardThree = 0;
  248.  
  249.                 sum = 0;
  250.  
  251.                 string[] arr1 = new string[3];
  252.  
  253.                 arr1[0] = Console.ReadLine();
  254.                 arr1[1] = Console.ReadLine();
  255.                 arr1[2] = Console.ReadLine();
  256.  
  257.                 if (arr1[0] == "2")
  258.                 {
  259.                     cardOne = 10;
  260.                 }
  261.                 if (arr1[0] == "3")
  262.                 {
  263.                     cardOne = 9;
  264.                 }
  265.                 if (arr1[0] == "4")
  266.                 {
  267.                     cardOne = 8;
  268.                 }
  269.                 if (arr1[0] == "5")
  270.                 {
  271.                     cardOne = 7;
  272.                 }
  273.                 if (arr1[0] == "6")
  274.                 {
  275.                     cardOne = 6;
  276.                 }
  277.                 if (arr1[0] == "7")
  278.                 {
  279.                     cardOne = 5;
  280.                 }
  281.                 if (arr1[0] == "8")
  282.                 {
  283.                     cardOne = 4;
  284.                 }
  285.                 if (arr1[0] == "9")
  286.                 {
  287.                     cardOne = 3;
  288.                 }
  289.                 if (arr1[0] == "10")
  290.                 {
  291.                     cardOne = 2;
  292.                 }
  293.                 if (arr1[0] == "A")
  294.                 {
  295.                     cardOne = 1;
  296.                 }
  297.                 if (arr1[0] == "J")
  298.                 {
  299.                     cardOne = 11;
  300.                 }
  301.                 if (arr1[0] == "Q")
  302.                 {
  303.                     cardOne = 12;
  304.                 }
  305.                 if (arr1[0] == "K")
  306.                 {
  307.                     cardOne = 13;
  308.                 }
  309.                 if (arr1[0] == "X")
  310.                 {
  311.                     xCounter2++;
  312.                     temp1 = 0;
  313.                 }
  314.                 if (arr1[0] == "Y")
  315.                 {
  316.                     scorePlayerTwo = scorePlayerTwo - 200;
  317.                     temp1 = 0;
  318.                 }
  319.                 if (arr1[0] == "Z")
  320.                 {
  321.                     scorePlayerTwo = scorePlayerTwo * 2;
  322.                     temp1 = 0;
  323.                 }
  324.  
  325.                 if (arr1[1] == "2")
  326.                 {
  327.                     cardTwo = 10;
  328.                 }
  329.                 if (arr1[1] == "3")
  330.                 {
  331.                     cardTwo = 9;
  332.                 }
  333.                 if (arr1[1] == "4")
  334.                 {
  335.                     cardTwo = 8;
  336.                 }
  337.                 if (arr1[1] == "5")
  338.                 {
  339.                     cardTwo = 7;
  340.                 }
  341.                 if (arr1[1] == "6")
  342.                 {
  343.                     cardTwo = 6;
  344.                 }
  345.                 if (arr1[1] == "7")
  346.                 {
  347.                     cardTwo = 5;
  348.                 }
  349.                 if (arr1[1] == "8")
  350.                 {
  351.                     cardTwo = 4;
  352.                 }
  353.                 if (arr1[1] == "9")
  354.                 {
  355.                     cardTwo = 3;
  356.                 }
  357.                 if (arr1[1] == "10")
  358.                 {
  359.                     cardTwo = 2;
  360.                 }
  361.                 if (arr1[1] == "A")
  362.                 {
  363.                     cardTwo = 1;
  364.                 }
  365.                 if (arr1[1] == "J")
  366.                 {
  367.                     cardTwo = 11;
  368.                 }
  369.                 if (arr1[1] == "Q")
  370.                 {
  371.                     cardTwo = 12;
  372.                 }
  373.                 if (arr1[1] == "K")
  374.                 {
  375.                     cardTwo = 13;
  376.                 }
  377.                 if (arr1[1] == "X")
  378.                 {
  379.                     xCounter2++;
  380.                     temp1 = 0;
  381.                 }
  382.                 if (arr1[1] == "Y")
  383.                 {
  384.                     scorePlayerTwo = scorePlayerTwo - 200;
  385.                     temp1 = 0;
  386.                 }
  387.                 if (arr1[1] == "Z")
  388.                 {
  389.                     scorePlayerTwo = scorePlayerTwo * 2;
  390.                     temp1 = 0;
  391.                 }
  392.  
  393.                 if (arr1[2] == "2")
  394.                 {
  395.                     cardThree = 10;
  396.                 }
  397.                 if (arr1[2] == "3")
  398.                 {
  399.                     cardThree = 9;
  400.                 }
  401.                 if (arr1[2] == "4")
  402.                 {
  403.                     cardThree = 8;
  404.                 }
  405.                 if (arr1[2] == "5")
  406.                 {
  407.                     cardThree = 7;
  408.                 }
  409.                 if (arr1[2] == "6")
  410.                 {
  411.                     cardThree = 6;
  412.                 }
  413.                 if (arr1[2] == "7")
  414.                 {
  415.                     cardThree = 5;
  416.                 }
  417.                 if (arr1[2] == "8")
  418.                 {
  419.                     cardThree = 4;
  420.                 }
  421.                 if (arr1[2] == "9")
  422.                 {
  423.                     cardThree = 3;
  424.                 }
  425.                 if (arr1[2] == "10")
  426.                 {
  427.                     cardThree = 2;
  428.                 }
  429.                 if (arr1[2] == "A")
  430.                 {
  431.                     cardThree = 1;
  432.                 }
  433.                 if (arr1[2] == "J")
  434.                 {
  435.                     cardThree = 11;
  436.                 }
  437.                 if (arr1[2] == "Q")
  438.                 {
  439.                     cardThree = 12;
  440.                 }
  441.                 if (arr1[2] == "K")
  442.                 {
  443.                     cardThree = 13;
  444.                 }
  445.                 if (arr1[2] == "X")
  446.                 {
  447.                     xCounter2++;
  448.                     temp1 = 0;
  449.                 }
  450.                 if (arr1[2] == "Y")
  451.                 {
  452.                     scorePlayerTwo = scorePlayerTwo - 200;
  453.                     temp1 = 0;
  454.                 }
  455.                 if (arr1[2] == "Z")
  456.                 {
  457.                     scorePlayerTwo = scorePlayerTwo * 2;
  458.                     temp1 = 0;
  459.                 }
  460.                 sum = cardOne + cardTwo + cardThree;
  461.                 temp1 = sum;
  462.                 sum = 0;
  463.  
  464.                 if ((xCounter1 > 0) && (xCounter2 == 0))
  465.                 {
  466.                     Console.Write("X card drawn! ");
  467.                     Console.Write("Player one wins the match!");
  468.                     scorePlayerOne = -1;
  469.                     return;
  470.                 }
  471.  
  472.                 if ((xCounter2 > 0) && (xCounter1 == 0))
  473.                 {
  474.                     Console.Write("X card drawn! ");
  475.                     Console.Write("Player two wins the match!");
  476.                     scorePlayerTwo = -1;
  477.                     return;
  478.                 }
  479.  
  480.                 if ((xCounter1 != 0) && (xCounter2 != 0))
  481.                 {
  482.                     scorePlayerOne = scorePlayerOne + 50;
  483.                     scorePlayerTwo = scorePlayerTwo + 50;
  484.                 }
  485.  
  486.                 if (temp > temp1)
  487.                 {
  488.  
  489.                     gamesWon1++;
  490.                     scorePlayerOne = scorePlayerOne + temp;
  491.  
  492.                 }
  493.                 if (temp < temp1)
  494.                 {
  495.  
  496.                     gamesWon2++;
  497.                     scorePlayerTwo = scorePlayerTwo + temp1;
  498.  
  499.                 }
  500.                 if (temp == temp1)
  501.                 {
  502.  
  503.                     continue;
  504.                 }
  505.             }
  506.  
  507.  
  508.             //if ((scorePlayerOne | scorePlayerTwo) < 0)
  509.             //{
  510.             //    return;
  511.             //}
  512.  
  513.             if (scorePlayerOne > scorePlayerTwo)
  514.             {
  515.                 Console.WriteLine("First player wins!");
  516.                 Console.WriteLine("Score: {0}", scorePlayerOne);
  517.                 Console.Write("Games won: {0}", gamesWon1);
  518.             }
  519.             if (scorePlayerTwo > scorePlayerOne)
  520.             {
  521.                 Console.WriteLine("Second player wins!");
  522.                 Console.WriteLine("Score: {0}", scorePlayerTwo);
  523.                 Console.Write("Games won: {0}", gamesWon2);
  524.             }
  525.             if (scorePlayerOne == scorePlayerTwo)
  526.             {
  527.                 Console.WriteLine("It's a tie!");
  528.                 Console.Write("Score: {0}", scorePlayerOne);
  529.             }
  530.         }
  531.     }
  532. }
Advertisement
Add Comment
Please, Sign In to add comment