Commit 8a0195b2 authored by nanahira's avatar nanahira

Merge branch 'fh' into mc

parents 86e5aa82 2b31bb07
......@@ -242,7 +242,19 @@ uint32 card::get_info_location() {
return c + (l << 8) + (s << 16) + (ss << 24);
}
}
// get the current code
// mapping of double-name cards
uint32 card::second_code(uint32 code){
switch(code){
case CARD_MARINE_DOLPHIN:
return 17955766u;
case CARD_TWINKLE_MOSS:
return 17732278u;
default:
return 0;
}
}
// return: the current card name
// for double-name card, it returns printed name
uint32 card::get_code() {
if(assume_type == ASSUME_CODE)
return assume_value;
......@@ -261,21 +273,24 @@ uint32 card::get_code() {
} else {
card_data dat;
read_card(code, &dat);
if (dat.alias)
if (dat.alias && !second_code(code))
code = dat.alias;
}
return code;
}
// get the current second-code
// return: the current second card name
// for double-name cards, it returns the name in description
uint32 card::get_another_code() {
if(is_affected_by_effect(EFFECT_CHANGE_CODE))
return 0;
uint32 code = get_code();
if(code != data.code){
return second_code(code);
}
effect_set eset;
filter_effect(EFFECT_ADD_CODE, &eset);
if(!eset.size())
return 0;
uint32 otcode = eset.get_last()->get_value(this);
if(get_code() != otcode)
if(code != otcode)
return otcode;
return 0;
}
......@@ -490,7 +505,7 @@ int32 card::get_base_attack() {
if(swap)
filter_effect(EFFECT_SET_BASE_DEFENSE, &eset, FALSE);
eset.sort();
// calculate continous effects of this first
// calculate continuous effects of this first
for(int32 i = 0; i < eset.size();) {
if((eset[i]->type & EFFECT_TYPE_SINGLE) && eset[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE)) {
switch(eset[i]->code) {
......@@ -877,31 +892,22 @@ uint32 card::get_level() {
effect_set effects;
int32 level = data.level;
temp.level = level;
int32 up = 0, upc = 0;
int32 up = 0;
filter_effect(EFFECT_UPDATE_LEVEL, &effects, FALSE);
filter_effect(EFFECT_CHANGE_LEVEL, &effects, FALSE);
filter_effect(EFFECT_CHANGE_LEVEL_FINAL, &effects);
filter_effect(EFFECT_CHANGE_LEVEL, &effects);
for (int32 i = 0; i < effects.size(); ++i) {
switch (effects[i]->code) {
case EFFECT_UPDATE_LEVEL:
if ((effects[i]->type & EFFECT_TYPE_SINGLE) && !effects[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE))
up += effects[i]->get_value(this);
else
upc += effects[i]->get_value(this);
up += effects[i]->get_value(this);
break;
case EFFECT_CHANGE_LEVEL:
level = effects[i]->get_value(this);
up = 0;
break;
case EFFECT_CHANGE_LEVEL_FINAL:
level = effects[i]->get_value(this);
up = 0;
upc = 0;
break;
}
temp.level = level + up + upc;
temp.level = level + up;
}
level += up + upc;
level += up;
if(level < 1 && (get_type() & TYPE_MONSTER))
level = 1;
temp.level = 0xffffffff;
......@@ -919,31 +925,22 @@ uint32 card::get_rank() {
effect_set effects;
int32 rank = data.level;
temp.level = rank;
int32 up = 0, upc = 0;
int32 up = 0;
filter_effect(EFFECT_UPDATE_RANK, &effects, FALSE);
filter_effect(EFFECT_CHANGE_RANK, &effects, FALSE);
filter_effect(EFFECT_CHANGE_RANK_FINAL, &effects);
filter_effect(EFFECT_CHANGE_RANK, &effects);
for (int32 i = 0; i < effects.size(); ++i) {
switch (effects[i]->code) {
case EFFECT_UPDATE_RANK:
if ((effects[i]->type & EFFECT_TYPE_SINGLE) && !effects[i]->is_flag(EFFECT_FLAG_SINGLE_RANGE))
up += effects[i]->get_value(this);
else
upc += effects[i]->get_value(this);
up += effects[i]->get_value(this);
break;
case EFFECT_CHANGE_RANK:
rank = effects[i]->get_value(this);
up = 0;
break;
case EFFECT_CHANGE_RANK_FINAL:
rank = effects[i]->get_value(this);
up = 0;
upc = 0;
break;
}
temp.level = rank + up + upc;
temp.level = rank + up;
}
rank += up + upc;
rank += up;
if(rank < 1 && (get_type() & TYPE_MONSTER))
rank = 1;
temp.level = 0xffffffff;
......@@ -2730,7 +2727,7 @@ effect* card::is_affected_by_effect(int32 code, card* target) {
}
return 0;
}
// return the last control-changing continous effect
// return the last control-changing continuous effect
effect* card::check_control_effect() {
effect* ret_effect = 0;
for (auto& pcard : equiping_cards) {
......
......@@ -192,6 +192,7 @@ public:
uint32 get_infos(byte* buf, int32 query_flag, int32 use_cache = TRUE);
uint32 get_info_location();
uint32 second_code(uint32 code);
uint32 get_code();
uint32 get_another_code();
int32 is_set_card(uint32 set_code);
......@@ -373,4 +374,8 @@ public:
#define ASSUME_ATTACK 7
#define ASSUME_DEFENSE 8
//double-name cards
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#endif /* CARD_H_ */
......@@ -407,8 +407,8 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_QP_ACT_IN_NTPHAND 311
#define EFFECT_MUST_BE_SMATERIAL 312
#define EFFECT_TO_GRAVE_REDIRECT_CB 313
#define EFFECT_CHANGE_LEVEL_FINAL 314
#define EFFECT_CHANGE_RANK_FINAL 315
//#define EFFECT_CHANGE_LEVEL_FINAL 314
//#define EFFECT_CHANGE_RANK_FINAL 315
#define EFFECT_MUST_BE_FMATERIAL 316
#define EFFECT_MUST_BE_XMATERIAL 317
#define EFFECT_MUST_BE_LMATERIAL 318
......
......@@ -100,6 +100,7 @@ static const struct luaL_Reg cardlib[] = {
{ "GetTurnID", scriptlib::card_get_turnid },
{ "GetFieldID", scriptlib::card_get_fieldid },
{ "GetRealFieldID", scriptlib::card_get_fieldidr },
{ "IsOriginalCodeRule", scriptlib::card_is_origin_code_rule },
{ "IsCode", scriptlib::card_is_code },
{ "IsType", scriptlib::card_is_type },
{ "IsFusionType", scriptlib::card_is_fusion_type },
......
......@@ -795,6 +795,37 @@ int32 scriptlib::card_get_fieldidr(lua_State *L) {
lua_pushinteger(L, pcard->fieldid_r);
return 1;
}
int32 scriptlib::card_is_origin_code_rule(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 code1 = 0;
uint32 code2 = 0;
effect_set eset;
pcard->filter_effect(EFFECT_ADD_CODE, &eset);
if(pcard->data.alias && !eset.size()){
code1 = pcard->data.alias;
code2 = 0;
}
else {
code1 = pcard->data.code;
if(eset.size())
code2 = eset.get_last()->get_value(pcard);
}
uint32 count = lua_gettop(L) - 1;
uint32 result = FALSE;
for(uint32 i = 0; i < count; ++i) {
if(lua_isnil(L, i + 2))
continue;
uint32 tcode = lua_tointeger(L, i + 2);
if(code1 == tcode || (code2 && code2 == tcode)) {
result = TRUE;
break;
}
}
lua_pushboolean(L, result);
return 1;
}
int32 scriptlib::card_is_code(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
......
......@@ -825,8 +825,6 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a
}
return TRUE;
}
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
static int32 is_declarable(card_data const& cd, const std::vector<uint32>& opcode) {
std::stack<int32> stack;
for(auto& it : opcode) {
......
......@@ -692,7 +692,7 @@ int32 field::process() {
pduel->lua->add_param((void*)0, PARAM_TYPE_GROUP);
else {
card* pcard;
if(returns.bvalue[1] < core.select_cards.size())
if((uint8)returns.bvalue[1] < core.select_cards.size())
pcard = core.select_cards[returns.bvalue[1]];
else
pcard = core.unselect_cards[returns.bvalue[1] - core.select_cards.size()];
......
......@@ -104,6 +104,7 @@ public:
static int32 card_get_turnid(lua_State *L);
static int32 card_get_fieldid(lua_State *L);
static int32 card_get_fieldidr(lua_State *L);
static int32 card_is_origin_code_rule(lua_State *L);
static int32 card_is_code(lua_State *L);
static int32 card_is_type(lua_State *L);
static int32 card_is_fusion_type(lua_State *L);
......
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