Commit 2d486e69 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:moecube/ygopro-core

parents 5a82befc 157cb45d
......@@ -3425,69 +3425,32 @@ int32_t scriptlib::card_add_monster_attribute(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1);
duel* pduel = pcard->pduel;
pcard->set_status(STATUS_NO_LEVEL, FALSE);
// pre-monster
effect* peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_PRE_MONSTER;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_CHAIN + RESET_EVENT + 0x47e0000;
peffect->value = type;
pcard->add_effect(peffect);
//attribute
if(attribute) {
effect* peffect;
auto add_temp_effect = [&](uint32_t code, int32_t value, uint32_t extra_reset_flag = 0) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_ATTRIBUTE;
peffect->code = code;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = attribute;
peffect->reset_flag = RESET_EVENT | 0x47e0000 | extra_reset_flag;
peffect->value = value;
pcard->add_effect(peffect);
};
add_temp_effect(EFFECT_PRE_MONSTER, type, RESET_CHAIN);
if(attribute) {
add_temp_effect(EFFECT_CHANGE_ATTRIBUTE, attribute);
}
//race
if(race) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_ADD_RACE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = race;
pcard->add_effect(peffect);
add_temp_effect(EFFECT_CHANGE_RACE, race);
}
//level
if(level) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_CHANGE_LEVEL;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = level;
pcard->add_effect(peffect);
add_temp_effect(EFFECT_CHANGE_LEVEL, level);
}
//atk
if(atk) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_ATTACK;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = atk;
pcard->add_effect(peffect);
add_temp_effect(EFFECT_SET_BASE_ATTACK, atk);
}
//def
if(def) {
peffect = pduel->new_effect();
peffect->owner = pcard;
peffect->type = EFFECT_TYPE_SINGLE;
peffect->code = EFFECT_SET_BASE_DEFENSE;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE;
peffect->reset_flag = RESET_EVENT + 0x47e0000;
peffect->value = def;
pcard->add_effect(peffect);
add_temp_effect(EFFECT_SET_BASE_DEFENSE, def);
}
return 0;
}
......
......@@ -1465,14 +1465,14 @@ int32_t scriptlib::duel_confirm_cards(lua_State *L) {
int32_t scriptlib::duel_sort_decktop(lua_State *L) {
check_action_permission(L);
check_param_count(L, 3);
uint32_t sort_player = (uint32_t)lua_tointeger(L, 1);
uint32_t target_player = (uint32_t)lua_tointeger(L, 2);
uint32_t count = (uint32_t)lua_tointeger(L, 3);
if(sort_player != 0 && sort_player != 1)
int32_t sort_player = (int32_t)lua_tointeger(L, 1);
int32_t target_player = (int32_t)lua_tointeger(L, 2);
int32_t count = (int32_t)lua_tointeger(L, 3);
if (!check_playerid(sort_player))
return 0;
if(target_player != 0 && target_player != 1)
if (!check_playerid(target_player))
return 0;
if(count < 1 || count > 16)
if (count < 1)
return 0;
duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->add_process(PROCESSOR_SORT_DECK, 0, 0, 0, sort_player + (target_player << 16), count);
......
......@@ -368,12 +368,12 @@ int32_t scriptlib::group_random_select(lua_State *L) {
check_param(L, PARAM_TYPE_GROUP, 1);
group* pgroup = *(group**) lua_touserdata(L, 1);
int32_t playerid = (int32_t)lua_tointeger(L, 2);
uint32_t count = (uint32_t)lua_tointeger(L, 3);
int32_t count = (int32_t)lua_tointeger(L, 3);
int32_t no_hint = lua_toboolean(L, 4);
duel* pduel = pgroup->pduel;
group* newgroup = pduel->new_group();
if(count > pgroup->container.size())
count = (uint32_t)pgroup->container.size();
if (count > (int32_t)pgroup->container.size())
count = (int32_t)pgroup->container.size();
if(count == 0) {
interpreter::group2value(L, newgroup);
return 1;
......@@ -381,12 +381,13 @@ int32_t scriptlib::group_random_select(lua_State *L) {
if(count == pgroup->container.size())
newgroup->container = pgroup->container;
else {
while(newgroup->container.size() < count) {
int32_t i = pduel->get_next_integer(0, (int32_t)pgroup->container.size() - 1);
auto cit = pgroup->container.begin();
std::advance(cit, i);
newgroup->container.insert(*cit);
card_vector cv(pgroup->container.begin(), pgroup->container.end());
int32_t back = (int32_t)cv.size() - 1;
for (int32_t i = 0; i < count; ++i) {
int32_t r = pduel->get_next_integer(i, back);
std::swap(cv[i], cv[r]);
}
newgroup->container.insert(cv.begin(), cv.begin() + count);
}
if(no_hint) {
interpreter::group2value(L, newgroup);
......
......@@ -675,15 +675,15 @@ uint32_t field::process() {
++it->step;
} else {
if(returns.bvalue[0] != 0xff) {
card* tc[16];
card* tc[256];
for(i = 0; i < count; ++i)
player[target_player].list_main.pop_back();
for(i = 0; i < count; ++i)
tc[returns.bvalue[i]] = core.select_cards[i];
for(i = 0; i < count; ++i) {
player[target_player].list_main.push_back(tc[count - i - 1]);
tc[count - i - 1]->current.sequence = (uint8_t)player[target_player].list_main.size() - 1;
player[target_player].list_main.push_back(tc[count - 1 - i]);
}
reset_sequence(target_player, LOCATION_DECK);
auto clit = player[target_player].list_main.rbegin();
for(i = 0; i < count; ++i, ++clit) {
card* pcard = *clit;
......
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