title: Poker hand strength
body: <p>I've programatically determined hand rankings as added below. However, the issue is - if per say, two players end up with a pair.. How do I determine the winner? </p>
  
  <p>To each card object I've added a prime number value. Ace being 41 and  deuce being 3 and the in betweens. I'm thinking of multiplying these values when the hand is determined and whoever has the highest is winning. I need help determining whether this is the correct approach.</p>
  
  <pre><code>+(BOOL)isFull:(NSArray*)cards {
      Cards *card1 = [cards objectAtIndex:0];
      Cards *card2 = [cards objectAtIndex:1];
      Cards *card3 = [cards objectAtIndex:2];
      Cards *card4 = [cards objectAtIndex:3];
      Cards *card5 = [cards objectAtIndex:4];
  
      if (([card1.face isEqualToString:card3.face] &amp;&amp; [card4.face isEqualToString:card5.face]) || ([card1.face isEqualToString:card2.face] &amp;&amp; [card3.face isEqualToString:card5.face])) {
          return true;
      }
      return false;
  }
  +(BOOL)isFlush:(NSArray*)cards {
      NSMutableArray *organizedBySuit = [self organizeCardsSuitOrder:cards];
  
      Cards *card1 = [organizedBySuit objectAtIndex:0];
      Cards *card2 = [organizedBySuit objectAtIndex:4];
  
      if ([card1.suit isEqualToString:card2.suit]) {  return true; } else { return false; } // cards are organized by suit, so if the first equals the last..
  }
  +(BOOL)isStraight:(NSArray*)cards {
      Cards *card1 = [cards objectAtIndex:0];
      Cards *card2 = [cards objectAtIndex:1];
      Cards *card3 = [cards objectAtIndex:2];
      Cards *card4 = [cards objectAtIndex:3];
      Cards *card5 = [cards objectAtIndex:4];
  
      if ((card1.rankByInt) == 0 &amp;&amp; (card2.rankByInt) == 9 &amp;&amp; (card3.rankByInt) == 10 &amp;&amp; (card4.rankByInt) == 11 &amp;&amp; (card5.rankByInt) == 12) {
          return true;
      }
      else if ((card1.rankByInt) &lt; 9) {
          if ((card2.rankByInt) == (card1.rankByInt) + 1) {
              if ((card3.rankByInt) == (card1.rankByInt) + 2) {
                  if ((card4.rankByInt) == (card1.rankByInt) + 3) {
                      if ((card5.rankByInt) == (card1.rankByInt) + 4) {
                          return true;
                      }
                  }
              }
          }
      }
  
      return false;
  }
  +(BOOL)isTrip:(NSArray*)cards {
      NSArray *faces = [self returnArrayOfFaces];
  
      __block int pairCounter = 0;
      for (int i = 0; i &lt; [faces count]; i++) {
          for (int t = 0; t &lt; [cards count]; t++) {
              Cards *card = [cards objectAtIndex:t];
              if ([card.face isEqualToString:faces[i]]) {
                  pairCounter++;
              }
          }
          if (pairCounter &gt; 2) {
              return true;
          }
          pairCounter = 0;
      }
      return false;
  }
  +(BOOL)isTwoPair:(NSArray*)cards {
      NSArray *faces = [self returnArrayOfFaces];
  
      __block int pairCount = 0;
      __block int doublePairCount = 0;
  
      for (int i = 0; i &lt; [faces count]; i++) {
          for (int t = 0; t &lt; [cards count]; t++) {
              Cards *card = [cards objectAtIndex:t];
              if ([card.face isEqualToString:faces[i]]) {
                  pairCount++;
              }
          }
          if (pairCount &gt; 1) {
              doublePairCount++;
          }
          pairCount = 0;
      }
      if (doublePairCount &gt; 1) {
          return true;
      }
  
      return false;
  }
  +(BOOL)isPair:(NSArray*)cards {
      NSArray *faces = [self returnArrayOfFaces];
  
      __block int pairCounter = 0;
      for (int i = 0; i &lt; [faces count]; i++) {
          for (int t = 0; t &lt; [cards count]; t++) {
              Cards *card = [cards objectAtIndex:t];
              if ([card.face isEqualToString:faces[i]]) {
                  pairCounter++;
              }
          }
          if (pairCounter &gt; 1) {
              return true;
          }
          pairCounter = 0;
      }
  
      return false;
  }
  </code></pre>
  
  <p>And the cards are generated to include their primes here.</p>
  
  <pre><code>+(NSMutableArray*)createDeck:(id)sender {
      [sender removeAllObjects];
      NSArray *faces = [[NSArray alloc] initWithObjects:@"A",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"J",@"Q",@"K", nil];
      NSArray *suits = [[NSArray alloc] initWithObjects:@"h",@"d",@"c",@"s", nil];
      NSArray *primes = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:41],[NSNumber numberWithInt:2],[NSNumber numberWithInt:3],[NSNumber numberWithInt:5],[NSNumber numberWithInt:7],[NSNumber numberWithInt:11],[NSNumber numberWithInt:13],[NSNumber numberWithInt:17],[NSNumber numberWithInt:19],[NSNumber numberWithInt:23],[NSNumber numberWithInt:29],[NSNumber numberWithInt:31],[NSNumber numberWithInt:37], nil];
      for (int i = 0; i &lt; 52; i++) {
          Cards *card = [[Cards alloc]init];
          card.face = [NSString stringWithFormat:@"%@", faces[i % 13]];
          card.suit = [NSString stringWithFormat:@"%@", suits[i / 13]];
          card.rankByInt = i % 13;
          card.symbol = [Cards symbolForSuit:card.suit];
          card.prime = [[primes objectAtIndex:(i % 13)] intValue];
  
          [sender addObject:card];
      }
      [sender shuffle];
  
      return sender;
  }
  </code></pre>
  
  <p>So if possible can you provide me with the way to go forward to essentially 'rank' each hand by the cards values after I have retrieved their rank such as flush, straight etc..</p>
  
  <p>Also, if you see any ways to improve the efficiency of my checks for hand ranks, please share.</p>