-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathCard.cpp
More file actions
145 lines (125 loc) · 3.31 KB
/
Copy pathCard.cpp
File metadata and controls
145 lines (125 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// Copyright (c) 2017-2024 Chris Ohk
// We are making my contributions/submissions to this project solely in our
// personal capacity and are not conveying any rights to any intellectual
// property of any third parties.
#include <Rosetta/Battlegrounds/Cards/Card.hpp>
#include <Rosetta/Common/Constants.hpp>
#include <Rosetta/Common/Enums/TargetingEnums.hpp>
#include <algorithm>
namespace RosettaStone::Battlegrounds
{
void Card::Initialize()
{
bool needsTarget = false;
CharacterType characterType = CharacterType::CHARACTERS;
FriendlyType friendlyType = FriendlyType::ALL;
for (auto& requirement : playRequirements)
{
switch (requirement.first)
{
case PlayReq::REQ_TARGET_IF_AVAILABLE:
needsTarget = true;
break;
case PlayReq::REQ_MINION_TARGET:
characterType = CharacterType::MINIONS;
break;
case PlayReq::REQ_FRIENDLY_TARGET:
friendlyType = FriendlyType::FRIENDLY;
break;
case PlayReq::REQ_TARGET_WITH_RACE:
{
const Race race = static_cast<Race>(requirement.second);
targetingPredicate.emplace_back(
TargetingPredicates::ReqTargetWithRace(race));
}
break;
default:
continue;
}
}
if (needsTarget)
{
switch (characterType)
{
case CharacterType::MINIONS:
switch (friendlyType)
{
case FriendlyType::FRIENDLY:
targetingType = TargetingType::FRIENDLY_MINIONS;
break;
default:
break;
}
break;
default:
break;
}
}
}
CardSet Card::GetCardSet() const
{
return static_cast<CardSet>(gameTags.at(GameTag::CARD_SET));
}
CardType Card::GetCardType() const
{
return static_cast<CardType>(gameTags.at(GameTag::CARDTYPE));
}
Race Card::GetRace() const
{
if (gameTags.find(GameTag::CARDRACE) == gameTags.end())
{
return Race::INVALID;
}
return static_cast<Race>(gameTags.at(GameTag::CARDRACE));
}
int Card::GetAttack() const
{
if (gameTags.find(GameTag::ATK) == gameTags.end())
{
return 0;
}
return gameTags.at(GameTag::ATK);
}
int Card::GetHealth() const
{
if (gameTags.find(GameTag::HEALTH) == gameTags.end())
{
return 0;
}
return gameTags.at(GameTag::HEALTH);
}
int Card::GetTier() const
{
if (gameTags.find(GameTag::TECH_LEVEL) == gameTags.end())
{
return 0;
}
return gameTags.at(GameTag::TECH_LEVEL);
}
bool Card::IsPlayableByCardReq([[maybe_unused]] Player& player) const
{
// for (const auto& playReq : playRequirements)
//{
// switch (playReq.first)
// {
// default:
// break;
// }
// }
return true;
}
bool Card::TargetingRequirements(Minion& target) const
{
if (!targetingPredicate.empty())
{
for (const auto& predicate : targetingPredicate)
{
if (!predicate(target))
{
return false;
}
}
}
return true;
}
} // namespace RosettaStone::Battlegrounds