GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/resources/item/cardslist.h Lines: 5 14 35.7 %
Date: 2017-11-29 Branches: 0 120 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2004-2009  The Mana World Development Team
4
 *  Copyright (C) 2009-2010  The Mana Developers
5
 *  Copyright (C) 2011-2017  The ManaPlus Developers
6
 *
7
 *  This file is part of The ManaPlus Client.
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
#ifndef RESOURCES_ITEM_CARDSLIST_H
24
#define RESOURCES_ITEM_CARDSLIST_H
25
26
#include "const/resources/item/cards.h"
27
28
#include "localconsts.h"
29
30
struct CardsList final
31
{
32
    CardsList(const int card0,
33
              const int card1,
34
              const int card2,
35
              const int card3)
36
2
    {
37
2
        cards[0] = card0;
38
2
        cards[1] = card1;
39
2
        cards[2] = card2;
40
2
        cards[3] = card3;
41
    }
42
43
    explicit CardsList(const int *const cards0)
44
    {
45
        if (cards0 != nullptr)
46
        {
47
            for (int f = 0; f < maxCards; f ++)
48
                cards[f] = cards0[f];
49
        }
50
        else
51
        {
52
            for (int f = 0; f < maxCards; f ++)
53
                cards[f] = 0;
54
        }
55
    }
56
57
    A_DEFAULT_COPY(CardsList)
58
59
    bool isEmpty() const noexcept2 A_WARN_UNUSED
60
    {
61
        return cards[0] == 0 &&
62
            cards[1] == 0 &&
63
            cards[2] == 0 &&
64
            cards[3] == 0;
65
    }
66
67
    int cards[maxCards];
68
};
69
70
extern CardsList zeroCards;
71
72
#endif  // RESOURCES_ITEM_CARDSLIST_H