Skip to content

Commit

Permalink
new features & scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
argon.sun committed Dec 1, 2011
1 parent 7482ae6 commit ceda665
Show file tree
Hide file tree
Showing 35 changed files with 1,412 additions and 72 deletions.
32 changes: 1 addition & 31 deletions gframe/deck_con.cpp
Expand Up @@ -579,37 +579,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
if(!is_draging && pre_code != hovered_code) {
if(hovered_code) {
CardData cd;
wchar_t formatBuffer[64];
mainGame->dataManager.GetData(hovered_code, &cd);
mainGame->imgCard->setImage(mainGame->imageManager.GetTexture(hovered_code));
myswprintf(formatBuffer, L"%ls[%d]", mainGame->dataManager.GetName(hovered_code), hovered_code);
mainGame->stName->setText(formatBuffer);
if(cd.type & TYPE_MONSTER) {
myswprintf(formatBuffer, L"[%ls] %ls/%ls", DataManager::FormatType(cd.type), DataManager::FormatRace(cd.race), DataManager::FormatAttribute(cd.attribute));
mainGame->stInfo->setText(formatBuffer);
formatBuffer[0] = L'[';
for(int i = 1; i <= cd.level; ++i)
formatBuffer[i] = L'';
formatBuffer[cd.level + 1] = L']';
formatBuffer[cd.level + 2] = L' ';
if(cd.attack < 0 && cd.defence < 0)
myswprintf(&formatBuffer[cd.level + 3], L"?/?");
else if(cd.attack < 0)
myswprintf(&formatBuffer[cd.level + 3], L"?/%d", cd.defence);
else if(cd.defence < 0)
myswprintf(&formatBuffer[cd.level + 3], L"%d/?", cd.attack);
else
myswprintf(&formatBuffer[cd.level + 3], L"%d/%d", cd.attack, cd.defence);
mainGame->stDataInfo->setText(formatBuffer);
mainGame->stText->setRelativePosition(irr::core::position2di(15, 83));
} else {
myswprintf(formatBuffer, L"[%ls]", DataManager::FormatType(cd.type));
mainGame->stInfo->setText(formatBuffer);
mainGame->stDataInfo->setText(L"");
mainGame->stText->setRelativePosition(irr::core::position2di(15, 60));
}
mainGame->SetStaticText(mainGame->stText, 270, mainGame->textFont, (wchar_t*)mainGame->dataManager.GetText(hovered_code));
mainGame->ShowCardInfo(hovered_code);
}
if(pre_code)
mainGame->imageManager.RemoveTexture(pre_code);
Expand Down
51 changes: 21 additions & 30 deletions gframe/event_handler.cpp
Expand Up @@ -17,6 +17,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
switch(id) {
case BUTTON_CLEAR_LOG: {
mainGame->lstLog->clear();
mainGame->logParam.clear();
break;
}
case BUTTON_MODE_EXIT: {
Expand Down Expand Up @@ -759,6 +760,25 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
mainGame->ebJoinPort->setText(formatBuffer);
break;
}
case LISTBOX_LOG: {
int sel = mainGame->lstLog->getSelected();
if(sel != -1 && mainGame->logParam.size() >= sel && mainGame->logParam[sel]) {
mainGame->ShowCardInfo(mainGame->logParam[sel]);
}
break;
}
}
break;
}
case irr::gui::EGET_LISTBOX_SELECTED_AGAIN: {
switch(id) {
case LISTBOX_LOG: {
int sel = mainGame->lstLog->getSelected();
if(sel != -1 && mainGame->logParam.size() >= sel && mainGame->logParam[sel]) {
mainGame->wInfos->setActiveTab(0);
}
break;
}
}
break;
}
Expand Down Expand Up @@ -1285,36 +1305,7 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
for(auto cit = mcard->ownerTarget.begin(); cit != mcard->ownerTarget.end(); ++cit)
(*cit)->is_showtarget = true;
if(mcard->code) {
CardData cd;
mainGame->dataManager.GetData(mcard->code, &cd);
mainGame->imgCard->setImage(mainGame->imageManager.GetTexture(mcard->code));
myswprintf(formatBuffer, L"%ls[%d]", mainGame->dataManager.GetName(mcard->code), mcard->code);
mainGame->stName->setText(formatBuffer);
if(cd.type & TYPE_MONSTER) {
myswprintf(formatBuffer, L"[%ls] %ls/%ls", DataManager::FormatType(cd.type), DataManager::FormatRace(cd.race), DataManager::FormatAttribute(cd.attribute));
mainGame->stInfo->setText(formatBuffer);
formatBuffer[0] = L'[';
for(int i = 1; i <= cd.level; ++i)
formatBuffer[i] = L'';
formatBuffer[cd.level + 1] = L']';
formatBuffer[cd.level + 2] = L' ';
if(cd.attack < 0 && cd.defence < 0)
myswprintf(&formatBuffer[cd.level + 3], L"?/?");
else if(cd.attack < 0)
myswprintf(&formatBuffer[cd.level + 3], L"?/%d", cd.defence);
else if(cd.defence < 0)
myswprintf(&formatBuffer[cd.level + 3], L"%d/?", cd.attack);
else
myswprintf(&formatBuffer[cd.level + 3], L"%d/%d", cd.attack, cd.defence);
mainGame->stDataInfo->setText(formatBuffer);
mainGame->stText->setRelativePosition(irr::core::position2di(15, 83));
} else {
myswprintf(formatBuffer, L"[%ls]", DataManager::FormatType(cd.type));
mainGame->stInfo->setText(formatBuffer);
mainGame->stDataInfo->setText(L"");
mainGame->stText->setRelativePosition(irr::core::position2di(15, 60));
}
mainGame->SetStaticText(mainGame->stText, 270, mainGame->textFont, (wchar_t*)mainGame->dataManager.GetText(mcard->code));
mainGame->ShowCardInfo(mcard->code);
if(mcard->location & 0xe) {
std::wstring str;
if(mcard->type & TYPE_MONSTER) {
Expand Down
35 changes: 34 additions & 1 deletion gframe/game.cpp
Expand Up @@ -165,7 +165,7 @@ bool Game::Initialize() {
stText = env->addStaticText(L"", rect<s32>(15, 83, 296, 324), false, true, tabInfo, -1, false);
//log
irr::gui::IGUITab* tabLog = wInfos->addTab(L"消息记录");
lstLog = env->addListBox(rect<s32>(10, 10, 290, 290), tabLog, -1, false);
lstLog = env->addListBox(rect<s32>(10, 10, 290, 290), tabLog, LISTBOX_LOG, false);
lstLog->setItemHeight(18);
btnClearLog = env->addButton(rect<s32>(160, 300, 260, 325), tabLog, BUTTON_CLEAR_LOG, L"清除记录");
btnSaveLog = env->addButton(rect<s32>(40, 300, 140, 325), tabLog, BUTTON_SAVE_LOG, L"保存记录");
Expand Down Expand Up @@ -604,5 +604,38 @@ void Game::LoadConfig() {
void Game::SaveConfig() {

}
void Game::ShowCardInfo(int code) {
CardData cd;
wchar_t formatBuffer[256];
dataManager.GetData(code, &cd);
imgCard->setImage(imageManager.GetTexture(code));
myswprintf(formatBuffer, L"%ls[%d]", dataManager.GetName(code), code);
stName->setText(formatBuffer);
if(cd.type & TYPE_MONSTER) {
myswprintf(formatBuffer, L"[%ls] %ls/%ls", DataManager::FormatType(cd.type), DataManager::FormatRace(cd.race), DataManager::FormatAttribute(cd.attribute));
stInfo->setText(formatBuffer);
formatBuffer[0] = L'[';
for(int i = 1; i <= cd.level; ++i)
formatBuffer[i] = L'';
formatBuffer[cd.level + 1] = L']';
formatBuffer[cd.level + 2] = L' ';
if(cd.attack < 0 && cd.defence < 0)
myswprintf(&formatBuffer[cd.level + 3], L"?/?");
else if(cd.attack < 0)
myswprintf(&formatBuffer[cd.level + 3], L"?/%d", cd.defence);
else if(cd.defence < 0)
myswprintf(&formatBuffer[cd.level + 3], L"%d/?", cd.attack);
else
myswprintf(&formatBuffer[cd.level + 3], L"%d/%d", cd.attack, cd.defence);
stDataInfo->setText(formatBuffer);
stText->setRelativePosition(irr::core::position2di(15, 83));
} else {
myswprintf(formatBuffer, L"[%ls]", DataManager::FormatType(cd.type));
stInfo->setText(formatBuffer);
stDataInfo->setText(L"");
stText->setRelativePosition(irr::core::position2di(15, 60));
}
SetStaticText(stText, 270, textFont, (wchar_t*)dataManager.GetText(code));
}

}
6 changes: 4 additions & 2 deletions gframe/game.h
Expand Up @@ -74,7 +74,8 @@ class Game {
void DrawDeckBd();
void LoadConfig();
void SaveConfig();

void ShowCardInfo(int code);

int LocalPlayer(int player);
const wchar_t* LocalName(int local_player);
bool SendByte(int player, char val);
Expand Down Expand Up @@ -123,7 +124,7 @@ class Game {
DeckManager deckManager;
Materials matManager;
Replay lastReplay;

std::vector<int> logParam;
unsigned short linePattern;
int waitFrame;
int signalFrame;
Expand Down Expand Up @@ -342,6 +343,7 @@ class Game {
#define TAB_MODES 50
#define BUTTON_SAVE_LOG 100
#define BUTTON_CLEAR_LOG 101
#define LISTBOX_LOG 102
#define BUTTON_LAN_START_SERVER 110
#define BUTTON_LAN_CANCEL_SERVER 111
#define BUTTON_LAN_CONNECT 112
Expand Down
13 changes: 13 additions & 0 deletions gframe/message.cpp
Expand Up @@ -338,6 +338,7 @@ int Game::EngineThread(void* pd) {
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->lstLog->clear();
mainGame->logParam.clear();
mainGame->imgCard->setImage(0);
mainGame->stName->setText(L"");
mainGame->stDataInfo->setText(L"");
Expand Down Expand Up @@ -1065,6 +1066,7 @@ int Game::RecvThread(void* pd) {
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->lstLog->clear();
mainGame->logParam.clear();
mainGame->imgCard->setImage(0);
mainGame->stName->setText(L"");
mainGame->stDataInfo->setText(L"");
Expand Down Expand Up @@ -1149,6 +1151,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
case HINT_OPSELECTED: {
myswprintf(textBuffer, L"对方选择了:[%ls]", mainGame->dataManager.GetDesc(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
Expand All @@ -1164,6 +1167,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
case HINT_RACE: {
myswprintf(textBuffer, L"对方宣言了:[%ls]", DataManager::FormatRace(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
Expand All @@ -1172,6 +1176,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
case HINT_ATTRIB: {
myswprintf(textBuffer, L"对方宣言了:[%ls]", DataManager::FormatAttribute(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
Expand All @@ -1180,6 +1185,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
case HINT_CODE: {
myswprintf(textBuffer, L"对方宣言了:[%ls]", mainGame->dataManager.GetName(data));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
Expand All @@ -1188,6 +1194,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
case HINT_NUMBER: {
myswprintf(textBuffer, L"对方选择了:[%d]", data);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->SetStaticText(mainGame->stACMessage, 310, mainGame->textFont, textBuffer);
mainGame->PopupElement(mainGame->wACMessage, 20);
mainGame->WaitFrameSignal(40);
Expand Down Expand Up @@ -1864,6 +1871,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
ClientCard* pcard;
myswprintf(textBuffer, L"翻开卡组上方%d张卡:", count);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
mainGame->dField.selectable_cards.clear();
for (int i = 0; i < count; ++i) {
code = NetManager::ReadInt32(pbuf);
Expand All @@ -1875,6 +1883,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
pcard->SetCode(code);
myswprintf(textBuffer, L"%d [%ls]", i, mainGame->dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
float shift = -0.15f;
if (player == 1) shift = 0.15f;
pcard->dPos = irr::core::vector3df(shift, 0, 0);
Expand All @@ -1895,6 +1904,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
ClientCard* pcard;
myswprintf(textBuffer, L"确认%d张卡:", count);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
for (int i = 0; i < count; ++i) {
code = NetManager::ReadInt32(pbuf);
c = mainGame->LocalPlayer(NetManager::ReadInt8(pbuf));
Expand All @@ -1905,6 +1915,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
pcard->SetCode(code);
myswprintf(textBuffer, L"%d [%ls]", i, mainGame->dataManager.GetName(code));
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(code);
if (l & 0x41) {
float shift = -0.15f;
if ((c == 0 && l == 0x40) || (c == 1 && l == 0x1)) shift = 0.15f;
Expand Down Expand Up @@ -2547,6 +2558,7 @@ bool Game::SolveMessage(void* pd, char* msg, int len) {
mainGame->WaitFrameSignal(30);
myswprintf(textBuffer, L"[%ls](%ls,%d)成为对象", mainGame->dataManager.GetName(pcard->code), DataManager::FormatLocation(l), s);
mainGame->lstLog->addItem(textBuffer);
mainGame->logParam.push_back(0);
pcard->is_highlighting = false;
}
return true;
Expand Down Expand Up @@ -3107,6 +3119,7 @@ int Game::ReplayThread(void* pd) {
mainGame->btnM2->setVisible(false);
mainGame->btnEP->setVisible(false);
mainGame->lstLog->clear();
mainGame->logParam.clear();
mainGame->imgCard->setImage(0);
mainGame->stName->setText(L"");
mainGame->stDataInfo->setText(L"");
Expand Down
2 changes: 1 addition & 1 deletion gframe/network.h
Expand Up @@ -5,7 +5,7 @@
#include <set>
#include <vector>

#define PROTO_VERSION 0x100e
#define PROTO_VERSION 0x100f

namespace ygo {

Expand Down
2 changes: 1 addition & 1 deletion ocgcore/processor.cpp
Expand Up @@ -3460,6 +3460,7 @@ int32 field::add_chain(uint16 step) {
clit->disable_player = PLAYER_NONE;
clit->replace_op = 0;
core.current_chain.push_back(*clit);
peffect->handler->create_relation(peffect);
if(peffect->cost) {
core.sub_solving_event.push_back(clit->evt);
add_process(PROCESSOR_EXECUTE_COST, 0, peffect, 0, clit->triggering_player, 0);
Expand Down Expand Up @@ -3491,7 +3492,6 @@ int32 field::add_chain(uint16 step) {
process_single_event();
}
}
clit->triggering_effect->handler->create_relation(clit->triggering_effect);
if(peffect->type & EFFECT_TYPE_ACTIVATE) {
core.leave_confirmed.insert(peffect->handler);
if(!(peffect->handler->data.type & (TYPE_CONTINUOUS + TYPE_FIELD + TYPE_EQUIP))
Expand Down
45 changes: 45 additions & 0 deletions script/c16708652.lua
@@ -0,0 +1,45 @@
--カラクリ粉
function c16708652.initial_effect(c)
--Activate
local e1=Effect.CreateEffect(c)
e1:SetCategory(CATEGORY_ATKCHANGE+CATEGORY_DEFCHANGE)
e1:SetType(EFFECT_TYPE_ACTIVATE)
e1:SetProperty(EFFECT_FLAG_CARD_TARGET+EFFECT_FLAG_DAMAGE_STEP)
e1:SetCode(EVENT_FREE_CHAIN)
e1:SetHintTiming(TIMING_DAMAGE_STEP)
e1:SetCondition(c16708652.condition)
e1:SetTarget(c16708652.target)
e1:SetOperation(c16708652.activate)
c:RegisterEffect(e1)
end
function c16708652.condition(e,tp,eg,ep,ev,re,r,rp)
local ph=Duel.GetCurrentPhase()
return ph==PHASE_BATTLE or (ph==PHASE_DAMAGE and not Duel.IsDamageCalculated())
end
function c16708652.filter(c)
return c:IsPosition(POS_FACEUP_ATTACK) and c:IsSetCard(0x11)
end
function c16708652.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return false end
if chk==0 then return Duel.IsExistingTarget(c16708652.filter,tp,LOCATION_MZONE,LOCATION_MZONE,2,nil) end
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(16708652,0))
local g1=Duel.SelectTarget(tp,c16708652.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,nil)
Duel.Hint(HINT_SELECTMSG,tp,aux.Stringid(16708652,1))
local g2=Duel.SelectTarget(tp,c16708652.filter,tp,LOCATION_MZONE,LOCATION_MZONE,1,1,g1:GetFirst())
e:SetLabelObject(g1:GetFirst())
end
function c16708652.activate(e,tp,eg,ep,ev,re,r,rp)
local tc1=e:GetLabelObject()
local g=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS)
local tc2=g:GetFirst()
if tc1==tc2 then tc2=g:GetNext() end
if tc1:IsRelateToEffect(e) and tc1:IsPosition(POS_FACEUP_ATTACK) and tc2:IsRelateToEffect(e) then
Duel.ChangePosition(tc1,POS_FACEUP_DEFENCE)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetReset(RESET_EVENT+0x1fe0000+RESET_PHASE+RESET_END)
e1:SetValue(tc1:GetAttack())
tc2:RegisterEffect(e1)
end
end

0 comments on commit ceda665

Please sign in to comment.