classifier: it's your boy, clippy
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use crate::card::{Card, Rank};
|
||||
use crate::card::Card;
|
||||
use crate::hand::{Hand, PokerType};
|
||||
|
||||
impl Hand {
|
||||
@@ -68,8 +68,7 @@ fn try_poker_hand(num_jokers: usize, cards: &[Card]) -> Option<PokerType> {
|
||||
|
||||
let mut counter_ranks = [0; 13];
|
||||
let mut counter_suits = [0; 13];
|
||||
for i in 0..playing_cards.len() {
|
||||
let card = playing_cards[i];
|
||||
for card in playing_cards {
|
||||
let rank = card.rank().unwrap() as usize;
|
||||
let suit = card.suit().unwrap() as usize;
|
||||
counter_ranks[rank] += 1;
|
||||
@@ -79,9 +78,7 @@ fn try_poker_hand(num_jokers: usize, cards: &[Card]) -> Option<PokerType> {
|
||||
let highest_rank_freq = *counter_ranks.iter().max().unwrap();
|
||||
let num_pairs = counter_ranks.iter().filter(|&count| *count == 2).count();
|
||||
let is_straight = is_straight(num_jokers, playing_cards);
|
||||
let is_flush = counter_suits
|
||||
.iter()
|
||||
.any(|&count| count == playing_cards.len());
|
||||
let is_flush = counter_suits.contains(&playing_cards.len());
|
||||
|
||||
if is_straight && is_flush || num_jokers == 4 {
|
||||
Some(PokerType::StraightFlush)
|
||||
@@ -89,9 +86,9 @@ fn try_poker_hand(num_jokers: usize, cards: &[Card]) -> Option<PokerType> {
|
||||
Some(PokerType::FiveKind)
|
||||
} else if num_jokers + highest_rank_freq == 4 {
|
||||
Some(PokerType::FourKind)
|
||||
} else if num_pairs == 1 && highest_rank_freq == 3 {
|
||||
Some(PokerType::FullHouse)
|
||||
} else if num_jokers == 1 && num_pairs == 2 {
|
||||
} else if (num_pairs == 1 && highest_rank_freq == 3)
|
||||
|| (num_jokers == 1 && num_pairs == 2)
|
||||
{
|
||||
Some(PokerType::FullHouse)
|
||||
} else if is_straight {
|
||||
Some(PokerType::Straight)
|
||||
@@ -125,7 +122,7 @@ fn is_straight(num_jokers: i32, cards: &[Card]) -> bool {
|
||||
};
|
||||
for m in nums {
|
||||
let diff = m - prev;
|
||||
if diff == 0 || diff - 1 > gaps {
|
||||
if diff <= 0 || diff - 1 > gaps {
|
||||
return false;
|
||||
}
|
||||
gaps -= diff - 1;
|
||||
|
||||
Reference in New Issue
Block a user