Commit 83bfe169 authored by VanillaSalt's avatar VanillaSalt

fix

parent 8af795c9
...@@ -404,6 +404,7 @@ void card::calc_attack_defence(int32 *patk, int32 *pdef) { ...@@ -404,6 +404,7 @@ void card::calc_attack_defence(int32 *patk, int32 *pdef) {
if (is_affected_by_effect(EFFECT_REVERSE_UPDATE)) if (is_affected_by_effect(EFFECT_REVERSE_UPDATE))
rev = TRUE; rev = TRUE;
effect_set effects_atk, effects_def; effect_set effects_atk, effects_def;
int32 swap_final = FALSE;
for (int32 i = 0; i < eset.size(); ++i) { for (int32 i = 0; i < eset.size(); ++i) {
switch (eset[i]->code) { switch (eset[i]->code) {
case EFFECT_UPDATE_ATTACK: case EFFECT_UPDATE_ATTACK:
...@@ -461,14 +462,17 @@ void card::calc_attack_defence(int32 *patk, int32 *pdef) { ...@@ -461,14 +462,17 @@ void card::calc_attack_defence(int32 *patk, int32 *pdef) {
effects_def.add_item(eset[i]); effects_def.add_item(eset[i]);
break; break;
case EFFECT_SWAP_AD: case EFFECT_SWAP_AD:
int32 a = base_atk + up_atk + upc_atk; if ((eset[i]->type & EFFECT_TYPE_SINGLE) && !(eset[i]->flag & EFFECT_FLAG_SINGLE_RANGE)) {
int32 d = base_def + up_def + upc_def; int32 a = base_atk + up_atk + upc_atk;
base_atk = d; int32 d = base_def + up_def + upc_def;
up_atk = 0; base_atk = d;
upc_atk = 0; up_atk = 0;
base_def = a; upc_atk = 0;
up_def = 0; base_def = a;
upc_def = 0; up_def = 0;
upc_def = 0;
} else
swap_final = !swap_final;
break; break;
} }
if (!rev) { if (!rev) {
...@@ -479,36 +483,24 @@ void card::calc_attack_defence(int32 *patk, int32 *pdef) { ...@@ -479,36 +483,24 @@ void card::calc_attack_defence(int32 *patk, int32 *pdef) {
temp.defence = base_def - up_def - upc_def; temp.defence = base_def - up_def - upc_def;
} }
} }
if (swap_final) {
int32 atk = temp.attack;
int32 def = temp.defence;
temp.attack = def;
temp.defence = atk;
}
if (patk) { if (patk) {
int32 final = -1, atk; for (int32 i = 0; i < effects_atk.size(); ++i)
for (int32 i = 0; i < effects_atk.size(); ++i) { temp.attack = effects_atk[i]->get_value(this);
final = effects_atk[i]->get_value(this); int32 atk = temp.attack;
temp.attack = final;
}
if (final == -1) {
if (!rev)
atk = base_atk + up_atk + upc_atk;
else
atk = base_atk - up_atk - upc_atk;
} else
atk = final;
if (atk < 0) if (atk < 0)
atk = 0; atk = 0;
*patk = atk; *patk = atk;
} }
if (pdef) { if (pdef) {
int32 final = -1, def; for (int32 i = 0; i < effects_def.size(); ++i)
for (int32 i = 0; i < effects_def.size(); ++i) { temp.defence = effects_def[i]->get_value(this);
final = effects_def[i]->get_value(this); int32 def = temp.defence;
temp.defence = final;
}
if (final == -1) {
if (!rev)
def = base_def + up_def + upc_def;
else
def = base_def - up_def - upc_def;
} else
def = final;
if (def < 0) if (def < 0)
def = 0; def = 0;
*pdef = def; *pdef = def;
......
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