Module: HandEvaluator

Defined in:
ext/hand_evaluator/hand_evaluator.c

Class Method Summary collapse

Class Method Details

.rank_hand(ruby_card_list) ⇒ int

Returns The rank of the hand.

Parameters:

  • self (VALUE)

    The class from which this method was called. This is an implicit argument.

  • ruby_card_list (VALUE)

    The list of numeric ACPC represented cards in a Ruby array.

Returns:

  • (int)

    The rank of the hand.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'ext/hand_evaluator/hand_evaluator.c', line 18

static VALUE rank_hand(VALUE self, VALUE ruby_card_list) {
   VALUE* card_list = RARRAY_PTR(ruby_card_list);
   int card_list_length = RARRAY_LEN(ruby_card_list);
  
   int card;
   Cardset card_set = emptyCardset();
   
   int i;
   for(i = 0; i < card_list_length; ++i) {
      card = NUM2INT(card_list[i]);
      addCardToCardset(&card_set, suitOfCard(card),
         rankOfCard(card));
   }
 
   return INT2NUM(rankCardset(card_set));
}