Commit 90baf203 authored by mercury233's avatar mercury233

update sum_param

parent bf2339ce
...@@ -2864,12 +2864,20 @@ int32 field::check_tribute(card* pcard, int32 min, int32 max, group* mg, uint8 t ...@@ -2864,12 +2864,20 @@ int32 field::check_tribute(card* pcard, int32 min, int32 max, group* mg, uint8 t
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
static void get_sum_params(uint32 sum_param, int32& op1, int32& op2) {
op1 = sum_param & 0xffff;
op2 = (sum_param >> 16) & 0xffff;
if(op2 & 0x8000) {
op1 = sum_param & 0x7fffffff;
op2 = 0;
}
}
int32 field::check_with_sum_limit(const card_vector& mats, int32 acc, int32 index, int32 count, int32 min, int32 max, int32 opmin) { int32 field::check_with_sum_limit(const card_vector& mats, int32 acc, int32 index, int32 count, int32 min, int32 max, int32 opmin) {
if(count > max) if(count > max)
return FALSE; return FALSE;
while(index < (int32)mats.size()) { while(index < (int32)mats.size()) {
int32 op1 = mats[index]->sum_param & 0xffff; int32 op1, op2;
int32 op2 = (mats[index]->sum_param >> 16) & 0xffff; get_sum_params(mats[index]->sum_param, op1, op2);
if(((op1 == acc && acc + opmin > op1) || (op2 && op2 == acc && acc + opmin > op2)) && count >= min) if(((op1 == acc && acc + opmin > op1) || (op2 && op2 == acc && acc + opmin > op2)) && count >= min)
return TRUE; return TRUE;
index++; index++;
...@@ -2887,8 +2895,9 @@ int32 field::check_with_sum_limit_m(const card_vector& mats, int32 acc, int32 in ...@@ -2887,8 +2895,9 @@ int32 field::check_with_sum_limit_m(const card_vector& mats, int32 acc, int32 in
return check_with_sum_limit(mats, acc, index, 1, min, max, opmin); return check_with_sum_limit(mats, acc, index, 1, min, max, opmin);
if(index >= (int32)mats.size()) if(index >= (int32)mats.size())
return FALSE; return FALSE;
int32 op1 = mats[index]->sum_param & 0xffff; int32 op1;
int32 op2 = (mats[index]->sum_param >> 16) & 0xffff; int32 op2;
get_sum_params(mats[index]->sum_param, op1, op2);
if(acc >= op1 && check_with_sum_limit_m(mats, acc - op1, index + 1, min, max, std::min(opmin, op1), must_count)) if(acc >= op1 && check_with_sum_limit_m(mats, acc - op1, index + 1, min, max, std::min(opmin, op1), must_count))
return TRUE; return TRUE;
if(op2 && acc >= op2 && check_with_sum_limit_m(mats, acc - op2, index + 1, min, max, std::min(opmin, op2), must_count)) if(op2 && acc >= op2 && check_with_sum_limit_m(mats, acc - op2, index + 1, min, max, std::min(opmin, op2), must_count))
...@@ -2897,8 +2906,9 @@ int32 field::check_with_sum_limit_m(const card_vector& mats, int32 acc, int32 in ...@@ -2897,8 +2906,9 @@ int32 field::check_with_sum_limit_m(const card_vector& mats, int32 acc, int32 in
} }
int32 field::check_with_sum_greater_limit(const card_vector& mats, int32 acc, int32 index, int32 opmin) { int32 field::check_with_sum_greater_limit(const card_vector& mats, int32 acc, int32 index, int32 opmin) {
while(index < (int32)mats.size()) { while(index < (int32)mats.size()) {
int32 op1 = mats[index]->sum_param & 0xffff; int32 op1;
int32 op2 = (mats[index]->sum_param >> 16) & 0xffff; int32 op2;
get_sum_params(mats[index]->sum_param, op1, op2);
if((acc <= op1 && acc + opmin > op1) || (op2 && acc <= op2 && acc + opmin > op2)) if((acc <= op1 && acc + opmin > op1) || (op2 && acc <= op2 && acc + opmin > op2))
return TRUE; return TRUE;
index++; index++;
...@@ -2916,8 +2926,9 @@ int32 field::check_with_sum_greater_limit_m(const card_vector& mats, int32 acc, ...@@ -2916,8 +2926,9 @@ int32 field::check_with_sum_greater_limit_m(const card_vector& mats, int32 acc,
return check_with_sum_greater_limit(mats, acc, index, opmin); return check_with_sum_greater_limit(mats, acc, index, opmin);
if(index >= (int32)mats.size()) if(index >= (int32)mats.size())
return FALSE; return FALSE;
int32 op1 = mats[index]->sum_param & 0xffff; int32 op1;
int32 op2 = (mats[index]->sum_param >> 16) & 0xffff; int32 op2;
get_sum_params(mats[index]->sum_param, op1, op2);
if(check_with_sum_greater_limit_m(mats, acc - op1, index + 1, std::min(opmin, op1), must_count)) if(check_with_sum_greater_limit_m(mats, acc - op1, index + 1, std::min(opmin, op1), must_count))
return TRUE; return TRUE;
if(op2 && check_with_sum_greater_limit_m(mats, acc - op2, index + 1, std::min(opmin, op2), must_count)) if(op2 && check_with_sum_greater_limit_m(mats, acc - op2, index + 1, std::min(opmin, op2), must_count))
......
...@@ -605,11 +605,19 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin ...@@ -605,11 +605,19 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin
} }
return TRUE; return TRUE;
} }
static void get_sum_params(int32 sum_param, int32& op1, int32& op2) {
op1 = sum_param & 0xffff;
op2 = (sum_param >> 16) & 0xffff;
if(op2 & 0x8000) {
op1 = sum_param & 0x7fffffff;
op2 = 0;
}
}
static int32 select_sum_check1(const int32* oparam, int32 size, int32 index, int32 acc, int32 opmin) { static int32 select_sum_check1(const int32* oparam, int32 size, int32 index, int32 acc, int32 opmin) {
if(acc == 0 || index == size) if(acc == 0 || index == size)
return FALSE; return FALSE;
int32 o1 = oparam[index] & 0xffff; int32 o1, o2;
int32 o2 = oparam[index] >> 16; get_sum_params(oparam[index], o1, o2);
if(index == size - 1) if(index == size - 1)
return (acc == o1 && acc + opmin > o1) || (o2 && acc == o2 && acc + opmin > o2); return (acc == o1 && acc + opmin > o1) || (o2 && acc == o2 && acc + opmin > o2);
return (acc > o1 && select_sum_check1(oparam, size, index + 1, acc - o1, std::min(o1, opmin))) return (acc > o1 && select_sum_check1(oparam, size, index + 1, acc - o1, std::min(o1, opmin)))
...@@ -628,7 +636,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 ...@@ -628,7 +636,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
if(max < min) if(max < min)
max = min; max = min;
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
pduel->write_buffer32(acc & 0xffff); pduel->write_buffer32(acc);
pduel->write_buffer8(min); pduel->write_buffer8(min);
pduel->write_buffer8(max); pduel->write_buffer8(max);
pduel->write_buffer8((uint8)core.must_select_cards.size()); pduel->write_buffer8((uint8)core.must_select_cards.size());
...@@ -679,9 +687,8 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 ...@@ -679,9 +687,8 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
int32 mcount = (int32)core.must_select_cards.size(); int32 mcount = (int32)core.must_select_cards.size();
int32 sum = 0, mx = 0, mn = 0x7fffffff; int32 sum = 0, mx = 0, mn = 0x7fffffff;
for(int32 i = 0; i < mcount; ++i) { for(int32 i = 0; i < mcount; ++i) {
int32 op = core.must_select_cards[i]->sum_param; int32 o1, o2;
int32 o1 = op & 0xffff; get_sum_params(core.must_select_cards[i]->sum_param, o1, o2);
int32 o2 = op >> 16;
int32 ms = (o2 && o2 < o1) ? o2 : o1; int32 ms = (o2 && o2 < o1) ? o2 : o1;
sum += ms; sum += ms;
mx += (o2 > o1) ? o2 : o1; mx += (o2 > o1) ? o2 : o1;
...@@ -696,9 +703,8 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 ...@@ -696,9 +703,8 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
return FALSE; return FALSE;
} }
c.insert(v); c.insert(v);
int32 op = core.select_cards[v]->sum_param; int32 o1, o2;
int32 o1 = op & 0xffff; get_sum_params(core.select_cards[v]->sum_param, o1, o2);
int32 o2 = op >> 16;
int32 ms = (o2 && o2 < o1) ? o2 : o1; int32 ms = (o2 && o2 < o1) ? o2 : o1;
sum += ms; sum += ms;
mx += (o2 > o1) ? o2 : o1; mx += (o2 > o1) ? o2 : o1;
......
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