poker_eval 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -613,29 +613,6 @@ int findanddelete(CardMask* hand, int rank)
613
613
  return -1;
614
614
  }
615
615
 
616
- static VALUE
617
- t_card2Rbstring(VALUE self, VALUE args)
618
- {
619
- int card = 0;
620
-
621
- card = NUM2INT(args);
622
-
623
- /* if (!PyArg_ParseTuple(args, "i", &card))*/
624
- /* return NULL;*/
625
-
626
- if(card == 255) {
627
- return rb_str_new2("__");
628
- } else {
629
- /*
630
- * Avoid using GenericDeck_cardString as long as it insists
631
- * on using the "static thread" hack (see lib/deck.c).
632
- */
633
- char tmp[16];
634
- StdDeck.cardToString(card, tmp);
635
- rb_str_new2(tmp);
636
- }
637
- }
638
-
639
616
  static int
640
617
  OmahaHiLow8_Best(StdDeck_CardMask hole, StdDeck_CardMask board,
641
618
  HandVal *hival, LowHandVal *loval,
@@ -976,6 +953,5 @@ Init_poker_eval_api()
976
953
  cPokerEval = rb_define_class("PokerEval", rb_cObject);
977
954
  rb_define_singleton_method(cPokerEval, "eval", t_eval, 1);
978
955
  rb_define_singleton_method(cPokerEval, "eval_hand", t_eval_hand, 1);
979
- rb_define_singleton_method(cPokerEval, "card2string", t_card2Rbstring, 1);
980
956
  }
981
957
 
data/lib/poker_eval.rb CHANGED
@@ -6,18 +6,36 @@ end
6
6
  # define version string to be used internally for the Gem by Hoe.
7
7
  class PokerEval
8
8
  module GemVersion
9
- VERSION = '0.0.1'
9
+ VERSION = '0.0.3'
10
+ end
11
+
12
+ @@rankChars = "23456789TJQKA"
13
+ @@suitChars = "hdcs"
14
+ @@suitBase = 13
15
+
16
+ def self.card2string index
17
+ index = index.to_i
18
+ card = ""
19
+ if index == 255
20
+ card = "__"
21
+ elsif index < 52
22
+ card = @@rankChars[index % @@suitBase] + @@suitChars[index / @@suitBase]
23
+ else
24
+ raise 'Unexisting card index given: ' + index.to_s
25
+ end
26
+
27
+ card
10
28
  end
11
29
 
12
30
  def self.best args
13
31
  results = self.eval_hand(args)
14
32
  results["combination"].each_with_index do |i, index|
15
33
  if index > 0
16
- results["combination"][index] = self.card2string(i.to_i)
34
+ results["combination"][index] = card2string(i)
17
35
  end
18
36
  end
19
37
 
20
- return results
38
+ results
21
39
  end
22
40
 
23
41
  def self.winner args
data/poker_eval.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "poker_eval"
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Miks Mikelsons"]
12
- s.date = "2012-01-04"
12
+ s.date = "2012-01-25"
13
13
  s.description = "poker evaluation Ruby Interface"
14
14
  s.email = "miks@cube.lv"
15
15
  s.extensions = ["ext/poker_eval_api/extconf.rb"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poker_eval
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-04 00:00:00.000000000Z
12
+ date: 2012-01-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jeweler
16
- requirement: &70223472571760 !ruby/object:Gem::Requirement
16
+ requirement: &70150739029460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70223472571760
24
+ version_requirements: *70150739029460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake-compiler
27
- requirement: &70223472571260 !ruby/object:Gem::Requirement
27
+ requirement: &70150739025040 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70223472571260
35
+ version_requirements: *70150739025040
36
36
  description: poker evaluation Ruby Interface
37
37
  email: miks@cube.lv
38
38
  executables: []