LibCards: Fix some minor clang-tidy issues
This commit is contained in:
parent
21a818ab50
commit
b26383bc6c
Notes:
sideshowbarker
2024-07-17 07:31:31 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/b26383bc6c Pull-request: https://github.com/SerenityOS/serenity/pull/15388
2 changed files with 8 additions and 8 deletions
Userland/Libraries/LibCards
|
@ -36,8 +36,8 @@ void CardStack::paint(GUI::Painter& painter, Gfx::Color const& background_color)
|
|||
{
|
||||
auto draw_background_if_empty = [&]() {
|
||||
size_t number_of_moving_cards = 0;
|
||||
for (const auto& card : m_stack)
|
||||
number_of_moving_cards += card.is_moving();
|
||||
for (auto const& card : m_stack)
|
||||
number_of_moving_cards += card.is_moving() ? 1 : 0;
|
||||
|
||||
if (m_covered_stack && !m_covered_stack->is_empty())
|
||||
return false;
|
||||
|
@ -194,7 +194,7 @@ bool CardStack::is_allowed_to_push(Card const& card, size_t stack_size, Movement
|
|||
return card.rank() == Rank::Ace;
|
||||
|
||||
if (!is_empty()) {
|
||||
auto& top_card = peek();
|
||||
auto const& top_card = peek();
|
||||
if (top_card.is_upside_down())
|
||||
return false;
|
||||
|
||||
|
@ -203,7 +203,8 @@ bool CardStack::is_allowed_to_push(Card const& card, size_t stack_size, Movement
|
|||
if (stack_size > 1)
|
||||
return false;
|
||||
return top_card.suit() == card.suit() && m_stack.size() == to_underlying(card.rank());
|
||||
} else if (m_type == Type::Normal) {
|
||||
}
|
||||
if (m_type == Type::Normal) {
|
||||
bool color_match;
|
||||
switch (movement_rule) {
|
||||
case MovementRule::Alternating:
|
||||
|
@ -228,10 +229,9 @@ bool CardStack::is_allowed_to_push(Card const& card, size_t stack_size, Movement
|
|||
|
||||
void CardStack::push(NonnullRefPtr<Card> card)
|
||||
{
|
||||
auto size = m_stack.size();
|
||||
auto top_most_position = m_stack_positions.is_empty() ? m_position : m_stack_positions.last();
|
||||
|
||||
if (size && size % m_rules.step == 0) {
|
||||
if (!m_stack.is_empty() && m_stack.size() % m_rules.step == 0) {
|
||||
if (peek().is_upside_down())
|
||||
top_most_position.translate_by(m_rules.shift_x, m_rules.shift_y_upside_down);
|
||||
else
|
||||
|
@ -282,7 +282,7 @@ void CardStack::calculate_bounding_box()
|
|||
uint16_t height = 0;
|
||||
size_t card_position = 0;
|
||||
for (auto& card : m_stack) {
|
||||
if (card_position % m_rules.step == 0 && card_position) {
|
||||
if (card_position % m_rules.step == 0 && card_position != 0) {
|
||||
if (card.is_upside_down()) {
|
||||
width += m_rules.shift_x;
|
||||
height += m_rules.shift_y_upside_down;
|
||||
|
|
|
@ -62,7 +62,7 @@ private:
|
|||
uint8_t shift_y_upside_down { 0 };
|
||||
};
|
||||
|
||||
constexpr StackRules rules_for_type(Type stack_type)
|
||||
static constexpr StackRules rules_for_type(Type stack_type)
|
||||
{
|
||||
switch (stack_type) {
|
||||
case Type::Foundation:
|
||||
|
|
Loading…
Add table
Reference in a new issue