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

fix LP cost accumulate #427

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2867,10 +2867,12 @@ int32 card::fusion_check(group* fusion_m, card* cg, uint32 chkf, uint8 not_mater
pduel->lua->add_param(chkf, PARAM_TYPE_INT);
effect* oreason = pduel->game_field->core.reason_effect;
uint8 op = pduel->game_field->core.reason_player;
pduel->game_field->save_lp_cost();
pduel->game_field->core.reason_effect = peffect;
pduel->game_field->core.reason_player = peffect->get_handler_player();
pduel->game_field->core.not_material = not_material;
int32 res = pduel->lua->check_condition(peffect->condition, 4);
pduel->game_field->restore_lp_cost();
pduel->game_field->core.reason_effect = oreason;
pduel->game_field->core.reason_player = op;
pduel->game_field->core.not_material = 0;
Expand Down
19 changes: 8 additions & 11 deletions field.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ field::field(duel* pduel) {
infos.phase = 0;
infos.turn_player = 0;
for (int32 i = 0; i < 2; ++i) {
//cost[i].count = 0;
//cost[i].amount = 0;
cost[i].count = 0;
cost[i].amount = 0;
player[i].lp = 8000;
player[i].start_count = 5;
player[i].draw_count = 1;
Expand Down Expand Up @@ -2297,12 +2297,11 @@ int32 field::check_lp_cost(uint8 playerid, uint32 lp, uint32 must_pay) {
if(effect_replace_check(EFFECT_LPCOST_REPLACE, e))
return TRUE;
}
//cost[playerid].amount += val;
if(val <= player[playerid].lp)
cost[playerid].amount += val;
if(cost[playerid].amount <= player[playerid].lp)
return TRUE;
return FALSE;
}
/*
void field::save_lp_cost() {
for(uint8 playerid = 0; playerid < 2; ++playerid) {
if(cost[playerid].count < 8)
Expand All @@ -2317,7 +2316,6 @@ void field::restore_lp_cost() {
cost[playerid].amount = cost[playerid].lpstack[cost[playerid].count];
}
}
*/
uint32 field::get_field_counter(uint8 self, uint8 s, uint8 o, uint16 countertype) {
uint8 c = s;
uint32 count = 0;
Expand Down Expand Up @@ -2516,12 +2514,11 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32
pduel->lua->add_param(findex2, PARAM_TYPE_INDEX);
pduel->lua->add_param(min, PARAM_TYPE_INT);
pduel->lua->add_param(max, PARAM_TYPE_INT);
if(pduel->lua->check_condition(pcustom->target, 5)) {
pduel->restore_assumes();
return TRUE;
}
pduel->game_field->save_lp_cost();
int32 res = pduel->lua->check_condition(pcustom->target, 5);
pduel->game_field->restore_lp_cost();
pduel->restore_assumes();
return FALSE;
return res;
}
int32 playerid = pcard->current.controler;
int32 ct = get_spsummonable_count(pcard, playerid);
Expand Down
6 changes: 3 additions & 3 deletions field.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ class field {
player_info player[2];
card* temp_card;
field_info infos;
//lpcost cost[2];
lpcost cost[2];
field_effect effects;
processor core;
return_value returns;
Expand Down Expand Up @@ -469,8 +469,8 @@ class field {
int32 check_spsummon_counter(uint8 playerid, uint8 ct = 1);

int32 check_lp_cost(uint8 playerid, uint32 cost, uint32 must_pay);
void save_lp_cost() {}
void restore_lp_cost() {}
void save_lp_cost();
void restore_lp_cost();
int32 pay_lp_cost(uint32 step, uint8 playerid, uint32 cost, uint32 must_pay);

uint32 get_field_counter(uint8 self, uint8 s, uint8 o, uint16 countertype);
Expand Down
1 change: 1 addition & 0 deletions operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ int32 field::pay_lp_cost(uint32 step, uint8 playerid, uint32 cost, uint32 must_p
effect* peffect = core.select_effects[returns.ivalue[0]];
if(!peffect) {
player[playerid].lp -= cost;
this->cost[playerid].amount -= cost;
pduel->write_buffer8(MSG_PAY_LPCOST);
pduel->write_buffer8(playerid);
pduel->write_buffer32(cost);
Expand Down
8 changes: 4 additions & 4 deletions processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,10 @@ int32 field::execute_operation(uint16 step, effect * triggering_effect, uint8 tr
shuffle(0, LOCATION_DECK);
if(core.shuffle_deck_check[1])
shuffle(1, LOCATION_DECK);
//cost[0].count = 0;
//cost[1].count = 0;
//cost[0].amount = 0;
//cost[1].amount = 0;
cost[0].count = 0;
cost[1].count = 0;
cost[0].amount = 0;
cost[1].amount = 0;
}
core.shuffle_check_disabled = (uint8)core.units.begin()->arg2;
return TRUE;
Expand Down