Commit 00ede3c8 authored by salix5's avatar salix5

card_data: add is_setcode()

parent 13b28cd3
#ifndef CARD_DATA_H_
#define CARD_DATA_H_
#include "common.h"
#include <vector>
struct card_data {
uint32 code{ 0 };
uint32 alias{ 0 };
uint64 setcode{ 0 };
uint32 type{ 0 };
uint32 level{ 0 };
uint32 attribute{ 0 };
uint32 race{ 0 };
int32 attack{ 0 };
int32 defense{ 0 };
uint32 lscale{ 0 };
uint32 rscale{ 0 };
uint32 link_marker{ 0 };
uint32 code{};
uint32 alias{};
std::vector<uint16_t> setcode;
uint32 type{};
uint32 level{};
uint32 attribute{};
uint32 race{};
int32 attack{};
int32 defense{};
uint32 lscale{};
uint32 rscale{};
uint32 link_marker{};
void clear() {
code = 0;
alias = 0;
setcode = 0;
setcode.clear();
type = 0;
level = 0;
attribute = 0;
......@@ -29,6 +32,25 @@ struct card_data {
rscale = 0;
link_marker = 0;
}
bool is_setcode(uint32 value) const {
uint16_t settype = value & 0x0fff;
uint16_t setsubtype = value & 0xf000;
for (auto& x : setcode) {
if ((x & 0x0fff) == settype && (x & 0xf000 & setsubtype) == setsubtype)
return true;
}
return false;
}
void set_setcode(uint64 value) {
setcode.clear();
while (value) {
if (value & 0xffff)
setcode.push_back(value & 0xffff);
value >>= 16;
}
}
};
#endif /* CARD_DATA_H_ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment