Commit 1422a8d7 authored by Argon.Sun's avatar Argon.Sun

merge master

parents f3fa58dd 86121c09
This diff is collapsed.
...@@ -12,12 +12,14 @@ ...@@ -12,12 +12,14 @@
#include "effectset.h" #include "effectset.h"
#include <set> #include <set>
#include <map> #include <map>
#include <unordered_set>
#include <unordered_map> #include <unordered_map>
class card; class card;
class duel; class duel;
class effect; class effect;
class group; class group;
struct chain;
struct card_state { struct card_state {
uint32 code; uint32 code;
...@@ -64,14 +66,22 @@ struct query_cache { ...@@ -64,14 +66,22 @@ struct query_cache {
class card { class card {
public: public:
struct effect_relation_hash {
inline std::size_t operator()(const std::pair<effect*, uint16>& v) const {
return std::hash<uint16>()(v.second);
}
};
typedef std::vector<card*> card_vector; typedef std::vector<card*> card_vector;
typedef std::multimap<uint32, effect*> effect_container; typedef std::multimap<uint32, effect*> effect_container;
typedef std::set<card*, card_sort> card_set; typedef std::set<card*, card_sort> card_set;
typedef std::unordered_map<effect*, effect_container::iterator> effect_indexer; typedef std::unordered_map<effect*, effect_container::iterator> effect_indexer;
typedef std::unordered_map<effect*, uint32> effect_relation; typedef std::unordered_set<std::pair<effect*, uint16>, effect_relation_hash> effect_relation;
typedef std::unordered_map<card*, uint32> relation_map; typedef std::unordered_map<card*, uint32> relation_map;
typedef std::map<uint16, uint16> counter_map; typedef std::map<uint16, std::array<uint16, 2> > counter_map;
typedef std::unordered_map<uint16, card*> attacker_map; class attacker_map : public std::unordered_map<uint16, std::pair<card*, uint32> > {
public:
void addcard(card* pcard);
} ;
int32 scrtype; int32 scrtype;
int32 ref_handle; int32 ref_handle;
duel* pduel; duel* pduel;
...@@ -133,6 +143,7 @@ public: ...@@ -133,6 +143,7 @@ public:
uint32 get_another_code(); uint32 get_another_code();
int32 is_set_card(uint32 set_code); int32 is_set_card(uint32 set_code);
int32 is_pre_set_card(uint32 set_code); int32 is_pre_set_card(uint32 set_code);
int32 is_fusion_set_card(uint32 set_code);
uint32 get_type(); uint32 get_type();
int32 get_base_attack(uint8 swap = FALSE); int32 get_base_attack(uint8 swap = FALSE);
int32 get_attack(); int32 get_attack();
...@@ -166,6 +177,7 @@ public: ...@@ -166,6 +177,7 @@ public:
void remove_effect(effect* peffect); void remove_effect(effect* peffect);
void remove_effect(effect* peffect, effect_container::iterator it); void remove_effect(effect* peffect, effect_container::iterator it);
int32 copy_effect(uint32 code, uint32 reset, uint32 count); int32 copy_effect(uint32 code, uint32 reset, uint32 count);
int32 replace_effect(uint32 code, uint32 reset, uint32 count);
void reset(uint32 id, uint32 reset_type); void reset(uint32 id, uint32 reset_type);
void reset_effect_count(); void reset_effect_count();
int32 refresh_disable_status(); int32 refresh_disable_status();
...@@ -173,10 +185,14 @@ public: ...@@ -173,10 +185,14 @@ public:
void count_turn(uint16 ct); void count_turn(uint16 ct);
void create_relation(card* target, uint32 reset); void create_relation(card* target, uint32 reset);
void create_relation(effect* peffect);
int32 is_has_relation(card* target); int32 is_has_relation(card* target);
int32 is_has_relation(effect* peffect);
void release_relation(card* target); void release_relation(card* target);
void create_relation(const chain& ch);
int32 is_has_relation(const chain& ch);
void release_relation(const chain& ch);
void clear_relate_effect();
void create_relation(effect* peffect);
int32 is_has_relation(effect* peffect);
void release_relation(effect* peffect); void release_relation(effect* peffect);
int32 leave_field_redirect(uint32 reason); int32 leave_field_redirect(uint32 reason);
int32 destination_redirect(uint8 destination, uint32 reason); int32 destination_redirect(uint8 destination, uint32 reason);
......
...@@ -78,7 +78,9 @@ struct card_data { ...@@ -78,7 +78,9 @@ struct card_data {
#define POS_FACEDOWN 0xa #define POS_FACEDOWN 0xa
#define POS_ATTACK 0x3 #define POS_ATTACK 0x3
#define POS_DEFENCE 0xc #define POS_DEFENCE 0xc
//Flip effect flags
#define NO_FLIP_EFFECT 0x10000 #define NO_FLIP_EFFECT 0x10000
#define FLIP_SET_AVAILABLE 0x20000
//Types //Types
#define TYPE_MONSTER 0x1 // #define TYPE_MONSTER 0x1 //
#define TYPE_SPELL 0x2 // #define TYPE_SPELL 0x2 //
...@@ -136,7 +138,7 @@ struct card_data { ...@@ -136,7 +138,7 @@ struct card_data {
#define RACE_PSYCHO 0x100000 // #define RACE_PSYCHO 0x100000 //
#define RACE_DEVINE 0x200000 // #define RACE_DEVINE 0x200000 //
#define RACE_CREATORGOD 0x400000 // #define RACE_CREATORGOD 0x400000 //
#define RACE_PHANTOMDRAGON 0x800000 // #define RACE_PHANTOMDRAGON 0x800000 //
//Reason //Reason
#define REASON_DESTROY 0x1 // #define REASON_DESTROY 0x1 //
#define REASON_RELEASE 0x2 // #define REASON_RELEASE 0x2 //
...@@ -173,6 +175,7 @@ struct card_data { ...@@ -173,6 +175,7 @@ struct card_data {
#define SUMMON_TYPE_RITUAL 0x45000000 #define SUMMON_TYPE_RITUAL 0x45000000
#define SUMMON_TYPE_SYNCHRO 0x46000000 #define SUMMON_TYPE_SYNCHRO 0x46000000
#define SUMMON_TYPE_XYZ 0x49000000 #define SUMMON_TYPE_XYZ 0x49000000
#define SUMMON_TYPE_PENDULUM 0x4a000000
//Status //Status
#define STATUS_DISABLED 0x0001 // #define STATUS_DISABLED 0x0001 //
#define STATUS_TO_ENABLE 0x0002 // #define STATUS_TO_ENABLE 0x0002 //
...@@ -180,8 +183,8 @@ struct card_data { ...@@ -180,8 +183,8 @@ struct card_data {
#define STATUS_PROC_COMPLETE 0x0008 // #define STATUS_PROC_COMPLETE 0x0008 //
#define STATUS_SET_TURN 0x0010 // #define STATUS_SET_TURN 0x0010 //
#define STATUS_NO_LEVEL 0x0020 // #define STATUS_NO_LEVEL 0x0020 //
#define STATUS_REVIVE_LIMIT 0x0040 // #define STATUS_SET_AVAILABLE 0x0040 //
#define STATUS_ATTACKED 0x0080 // #define STATUS_SPSUMMON_STEP 0x0080 //
#define STATUS_FORM_CHANGED 0x0100 // #define STATUS_FORM_CHANGED 0x0100 //
#define STATUS_SUMMONING 0x0200 // #define STATUS_SUMMONING 0x0200 //
#define STATUS_EFFECT_ENABLED 0x0400 // #define STATUS_EFFECT_ENABLED 0x0400 //
...@@ -193,14 +196,19 @@ struct card_data { ...@@ -193,14 +196,19 @@ struct card_data {
#define STATUS_CHAINING 0x10000 // #define STATUS_CHAINING 0x10000 //
#define STATUS_SUMMON_DISABLED 0x20000 // #define STATUS_SUMMON_DISABLED 0x20000 //
#define STATUS_ACTIVATE_DISABLED 0x40000 // #define STATUS_ACTIVATE_DISABLED 0x40000 //
#define STATUS_UNSUMMONABLE_CARD 0x80000 // #define STATUS_EFFECT_REPLACED 0x80000
#define STATUS_UNION 0x100000 #define STATUS_UNION 0x100000
#define STATUS_ATTACK_CANCELED 0x200000 #define STATUS_ATTACK_CANCELED 0x200000
#define STATUS_INITIALIZING 0x400000 #define STATUS_INITIALIZING 0x400000
#define STATUS_ACTIVATED 0x800000 #define STATUS_ACTIVATED 0x800000
#define STATUS_JUST_POS 0x1000000 #define STATUS_JUST_POS 0x1000000
#define STATUS_CONTINUOUS_POS 0x2000000 #define STATUS_CONTINUOUS_POS 0x2000000
//#define STATUS_IS_PUBLIC 0x4000000
#define STATUS_ACT_FROM_HAND 0x8000000 #define STATUS_ACT_FROM_HAND 0x8000000
#define STATUS_OPPO_BATTLE 0x10000000
#define STATUS_FLIP_SUMMON_TURN 0x20000000
#define STATUS_SPSUMMON_TURN 0x40000000
//Counter //Counter
#define COUNTER_NEED_PERMIT 0x1000 #define COUNTER_NEED_PERMIT 0x1000
#define COUNTER_NEED_ENABLE 0x2000 #define COUNTER_NEED_ENABLE 0x2000
...@@ -370,20 +378,22 @@ struct card_data { ...@@ -370,20 +378,22 @@ struct card_data {
#define PLAYER_ALL 3 // #define PLAYER_ALL 3 //
//Phase //Phase
#define PHASE_DRAW 0x01 // #define PHASE_DRAW 0x01
#define PHASE_STANDBY 0x02 // #define PHASE_STANDBY 0x02
#define PHASE_MAIN1 0x04 // #define PHASE_MAIN1 0x04
#define PHASE_BATTLE 0x08 // #define PHASE_BATTLE_START 0x08
#define PHASE_DAMAGE 0x10 // #define PHASE_BATTLE_STEP 0x10
#define PHASE_DAMAGE_CAL 0x20 // #define PHASE_DAMAGE 0x20
#define PHASE_MAIN2 0x40 // #define PHASE_DAMAGE_CAL 0x40
#define PHASE_END 0x80 // #define PHASE_BATTLE 0x80
#define PHASE_MAIN2 0x100
#define PHASE_END 0x200
//Options //Options
#define DUEL_TEST_MODE 0x01 #define DUEL_TEST_MODE 0x01
#define DUEL_ATTACK_FIRST_TURN 0x02 #define DUEL_ATTACK_FIRST_TURN 0x02
#define DUEL_NO_CHAIN_HINT 0x04 #define DUEL_NO_CHAIN_HINT 0x04
#define DUEL_ENABLE_PRIORITY 0x08 #define DUEL_OBSOLETE_RULING 0x08
#define DUEL_PSEUDO_SHUFFLE 0x10 #define DUEL_PSEUDO_SHUFFLE 0x10
#define DUEL_TAG_MODE 0x20 #define DUEL_TAG_MODE 0x20
#define DUEL_SIMPLE_AI 0x40 #define DUEL_SIMPLE_AI 0x40
......
...@@ -71,25 +71,4 @@ private: ...@@ -71,25 +71,4 @@ private:
group* register_group(group* pgroup); group* register_group(group* pgroup);
}; };
//Player
#define PLAYER_NONE 2 //
#define PLAYER_ALL 3 //
//Phase
#define PHASE_DRAW 0x01 //
#define PHASE_STANDBY 0x02 //
#define PHASE_MAIN1 0x04 //
#define PHASE_BATTLE 0x08 //
#define PHASE_DAMAGE 0x10 //
#define PHASE_DAMAGE_CAL 0x20 //
#define PHASE_MAIN2 0x40 //
#define PHASE_END 0x80 //
//Options
#define DUEL_TEST_MODE 0x01
#define DUEL_ATTACK_FIRST_TURN 0x02
#define DUEL_NO_CHAIN_HINT 0x04
#define DUEL_OBSOLETE_RULING 0x08
#define DUEL_PSEUDO_SHUFFLE 0x10
#define DUEL_TAG_MODE 0x20
#define DUEL_SIMPLE_AI 0x40
#endif /* DUEL_H_ */ #endif /* DUEL_H_ */
...@@ -57,7 +57,7 @@ int32 effect::is_disable_related() { ...@@ -57,7 +57,7 @@ int32 effect::is_disable_related() {
return TRUE; return TRUE;
return FALSE; return FALSE;
} }
// check if a single/field/field effect is available // check if a single/field/equip effect is available
// check range, EFFECT_FLAG_OWNER_RELATE, STATUS_BATTLE_DESTROYED, STATUS_EFFECT_ENABLED // check range, EFFECT_FLAG_OWNER_RELATE, STATUS_BATTLE_DESTROYED, STATUS_EFFECT_ENABLED
int32 effect::is_available() { int32 effect::is_available() {
if (type & EFFECT_TYPE_ACTIONS) if (type & EFFECT_TYPE_ACTIONS)
...@@ -207,17 +207,24 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con ...@@ -207,17 +207,24 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
if(handler->is_affected_by_effect(EFFECT_CANNOT_TRIGGER)) if(handler->is_affected_by_effect(EFFECT_CANNOT_TRIGGER))
return FALSE; return FALSE;
} else if(!(type & EFFECT_TYPE_CONTINUOUS)) { } else if(!(type & EFFECT_TYPE_CONTINUOUS)) {
if((handler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED)) && (code != EVENT_FLIP && !(is_flag(EFFECT_FLAG_SET_AVAILABLE))) if((handler->data.type & TYPE_MONSTER) && (handler->current.location & LOCATION_SZONE)
&& !in_range(handler->current.location, handler->current.sequence))
return FALSE;
// effects with EFFECT_FLAG_SET_AVAILABLE can be activated while face-down
if((handler->current.location & (LOCATION_ONFIELD | LOCATION_REMOVED))
&& !is_flag(EFFECT_FLAG_SET_AVAILABLE)
&& (code != EVENT_FLIP || !(e.event_value & (FLIP_SET_AVAILABLE >> 16)))
&& (!handler->is_position(POS_FACEUP) || !handler->is_status(STATUS_EFFECT_ENABLED))) && (!handler->is_position(POS_FACEUP) || !handler->is_status(STATUS_EFFECT_ENABLED)))
return FALSE; return FALSE;
if(!(type & (EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_F)) if(!(type & (EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_F))
&& !((type & EFFECT_TYPE_SINGLE) && !((type & EFFECT_TYPE_SINGLE) && (code == EVENT_TO_GRAVE || code == EVENT_DESTROYED || code == EVENT_SPSUMMON_SUCCESS || code == EVENT_TO_HAND))) {
&& (code == EVENT_TO_GRAVE || code == EVENT_DESTROYED || code == EVENT_SPSUMMON_SUCCESS || code == EVENT_TO_HAND))) {
if((code < 1132 || code > 1149) && pduel->game_field->infos.phase == PHASE_DAMAGE && !(is_flag(EFFECT_FLAG_DAMAGE_STEP))) if((code < 1132 || code > 1149) && pduel->game_field->infos.phase == PHASE_DAMAGE && !(is_flag(EFFECT_FLAG_DAMAGE_STEP)))
return FALSE; return FALSE;
if((code < 1134 || code > 1136) && pduel->game_field->infos.phase == PHASE_DAMAGE_CAL && !(is_flag(EFFECT_FLAG_DAMAGE_CAL))) if((code < 1134 || code > 1136) && pduel->game_field->infos.phase == PHASE_DAMAGE_CAL && !(is_flag(EFFECT_FLAG_DAMAGE_CAL)))
return FALSE; return FALSE;
} }
if(handler->current.location == LOCATION_OVERLAY)
return FALSE;
if((type & EFFECT_TYPE_FIELD) && (handler->current.controler != playerid) && !(is_flag(EFFECT_FLAG_BOTH_SIDE))) if((type & EFFECT_TYPE_FIELD) && (handler->current.controler != playerid) && !(is_flag(EFFECT_FLAG_BOTH_SIDE)))
return FALSE; return FALSE;
if(handler->is_affected_by_effect(EFFECT_FORBIDDEN)) if(handler->is_affected_by_effect(EFFECT_FORBIDDEN))
...@@ -502,7 +509,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) { ...@@ -502,7 +509,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
uint8 pid = get_handler_player(); uint8 pid = get_handler_player();
uint8 tp = handler->pduel->game_field->infos.turn_player; uint8 tp = handler->pduel->game_field->infos.turn_player;
if((((reset_flag & RESET_SELF_TURN) && pid == tp) || ((reset_flag & RESET_OPPO_TURN) && pid != tp)) if((((reset_flag & RESET_SELF_TURN) && pid == tp) || ((reset_flag & RESET_OPPO_TURN) && pid != tp))
&& (reset_level & 0xff & reset_flag)) && (reset_level & 0x3ff & reset_flag))
reset_count--; reset_count--;
if((reset_count & 0xff) == 0) if((reset_count & 0xff) == 0)
return TRUE; return TRUE;
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include <vector> #include <vector>
#include <map> #include <map>
using namespace std;
class card; class card;
class duel; class duel;
class group; class group;
...@@ -24,8 +22,8 @@ class effect; ...@@ -24,8 +22,8 @@ class effect;
struct tevent; struct tevent;
struct effect_set; struct effect_set;
struct effect_set_v; struct effect_set_v;
enum effect_flag; enum effect_flag : uint32;
enum effect_flag2; enum effect_flag2 : uint32;
class effect { class effect {
public: public:
...@@ -104,18 +102,10 @@ public: ...@@ -104,18 +102,10 @@ public:
#define EFFECT_COUNT_CODE_DUEL 0x20000000 #define EFFECT_COUNT_CODE_DUEL 0x20000000
//========== Reset ========== //========== Reset ==========
#define RESET_DRAW PHASE_DRAW #define RESET_SELF_TURN 0x10000000
#define RESET_STANDBY PHASE_STANDBY #define RESET_OPPO_TURN 0x20000000
#define RESET_MAIN1 PHASE_MAIN1 #define RESET_PHASE 0x40000000
#define RESET_BATTLE PHASE_BATTLE #define RESET_CHAIN 0x80000000
#define RESET_DAMAGE PHASE_DAMAGE
#define RESET_DAMAGE_CAL PHASE_DAMAGE_CAL
#define RESET_MAIN2 PHASE_MAIN2
#define RESET_END PHASE_END
#define RESET_SELF_TURN 0x0100
#define RESET_OPPO_TURN 0x0200
#define RESET_PHASE 0x0400
#define RESET_CHAIN 0x0800
#define RESET_EVENT 0x1000 #define RESET_EVENT 0x1000
#define RESET_CARD 0x2000 #define RESET_CARD 0x2000
#define RESET_CODE 0x4000 #define RESET_CODE 0x4000
...@@ -149,7 +139,7 @@ public: ...@@ -149,7 +139,7 @@ public:
#define EFFECT_TYPE_CONTINUOUS 0x0800 // #define EFFECT_TYPE_CONTINUOUS 0x0800 //
//========== Flags ========== //========== Flags ==========
enum effect_flag { enum effect_flag : uint32 {
EFFECT_FLAG_INITIAL = 0x0001, EFFECT_FLAG_INITIAL = 0x0001,
EFFECT_FLAG_FUNC_VALUE = 0x0002, EFFECT_FLAG_FUNC_VALUE = 0x0002,
EFFECT_FLAG_COUNT_LIMIT = 0x0004, EFFECT_FLAG_COUNT_LIMIT = 0x0004,
...@@ -183,7 +173,7 @@ enum effect_flag { ...@@ -183,7 +173,7 @@ enum effect_flag {
EFFECT_FLAG_CVAL_CHECK = 0x40000000, EFFECT_FLAG_CVAL_CHECK = 0x40000000,
EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000, EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000,
}; };
enum effect_flag2 { enum effect_flag2 : uint32 {
EFFECT_FLAG2_NAGA = 0x0001, EFFECT_FLAG2_NAGA = 0x0001,
EFFECT_FLAG2_COF = 0x0002, EFFECT_FLAG2_COF = 0x0002,
}; };
...@@ -402,6 +392,8 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -402,6 +392,8 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EFFECT_DISABLE_CHAIN_FIELD 337 #define EFFECT_DISABLE_CHAIN_FIELD 337
#define EFFECT_DISCARD_COST_CHANGE 338 #define EFFECT_DISCARD_COST_CHANGE 338
#define EFFECT_HAND_SYNCHRO 339 #define EFFECT_HAND_SYNCHRO 339
#define EFFECT_ADD_FUSION_CODE 340
#define EFFECT_ADD_FUSION_SETCODE 341
#define EVENT_STARTUP 1000 #define EVENT_STARTUP 1000
#define EVENT_FLIP 1001 #define EVENT_FLIP 1001
...@@ -468,7 +460,6 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2) ...@@ -468,7 +460,6 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EVENT_TURN_END 1210 #define EVENT_TURN_END 1210
#define EVENT_PHASE 0x1000 #define EVENT_PHASE 0x1000
#define EVENT_PHASE_START 0x2000 #define EVENT_PHASE_START 0x2000
#define EVENT_PHASE_PRESTART 0x2100
#define EVENT_ADD_COUNTER 0x10000 #define EVENT_ADD_COUNTER 0x10000
#define EVENT_REMOVE_COUNTER 0x20000 #define EVENT_REMOVE_COUNTER 0x20000
......
This diff is collapsed.
...@@ -113,7 +113,7 @@ struct field_info { ...@@ -113,7 +113,7 @@ struct field_info {
int16 copy_id; int16 copy_id;
int16 turn_id; int16 turn_id;
int16 card_id; int16 card_id;
uint8 phase; uint16 phase;
uint8 turn_player; uint8 turn_player;
uint8 priorities[2]; uint8 priorities[2];
uint8 can_shuffle; uint8 can_shuffle;
...@@ -162,6 +162,7 @@ struct processor { ...@@ -162,6 +162,7 @@ struct processor {
card_vector attackable_cards; card_vector attackable_cards;
effect_vector select_effects; effect_vector select_effects;
option_vector select_options; option_vector select_options;
card_vector must_select_cards;
event_list point_event; event_list point_event;
event_list instant_event; event_list instant_event;
event_list queue_event; event_list queue_event;
...@@ -245,8 +246,10 @@ struct processor { ...@@ -245,8 +246,10 @@ struct processor {
card* attack_target; card* attack_target;
card* sub_attack_target; card* sub_attack_target;
card* limit_tuner; card* limit_tuner;
group* limit_xyz;
group* limit_syn; group* limit_syn;
group* limit_xyz;
int32 limit_xyz_minc;
int32 limit_xyz_maxc;
uint8 attack_cancelable; uint8 attack_cancelable;
uint8 attack_rollback; uint8 attack_rollback;
uint8 effect_damage_step; uint8 effect_damage_step;
...@@ -363,7 +366,7 @@ public: ...@@ -363,7 +366,7 @@ public:
int32 get_draw_count(uint8 playerid); int32 get_draw_count(uint8 playerid);
void get_ritual_material(uint8 playerid, effect* peffect, card_set* material); void get_ritual_material(uint8 playerid, effect* peffect, card_set* material);
void ritual_release(card_set* material); void ritual_release(card_set* material);
void get_xyz_material(card* scard, int32 findex, uint32 lv, int32 maxc); void get_xyz_material(card* scard, int32 findex, uint32 lv, int32 maxc, group* mg);
void get_overlay_group(uint8 self, uint8 s, uint8 o, card_set* pset); void get_overlay_group(uint8 self, uint8 s, uint8 o, card_set* pset);
int32 get_overlay_count(uint8 self, uint8 s, uint8 o); int32 get_overlay_count(uint8 self, uint8 s, uint8 o);
void update_disable_check_list(effect* peffect); void update_disable_check_list(effect* peffect);
...@@ -390,7 +393,8 @@ public: ...@@ -390,7 +393,8 @@ public:
void attack_all_target_check(); void attack_all_target_check();
int32 check_synchro_material(card* pcard, int32 findex1, int32 findex2, int32 min, int32 max, card* smat, group* mg); int32 check_synchro_material(card* pcard, int32 findex1, int32 findex2, int32 min, int32 max, card* smat, group* mg);
int32 check_tuner_material(card* pcard, card* tuner, int32 findex1, int32 findex2, int32 min, int32 max, card* smat, group* mg); int32 check_tuner_material(card* pcard, card* tuner, int32 findex1, int32 findex2, int32 min, int32 max, card* smat, group* mg);
int32 check_with_sum_limit(card_vector* mats, int32 acc, int32 index, int32 count, int32 min, int32 max); static int32 check_with_sum_limit(const card_vector& mats, int32 acc, int32 index, int32 count, int32 min, int32 max);
static int32 check_with_sum_limit_m(const card_vector& mats, int32 acc, int32 index, int32 min, int32 max, int32 must_count);
int32 check_xyz_material(card* pcard, int32 findex, int32 lv, int32 min, int32 max, group* mg); int32 check_xyz_material(card* pcard, int32 findex, int32 lv, int32 min, int32 max, group* mg);
int32 is_player_can_draw(uint8 playerid); int32 is_player_can_draw(uint8 playerid);
...@@ -479,8 +483,8 @@ public: ...@@ -479,8 +483,8 @@ public:
void send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position); void send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position);
void send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position); void send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position);
void move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = FALSE, uint32 is_equip = FALSE); void move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = FALSE, uint32 is_equip = FALSE);
void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 noflip, uint32 enable = FALSE); void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE);
void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 noflip, uint32 enable = FALSE); void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE);
int32 remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 countertype, uint16 count); int32 remove_counter(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 countertype, uint16 count);
int32 remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 min, uint16 max); int32 remove_overlay_card(uint16 step, uint32 reason, card* pcard, uint8 rplayer, uint8 s, uint8 o, uint16 min, uint16 max);
...@@ -532,7 +536,7 @@ public: ...@@ -532,7 +536,7 @@ public:
int32 sort_card(int16 step, uint8 playerid, uint8 is_chain); int32 sort_card(int16 step, uint8 playerid, uint8 is_chain);
int32 announce_race(int16 step, uint8 playerid, int32 count, int32 available); int32 announce_race(int16 step, uint8 playerid, int32 count, int32 available);
int32 announce_attribute(int16 step, uint8 playerid, int32 count, int32 available); int32 announce_attribute(int16 step, uint8 playerid, int32 count, int32 available);
int32 announce_card(int16 step, uint8 playerid); int32 announce_card(int16 step, uint8 playerid, uint32 ttype);
int32 announce_number(int16 step, uint8 playerid); int32 announce_number(int16 step, uint8 playerid);
}; };
...@@ -558,6 +562,35 @@ public: ...@@ -558,6 +562,35 @@ public:
#define CHAININFO_TYPE 0x1000 #define CHAININFO_TYPE 0x1000
#define CHAININFO_EXTTYPE 0x2000 #define CHAININFO_EXTTYPE 0x2000
//Timing
#define TIMING_DRAW_PHASE 0x1
#define TIMING_STANDBY_PHASE 0x2
#define TIMING_MAIN_END 0x4
#define TIMING_BATTLE_START 0x8
#define TIMING_BATTLE_END 0x10
#define TIMING_END_PHASE 0x20
#define TIMING_SUMMON 0x40
#define TIMING_SPSUMMON 0x80
#define TIMING_FLIPSUMMON 0x100
#define TIMING_MSET 0x200
#define TIMING_SSET 0x400
#define TIMING_POS_CHANGE 0x800
#define TIMING_ATTACK 0x1000
#define TIMING_DAMAGE_STEP 0x2000
#define TIMING_DAMAGE_CAL 0x4000
#define TIMING_CHAIN_END 0x8000
#define TIMING_DRAW 0x10000
#define TIMING_DAMAGE 0x20000
#define TIMING_RECOVER 0x40000
#define TIMING_DESTROY 0x80000
#define TIMING_REMOVE 0x100000
#define TIMING_TOHAND 0x200000
#define TIMING_TODECK 0x400000
#define TIMING_TOGRAVE 0x800000
#define TIMING_BATTLE_PHASE 0x1000000
#define TIMING_EQUIP 0x2000000
#define TIMING_BATTLE_STEP_END 0x4000000
#define GLOBALFLAG_DECK_REVERSE_CHECK 0x1 #define GLOBALFLAG_DECK_REVERSE_CHECK 0x1
#define GLOBALFLAG_BRAINWASHING_CHECK 0x2 #define GLOBALFLAG_BRAINWASHING_CHECK 0x2
#define GLOBALFLAG_SCRAP_CHIMERA 0x4 #define GLOBALFLAG_SCRAP_CHIMERA 0x4
......
...@@ -19,8 +19,11 @@ static const struct luaL_Reg cardlib[] = { ...@@ -19,8 +19,11 @@ static const struct luaL_Reg cardlib[] = {
{ "GetCode", scriptlib::card_get_code }, { "GetCode", scriptlib::card_get_code },
{ "GetOriginalCode", scriptlib::card_get_origin_code }, { "GetOriginalCode", scriptlib::card_get_origin_code },
{ "GetOriginalCodeRule", scriptlib::card_get_origin_code_rule }, { "GetOriginalCodeRule", scriptlib::card_get_origin_code_rule },
{ "GetFusionCode", scriptlib::card_get_fusion_code },
{ "IsFusionCode", scriptlib::card_is_fusion_code },
{ "IsSetCard", scriptlib::card_is_set_card }, { "IsSetCard", scriptlib::card_is_set_card },
{ "IsPreviousSetCard", scriptlib::card_is_pre_set_card }, { "IsPreviousSetCard", scriptlib::card_is_pre_set_card },
{ "IsFusionSetCard", scriptlib::card_is_fusion_set_card },
{ "GetType", scriptlib::card_get_type }, { "GetType", scriptlib::card_get_type },
{ "GetOriginalType", scriptlib::card_get_origin_type }, { "GetOriginalType", scriptlib::card_get_origin_type },
{ "GetLevel", scriptlib::card_get_level }, { "GetLevel", scriptlib::card_get_level },
...@@ -132,9 +135,11 @@ static const struct luaL_Reg cardlib[] = { ...@@ -132,9 +135,11 @@ static const struct luaL_Reg cardlib[] = {
{ "ReleaseEffectRelation", scriptlib::card_release_effect_relation }, { "ReleaseEffectRelation", scriptlib::card_release_effect_relation },
{ "ClearEffectRelation", scriptlib::card_clear_effect_relation }, { "ClearEffectRelation", scriptlib::card_clear_effect_relation },
{ "IsRelateToEffect", scriptlib::card_is_relate_to_effect }, { "IsRelateToEffect", scriptlib::card_is_relate_to_effect },
{ "IsRelateToChain", scriptlib::card_is_relate_to_chain },
{ "IsRelateToCard", scriptlib::card_is_relate_to_card }, { "IsRelateToCard", scriptlib::card_is_relate_to_card },
{ "IsRelateToBattle", scriptlib::card_is_relate_to_battle }, { "IsRelateToBattle", scriptlib::card_is_relate_to_battle },
{ "CopyEffect", scriptlib::card_copy_effect }, { "CopyEffect", scriptlib::card_copy_effect },
{ "ReplaceEffect", scriptlib::card_replace_effect },
{ "EnableUnsummonable", scriptlib::card_enable_unsummonable }, { "EnableUnsummonable", scriptlib::card_enable_unsummonable },
{ "EnableReviveLimit", scriptlib::card_enable_revive_limit }, { "EnableReviveLimit", scriptlib::card_enable_revive_limit },
{ "CompleteProcedure", scriptlib::card_complete_procedure }, { "CompleteProcedure", scriptlib::card_complete_procedure },
...@@ -672,15 +677,15 @@ int32 interpreter::load_card_script(uint32 code) { ...@@ -672,15 +677,15 @@ int32 interpreter::load_card_script(uint32 code) {
} }
void interpreter::add_param(void *param, int32 type, bool front) { void interpreter::add_param(void *param, int32 type, bool front) {
if(front) if(front)
params.push_front(make_pair(param, type)); params.push_front(std::make_pair(param, type));
else else
params.push_back(make_pair(param, type)); params.push_back(std::make_pair(param, type));
} }
void interpreter::add_param(ptr param, int32 type, bool front) { void interpreter::add_param(ptr param, int32 type, bool front) {
if(front) if(front)
params.push_front(make_pair((void*)param, type)); params.push_front(std::make_pair((void*)param, type));
else else
params.push_back(make_pair((void*)param, type)); params.push_back(std::make_pair((void*)param, type));
} }
void interpreter::push_param(lua_State* L, bool is_coroutine) { void interpreter::push_param(lua_State* L, bool is_coroutine) {
uint32 type; uint32 type;
...@@ -1015,7 +1020,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va ...@@ -1015,7 +1020,7 @@ int32 interpreter::call_coroutine(int32 f, uint32 param_count, uint32 * yield_va
return OPERATION_FAIL; return OPERATION_FAIL;
} }
call_depth++; call_depth++;
coroutines.insert(make_pair(f, rthread)); coroutines.insert(std::make_pair(f, rthread));
} else { } else {
rthread = it->second; rthread = it->second;
if(step == 0) { if(step == 0) {
......
...@@ -61,6 +61,50 @@ int32 scriptlib::card_get_origin_code_rule(lua_State *L) { ...@@ -61,6 +61,50 @@ int32 scriptlib::card_get_origin_code_rule(lua_State *L) {
} }
return 1; return 1;
} }
int32 scriptlib::card_get_fusion_code(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
lua_pushinteger(L, pcard->get_code());
int32 count = 1;
uint32 otcode = pcard->get_another_code();
if(otcode) {
lua_pushinteger(L, otcode);
count++;
}
effect_set eset;
pcard->filter_effect(EFFECT_ADD_FUSION_CODE, &eset);
for(int32 i = 0; i < eset.size(); ++i)
lua_pushinteger(L, eset[i]->get_value(pcard));
return count + eset.size();
}
int32 scriptlib::card_is_fusion_code(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
effect_set eset;
pcard->filter_effect(EFFECT_ADD_FUSION_CODE, &eset);
if(!eset.size())
return card_is_code(L);
uint32 code1 = pcard->get_code();
uint32 code2 = pcard->get_another_code();
std::unordered_set<uint32> fcode;
for(int32 i = 0; i < eset.size(); ++i)
fcode.insert(eset[i]->get_value(pcard));
uint32 count = lua_gettop(L) - 1;
uint32 result = FALSE;
for(uint32 i = 0; i < count; ++i) {
if(lua_isnil(L, i + 2))
continue;
uint32 tcode = lua_tointeger(L, i + 2);
if(code1 == tcode || (code2 && code2 == tcode) || fcode.find(tcode) != fcode.end()) {
result = TRUE;
break;
}
}
lua_pushboolean(L, result);
return 1;
}
int32 scriptlib::card_is_set_card(lua_State *L) { int32 scriptlib::card_is_set_card(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -77,6 +121,14 @@ int32 scriptlib::card_is_pre_set_card(lua_State *L) { ...@@ -77,6 +121,14 @@ int32 scriptlib::card_is_pre_set_card(lua_State *L) {
lua_pushboolean(L, pcard->is_pre_set_card(set_code)); lua_pushboolean(L, pcard->is_pre_set_card(set_code));
return 1; return 1;
} }
int32 scriptlib::card_is_fusion_set_card(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 set_code = lua_tointeger(L, 2);
lua_pushboolean(L, pcard->is_fusion_set_card(set_code));
return 1;
}
int32 scriptlib::card_get_type(lua_State *L) { int32 scriptlib::card_get_type(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -744,8 +796,8 @@ int32 scriptlib::card_get_attacked_group(lua_State *L) { ...@@ -744,8 +796,8 @@ int32 scriptlib::card_get_attacked_group(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
group* pgroup = pcard->pduel->new_group(); group* pgroup = pcard->pduel->new_group();
for(auto cit = pcard->attacked_cards.begin(); cit != pcard->attacked_cards.end(); ++cit) { for(auto cit = pcard->attacked_cards.begin(); cit != pcard->attacked_cards.end(); ++cit) {
if(cit->second) if(cit->second.first)
pgroup->container.insert(cit->second); pgroup->container.insert(cit->second.first);
} }
interpreter::group2value(L, pgroup); interpreter::group2value(L, pgroup);
return 1; return 1;
...@@ -770,8 +822,8 @@ int32 scriptlib::card_get_battled_group(lua_State *L) { ...@@ -770,8 +822,8 @@ int32 scriptlib::card_get_battled_group(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
group* pgroup = pcard->pduel->new_group(); group* pgroup = pcard->pduel->new_group();
for(auto cit = pcard->battled_cards.begin(); cit != pcard->battled_cards.end(); ++cit) { for(auto cit = pcard->battled_cards.begin(); cit != pcard->battled_cards.end(); ++cit) {
if(cit->second) if(cit->second.first)
pgroup->container.insert(cit->second); pgroup->container.insert(cit->second.first);
} }
interpreter::group2value(L, pgroup); interpreter::group2value(L, pgroup);
return 1; return 1;
...@@ -795,9 +847,8 @@ int32 scriptlib::card_is_direct_attacked(lua_State *L) { ...@@ -795,9 +847,8 @@ int32 scriptlib::card_is_direct_attacked(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
bool ret = false; bool ret = false;
for(auto cit = pcard->attacked_cards.begin(); cit != pcard->attacked_cards.end(); ++cit) if(pcard->attacked_cards.find(0) != pcard->attacked_cards.end())
if(cit->first == 0) ret = true;
ret = true;
lua_pushboolean(L, ret); lua_pushboolean(L, ret);
return 1; return 1;
} }
...@@ -1079,7 +1130,7 @@ int32 scriptlib::card_clear_effect_relation(lua_State *L) { ...@@ -1079,7 +1130,7 @@ int32 scriptlib::card_clear_effect_relation(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
pcard->relate_effect.clear(); pcard->clear_relate_effect();
return 0; return 0;
} }
int32 scriptlib::card_is_relate_to_effect(lua_State *L) { int32 scriptlib::card_is_relate_to_effect(lua_State *L) {
...@@ -1094,6 +1145,20 @@ int32 scriptlib::card_is_relate_to_effect(lua_State *L) { ...@@ -1094,6 +1145,20 @@ int32 scriptlib::card_is_relate_to_effect(lua_State *L) {
lua_pushboolean(L, 0); lua_pushboolean(L, 0);
return 1; return 1;
} }
int32 scriptlib::card_is_relate_to_chain(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32 chain_count = lua_tointeger(L, 2);
duel* pduel = pcard->pduel;
if(chain_count > pduel->game_field->core.current_chain.size() || chain_count < 1)
chain_count = pduel->game_field->core.current_chain.size();
if(pcard && pcard->is_has_relation(pduel->game_field->core.current_chain[chain_count - 1]))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::card_is_relate_to_card(lua_State *L) { int32 scriptlib::card_is_relate_to_card(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -1131,6 +1196,20 @@ int32 scriptlib::card_copy_effect(lua_State *L) { ...@@ -1131,6 +1196,20 @@ int32 scriptlib::card_copy_effect(lua_State *L) {
lua_pushinteger(L, pcard->copy_effect(code, reset, count)); lua_pushinteger(L, pcard->copy_effect(code, reset, count));
return 1; return 1;
} }
int32 scriptlib::card_replace_effect(lua_State * L) {
check_param_count(L, 3);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**)lua_touserdata(L, 1);
uint32 code = lua_tointeger(L, 2);
uint32 reset = lua_tointeger(L, 3);
uint32 count = lua_tointeger(L, 4);
if(count == 0)
count = 1;
if(reset & RESET_PHASE && !(reset & (RESET_SELF_TURN | RESET_OPPO_TURN)))
reset |= (RESET_SELF_TURN | RESET_OPPO_TURN);
lua_pushinteger(L, pcard->replace_effect(code, reset, count));
return 1;
}
int32 scriptlib::card_enable_unsummonable(lua_State *L) { int32 scriptlib::card_enable_unsummonable(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -1274,8 +1353,16 @@ int32 scriptlib::card_is_xyz_summonable(lua_State *L) { ...@@ -1274,8 +1353,16 @@ int32 scriptlib::card_is_xyz_summonable(lua_State *L) {
check_param(L, PARAM_TYPE_GROUP, 2); check_param(L, PARAM_TYPE_GROUP, 2);
materials = *(group**) lua_touserdata(L, 2); materials = *(group**) lua_touserdata(L, 2);
} }
int32 minc = 0;
if(lua_gettop(L) >= 3)
minc = lua_tointeger(L, 3);
int32 maxc = 0;
if(lua_gettop(L) >= 4)
maxc = lua_tointeger(L, 4);
uint32 p = pcard->pduel->game_field->core.reason_player; uint32 p = pcard->pduel->game_field->core.reason_player;
pcard->pduel->game_field->core.limit_xyz = materials; pcard->pduel->game_field->core.limit_xyz = materials;
pcard->pduel->game_field->core.limit_xyz_minc = minc;
pcard->pduel->game_field->core.limit_xyz_maxc = maxc;
lua_pushboolean(L, pcard->is_special_summonable(p, SUMMON_TYPE_XYZ)); lua_pushboolean(L, pcard->is_special_summonable(p, SUMMON_TYPE_XYZ));
return 1; return 1;
} }
...@@ -1769,7 +1856,7 @@ int32 scriptlib::card_remove_counter(lua_State *L) { ...@@ -1769,7 +1856,7 @@ int32 scriptlib::card_remove_counter(lua_State *L) {
pcard->pduel->write_buffer8(MSG_REMOVE_COUNTER); pcard->pduel->write_buffer8(MSG_REMOVE_COUNTER);
pcard->pduel->write_buffer16(cmit->first); pcard->pduel->write_buffer16(cmit->first);
pcard->pduel->write_buffer32(pcard->get_info_location()); pcard->pduel->write_buffer32(pcard->get_info_location());
pcard->pduel->write_buffer8(cmit->second); pcard->pduel->write_buffer8(cmit->second[0] + cmit->second[1]);
} }
pcard->counters.clear(); pcard->counters.clear();
return 0; return 0;
......
...@@ -109,9 +109,21 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) { ...@@ -109,9 +109,21 @@ int32 scriptlib::debug_pre_add_counter(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 ctype = lua_tointeger(L, 2); uint32 countertype = lua_tointeger(L, 2);
uint32 ccount = lua_tointeger(L, 3); uint32 count = lua_tointeger(L, 3);
pcard->counters[ctype] += ccount; uint16 cttype = countertype;
if((countertype & COUNTER_NEED_ENABLE) && !(countertype & COUNTER_NEED_PERMIT))
cttype &= 0xfff;
auto pr = pcard->counters.insert(std::make_pair(cttype, card::counter_map::mapped_type()));
auto cmit = pr.first;
if(pr.second) {
cmit->second[0] = 0;
cmit->second[1] = 0;
}
if(!(countertype & COUNTER_NEED_ENABLE))
cmit->second[0] += count;
else
cmit->second[1] += count;
return 0; return 0;
} }
int32 scriptlib::debug_reload_field_begin(lua_State *L) { int32 scriptlib::debug_reload_field_begin(lua_State *L) {
......
...@@ -278,8 +278,16 @@ int32 scriptlib::duel_xyz_summon(lua_State *L) { ...@@ -278,8 +278,16 @@ int32 scriptlib::duel_xyz_summon(lua_State *L) {
check_param(L, PARAM_TYPE_GROUP, 3); check_param(L, PARAM_TYPE_GROUP, 3);
materials = *(group**)lua_touserdata(L, 3); materials = *(group**)lua_touserdata(L, 3);
} }
int32 minc = 0;
if(lua_gettop(L) >= 4)
minc = lua_tointeger(L, 4);
int32 maxc = 0;
if(lua_gettop(L) >= 5)
maxc = lua_tointeger(L, 5);
duel * pduel = pcard->pduel; duel * pduel = pcard->pduel;
pduel->game_field->core.limit_xyz = materials; pduel->game_field->core.limit_xyz = materials;
pduel->game_field->core.limit_xyz_minc = minc;
pduel->game_field->core.limit_xyz_maxc = maxc;
pduel->game_field->core.summon_cancelable = FALSE; pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_XYZ); pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_XYZ);
return lua_yield(L, 0); return lua_yield(L, 0);
...@@ -540,18 +548,19 @@ int32 scriptlib::duel_change_form(lua_State *L) { ...@@ -540,18 +548,19 @@ int32 scriptlib::duel_change_form(lua_State *L) {
} else } else
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1); luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32 au = lua_tointeger(L, 2); uint32 au = lua_tointeger(L, 2);
uint32 ad = au, du = au, dd = au, noflip = 0; uint32 ad = au, du = au, dd = au, flag = 0;
uint32 top = lua_gettop(L); uint32 top = lua_gettop(L);
if(top > 2) ad = lua_tointeger(L, 3); if(top > 2) ad = lua_tointeger(L, 3);
if(top > 3) du = lua_tointeger(L, 4); if(top > 3) du = lua_tointeger(L, 4);
if(top > 4) dd = lua_tointeger(L, 5); if(top > 4) dd = lua_tointeger(L, 5);
if(top > 5) noflip = lua_toboolean(L, 6); if(top > 5 && lua_toboolean(L, 6)) flag |= NO_FLIP_EFFECT;
if(top > 6 && lua_toboolean(L, 7)) flag |= FLIP_SET_AVAILABLE;
if(pcard) { if(pcard) {
field::card_set cset; field::card_set cset;
cset.insert(pcard); cset.insert(pcard);
pduel->game_field->change_position(&cset, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, noflip, TRUE); pduel->game_field->change_position(&cset, pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE);
} else } else
pduel->game_field->change_position(&(pgroup->container), pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, noflip, TRUE); pduel->game_field->change_position(&(pgroup->container), pduel->game_field->core.reason_effect, pduel->game_field->core.reason_player, au, ad, du, dd, flag, TRUE);
pduel->game_field->core.subunits.begin()->type = PROCESSOR_CHANGEPOS_S; pduel->game_field->core.subunits.begin()->type = PROCESSOR_CHANGEPOS_S;
return lua_yield(L, 0); return lua_yield(L, 0);
} }
...@@ -1150,11 +1159,7 @@ int32 scriptlib::duel_change_attacker(lua_State *L) { ...@@ -1150,11 +1159,7 @@ int32 scriptlib::duel_change_attacker(lua_State *L) {
card* attacker = pduel->game_field->core.attacker; card* attacker = pduel->game_field->core.attacker;
card* attack_target = pduel->game_field->core.attack_target; card* attack_target = pduel->game_field->core.attack_target;
attacker->announce_count++; attacker->announce_count++;
if(attack_target) { attacker->announced_cards.addcard(attack_target);
attacker->announced_cards[attack_target->fieldid_r] = attack_target;
} else {
attacker->announced_cards[0] = 0;
}
pduel->game_field->core.sub_attacker = target; pduel->game_field->core.sub_attacker = target;
return 0; return 0;
} }
...@@ -1513,7 +1518,7 @@ int32 scriptlib::duel_skip_phase(lua_State *L) { ...@@ -1513,7 +1518,7 @@ int32 scriptlib::duel_skip_phase(lua_State *L) {
peffect->effect_owner = playerid; peffect->effect_owner = playerid;
peffect->type = EFFECT_TYPE_FIELD; peffect->type = EFFECT_TYPE_FIELD;
peffect->code = code; peffect->code = code;
peffect->reset_flag = (reset & 0xff) | RESET_PHASE | RESET_SELF_TURN; peffect->reset_flag = (reset & 0x3ff) | RESET_PHASE | RESET_SELF_TURN;
peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_PLAYER_TARGET; peffect->flag[0] = EFFECT_FLAG_CANNOT_DISABLE | EFFECT_FLAG_PLAYER_TARGET;
peffect->s_range = 1; peffect->s_range = 1;
peffect->o_range = 0; peffect->o_range = 0;
...@@ -2465,8 +2470,13 @@ int32 scriptlib::duel_select_xyz_material(lua_State *L) { ...@@ -2465,8 +2470,13 @@ int32 scriptlib::duel_select_xyz_material(lua_State *L) {
uint32 lv = lua_tointeger(L, 4); uint32 lv = lua_tointeger(L, 4);
uint32 minc = lua_tointeger(L, 5); uint32 minc = lua_tointeger(L, 5);
uint32 maxc = lua_tointeger(L, 6); uint32 maxc = lua_tointeger(L, 6);
group* mg = 0;
if(lua_gettop(L) >= 7 && !lua_isnil(L, 7)) {
check_param(L, PARAM_TYPE_GROUP, 7);
mg = *(group**) lua_touserdata(L, 7);
}
duel* pduel = scard->pduel; duel* pduel = scard->pduel;
pduel->game_field->get_xyz_material(scard, findex, lv, maxc); pduel->game_field->get_xyz_material(scard, findex, lv, maxc, mg);
scard->pduel->game_field->add_process(PROCESSOR_SELECT_XMATERIAL, 0, 0, (group*)scard, playerid + (lv << 16), minc + (maxc << 16)); scard->pduel->game_field->add_process(PROCESSOR_SELECT_XMATERIAL, 0, 0, (group*)scard, playerid + (lv << 16), minc + (maxc << 16));
return lua_yield(L, 0); return lua_yield(L, 0);
} }
...@@ -2696,7 +2706,10 @@ int32 scriptlib::duel_announce_card(lua_State * L) { ...@@ -2696,7 +2706,10 @@ int32 scriptlib::duel_announce_card(lua_State * L) {
check_param_count(L, 1); check_param_count(L, 1);
int32 playerid = lua_tointeger(L, 1); int32 playerid = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_CARD, 0, 0, 0, playerid, 0); uint32 ttype = TYPE_MONSTER | TYPE_SPELL | TYPE_TRAP;
if(lua_gettop(L) >= 2)
ttype = lua_tointeger(L, 2);
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_CARD, 0, 0, 0, playerid, ttype);
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_announce_type(lua_State * L) { int32 scriptlib::duel_announce_type(lua_State * L) {
......
...@@ -40,7 +40,6 @@ int32 scriptlib::effect_clone(lua_State *L) { ...@@ -40,7 +40,6 @@ int32 scriptlib::effect_clone(lua_State *L) {
*ceffect = *peffect; *ceffect = *peffect;
ceffect->ref_handle = ref; ceffect->ref_handle = ref;
ceffect->handler = 0; ceffect->handler = 0;
ceffect->effect_owner = peffect->effect_owner;
if(peffect->condition) { if(peffect->condition) {
lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->condition); lua_rawgeti(L, LUA_REGISTRYINDEX, peffect->condition);
ceffect->condition = luaL_ref(L, LUA_REGISTRYINDEX); ceffect->condition = luaL_ref(L, LUA_REGISTRYINDEX);
...@@ -87,7 +86,7 @@ int32 scriptlib::effect_set_description(lua_State *L) { ...@@ -87,7 +86,7 @@ int32 scriptlib::effect_set_description(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->description = v; peffect->description = v;
return 0; return 0;
} }
...@@ -95,7 +94,7 @@ int32 scriptlib::effect_set_code(lua_State *L) { ...@@ -95,7 +94,7 @@ int32 scriptlib::effect_set_code(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->code = v; peffect->code = v;
return 0; return 0;
} }
...@@ -103,7 +102,7 @@ int32 scriptlib::effect_set_range(lua_State *L) { ...@@ -103,7 +102,7 @@ int32 scriptlib::effect_set_range(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->range = v; peffect->range = v;
return 0; return 0;
} }
...@@ -111,8 +110,8 @@ int32 scriptlib::effect_set_target_range(lua_State *L) { ...@@ -111,8 +110,8 @@ int32 scriptlib::effect_set_target_range(lua_State *L) {
check_param_count(L, 3); check_param_count(L, 3);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 s = lua_tointeger(L, 2); uint32 s = lua_tounsigned(L, 2);
int32 o = lua_tointeger(L, 3); uint32 o = lua_tounsigned(L, 3);
peffect->s_range = s; peffect->s_range = s;
peffect->o_range = o; peffect->o_range = o;
peffect->flag[0] &= ~EFFECT_FLAG_ABSOLUTE_TARGET; peffect->flag[0] &= ~EFFECT_FLAG_ABSOLUTE_TARGET;
...@@ -122,9 +121,9 @@ int32 scriptlib::effect_set_absolute_range(lua_State *L) { ...@@ -122,9 +121,9 @@ int32 scriptlib::effect_set_absolute_range(lua_State *L) {
check_param_count(L, 4); check_param_count(L, 4);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 playerid = lua_tointeger(L, 2); uint32 playerid = lua_tounsigned(L, 2);
int32 s = lua_tointeger(L, 3); uint32 s = lua_tounsigned(L, 3);
int32 o = lua_tointeger(L, 4); uint32 o = lua_tounsigned(L, 4);
if(playerid == 0) { if(playerid == 0) {
peffect->s_range = s; peffect->s_range = s;
peffect->o_range = o; peffect->o_range = o;
...@@ -139,10 +138,10 @@ int32 scriptlib::effect_set_count_limit(lua_State *L) { ...@@ -139,10 +138,10 @@ int32 scriptlib::effect_set_count_limit(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
uint32 code = 0; uint32 code = 0;
if(lua_gettop(L) >= 3) if(lua_gettop(L) >= 3)
code = lua_tointeger(L, 3); code = lua_tounsigned(L, 3);
if(v == 0) if(v == 0)
v = 1; v = 1;
peffect->flag[0] |= EFFECT_FLAG_COUNT_LIMIT; peffect->flag[0] |= EFFECT_FLAG_COUNT_LIMIT;
...@@ -154,8 +153,8 @@ int32 scriptlib::effect_set_reset(lua_State *L) { ...@@ -154,8 +153,8 @@ int32 scriptlib::effect_set_reset(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
int32 c = lua_tointeger(L, 3); uint32 c = lua_tounsigned(L, 3);
if(c == 0) if(c == 0)
c = 1; c = 1;
if(v & (RESET_PHASE) && !(v & (RESET_SELF_TURN | RESET_OPPO_TURN))) if(v & (RESET_PHASE) && !(v & (RESET_SELF_TURN | RESET_OPPO_TURN)))
...@@ -168,7 +167,7 @@ int32 scriptlib::effect_set_type(lua_State *L) { ...@@ -168,7 +167,7 @@ int32 scriptlib::effect_set_type(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
if (v & 0x0ff0) if (v & 0x0ff0)
v |= EFFECT_TYPE_ACTIONS; v |= EFFECT_TYPE_ACTIONS;
else else
...@@ -199,7 +198,7 @@ int32 scriptlib::effect_set_label(lua_State *L) { ...@@ -199,7 +198,7 @@ int32 scriptlib::effect_set_label(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->label = v; peffect->label = v;
return 0; return 0;
} }
...@@ -221,7 +220,7 @@ int32 scriptlib::effect_set_category(lua_State *L) { ...@@ -221,7 +220,7 @@ int32 scriptlib::effect_set_category(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 v = lua_tointeger(L, 2); uint32 v = lua_tounsigned(L, 2);
peffect->category = v; peffect->category = v;
return 0; return 0;
} }
...@@ -229,10 +228,10 @@ int32 scriptlib::effect_set_hint_timing(lua_State *L) { ...@@ -229,10 +228,10 @@ int32 scriptlib::effect_set_hint_timing(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 vs = lua_tointeger(L, 2); uint32 vs = lua_tounsigned(L, 2);
int32 vo = vs; uint32 vo = vs;
if(lua_gettop(L) >= 3) if(lua_gettop(L) >= 3)
vo = lua_tointeger(L, 3); vo = lua_tounsigned(L, 3);
peffect->hint_timing[0] = vs; peffect->hint_timing[0] = vs;
peffect->hint_timing[1] = vo; peffect->hint_timing[1] = vo;
return 0; return 0;
...@@ -302,7 +301,7 @@ int32 scriptlib::effect_set_owner_player(lua_State *L) { ...@@ -302,7 +301,7 @@ int32 scriptlib::effect_set_owner_player(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
int32 p = lua_tointeger(L, 2); uint32 p = lua_tounsigned(L, 2);
if(p != 0 && p != 1) if(p != 0 && p != 1)
return 0; return 0;
peffect->effect_owner = p; peffect->effect_owner = p;
......
...@@ -287,11 +287,13 @@ int32 scriptlib::group_check_with_sum_equal(lua_State *L) { ...@@ -287,11 +287,13 @@ int32 scriptlib::group_check_with_sum_equal(lua_State *L) {
max = min; max = min;
int32 extraargs = lua_gettop(L) - 5; int32 extraargs = lua_gettop(L) - 5;
field::card_vector cv; field::card_vector cv;
cv.swap(pduel->game_field->core.must_select_cards);
int32 mcount = cv.size();
for(auto cit = pgroup->container.begin(); cit != pgroup->container.end(); ++cit) { for(auto cit = pgroup->container.begin(); cit != pgroup->container.end(); ++cit) {
(*cit)->operation_param = pduel->lua->get_operation_value(*cit, 2, extraargs); (*cit)->operation_param = pduel->lua->get_operation_value(*cit, 2, extraargs);
cv.push_back(*cit); cv.push_back(*cit);
} }
lua_pushboolean(L, pduel->game_field->check_with_sum_limit(&cv, acc, 0, 1, min, max)); lua_pushboolean(L, field::check_with_sum_limit_m(cv, acc, 0, min, max, mcount));
return 1; return 1;
} }
int32 scriptlib::group_select_with_sum_equal(lua_State *L) { int32 scriptlib::group_select_with_sum_equal(lua_State *L) {
...@@ -317,7 +319,14 @@ int32 scriptlib::group_select_with_sum_equal(lua_State *L) { ...@@ -317,7 +319,14 @@ int32 scriptlib::group_select_with_sum_equal(lua_State *L) {
(*cit)->operation_param = pduel->lua->get_operation_value(*cit, 3, extraargs); (*cit)->operation_param = pduel->lua->get_operation_value(*cit, 3, extraargs);
pduel->game_field->core.select_cards.push_back(*cit); pduel->game_field->core.select_cards.push_back(*cit);
} }
if(!pduel->game_field->check_with_sum_limit(&pduel->game_field->core.select_cards, acc, 0, 1, min, max)) for(auto cit = pduel->game_field->core.must_select_cards.begin(); cit != pduel->game_field->core.must_select_cards.end(); ++cit) {
auto it = std::remove(pduel->game_field->core.select_cards.begin(), pduel->game_field->core.select_cards.end(), *cit);
pduel->game_field->core.select_cards.erase(it, pduel->game_field->core.select_cards.end());
}
field::card_vector cv(pduel->game_field->core.must_select_cards);
int32 mcount = cv.size();
cv.insert(cv.end(), pduel->game_field->core.select_cards.begin(), pduel->game_field->core.select_cards.end());
if(!field::check_with_sum_limit_m(cv, acc, 0, min, max, mcount))
return 0; return 0;
pduel->game_field->add_process(PROCESSOR_SELECT_SUM_S, 0, 0, 0, acc, playerid + (min << 16) + (max << 24)); pduel->game_field->add_process(PROCESSOR_SELECT_SUM_S, 0, 0, 0, acc, playerid + (min << 16) + (max << 24));
return lua_yield(L, 0); return lua_yield(L, 0);
......
...@@ -60,20 +60,22 @@ void duelAdapter::start_duel(int options) { ...@@ -60,20 +60,22 @@ void duelAdapter::start_duel(int options) {
pduel->game_field->draw(0, REASON_RULE, PLAYER_NONE, 1, pduel->game_field->player[1].start_count); pduel->game_field->draw(0, REASON_RULE, PLAYER_NONE, 1, pduel->game_field->player[1].start_count);
if(options & DUEL_TAG_MODE) { if(options & DUEL_TAG_MODE) {
for(int i = 0; i < pduel->game_field->player[0].start_count && pduel->game_field->player[0].tag_list_main.size(); ++i) { for(int i = 0; i < pduel->game_field->player[0].start_count && pduel->game_field->player[0].tag_list_main.size(); ++i) {
card* pcard = *pduel->game_field->player[0].tag_list_main.rbegin(); card* pcard = pduel->game_field->player[0].tag_list_main.back();
pduel->game_field->player[0].tag_list_main.pop_back(); pduel->game_field->player[0].tag_list_main.pop_back();
pduel->game_field->player[0].tag_list_hand.push_back(pcard); pduel->game_field->player[0].tag_list_hand.push_back(pcard);
pcard->current.controler = 0; pcard->current.controler = 0;
pcard->current.location = LOCATION_HAND; pcard->current.location = LOCATION_HAND;
pcard->current.sequence = pduel->game_field->player[0].tag_list_hand.size() - 1; pcard->current.sequence = pduel->game_field->player[0].tag_list_hand.size() - 1;
pcard->current.position = POS_FACEDOWN;
} }
for(int i = 0; i < pduel->game_field->player[1].start_count && pduel->game_field->player[1].tag_list_main.size(); ++i) { for(int i = 0; i < pduel->game_field->player[1].start_count && pduel->game_field->player[1].tag_list_main.size(); ++i) {
card* pcard = *pduel->game_field->player[1].tag_list_main.rbegin(); card* pcard = pduel->game_field->player[1].tag_list_main.back();
pduel->game_field->player[1].tag_list_main.pop_back(); pduel->game_field->player[1].tag_list_main.pop_back();
pduel->game_field->player[1].tag_list_hand.push_back(pcard); pduel->game_field->player[1].tag_list_hand.push_back(pcard);
pcard->current.controler = 1; pcard->current.controler = 1;
pcard->current.location = LOCATION_HAND; pcard->current.location = LOCATION_HAND;
pcard->current.sequence = pduel->game_field->player[1].tag_list_hand.size() - 1; pcard->current.sequence = pduel->game_field->player[1].tag_list_hand.size() - 1;
pcard->current.position = POS_FACEDOWN;
} }
} }
pduel->game_field->add_process(PROCESSOR_TURN, 0, 0, 0, 0, 0); pduel->game_field->add_process(PROCESSOR_TURN, 0, 0, 0, 0, 0);
......
This diff is collapsed.
...@@ -511,15 +511,15 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin ...@@ -511,15 +511,15 @@ int32 field::select_counter(uint16 step, uint8 playerid, uint16 countertype, uin
} }
return TRUE; return TRUE;
} }
int32 select_sum_check1(int32* oparam, int32 size, int32 index, int32 count, int32 acc, int32 min) { static int32 select_sum_check1(const int32* oparam, int32 size, int32 index, int32 acc) {
if(acc == 0 || index == size) if(acc == 0 || index == size)
return FALSE; return FALSE;
int32 o1 = oparam[index] & 0xffff; int32 o1 = oparam[index] & 0xffff;
int32 o2 = oparam[index] >> 16; int32 o2 = oparam[index] >> 16;
if((o1 == acc || o2 == acc) && index == size - 1 && count >= min) if(index == size - 1)
return TRUE; return acc == o1 || acc == o2;
return (acc > o1 && select_sum_check1(oparam, size, index + 1, count + 1, acc - o1, min)) return (acc > o1 && select_sum_check1(oparam, size, index + 1, acc - o1))
|| (o2 > 0 && acc > o2 && select_sum_check1(oparam, size, index + 1, count + 1, acc - o2, min)); || (o2 > 0 && acc > o2 && select_sum_check1(oparam, size, index + 1, acc - o2));
} }
int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 min, int32 max) { int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 min, int32 max) {
if(step == 0) { if(step == 0) {
...@@ -537,11 +537,19 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 ...@@ -537,11 +537,19 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
pduel->write_buffer32(acc & 0xffff); pduel->write_buffer32(acc & 0xffff);
pduel->write_buffer8(min); pduel->write_buffer8(min);
pduel->write_buffer8(max); pduel->write_buffer8(max);
pduel->write_buffer8(core.must_select_cards.size());
for(uint32 i = 0; i < core.must_select_cards.size(); ++i) {
card* pcard = core.must_select_cards[i];
pduel->write_buffer32(pcard->data.code);
pduel->write_buffer8(pcard->current.controler);
pduel->write_buffer8(pcard->current.location);
pduel->write_buffer8(pcard->current.sequence);
pduel->write_buffer32(pcard->operation_param);
}
pduel->write_buffer8(core.select_cards.size()); pduel->write_buffer8(core.select_cards.size());
card* pcard;
std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort); std::sort(core.select_cards.begin(), core.select_cards.end(), card::card_operation_sort);
for(uint32 i = 0; i < core.select_cards.size(); ++i) { for(uint32 i = 0; i < core.select_cards.size(); ++i) {
pcard = core.select_cards[i]; card* pcard = core.select_cards[i];
pduel->write_buffer32(pcard->data.code); pduel->write_buffer32(pcard->data.code);
pduel->write_buffer8(pcard->current.controler); pduel->write_buffer8(pcard->current.controler);
pduel->write_buffer8(pcard->current.location); pduel->write_buffer8(pcard->current.location);
...@@ -552,15 +560,18 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 ...@@ -552,15 +560,18 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
} else { } else {
byte c[64]; byte c[64];
memset(c, 0, 64); memset(c, 0, 64);
if(min) { if(max) {
int32 oparam[16]; int32 oparam[16];
if(returns.bvalue[0] < min || returns.bvalue[0] > max) { int32 mcount = core.must_select_cards.size();
if(returns.bvalue[0] < min + mcount || returns.bvalue[0] > max + mcount) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
uint8 m = core.select_cards.size(), v = 0; for(int32 i = 0; i < mcount; ++i)
for(int32 i = 0; i < returns.bvalue[0]; ++i) { oparam[i] = core.must_select_cards[i]->operation_param;
v = returns.bvalue[i + 1]; int32 m = core.select_cards.size();
for(int32 i = mcount; i < returns.bvalue[0]; ++i) {
int32 v = returns.bvalue[i + 1];
if(v < 0 || v >= m || c[v]) { if(v < 0 || v >= m || c[v]) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
...@@ -568,7 +579,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32 ...@@ -568,7 +579,7 @@ int32 field::select_with_sum_limit(int16 step, uint8 playerid, int32 acc, int32
c[v] = 1; c[v] = 1;
oparam[i] = core.select_cards[v]->operation_param; oparam[i] = core.select_cards[v]->operation_param;
} }
if(!select_sum_check1(oparam, returns.bvalue[0], 0, 1, acc, min)) { if(!select_sum_check1(oparam, returns.bvalue[0], 0, acc)) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
...@@ -719,10 +730,11 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a ...@@ -719,10 +730,11 @@ int32 field::announce_attribute(int16 step, uint8 playerid, int32 count, int32 a
} }
return TRUE; return TRUE;
} }
int32 field::announce_card(int16 step, uint8 playerid) { int32 field::announce_card(int16 step, uint8 playerid, uint32 ttype) {
if(step == 0) { if(step == 0) {
pduel->write_buffer8(MSG_DECLEAR_CARD); pduel->write_buffer8(MSG_DECLEAR_CARD);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
pduel->write_buffer32(ttype);
return FALSE; return FALSE;
} else { } else {
pduel->write_buffer8(MSG_HINT); pduel->write_buffer8(MSG_HINT);
......
This diff is collapsed.
...@@ -21,8 +21,11 @@ public: ...@@ -21,8 +21,11 @@ public:
static int32 card_get_code(lua_State *L); static int32 card_get_code(lua_State *L);
static int32 card_get_origin_code(lua_State *L); static int32 card_get_origin_code(lua_State *L);
static int32 card_get_origin_code_rule(lua_State *L); static int32 card_get_origin_code_rule(lua_State *L);
static int32 card_get_fusion_code(lua_State *L);
static int32 card_is_fusion_code(lua_State *L);
static int32 card_is_set_card(lua_State *L); static int32 card_is_set_card(lua_State *L);
static int32 card_is_pre_set_card(lua_State *L); static int32 card_is_pre_set_card(lua_State *L);
static int32 card_is_fusion_set_card(lua_State *L);
static int32 card_get_type(lua_State *L); static int32 card_get_type(lua_State *L);
static int32 card_get_origin_type(lua_State *L); static int32 card_get_origin_type(lua_State *L);
static int32 card_get_level(lua_State *L); static int32 card_get_level(lua_State *L);
...@@ -134,9 +137,11 @@ public: ...@@ -134,9 +137,11 @@ public:
static int32 card_release_effect_relation(lua_State *L); static int32 card_release_effect_relation(lua_State *L);
static int32 card_clear_effect_relation(lua_State *L); static int32 card_clear_effect_relation(lua_State *L);
static int32 card_is_relate_to_effect(lua_State *L); static int32 card_is_relate_to_effect(lua_State *L);
static int32 card_is_relate_to_chain(lua_State *L);
static int32 card_is_relate_to_card(lua_State *L); static int32 card_is_relate_to_card(lua_State *L);
static int32 card_is_relate_to_battle(lua_State *L); static int32 card_is_relate_to_battle(lua_State *L);
static int32 card_copy_effect(lua_State *L); static int32 card_copy_effect(lua_State *L);
static int32 card_replace_effect(lua_State *L);
static int32 card_enable_unsummonable(lua_State *L); static int32 card_enable_unsummonable(lua_State *L);
static int32 card_enable_revive_limit(lua_State *L); static int32 card_enable_revive_limit(lua_State *L);
static int32 card_complete_procedure(lua_State *L); static int32 card_complete_procedure(lua_State *L);
......
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