Commit bfc0589c authored by mercury233's avatar mercury233
parents 8a591503 f5ff25ce
......@@ -1579,6 +1579,10 @@ int32 card::add_effect(effect* peffect) {
peffect->count_limit = 1;
peffect->count_limit_max = 1;
}
// add EFFECT_FLAG_IGNORE_IMMUNE to EFFECT_CANNOT_TRIGGER by default
if (peffect->code == EFFECT_CANNOT_TRIGGER) {
peffect->flag[0] |= EFFECT_FLAG_IGNORE_IMMUNE;
}
card_set check_target = { this };
effect_container::iterator eit;
if (peffect->type & EFFECT_TYPE_SINGLE) {
......@@ -3285,7 +3289,7 @@ uint8 card::get_spsummonable_position(effect* reason_effect, uint32 sumtype, uin
continue;
if((data.type & (TYPE_TOKEN | TYPE_LINK)) && (positions[p] & POS_FACEDOWN))
continue;
pduel->game_field->filter_player_effect(sumplayer, EFFECT_CANNOT_SPECIAL_SUMMON, &eset);
pduel->game_field->filter_player_effect(sumplayer, EFFECT_LIMIT_SPECIAL_SUMMON_POSITION, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
if(!eset[i]->target)
continue;
......
......@@ -413,4 +413,6 @@ public:
#define CARD_MARINE_DOLPHIN 78734254
#define CARD_TWINKLE_MOSS 13857930
#define CARD_ARTWORK_VERSIONS_OFFSET 10
#endif /* CARD_H_ */
......@@ -463,6 +463,7 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_CHANGE_GRAVE_ATTRIBUTE 365
#define EFFECT_CHANGE_GRAVE_RACE 366
#define EFFECT_ACTIVATION_COUNT_LIMIT 367
#define EFFECT_LIMIT_SPECIAL_SUMMON_POSITION 368
#define EVENT_STARTUP 1000
#define EVENT_FLIP 1001
......
......@@ -957,14 +957,14 @@ void field::shuffle(uint8 playerid, uint8 location) {
}
}
if(location == LOCATION_HAND || !(core.duel_options & DUEL_PSEUDO_SHUFFLE)) {
uint32 s = (uint32)svector.size();
int32 s = (int32)svector.size();
if(location == LOCATION_EXTRA)
s = s - player[playerid].extra_p_count;
s = s - (int32)player[playerid].extra_p_count;
if(s > 1) {
if (core.duel_options & DUEL_OLD_REPLAY)
pduel->random.shuffle_vector_old(svector);
pduel->random.shuffle_vector_old(svector, 0, s - 1);
else
pduel->random.shuffle_vector(svector);
pduel->random.shuffle_vector(svector, 0, s - 1);
reset_sequence(playerid, location);
}
}
......
......@@ -63,7 +63,7 @@ int32 interpreter::register_card(card *pcard) {
//some userdata may be created in script like token so use current_state
lua_rawgeti(current_state, LUA_REGISTRYINDEX, pcard->ref_handle);
//load script
if(pcard->data.alias && (pcard->data.alias < pcard->data.code + 10) && (pcard->data.code < pcard->data.alias + 10))
if(pcard->data.alias && (pcard->data.alias < pcard->data.code + CARD_ARTWORK_VERSIONS_OFFSET) && (pcard->data.code < pcard->data.alias + CARD_ARTWORK_VERSIONS_OFFSET))
load_card_script(pcard->data.alias);
else
load_card_script(pcard->data.code);
......
......@@ -31,8 +31,7 @@ int32 scriptlib::card_get_origin_code(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
if(pcard->data.alias) {
int32 dif = pcard->data.code - pcard->data.alias;
if(dif > -10 && dif < 10)
if((pcard->data.alias < pcard->data.code + CARD_ARTWORK_VERSIONS_OFFSET) && (pcard->data.code < pcard->data.alias + CARD_ARTWORK_VERSIONS_OFFSET))
lua_pushinteger(L, pcard->data.alias);
else
lua_pushinteger(L, pcard->data.code);
......
......@@ -44,20 +44,26 @@ public:
return result;
}
// Fisher-Yates shuffle
// Fisher-Yates shuffle v[a]~v[b]
template<typename T>
void shuffle_vector(std::vector<T>& v) {
int n = (int)v.size();
for (int i = 0; i < n - 1; ++i) {
int r = get_random_integer(i, n - 1);
void shuffle_vector(std::vector<T>& v, int a = -1, int b = -1) {
if (a < 0)
a = 0;
if (b < 0)
b = (int)v.size() - 1;
for (int i = a; i < b; ++i) {
int r = get_random_integer(i, b);
std::swap(v[i], v[r]);
}
}
template<typename T>
void shuffle_vector_old(std::vector<T>& v) {
int n = (int)v.size();
for (int i = 0; i < n - 1; ++i) {
int r = get_random_integer_old(i, n - 1);
void shuffle_vector_old(std::vector<T>& v, int a = -1, int b = -1) {
if (a < 0)
a = 0;
if (b < 0)
b = (int)v.size() - 1;
for (int i = a; i < b; ++i) {
int r = get_random_integer_old(i, b);
std::swap(v[i], v[r]);
}
}
......
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