📄 lottosystem.cpp
字号:
void CLottoSystem::SendDBNewEvent()
{
t_packet p;
tm Date = GetCurDate();
Date.tm_year = Date.tm_year + 1900;//soto-LottoADD
LOTTO_EVENT_INFO Lotto_Info;memset(&Lotto_Info,0,sizeof(Lotto_Info));
Lotto_Info.nLottoID = m_Lotto_Info.nLottoID + 1;
memcpy(&Lotto_Info.StartDate,&Date,sizeof(tm));
p.h.header.type = CMD_NEW_EVENT;
p.h.header.size = sizeof(Lotto_Info);
memcpy(&p.u.Lotto_Info,&Lotto_Info,sizeof(Lotto_Info));
QueuePacket(connections,DB_DEMON,&p,1);
MyLog(0,"Lotto : NewEvent Start!!!! EventNumber : '%d' ",Lotto_Info.nLottoID);
}
void CLottoSystem::RecvDBNewEvent(LOTTO_EVENT_INFO* pInfo)
{
m_EventStatus = EVENT;
m_bGenNumbers = false;
memcpy(&m_Lotto_Info,pInfo,sizeof(LOTTO_EVENT_INFO));
}
void CLottoSystem::RecvBuyLotto(t_BUY_LOTTO *pBuyLotto)
{
int cn = ExistHe(pBuyLotto->strCharName);
if(cn)
{
t_packet p;
p.h.header.type = CMD_LOTTO_BUY;
p.h.header.size = sizeof(t_BUY_LOTTO);
CHARLIST* pChar = ::CheckServerId(cn);
if(pChar)
{
// tm Date = GetCurDate();
t_BUY_LOTTO BuyLotto; memcpy(&BuyLotto,pBuyLotto,sizeof(BuyLotto));
if(m_EventStatus == LOTTERIED)//寸梅 肯丰 扁埃捞促.
{
memcpy(&p.u.Lotto_Buy,pBuyLotto,sizeof(t_BUY_LOTTO));
p.u.Lotto_Buy.anLottoNumber[0] = -1;//锅龋狼 盖菊捞 -1捞搁
QueuePacket(connections,cn,&p,1);
return;
}
else
{
if(LocalMgr.IsAbleNation(TAIWAN | HONGKONG | CHINA))//苞陛 巩力肺 公炼扒 DBDEMON栏肺 蜡没阑 茄促.
{
t_packet p2;
p2.h.header.type = CMD_CAN_BUY;
p2.h.header.size = sizeof(t_BUY_LOTTO);
pBuyLotto->nLottoID = this->m_Lotto_Info.nLottoID;//soto-LottoADD
memcpy(&p2.u.Lotto_Buy,pBuyLotto,sizeof(t_BUY_LOTTO));
QueuePacket(connections,DB_DEMON,&p2,1);
}
else
{
if(pChar->GetBankMoney() < m_nLottoPay)//捣捞 葛磊扼促.
{
memcpy(&p.u.Lotto_Buy,pBuyLotto,sizeof(t_BUY_LOTTO));
p.u.Lotto_Buy.anLottoNumber[0] = 0;//锅龋狼 盖菊捞 0捞搁 捣捞 葛磊扼促.
QueuePacket(connections,cn,&p,1);
}
else//混荐 乐绰 炼扒捞 面练 登菌促. 付瘤阜栏肺 割厘阑 或绊 吝汗 锅龋啊 乐绰瘤 犬牢 秦具 茄促.
{
//咯扁辑父 DB_DEMON栏肺 犬牢 夸没阑 茄促.
t_packet p2;
p2.h.header.type = CMD_CAN_BUY;
p2.h.header.size = sizeof(t_BUY_LOTTO);
pBuyLotto->nLottoID = this->m_Lotto_Info.nLottoID;//soto-LottoADD
memcpy(&p2.u.Lotto_Buy,pBuyLotto,sizeof(t_BUY_LOTTO));
QueuePacket(connections,DB_DEMON,&p2,1);
}
}
}
}
}
}
void CLottoSystem::RecvCanBuyLotto(t_BUY_LOTTO *pCanBuyLotto)
{
int cn = ExistHe(pCanBuyLotto->strCharName);
if(cn)
{
CHARLIST *pChar = ::CheckServerId(cn);
if(pChar)
{
t_packet p;
p.h.header.type = CMD_LOTTO_BUY;
p.h.header.size = sizeof(t_BUY_LOTTO);
memcpy(&p.u.Lotto_Buy,pCanBuyLotto,sizeof(t_BUY_LOTTO));
if(p.u.Lotto_Buy.anLottoNumber[0] > 0)//混荐 乐促.//某腐磐客DB_DEMON 俊霸 悼矫俊 焊辰促.
{
p.u.Lotto_Buy.m_nLottoPay = m_nLottoPay;
if(LocalMgr.IsAbleNation(KOREA | CHINA | THAI | HONGKONG | USA | JAPAN))//soto-LottoADD 措父篮 器牢飘肺 茄促.
{
pChar->DecBankMoney(m_nLottoPay, BMCT_BUY_LOTTO); // CSD-030723
}
else
{
}
QueuePacket(connections,cn,&p,1);
QueuePacket(connections,DB_DEMON,&p,1);
}
else
{
QueuePacket(connections,cn,&p,1);//某腐磐俊霸父 焊辰促.
}
}
}
}
void CLottoSystem::RecvCheckWinner(int cn)
{
if(m_EventStatus == LOTTERIED)
{
//<! BBD 040127 肺肚 橇肺技胶 函版
if(m_bWinnerChecking)
{
// 肺肚 盲欧吝捞促 扁笛府扼绰 矫弊澄阑 焊郴技
t_packet p;
p.h.header.type = CMD_WINNER_CHECK;
p.h.header.size = sizeof(t_CHECK_WINNER);
memset(&p.u.Check_Winner,0,sizeof(t_CHECK_WINNER));
p.u.Check_Winner.nWinItemCount = -10; // <--- 捞逞捞 盲欧吝烙阑 钎矫茄促
QueuePacket(connections,cn,&p,1); //努扼捞攫飘俊霸..盲欧吝捞扼绰 皋技瘤.
return;
}
//> BBD 040127 肺肚 橇肺技胶 函版
t_packet p;
p.h.header.type = CMD_WINNER_CHECK;
p.h.header.size = sizeof(t_CHECK_WINNER);
memset(&p.u.Check_Winner,0,sizeof(t_CHECK_WINNER));
p.u.Check_Winner.nLottoID = m_Lotto_Info.nLottoID;//soto-LottoADD
strcpy(p.u.Check_Winner.strCharName,::CheckServerId(cn)->Name);
memcpy(p.u.Check_Winner.anWinNumbers,m_Lotto_Info.anWinNumbers,sizeof(int)*10);
QueuePacket(connections,DB_DEMON,&p,1);//单阁俊促...犬牢 夸没阑 茄促.
//<! BBD 040127 肺肚 喉钒 肺弊 巢辫
m_bWinnerChecking = true; // true老锭 喉钒吝捞促
MyLog(LOG_NORMAL, "Start Checking Lotto now UserID = %s",
p.u.Check_Winner.strCharName);
//> BBD 040127 肺肚 喉钒 肺弊 巢辫
}
else
{
t_packet p;
p.h.header.type = CMD_WINNER_CHECK;
p.h.header.size = sizeof(t_CHECK_WINNER);
memset(&p.u.Check_Winner,0,sizeof(t_CHECK_WINNER));
strcpy(p.u.Check_Winner.strCharName,::CheckServerId(cn)->Name);
memset(p.u.Check_Winner.anWinNumbers,0,sizeof(int)*10);
p.u.Check_Winner.nWinItemCount = -3;
// p.u.Check_Winner.anWinNumbers[0]
QueuePacket(connections,cn,&p,1);//努扼捞攫飘俊霸..眠梅 扁埃捞 酒聪扼绰 皋技瘤.
}
}
void CLottoSystem::RecvCheckOKWinner(t_CHECK_WINNER *pCheckOK)
{
int cn = ::ExistHe(pCheckOK->strCharName);
if(cn)
{
CHARLIST* pChar = ::CheckServerId(cn);
t_packet p;
p.h.header.type = CMD_WINNER_CHECK;
p.h.header.size = sizeof(t_CHECK_WINNER);
memcpy(&p.u.Check_Winner,pCheckOK,sizeof(t_CHECK_WINNER));
if(pCheckOK->nWinItemCount > 0)//老窜篮 寸梅 登菌扁绰 茄单.
{
//某腐磐狼 酒捞袍 芒绊狼 后傍埃阑 犬牢且鞘夸啊 乐促. 面盒窍搁. +荐 持绢 霖促. 面盒窍瘤 臼栏搁 -1
int nBlank = 0;
for(int i = 0;i < 5;i++)
for(int j = 0; j < 3;j++)
for(int k = 0;k < 6;k++)
if(!pChar->bank[i][j][k].item_no) nBlank++;
int nNeedBlank = pCheckOK->nWinItemCount;
if(nBlank >= pCheckOK->nWinItemCount )
{
QueuePacket(connections,cn,&p,1);//酒捞袍阑 父甸菌促.
//酒捞袍阑 父甸绢 林绢具 茄促.
int nItemCounter = pCheckOK->nWinItemCount;
//肺弊甫 巢变促.
for(int nGradeItemIndex = 0;nGradeItemIndex < 5;++nGradeItemIndex)
{
int nGradeItemCount = 0;
ItemAttr Item = ::GenerateItem(m_anGiveItemNumber[nGradeItemIndex]);
if(nGradeItemCount = pCheckOK->anWinItemsCount[nGradeItemIndex])
{
for(int i = 0;i < 5;i++)
{
for(int j = 0; j < 3;j++)
{
for(int k = 0;k < 6;k++)
{
if(!pChar->bank[i][j][k].item_no)
{
if(nGradeItemCount > 0)
{
pChar->bank[i][j][k] = Item;
nGradeItemCount--;
}
}
}
}
}
FILE* fp = NULL;
char szFileName[512] = {0,};
sprintf(szFileName,"./LotteryItem/_%03d_ItemGive.txt",this->m_Lotto_Info.nLottoID);
fp = fopen(szFileName,"at+");
GetCurDate();
if(fp != NULL)
{
fprintf(fp ,"Lotto 寸梅 : %s 丛俊霸 %d俺狼 %d殿 酒捞袍捞 瘤鞭 登菌嚼聪促.\n"
,pChar->Name,pCheckOK->anWinItemsCount[nGradeItemIndex]
,nGradeItemIndex+1);
fclose(fp);
}
else
{
}
}
}
p.h.header.type = CMD_DEL_LOTTO_USER;//单阁俊促 昏力 夸没阑 秦具 茄促.
QueuePacket(connections,DB_DEMON,&p,1);
}
else
{
pCheckOK->nWinItemCount = -1;
pCheckOK->anWinNumbers[0] = nNeedBlank;//鞘夸茄 后傍埃狼 荐.
memcpy(&p.u.Check_Winner,pCheckOK,sizeof(t_CHECK_WINNER)); // BBD 040127 皋葛府 墨乔啊 鞘夸窍促
QueuePacket(connections,cn,&p,1);//角菩 脚龋甫 焊郴磊.
//<! BBD 040127 肺肚 喉钒秦力 肺弊 巢辫
m_bWinnerChecking = false; // 肺肚 犬牢 啊瓷窍霸 钱绢林磊
MyLog(LOG_NORMAL, "End Checking Lotto now");
//> BBD 040127 肺肚 喉钒秦力 肺弊 巢辫
}
}
else if(pCheckOK->nWinItemCount == 0)//参捞促.
{
QueuePacket(connections,cn,&p,1);//努扼捞攫飘俊霸绰 焊陈促.
p.h.header.type = CMD_DEL_LOTTO_USER;//单阁俊促 昏力 夸没阑 秦具 茄促.
QueuePacket(connections,DB_DEMON,&p,1);
}
}
}
void CLottoSystem::RecvLottoInfo(LOTTO_EVENT_INFO *pLottoInfo)
{
m_EventStatus = LOTTERIED;
memcpy(&m_Lotto_Info,pLottoInfo,sizeof(LOTTO_EVENT_INFO));
}
void CLottoSystem::RecvOpenWinnerMenu(int cn)
{
t_packet p;
p.h.header.type = CMD_CHECK_WINNER_MENU;
p.h.header.size = sizeof(t_WINNER_MENU);
memset(&p.u.Lotto_Winner_Menu,0,sizeof(t_WINNER_MENU));
p.u.Lotto_Winner_Menu.nLottoID = m_Lotto_Info.nLottoID;//soto-LottoADD
strcpy(p.u.Lotto_Winner_Menu.strCharName,::CheckServerId(cn)->Name);
p.u.Lotto_Winner_Menu.nMaxLottoCount = this->m_nLottoNumberCount;
QueuePacket(connections,DB_DEMON,&p,1);
}
void CLottoSystem::RecvCheckOpenWinnerMenu(t_WINNER_MENU *pWinnerMenu)
{
int cn = ::ExistHe(pWinnerMenu->strCharName);
if(cn)
{
t_packet p;
p.h.header.type = CMD_OPEN_WINNER_MENU;
p.h.header.size = sizeof(t_WINNER_MENU);
memcpy(&p.u.Lotto_Winner_Menu,pWinnerMenu,sizeof(t_WINNER_MENU));
if(m_EventStatus == EVENT)
{
memset(p.u.Lotto_Winner_Menu.anWinNumbers,0,sizeof(int) * 10);
}
QueuePacket(connections,cn,&p,1);
}
}
void CLottoSystem::RecvOpenLottoMenu(int cn)
{
t_packet p;
p.h.header.type = CMD_OPEN_LOTTOMENU;
p.h.header.size = sizeof(t_OPEN_LOTTO_MENU);
p.u.Lotto_Menu_Open.nMaxNumberCount = this->m_nLottoNumberCount;
QueuePacket(connections,cn,&p,1);
}
void CLottoSystem::BroadCastLotteryMsg()
{
t_packet p;
p.h.header.type = CMD_LOTTERY_BROADCAST;
p.h.header.size = sizeof(t_LOTTERY_INFO);
p.u.Lotto_BroadCast.nLottoID = this->m_Lotto_Info.nLottoID;
p.u.Lotto_BroadCast.nWinNumCount = this->m_Lotto_Info.nWinNumCount;
memcpy(p.u.Lotto_BroadCast.anWinNumbers,this->m_Lotto_Info.anWinNumbers,sizeof(int)*10);
::SendPacket2Maps(&p);
g_pUserManager->SendPacket(&p); // CSD-CN-031213
}
int CLottoSystem::GetLottoID()
{
return m_Lotto_Info.nLottoID;
}
int CLottoSystem::GetNextLotteryIndex()
{
return -1;
}
int CLottoSystem::FindSameDayIndex(int nDay)
{
return -1;
}
//<! BBD 040127 肺肚 橇肺技胶 函版
void CLottoSystem::CheckIsDelOk(bool bIsOk)
{
// 葛电 犬牢 例瞒啊 场车栏骨肺 促弗 努扼捞攫飘狼 犬牢阑 倾侩茄促
if(bIsOk && m_bWinnerChecking)
{
//<! BBD 040127 肺肚 喉钒秦力 肺弊 巢辫
m_bWinnerChecking = false;
MyLog(LOG_NORMAL, "End Checking Lotto now");
//> BBD 040127 肺肚 喉钒秦力 肺弊 巢辫
}
}
//> BBD 040127 肺肚 橇肺技胶 函版
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -