Commit cb12d793 authored by argon.sun's avatar argon.sun

puz

parent 82c273f8
#include "client_card.h"
#include "client_field.h"
#include "game.h"
namespace ygo {
......@@ -102,6 +103,43 @@ void ClientCard::UpdateInfo(char* buf) {
base_defence = BufferIO::ReadInt32(buf);
if(flag & QUERY_REASON)
reason = BufferIO::ReadInt32(buf);
if(flag & QUERY_EQUIP_CARD) {
int c = BufferIO::ReadInt8(buf);
int l = BufferIO::ReadInt8(buf);
int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf);
ClientCard* ecard = mainGame->dField.GetCard(c, l, s);
equipTarget = ecard;
ecard->equipped.insert(this);
}
if(flag & QUERY_TARGET_CARD) {
int count = BufferIO::ReadInt8(buf);
for(int i = 0; i < count; ++i) {
int c = BufferIO::ReadInt8(buf);
int l = BufferIO::ReadInt8(buf);
int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf);
ClientCard* tcard = mainGame->dField.GetCard(c, l, s);
cardTarget.insert(tcard);
tcard->ownerTarget.insert(this);
}
}
if(flag & QUERY_OVERLAY_CARD) {
int count = BufferIO::ReadInt8(buf);
for(int i = 0; i < count; ++i) {
overlayed[i]->SetCode(BufferIO::ReadInt32(buf));
}
}
if(flag & QUERY_COUNTERS) {
int count = BufferIO::ReadInt8(buf);
for(int i = 0; i < count; ++i) {
int ctype = BufferIO::ReadInt16(buf);
int ccount = BufferIO::ReadInt16(buf);
counters[ctype] = ccount;
}
}
if(flag & QUERY_OWNER)
owner = BufferIO::ReadInt32(buf);
if(flag & QUERY_IS_DISABLED)
is_disabled = BufferIO::ReadInt32(buf);
if(flag & QUERY_IS_PUBLIC)
......
......@@ -558,7 +558,7 @@ void ClientField::GetChainLocation(int controler, int location, int sequence, ir
}
}
}
void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, irr::core::vector3df* r) {
void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, irr::core::vector3df* r, bool setTrans) {
int controler = pcard->controler;
int sequence = pcard->sequence;
int location = pcard->location;
......@@ -802,6 +802,10 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir
break;
}
}
if(setTrans) {
pcard->mTransform.setTranslation(*t);
pcard->mTransform.setRotationRadians(*r);
}
}
void ClientField::MoveCard(ClientCard * pcard, int frame) {
irr::core::vector3df trans = pcard->curPos;
......
......@@ -84,7 +84,7 @@ public:
void ReplaySwap();
void GetChainLocation(int controler, int location, int sequence, irr::core::vector3df* t);
void GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, irr::core::vector3df* r);
void GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, irr::core::vector3df* r, bool setTrans = false);
void MoveCard(ClientCard* pcard, int frame);
void FadeCard(ClientCard* pcard, int alpha, int frame);
bool CheckSelectSum();
......
......@@ -2,6 +2,7 @@
#include "client_card.h"
#include "materials.h"
#include "image_manager.h"
#include "single_mode.h"
#include "../ocgcore/field.h"
#include "../ocgcore/duel.h"
#include "game.h"
......@@ -938,7 +939,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnEP->setPressed(false);
}
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_SELECT_IDLECMD: {
int selecting_player = BufferIO::ReadInt8(pbuf);
......@@ -1037,7 +1038,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->btnEP->setEnabled(true);
mainGame->btnEP->setPressed(false);
}
return true;
return false;
}
case MSG_SELECT_EFFECTYN: {
int selecting_player = BufferIO::ReadInt8(pbuf);
......@@ -1054,7 +1055,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_SELECT_YESNO: {
int selecting_player = BufferIO::ReadInt8(pbuf);
......@@ -1063,7 +1064,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->SetStaticText(mainGame->stQMessage, 310, mainGame->textFont, (wchar_t*)dataManager.GetDesc(desc));
mainGame->PopupElement(mainGame->wQuery);
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_SELECT_OPTION: {
int selecting_player = BufferIO::ReadInt8(pbuf);
......@@ -1086,7 +1087,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->wOptions->setText(textBuffer);
mainGame->PopupElement(mainGame->wOptions);
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_SELECT_CARD: {
int selecting_player = BufferIO::ReadInt8(pbuf);
......@@ -1134,7 +1135,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
}
return true;
return false;
}
case MSG_SELECT_CHAIN: {
int selecting_player = BufferIO::ReadInt8(pbuf);
......@@ -1192,7 +1193,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->PopupElement(mainGame->wQuery);
}
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_SELECT_PLACE:
case MSG_SELECT_DISFIELD: {
......@@ -1236,7 +1237,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
DuelClient::SendResponse();
return true;
}
return true;
return false;
}
case MSG_SELECT_POSITION: {
int selecting_player = BufferIO::ReadInt8(pbuf);
......@@ -1279,7 +1280,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->gMutex.Lock();
mainGame->PopupElement(mainGame->wPosSelect);
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_SELECT_TRIBUTE: {
int selecting_player = BufferIO::ReadInt8(pbuf);
......@@ -1308,7 +1309,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
mainGame->stHintMsg->setText(dataManager.GetSysString(531));
mainGame->stHintMsg->setVisible(false);
return true;
return false;
}
case MSG_SELECT_COUNTER: {
int selecting_player = BufferIO::ReadInt8(pbuf);
......@@ -1334,7 +1335,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_SELECT_SUM: {
mainGame->dField.select_mode = BufferIO::ReadInt8(pbuf);
......@@ -1376,7 +1377,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->stHintMsg->setText(textBuffer);
mainGame->stHintMsg->setVisible(true);
}
return true;
return false;
}
case MSG_SORT_CARD:
case MSG_SORT_CHAIN: {
......@@ -2532,7 +2533,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->wANRace->setText(textBuffer);
mainGame->PopupElement(mainGame->wANRace);
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_ANNOUNCE_ATTRIB: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
......@@ -2552,7 +2553,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->wANAttribute->setText(textBuffer);
mainGame->PopupElement(mainGame->wANAttribute);
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_ANNOUNCE_CARD: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
......@@ -2565,7 +2566,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->wANCard->setText(textBuffer);
mainGame->PopupElement(mainGame->wANCard);
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_ANNOUNCE_NUMBER: {
int player = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
......@@ -2585,7 +2586,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->wANNumber->setText(textBuffer);
mainGame->PopupElement(mainGame->wANNumber);
mainGame->gMutex.Unlock();
return true;
return false;
}
case MSG_CARD_HINT: {
int c = mainGame->LocalPlayer(BufferIO::ReadInt8(pbuf));
......@@ -2724,13 +2725,15 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
mainGame->dField.Clear();
int val = 0;
for(int p = 0; p < 2; ++p) {
mainGame->dInfo.lp[p] = BufferIO::ReadInt32(pbuf);
myswprintf(mainGame->dInfo.strLP[p], L"%d", mainGame->dInfo.lp[p]);
for(int seq = 0; seq < 5; ++seq) {
val = BufferIO::ReadInt8(pbuf);
if(val) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_MZONE, 0);
mainGame->dField.AddCard(ccard, p, LOCATION_MZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
val = BufferIO::ReadInt8(pbuf);
if(val) {
for(int xyz = 0; xyz < val; ++xyz) {
......@@ -2741,7 +2744,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
xcard->overlayTarget = ccard;
xcard->location = 0x80;
xcard->sequence = ccard->overlayed.size() - 1;
mainGame->dField.GetCardLocation(xcard, &xcard->curPos, &xcard->curRot);
mainGame->dField.GetCardLocation(xcard, &xcard->curPos, &xcard->curRot, true);
}
}
}
......@@ -2752,38 +2755,38 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_SZONE, seq);
ccard->position = BufferIO::ReadInt8(pbuf);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
}
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_DECK, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_HAND, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_EXTRA, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_GRAVE, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
}
val = BufferIO::ReadInt8(pbuf);
for(int seq = 0; seq < val; ++seq) {
ClientCard* ccard = new ClientCard;
mainGame->dField.AddCard(ccard, p, LOCATION_REMOVED, seq);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot);
mainGame->dField.GetCardLocation(ccard, &ccard->curPos, &ccard->curRot, true);
}
}
mainGame->gMutex.Unlock();
......@@ -2839,6 +2842,7 @@ void DuelClient::SendResponse() {
}
}
if(mainGame->dInfo.isSingleMode) {
SingleMode::SetResponse(response_buf);
mainGame->singleSignal.Set();
} else {
mainGame->dInfo.time_player = 2;
......
......@@ -93,6 +93,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_LEAVE_GAME: {
if(mainGame->dInfo.isSingleMode) {
break;
}
if(mainGame->dInfo.player_type == 7) {
DuelClient::StopClient();
mainGame->CloseDuelWindow();
......
This diff is collapsed.
......@@ -17,6 +17,7 @@ private:
public:
static bool StartPlay();
static void StopPlay(bool is_exiting = false);
static void SetResponse(unsigned char* resp);
static int SinglePlayThread(void* param);
static bool SinglePlayAnalyze(char* msg, unsigned int len);
......@@ -26,6 +27,7 @@ public:
static void SinglePlayRefreshDeck(int player, int flag = 0x181fff);
static void SinglePlayRefreshExtra(int player, int flag = 0x181fff);
static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0x181fff);
static void SinglePlayReload();
static int MessageHandler(long fduel, int type);
};
......
......@@ -138,8 +138,12 @@ uint32 card::get_infos(byte* buf, int32 query_flag, int32 use_cache) {
}
if(query_flag & QUERY_REASON_CARD)
*p++ = current.reason_card ? current.reason_card->get_info_location() : 0;
if(query_flag & QUERY_EQUIP_CARD)
*p++ = equiping_target ? equiping_target->get_info_location() : 0;
if(query_flag & QUERY_EQUIP_CARD) {
if(equiping_target)
*p++ = equiping_target->get_info_location();
else
query_flag &= ~QUERY_EQUIP_CARD;
}
if(query_flag & QUERY_TARGET_CARD) {
*p++ = effect_target_cards.size();
card_set::iterator cit;
......
......@@ -38,13 +38,12 @@ void duel::clear() {
delete *git;
for(std::set<effect*>::iterator eit = effects.begin(); eit != effects.end(); ++eit)
delete *eit;
delete lua;
delete game_field;
lua = new interpreter(this);
cards.clear();
groups.clear();
effects.clear();
game_field = new field(this);
game_field->temp_card = new_card(0);
bufferlen = 0;
bufferp = buffer;
}
card* duel::new_card(uint32 code) {
card* pcard = new card();
......
......@@ -88,6 +88,7 @@ void field::reload_field_info() {
pduel->write_buffer8(MSG_RELOAD_FIELD);
card* pcard;
for(int playerid = 0; playerid < 2; ++playerid) {
pduel->write_buffer32(player[playerid].lp);
for(uint32 i = 0; i < 5; ++i) {
pcard = player[playerid].list_mzone[i];
if(pcard) {
......
......@@ -730,4 +730,6 @@ public:
#define MSG_CARD_HINT 160
#define MSG_TAG_SWAP 161
#define MSG_RELOAD_FIELD 162
#define MSG_AI_NAME 163
#define MSG_SHOW_HINT 164
#endif /* FIELD_H_ */
......@@ -464,6 +464,8 @@ static const struct luaL_Reg debuglib[] = {
{ "SetPlayerInfo", scriptlib::debug_set_player_info },
{ "ReloadFieldBegin", scriptlib::debug_reload_field_begin },
{ "ReloadFieldEnd", scriptlib::debug_reload_field_end },
{ "SetAIName", scriptlib::debug_set_ai_name },
{ "ShowHint", scriptlib::debug_show_hint },
{ NULL, NULL }
};
......@@ -505,8 +507,8 @@ interpreter::interpreter(duel* pd): coroutines(256) {
luaL_newlib(lua_state, debuglib);
lua_setglobal(lua_state, "Debug");
//extra scripts
load_script((char*) "constant.lua");
load_script((char*) "utility.lua");
load_script((char*) "./script/constant.lua");
load_script((char*) "./script/utility.lua");
}
interpreter::~interpreter() {
lua_close(lua_state);
......@@ -617,7 +619,7 @@ int32 interpreter::load_card_script(uint32 code) {
lua_pushvalue(current_state, -2);
lua_rawset(current_state, -3);
//load extra scripts
sprintf(script_name, "c%d.lua", code);
sprintf(script_name, "./script/c%d.lua", code);
if (!load_script(script_name)) {
return OPERATION_FAIL;
}
......
......@@ -67,27 +67,56 @@ int32 scriptlib::debug_set_player_info(lua_State *L) {
uint32 lp = lua_tointeger(L, 2);
uint32 startcount = lua_tointeger(L, 3);
uint32 drawcount = lua_tointeger(L, 4);
duel* pd = (duel*)pduel;
if(playerid != 0 && playerid != 1)
return 0;
pd->game_field->player[playerid].lp = lp;
pd->game_field->player[playerid].start_count = startcount;
pd->game_field->player[playerid].draw_count = drawcount;
pduel->game_field->player[playerid].lp = lp;
pduel->game_field->player[playerid].start_count = startcount;
pduel->game_field->player[playerid].draw_count = drawcount;
return 0;
}
int32 scriptlib::debug_set_duel_info(lua_State *L) {
int32 scriptlib::debug_reload_field_begin(lua_State *L) {
check_param_count(L, 1);
duel* pduel = interpreter::get_duel_info(L);
uint32 flag = lua_tointeger(L, 1);
pduel->game_field->core.duel_options = flag;
return 0;
}
int32 scriptlib::debug_reload_field_begin(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L);
pduel->clear();
pduel->game_field->core.duel_options = flag;
}
int32 scriptlib::debug_reload_field_end(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->core.shuffle_hand_check[0] = FALSE;
pduel->game_field->core.shuffle_hand_check[1] = FALSE;
pduel->game_field->core.shuffle_deck_check[0] = FALSE;
pduel->game_field->core.shuffle_deck_check[1] = FALSE;
pduel->game_field->reload_field_info();
return 0;
}
int32 scriptlib::debug_set_ai_name(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_STRING, 1);
duel* pduel = interpreter::get_duel_info(L);
pduel->write_buffer8(MSG_AI_NAME);
const char* pstr = lua_tostring(L, 1);
int len = strlen(pstr);
if(len > 100)
len = 100;
pduel->write_buffer16(len);
memcpy(pduel->bufferp, pstr, len);
pduel->bufferp += len;
pduel->bufferlen += len;
pduel->write_buffer8(0);
}
int32 scriptlib::debug_show_hint(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_STRING, 1);
duel* pduel = interpreter::get_duel_info(L);
pduel->write_buffer8(MSG_SHOW_HINT);
const char* pstr = lua_tostring(L, 1);
int len = strlen(pstr);
if(len > 1024)
len = 1024;
pduel->write_buffer16(len);
memcpy(pduel->bufferp, pstr, len);
pduel->bufferp += len;
pduel->bufferlen += len;
pduel->write_buffer8(0);
}
......@@ -40,10 +40,8 @@ uint32 handle_message(void* pduel, uint32 msg_type) {
return mhandler(pduel, msg_type);
}
byte* default_script_reader(const char* script_name, int* slen) {
char fullname[50];
sprintf(fullname, "./script/%s", script_name);
FILE *fp;
fp = fopen(fullname, "rb");
fp = fopen(script_name, "rb");
if (!fp)
return 0;
fseek(fp, 0, SEEK_END);
......@@ -73,6 +71,10 @@ extern "C" DECL_DLLEXPORT ptr create_duel(uint32 seed) {
extern "C" DECL_DLLEXPORT void start_duel(ptr pduel, int options) {
duel* pd = (duel*)pduel;
pd->game_field->core.duel_options |= options;
pd->game_field->core.shuffle_hand_check[0] = FALSE;
pd->game_field->core.shuffle_hand_check[1] = FALSE;
pd->game_field->core.shuffle_deck_check[0] = FALSE;
pd->game_field->core.shuffle_deck_check[1] = FALSE;
if(pd->game_field->player[0].start_count > 0)
pd->game_field->draw(0, REASON_RULE, PLAYER_NONE, 0, pd->game_field->player[0].start_count);
if(pd->game_field->player[1].start_count > 0)
......@@ -287,6 +289,8 @@ extern "C" DECL_DLLEXPORT int32 query_field_info(ptr pduel, byte* buf) {
*buf++ = MSG_RELOAD_FIELD;
card* pcard;
for(int playerid = 0; playerid < 2; ++playerid) {
*((int*)(buf)) = ptduel->game_field->player[playerid].lp;
buf += 4;
for(uint32 i = 0; i < 5; ++i) {
pcard = ptduel->game_field->player[playerid].list_mzone[i];
if(pcard) {
......
......@@ -234,7 +234,7 @@ int32 field::select_card(uint16 step, uint8 playerid, uint8 cancelable, uint8 mi
if((playerid == 1) && (core.duel_options & DUEL_SIMPLE_AI)) {
returns.bvalue[0] = min;
for(uint8 i = 0; i < min; ++i)
returns.bvalue[i + 1] = i + 1;
returns.bvalue[i + 1] = i;
return TRUE;
}
core.units.begin()->arg2 = ((uint32)min) + (((uint32)max) << 16);
......@@ -289,8 +289,16 @@ int32 field::select_chain(uint16 step, uint8 playerid, uint8 spe_count, uint8 fo
if((playerid == 1) && (core.duel_options & DUEL_SIMPLE_AI)) {
if(core.select_chains.size() == 0)
returns.ivalue[0] = -1;
else
returns.ivalue[0] = 0;
else {
bool act = true;
for(auto chit = core.current_chain.begin(); chit != core.current_chain.end(); ++chit)
if(chit->triggering_player == 1)
act = false;
if(act)
returns.ivalue[0] = 0;
else
returns.ivalue[0] = -1;
}
return TRUE;
}
pduel->write_buffer8(MSG_SELECT_CHAIN);
......
......@@ -461,9 +461,10 @@ public:
static int32 debug_message(lua_State *L);
static int32 debug_add_card(lua_State *L);
static int32 debug_set_player_info(lua_State *L);
static int32 debug_set_duel_info(lua_State *L);
static int32 debug_reload_field_begin(lua_State *L);
static int32 debug_reload_field_end(lua_State *L);
static int32 debug_set_ai_name(lua_State *L);
static int32 debug_show_hint(lua_State *L);
};
#endif /* SCRIPTLIB_H_ */
......@@ -35,9 +35,10 @@ function c70284332.operation(e,tp,eg,ep,ev,re,r,rp)
if c:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsRelateToEffect(e) then
c:SetCardTarget(tc)
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_SET_CONTROL)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_SINGLE_RANGE+EFFECT_FLAG_OWNER_RELATE)
e1:SetRange(LOCATION_MZONE)
e1:SetValue(tp)
e1:SetReset(RESET_EVENT+0x1fc0000)
e1:SetCondition(c70284332.con)
......@@ -55,7 +56,7 @@ end
function c70284332.con(e)
local c=e:GetOwner()
local h=e:GetHandler()
return not c:IsDisabled() and c:IsHasCardTarget(h)
return c:IsHasCardTarget(h)
end
function c70284332.dircon(e)
return e:GetHandler():IsReason(REASON_DESTROY)
......
......@@ -11,9 +11,10 @@ function c87902575.initial_effect(c)
e1:SetLabelObject(ng)
--remove
local e2=Effect.CreateEffect(c)
e2:SetCategory(CATEGORY_REMOVE)
e2:SetDescription(aux.Stringid(87902575,0))
e2:SetCategory(CATEGORY_REMOVE)
e2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_TRIGGER_F)
e2:SetProperty(EFFECT_FLAG_CARD_TARGET)
e2:SetRange(LOCATION_SZONE)
e2:SetCode(EVENT_SUMMON_SUCCESS)
e2:SetTarget(c87902575.rmtg)
......@@ -46,9 +47,11 @@ function c87902575.clear(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
e:GetLabelObject():Clear()
end
function c87902575.rmtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
eg:GetFirst():CreateEffectRelation(e)
function c87902575.rmtg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
if chk==0 then return eg:GetFirst():IsOnField()
and eg:GetFirst():IsCanBeEffectTarget(e) end
Duel.SetTargetCard(eg:GetFirst())
Duel.SetOperationInfo(0,CATEGORY_REMOVE,eg,1,0,0)
end
function c87902575.rmop(e,tp,eg,ep,ev,re,r,rp)
......
......@@ -46,6 +46,29 @@ function Auxiliary.DualNormalCondition(effect)
local c=effect:GetHandler()
return c:IsFaceup() and not c:IsDualState()
end
function Auxiliary.BeginPuzzle(effect)
local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_PHASE+PHASE_END)
e1:SetCountLimit(1)
e1:SetOperation(Auxiliary.PuzzleOp)
Duel.RegisterEffect(e1,0)
local e2=Effect.GlobalEffect()
e2:SetType(EFFECT_TYPE_FIELD)
e2:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e2:SetCode(EFFECT_SKIP_DP)
e2:SetTargetRange(1,0)
Duel.RegisterEffect(e2,0)
local e3=Effect.GlobalEffect()
e3:SetType(EFFECT_TYPE_FIELD)
e3:SetProperty(EFFECT_FLAG_PLAYER_TARGET)
e3:SetCode(EFFECT_SKIP_SP)
e3:SetTargetRange(1,0)
Duel.RegisterEffect(e3,0)
end
function Auxiliary.PuzzleOp(e,tp)
Duel.SetLP(0,0)
end
function Auxiliary.EnableDualAttribute(c)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
......
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