Commit 090321d2 authored by fallenstardust's avatar fallenstardust

sync ocgcore

parent a0b790cf
......@@ -67,7 +67,7 @@ public:
void EnableMusic(bool enable);
private:
std::vector<std::string> BGMList[8];
std::vector<std::string> BGMList[9];
std::map<unsigned int, std::string> ChantsList;
int bgm_scene = -1;
bool bgm_process;
......
......@@ -363,6 +363,8 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_PIERCE 203
#define EFFECT_BATTLE_DESTROY_REDIRECT 204
#define EFFECT_BATTLE_DAMAGE_TO_EFFECT 205
#define EFFECT_BOTH_BATTLE_DAMAGE 206
#define EFFECT_ALSO_BATTLE_DAMAGE 207
#define EFFECT_TOSS_COIN_REPLACE 220
#define EFFECT_TOSS_DICE_REPLACE 221
#define EFFECT_FUSION_MATERIAL 230
......@@ -518,4 +520,6 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EVENT_REMOVE_COUNTER 0x20000
#define EVENT_CUSTOM 0x10000000
#define DOUBLE_DAMAGE 0x80000000
#define HALF_DAMAGE 0x80000001
#endif /* EFFECT_H_ */
......@@ -1210,11 +1210,6 @@ void field::remove_oath_effect(effect* reason_effect) {
void field::reset_phase(uint32 phase) {
for(auto eit = effects.pheff.begin(); eit != effects.pheff.end();) {
auto rm = eit++;
// work around: skip turn still raise reset_phase(PHASE_END)
// without this taking control only for one turn will be returned when skipping turn
// RESET_TURN_END should be introduced
//if((*rm)->code == EFFECT_SET_CONTROL)
// continue;
if((*rm)->reset(phase, RESET_PHASE)) {
if((*rm)->is_flag(EFFECT_FLAG_FIELD_ONLY))
remove_effect((*rm));
......
......@@ -1031,7 +1031,7 @@ int32 interpreter::get_operation_value(card* pcard, int32 findex, int32 extraarg
}
return OPERATION_FAIL;
}
int32 result = std::round(lua_tonumber(current_state, -1));
int32 result = lua_isinteger(current_state, -1) ? lua_tointeger(current_state, -1) : std::round(lua_tonumber(current_state, -1));
lua_pop(current_state, 1);
no_action--;
call_depth--;
......@@ -1050,8 +1050,10 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count) {
call_depth++;
if (call_function(f, param_count, 1)) {
int32 result = 0;
if (lua_isboolean(current_state, -1))
if(lua_isboolean(current_state, -1))
result = lua_toboolean(current_state, -1);
else if(lua_isinteger(current_state, -1))
result = lua_tointeger(current_state, -1);
else
result = std::round(lua_tonumber(current_state, -1));
lua_pop(current_state, 1);
......@@ -1084,8 +1086,10 @@ int32 interpreter::get_function_value(int32 f, uint32 param_count, std::vector<i
int32 stack_newtop = lua_gettop(current_state);
for (int32 index = stack_top + 1; index <= stack_newtop; ++index) {
int32 return_value = 0;
if (lua_isboolean(current_state, index))
if(lua_isboolean(current_state, index))
return_value = lua_toboolean(current_state, index);
else if(lua_isinteger(current_state, index))
return_value = lua_tointeger(current_state, index);
else
return_value = std::round(lua_tonumber(current_state, index));
result->push_back(return_value);
......
......@@ -39,6 +39,8 @@ int32 scriptlib::debug_add_card(lua_State *L) {
if(pduel->game_field->is_location_useable(playerid, location, sequence)) {
card* pcard = pduel->new_card(code);
pcard->owner = owner;
if(location == LOCATION_EXTRA && position == 0)
position = POS_FACEDOWN_DEFENSE;
pcard->sendto_param.position = position;
if(location == LOCATION_PZONE) {
int32 seq = pduel->game_field->core.duel_rule >= 4 ? sequence * 4 : sequence + 6;
......
......@@ -1869,7 +1869,7 @@ int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
return 0;
duel* pduel = interpreter::get_duel_info(L);
uint32 uplayer = pduel->game_field->core.reason_player;
if(lua_gettop(L) >= 2)
if(lua_gettop(L) >= 2 && !lua_isnil(L, 2))
uplayer = lua_tointeger(L, 2);
bool swapped = false;
card* mcard = 0;
......
......@@ -266,6 +266,8 @@ int32 scriptlib::effect_set_value(lua_State *L) {
peffect->flag[0] &= ~EFFECT_FLAG_FUNC_VALUE;
if(lua_isboolean(L, 2))
peffect->value = lua_toboolean(L, 2);
else if(lua_isinteger(L, 2))
peffect->value = lua_tointeger(L, 2);
else
peffect->value = std::round(lua_tonumber(L, 2));
}
......
......@@ -1400,8 +1400,22 @@ int32 field::equip(uint16 step, uint8 equip_player, card * equip_card, card * ta
returns.ivalue[0] = FALSE;
if(!equip_card->is_affect_by_effect(core.reason_effect))
return TRUE;
if(equip_card == target || target->current.location != LOCATION_MZONE)
if(equip_card == target)
return TRUE;
bool to_grave = false;
if(target->current.location != LOCATION_MZONE || (target->current.position & POS_FACEDOWN))
to_grave = true;
if(equip_card->current.location != LOCATION_SZONE) {
refresh_location_info_instant();
if(get_useable_count(equip_card, equip_player, LOCATION_SZONE, equip_player, LOCATION_REASON_TOFIELD) <= 0)
to_grave = true;
}
if(to_grave) {
if(equip_card->current.location != LOCATION_GRAVE)
send_to(equip_card, 0, REASON_RULE, PLAYER_NONE, PLAYER_NONE, LOCATION_GRAVE, 0, POS_FACEUP);
core.units.begin()->step = 2;
return FALSE;
}
if(equip_card->equiping_target) {
equip_card->cancel_card_target(equip_card->equiping_target);
equip_card->unequip();
......@@ -1413,9 +1427,6 @@ int32 field::equip(uint16 step, uint8 equip_player, card * equip_card, card * ta
change_position(equip_card, 0, equip_player, POS_FACEUP, 0);
return FALSE;
}
refresh_location_info_instant();
if(get_useable_count(equip_card, equip_player, LOCATION_SZONE, equip_player, LOCATION_REASON_TOFIELD) <= 0)
return TRUE;
equip_card->enable_field_effect(false);
move_to_field(equip_card, equip_player, equip_player, LOCATION_SZONE, (up || equip_card->is_position(POS_FACEUP)) ? POS_FACEUP : POS_FACEDOWN, FALSE, 0, TRUE);
return FALSE;
......@@ -1465,6 +1476,10 @@ int32 field::equip(uint16 step, uint8 equip_player, card * equip_card, card * ta
returns.ivalue[0] = TRUE;
return TRUE;
}
case 3: {
returns.ivalue[0] = FALSE;
return TRUE;
}
}
return TRUE;
}
......
This diff is collapsed.
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