Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed assume to a map #209

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 16 additions & 18 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ card::card(duel* pd) {
spsummon_counter_rst[0] = spsummon_counter_rst[1] = 0;
unique_code = 0;
unique_fieldid = 0;
assume_type = 0;
assume_value = 0;
spsummon_code = 0;
current.controler = PLAYER_NONE;
}
Expand Down Expand Up @@ -244,8 +242,8 @@ uint32 card::get_info_location() {
}
// get the current code
uint32 card::get_code() {
if(assume_type == ASSUME_CODE)
return assume_value;
if (assume.find(ASSUME_CODE) != assume.end())
return assume[ASSUME_CODE];
if (temp.code != 0xffffffff)
return temp.code;
effect_set effects;
Expand Down Expand Up @@ -418,8 +416,8 @@ int32 card::is_link_set_card(uint32 set_code) {
return FALSE;
}
uint32 card::get_type() {
if(assume_type == ASSUME_TYPE)
return assume_value;
if (assume.find(ASSUME_TYPE) != assume.end())
return assume[ASSUME_TYPE];
if(!(current.location & (LOCATION_ONFIELD | LOCATION_HAND | LOCATION_GRAVE)))
return data.type;
if(current.is_location(LOCATION_PZONE))
Expand Down Expand Up @@ -533,8 +531,8 @@ int32 card::get_base_attack() {
return batk;
}
int32 card::get_attack() {
if(assume_type == ASSUME_ATTACK)
return assume_value;
if (assume.find(ASSUME_ATTACK) != assume.end())
return assume[ASSUME_ATTACK];
if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0;
if (current.location != LOCATION_MZONE || get_status(STATUS_SUMMONING | STATUS_SPSUMMON_STEP))
Expand Down Expand Up @@ -732,8 +730,8 @@ int32 card::get_base_defense() {
int32 card::get_defense() {
if(data.type & TYPE_LINK)
return 0;
if(assume_type == ASSUME_DEFENSE)
return assume_value;
if (assume.find(ASSUME_DEFENSE) != assume.end())
return assume[ASSUME_DEFENSE];
if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0;
if (current.location != LOCATION_MZONE || get_status(STATUS_SUMMONING | STATUS_SPSUMMON_STEP))
Expand Down Expand Up @@ -870,8 +868,8 @@ uint32 card::get_level() {
if((data.type & (TYPE_XYZ | TYPE_LINK)) || (status & STATUS_NO_LEVEL)
|| (!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER)))
return 0;
if(assume_type == ASSUME_LEVEL)
return assume_value;
if (assume.find(ASSUME_LEVEL) != assume.end())
return assume[ASSUME_LEVEL];
if (temp.level != 0xffffffff)
return temp.level;
effect_set effects;
Expand Down Expand Up @@ -910,8 +908,8 @@ uint32 card::get_level() {
uint32 card::get_rank() {
if(!(data.type & TYPE_XYZ) || (status & STATUS_NO_LEVEL))
return 0;
if(assume_type == ASSUME_RANK)
return assume_value;
if (assume.find(ASSUME_RANK) != assume.end())
return assume[ASSUME_RANK];
if(!(current.location & LOCATION_MZONE))
return data.level;
if (temp.level != 0xffffffff)
Expand Down Expand Up @@ -1001,8 +999,8 @@ uint32 card::check_xyz_level(card* pcard, uint32 lv) {
}
// see get_level()
uint32 card::get_attribute() {
if(assume_type == ASSUME_ATTRIBUTE)
return assume_value;
if (assume.find(ASSUME_ATTRIBUTE) != assume.end())
return assume[ASSUME_ATTRIBUTE];
if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0;
if (temp.attribute != 0xffffffff)
Expand Down Expand Up @@ -1052,8 +1050,8 @@ uint32 card::get_link_attribute(uint8 playerid) {
}
// see get_level()
uint32 card::get_race() {
if(assume_type == ASSUME_RACE)
return assume_value;
if (assume.find(ASSUME_RACE) != assume.end())
return assume[ASSUME_RACE];
if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0;
if (temp.race != 0xffffffff)
Expand Down
3 changes: 1 addition & 2 deletions card.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ class card {
uint32 spsummon_code;
uint16 spsummon_counter[2];
uint16 spsummon_counter_rst[2];
uint8 assume_type;
uint32 assume_value;
std::map<uint32, uint32> assume;
card* equiping_target;
card* pre_equip_target;
card* overlay_target;
Expand Down
2 changes: 1 addition & 1 deletion duel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void duel::release_script_group() {
}
void duel::restore_assumes() {
for(auto& pcard : assumes)
pcard->assume_type = 0;
pcard->assume.clear();
assumes.clear();
}
void duel::write_buffer32(uint32 value) {
Expand Down
5 changes: 3 additions & 2 deletions libcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2927,8 +2927,9 @@ int32 scriptlib::card_assume_prop(lua_State *L) {
check_param_count(L, 3);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
pcard->assume_type = lua_tointeger(L, 2);
pcard->assume_value = lua_tointeger(L, 3);
if ((lua_tointeger(L, 2) < ASSUME_CODE) || (lua_tointeger(L, 2) > ASSUME_DEFENSE))
return 0;
pcard->assume[lua_tointeger(L, 2)] = lua_tointeger(L, 3);
pcard->pduel->assumes.insert(pcard);
return 0;
}
Expand Down