chuyiwen_gmsv/npc/npc_gamblemaster.c

601 lines
21 KiB
C
Raw Normal View History

2016-12-24 08:45:52 +08:00
#include "version.h"
#include <string.h>
#include "char.h"
#include "object.h"
#include "char_base.h"
#include "npcutil.h"
#include "lssproto_serv.h"
#include "handletime.h"
#include "readmap.h"
#include "log.h"
#include "npc_eventaction.h"
#ifdef _GAMBLE_ROULETTE
#include "npc_gamblemaster.h"
void defPlayerGold( int meindex, int flg);
void NPC_GAMBLEMASTER_RESET( int meindex);
void Codef_Gold( int meindex, int toindex, int stone, int flg, char *token);
void NPC_GambleRoulette_selectWindow(int meindex,int toindex,int num,int select);
enum
{
ROULETTE_START=0,
ROULETTE_SELECT,
ROULETTE_LOOK,
ROULETTE_END,
};
enum
{
roulette1 = 11, roulette2, roulette3, roulette4, roulette5, roulette6, roulette7,
roulette8, roulette9, roulette10, roulette11, roulette12, roulette13, roulette14,
roulette15, roulette16, roulette17, roulette18, roulette19, roulette20,
roulette21 = 41, roulette22, roulette23, roulette24, roulette25, roulette26,
roulette27, roulette28, roulette29, roulette30, roulette31, roulette32,
roulette33, roulette34, roulette35, roulette36, roulette37, roulette38,
roulette39, roulette40,
roulette41 = 71, roulette42, roulette43, roulette44, roulette45,
roulette51 = 101, roulette52=102, roulette53=103,
roulette61 = 111, roulette62=112,
};
typedef struct tagGambleMaster
{
int m_fx;
int m_fy;
2017-01-13 23:37:03 +08:00
int m_type; //号码
int m_RG; //红绿1 2
int m_EO; //单双1 2
2016-12-24 08:45:52 +08:00
int m_SI;
int m_IN;
char str_type[56];
int m_nums;
}GambleEndType;
GambleEndType EndTypedef[60]={
2017-01-13 23:37:03 +08:00
{22, 8 , roulette1 , roulette41, roulette43, roulette51, roulette61, "号码红1", 0},
{7 , 8 , roulette1 , roulette41, roulette43, roulette51, roulette61, "号码红1", 0},
{22, 10, roulette3 , roulette41, roulette43, roulette51, roulette61, "号码红3", 0},
{7 , 6 , roulette3 , roulette41, roulette43, roulette51, roulette61, "号码红3", 0},
{20, 11, roulette5 , roulette41, roulette43, roulette51, roulette61, "号码红5", 0},
{9 , 5 , roulette5 , roulette41, roulette43, roulette51, roulette61, "号码红5", 0},
{19, 5 , roulette6 , roulette41, roulette44, roulette53, roulette61, "号码红6", 0},
{10, 11, roulette6 , roulette41, roulette44, roulette53, roulette61, "号码红6", 0},
{17, 5 , roulette8 , roulette41, roulette44, roulette53, roulette61, "号码红8", 0},
{12, 11, roulette8 , roulette41, roulette44, roulette53, roulette61, "号码红8", 0},
{16, 5 , roulette9 , roulette41, roulette43, roulette53, roulette61, "号码红9", 0},
{13, 11, roulette9 , roulette41, roulette43, roulette53, roulette61, "号码红9", 0},
{15, 5 , roulette10, roulette41, roulette44, roulette53, roulette61, "号码红10", 0},
{14, 11, roulette10, roulette41, roulette44, roulette53, roulette61, "号码红10", 0},
{12, 5 , roulette13, roulette41, roulette43, roulette52, roulette62, "号码红13", 0},
{17, 11, roulette13, roulette41, roulette43, roulette52, roulette62, "号码红13", 0},
{22, 6 , roulette17, roulette41, roulette43, roulette53, roulette62, "号码红17", 0},
{7 , 10, roulette17, roulette41, roulette43, roulette53, roulette62, "号码红17", 0},
{22, 5 , roulette18, roulette41, roulette44, roulette52, roulette62, "号码红18", 0},
{7 , 11, roulette18, roulette41, roulette44, roulette52, roulette62, "号码红18", 0},
{22, 9 , roulette22, roulette42, roulette44, roulette51, roulette61, "号码绿2", 0},
{7 , 7 , roulette22, roulette42, roulette44, roulette51, roulette61, "号码绿2", 0},
{21, 11, roulette24, roulette42, roulette44, roulette51, roulette61, "号码绿4", 0},
{8 , 5 , roulette24, roulette42, roulette44, roulette51, roulette61, "号码绿4", 0},
{18, 5 , roulette27, roulette42, roulette43, roulette53, roulette61, "号码绿7", 0},
{11, 11, roulette27, roulette42, roulette43, roulette53, roulette61, "号码绿7", 0},
{19, 11, roulette31, roulette42, roulette43, roulette51, roulette62, "号码绿11", 0},
{10, 5 , roulette31, roulette42, roulette43, roulette51, roulette62, "号码绿11", 0},
{18, 11, roulette32, roulette42, roulette44, roulette51, roulette62, "号码绿12", 0},
{11, 5 , roulette32, roulette42, roulette44, roulette51, roulette62, "号码绿12", 0},
{16, 11, roulette34, roulette42, roulette44, roulette52, roulette62, "号码绿14", 0},
{14, 5 , roulette34, roulette42, roulette44, roulette52, roulette62, "号码绿14", 0},
{15, 11, roulette35, roulette42, roulette43, roulette52, roulette62, "号码绿15", 0},
{13, 5 , roulette35, roulette42, roulette43, roulette52, roulette62, "号码绿15", 0},
{22, 7 , roulette36, roulette42, roulette44, roulette53, roulette62, "号码绿16", 0},
{7 , 9 , roulette36, roulette42, roulette44, roulette53, roulette62, "号码绿16", 0},
{21, 5 , roulette39, roulette42, roulette43, roulette52, roulette62, "号码绿19", 0},
{8 , 11, roulette39, roulette42, roulette43, roulette52, roulette62, "号码绿19", 0},
{20, 5 , roulette40, roulette42, roulette44, roulette52, roulette62, "号码绿20", 0},
{9 , 11, roulette40, roulette42, roulette44, roulette52, roulette62, "号码绿20", 0},
{22,11, roulette45, 0, 0, roulette52, 0, "号码00"},
{ 7, 5, -1, -1, -1, -1, -1, "号码X", 0},
{ -1, -1, -1, -1, -1, -1, -1, "", 0},
2016-12-24 08:45:52 +08:00
};
enum {
/*
NPC_WORK_ROUTETOX = CHAR_NPCWORKINT1,
NPC_WORK_ROUTETOY = CHAR_NPCWORKINT2,
NPC_WORK_ROUTEPOINT = CHAR_NPCWORKINT3,
*/
NPC_WORK_NPCAI = CHAR_NPCWORKINT3,
NPC_WORK_NPCACTION = CHAR_NPCWORKINT3,
NPC_WORK_MASTERSTONE = CHAR_NPCWORKINT4,
NPC_WORK_MODE = CHAR_NPCWORKINT5,
NPC_WORK_SYSTIME = CHAR_NPCWORKINT6,
NPC_WORK_GAMEFLG = CHAR_NPCWORKINT7,
NPC_WORK_GAMBLECODE = CHAR_NPCWORKINT8,
NPC_WORK_MASTERFLG = CHAR_NPCWORKINT9,
NPC_WORK_ENDPOINT = CHAR_NPCWORKINT10,
};
#define ROULETTE_ERRTIME 500
#define ROULETTE_STANDBY1 40
#define ROULETTE_LOOPTIME 3000
BOOL NPC_Gamble_MasterInit( int meindex )
{
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
char buf1[256];
if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) {
print("\n not found argstr ");
return FALSE;
}
if( NPC_Util_GetStrFromStrWithDelim( argstr, "gamble_code",buf1, sizeof(buf1)) == NULL ) {
print("\n gamble_code error: not found !!");
return FALSE;
}
CHAR_setWorkInt( meindex, NPC_WORK_GAMBLECODE, atoi( buf1));
2017-01-13 23:37:03 +08:00
//游戏阶段
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 0);
CHAR_setInt( meindex , CHAR_WHICHTYPE , CHAR_GAMBLEMASTER );
2017-01-13 23:37:03 +08:00
// NPC_WORK_MODE 主持人状态 0: 等待 1:GAME START 2:GAME END
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0);
CHAR_setWorkInt( meindex, NPC_WORK_MASTERFLG, 30);
CHAR_setWorkInt( meindex, NPC_WORK_MASTERSTONE, 0);
CHAR_setWorkInt( meindex, NPC_WORK_NPCAI, 0);
2017-01-13 23:37:03 +08:00
//设定LOOP TIMER
2016-12-24 08:45:52 +08:00
CHAR_setInt( meindex, CHAR_LOOPINTERVAL, ROULETTE_LOOPTIME);
2017-01-13 23:37:03 +08:00
//用来记录时间点
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, NPC_WORK_SYSTIME, NowTime.tv_sec);
return TRUE;
}
void NPC_Gamble_MasterTalked( int meindex , int talkerindex , char *szMes , int color )
{
char argstr[NPC_UTIL_GETARGSTR_BUFSIZE];
if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){
return;
}
if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) {
if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return;
}
if( NPC_Util_GetArgStr( meindex, argstr, sizeof( argstr)) == NULL ) {
print("\n not found argstr ");
return;
}
2017-01-13 23:37:03 +08:00
// 0 选单 11 - 19 规则 21 - 29 积分
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt(talkerindex , CHAR_WORKSHOPRELEVANT,0);
NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_START, -1 );
}
void NPC_GambleRoulette_selectWindow(int meindex,int toindex,int num,int select)
{
char npcarg[NPC_UTIL_GETARGSTR_BUFSIZE];
char buf1[256],buf2[256];
char token[256];
int buttontype = 0, windowtype = 0, windowno = 0;
int fd = getfdFromCharaIndex( toindex);
int pagenum=0, i;
windowtype = WINDOW_MESSAGETYPE_MESSAGE;
if( NPC_Util_GetArgStr( meindex, npcarg, sizeof( npcarg)) == NULL ) {
print("\n not found npcarg ");
CHAR_setWorkInt( toindex, CHAR_WORKSHOPRELEVANT,0);
return;
}
switch( num) {
case ROULETTE_START:
i = 1;
strcpy( token, "\0");
sprintf( buf2,"%s%d", "gamble_msg0", i);
while( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, buf1, sizeof( buf1) ) != NULL ) {
if( strstr( buf1, "NULL" ) == NULL ) {
strcat( token , buf1);
strcat( token, "\n");
}else {
strcat( token, "\n");
}
i++;
sprintf( buf2,"%s%d", "gamble_msg0", i);
}
windowtype=WINDOW_MESSAGETYPE_SELECT;
windowno = WINDOWTYPE_GAMBLEROULETTE_START;
break;
break;
case ROULETTE_SELECT:
2017-01-13 23:37:03 +08:00
//页 select
2016-12-24 08:45:52 +08:00
pagenum = CHAR_getWorkInt( toindex , CHAR_WORKSHOPRELEVANT);
strcpy( token, "\0");
if( select >= 0 ) {
sprintf( buf2,"%s%2d", "page_num", select);
CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT, select+1);
}else {
sprintf( buf2,"%s%2d", "page_num", pagenum );
pagenum+=1;
CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT, pagenum);
}
if( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, token, sizeof( token) ) == NULL ) {
print("\n error: not found token:%s", token);
CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT,0);
return;
}
sprintf( buf2,"%s%2d", "page_num", CHAR_getWorkInt( toindex , CHAR_WORKSHOPRELEVANT));
if( NPC_Util_GetStrFromStrWithDelim( npcarg, buf2, buf1, sizeof( buf1) ) == NULL ) {
windowno = WINDOWTYPE_GAMBLEROULETTE_END;
buttontype = WINDOW_BUTTONTYPE_OK;
}else {
windowno = WINDOWTYPE_GAMBLEROULETTE_SELECT;
buttontype = WINDOW_BUTTONTYPE_NEXT;
}
break;
case ROULETTE_LOOK:
2017-01-13 23:37:03 +08:00
{ //显示时补回积分
2016-12-24 08:45:52 +08:00
int G_num = CHAR_getInt( toindex, CHAR_GAMBLENUM );
if( CHAR_getWorkInt( toindex, CHAR_WORKSTAKEFLAG) != FALSE) {
for( i=0; i<5; i++) {
if( CHAR_getWorkInt( toindex, i+CHAR_WORKSTAKETYPE1) > 0 )
G_num++;
}
}
if( G_num < 0 ) G_num = 0;
2017-01-13 23:37:03 +08:00
sprintf( token,"你的游乐场积分为%d。", G_num );
2016-12-24 08:45:52 +08:00
windowno = WINDOWTYPE_GAMBLEROULETTE_END;
buttontype = WINDOW_BUTTONTYPE_OK;
}
break;
case ROULETTE_END:
if( NPC_Util_GetStrFromStrWithDelim( npcarg, "page_endmsg", token, sizeof( token) ) == NULL ) {
print("\n error: not found end_msg");
CHAR_setWorkInt( toindex , CHAR_WORKSHOPRELEVANT,0);
return;
}
windowno = WINDOWTYPE_GAMBLEROULETTE_END;
buttontype = WINDOW_BUTTONTYPE_OK;
break;
}
lssproto_WN_send( fd, windowtype, buttontype, windowno,
CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX), token);
}
void NPC_Gamble_MasterWindowTalked( int meindex, int talkerindex, int seqno, int select, char *data)
{
int pagenum=0;
if( CHAR_getInt( talkerindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER ){
return;
}
if(NPC_Util_isFaceToFace( meindex ,talkerindex , 2) == FALSE) {
if(NPC_Util_isFaceToChara( talkerindex, meindex, 1) == FALSE) return;
}
switch( seqno ) {
case WINDOWTYPE_GAMBLEROULETTE_START:
pagenum = atoi( data);
if( pagenum == 4 ) {
NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_END, -1 );
}else {
if( pagenum == 3 ) { //ROULETTE_LOOK
NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_LOOK, -1 );
}else {
pagenum = (pagenum*10)+1;
NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_SELECT, pagenum );
}
}
break;
case WINDOWTYPE_GAMBLEROULETTE_SELECT:
NPC_GambleRoulette_selectWindow( meindex, talkerindex, ROULETTE_SELECT, -1 );
break;
case WINDOWTYPE_GAMBLEROULETTE_END:
CHAR_setWorkInt(talkerindex , CHAR_WORKSHOPRELEVANT, 0);
break;
}
return;
}
void NPC_Gamble_MasterLoop( int meindex)
{
int objmeindex = -1;
int full_time;
//int Master_Stone = 0;
int timeNum = 0;
//int time_run=0;
//int act;
objmeindex = CHAR_getWorkInt( meindex, CHAR_WORKOBJINDEX);
switch( CHAR_getWorkInt( meindex, NPC_WORK_MODE )) {
2017-01-13 23:37:03 +08:00
case 0: // 等待
2016-12-24 08:45:52 +08:00
full_time = ROULETTE_STANDBY1;
timeNum = CHAR_getWorkInt( meindex, NPC_WORK_MASTERFLG );
if( ( CHAR_getWorkInt( meindex, NPC_WORK_SYSTIME) + full_time) < NowTime.tv_sec ) {
2017-01-13 23:37:03 +08:00
if( timeNum == 30 ) { //倒数20秒
//0 null 1 准备 2 跑 3 停
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 1);
2017-01-13 23:37:03 +08:00
showString( meindex, "下注时间剩下20秒。", 0);
2016-12-24 08:45:52 +08:00
}else if( timeNum == 10 ) {
2017-01-13 23:37:03 +08:00
showString( meindex, "standby_msg", 0); //广播
SetCasinoMap( meindex, 0, 0); //设定地图不可下注
}else if( timeNum <= 6 ) { //开始
//0 null 1 准备 2 跑 3 停
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 2);
CHAR_setWorkInt( meindex, NPC_WORK_MODE, 1);
2017-01-13 23:37:03 +08:00
showString( meindex, "start_msg", 0); //广播
2016-12-24 08:45:52 +08:00
}
CHAR_setWorkInt( meindex, NPC_WORK_MASTERFLG, timeNum - 2 );
}
break;
case 1: // GAME START
if( CHAR_getWorkInt( meindex, NPC_WORK_GAMEFLG) == 3 ) {
CHAR_setWorkInt( meindex, NPC_WORK_MODE, 2);
}
break;
case 2: // GAME END
CHAR_setWorkInt( meindex, NPC_WORK_MODE, 3);
2017-01-13 23:37:03 +08:00
defPlayerGold( meindex , TRUE); //计算输赢
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, NPC_WORK_ENDPOINT, 0);
NPC_MAPCLEANGOLD( meindex , CHAR_getInt( meindex, CHAR_FLOOR ));
LogGamble(
CHAR_getChar( meindex, CHAR_NAME ), "master",
"ROULETTE", CHAR_getInt( meindex, CHAR_FLOOR),
CHAR_getInt( meindex, CHAR_X ),
CHAR_getInt( meindex, CHAR_Y ) ,
CHAR_getWorkInt( meindex, NPC_WORK_MASTERSTONE), 0, 0, 0, 2
);
break;
case 3:
CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0);
CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 0);
2017-01-13 23:37:03 +08:00
showString( meindex, "end_msg", 0); //广播
SetCasinoMap( meindex, 0, 1); //设定地图可下注
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, NPC_WORK_MASTERFLG, 30 );
CHAR_setWorkInt( meindex, NPC_WORK_SYSTIME, NowTime.tv_sec);
break;
default:
NPC_GAMBLEMASTER_RESET( meindex);
break;
}
}
void defPlayerGold( int meindex , int flg)
{
int X,Y;
int endpoint;
int End_type = 0;
int toindex=0, i, master_floor;
int player_type;
int gamble_num;
//float def;
char token[256], buff[256];
char buf1[56],buf2[56];
BOOL GAMBLE_YES = FALSE;
endpoint = CHAR_getWorkInt( meindex, NPC_WORK_ENDPOINT);
X = (endpoint >> 16 );
Y = (endpoint & 0xffff);
for( End_type = 0; End_type < arraysizeof(EndTypedef) ; End_type++ ) {
if( (X == EndTypedef[ End_type].m_fx) && (Y == EndTypedef[ End_type].m_fy )) {
break;
}
}
if( End_type == arraysizeof(EndTypedef) ) {
print("\n\n **********GAMBLE MASTER ERROR !! **************");
print("\n NOT FOUND : X=%d Y=%d EndTypedef[I] !!", X, Y);
return;
}
/*Log=====================================
2017-01-13 23:37:03 +08:00
{ //记录用
2016-12-24 08:45:52 +08:00
FILE *fp;
int kp=0,pn=0;;
fp = fopen("./data/npc/roulette/lookgamble.txt","w+");
if( fp != NULL ) {
if( EndTypedef[ End_type].m_nums < 10000 )
EndTypedef[ End_type].m_nums = EndTypedef[ End_type].m_nums+1;
for( kp=0; kp<arraysizeof( EndTypedef)-1; kp++ ) {
if( EndTypedef[ kp].m_nums > 0 && EndTypedef[ kp].m_type > 0 ) {
2017-01-13 23:37:03 +08:00
fprintf( fp," %s 中奖次数 [%d] ", EndTypedef[ kp].str_type, EndTypedef[ kp].m_nums );
2016-12-24 08:45:52 +08:00
if( (pn+1)%2 == 0 ) {
fprintf( fp," \n");
}
pn ++;
}
}
fclose( fp);
}
}
//========================================*/
if( EndTypedef[ End_type].m_type <= 0 ) {
2017-01-13 23:37:03 +08:00
showString( meindex, "号码X,通杀!", 0);
2016-12-24 08:45:52 +08:00
}else {
2017-01-13 23:37:03 +08:00
sprintf( token ,"中奖号码 %s ", EndTypedef[End_type].str_type );
2016-12-24 08:45:52 +08:00
showString( meindex, token, 0 );
}
if( EndTypedef[ End_type].m_EO == roulette43 ) {
2017-01-13 23:37:03 +08:00
sprintf( buf1,"");
2016-12-24 08:45:52 +08:00
}else {
2017-01-13 23:37:03 +08:00
sprintf( buf1,"");
2016-12-24 08:45:52 +08:00
}
if( EndTypedef[ End_type].m_RG == roulette41 ) {
2017-01-13 23:37:03 +08:00
sprintf( buf2,"");
2016-12-24 08:45:52 +08:00
}else {
2017-01-13 23:37:03 +08:00
sprintf( buf2,"绿");
2016-12-24 08:45:52 +08:00
}
2017-01-13 23:37:03 +08:00
//找在场的人
2016-12-24 08:45:52 +08:00
toindex = -1;
master_floor = CHAR_getInt( meindex , CHAR_FLOOR);
while( toindex < 10000 ) {
toindex++;
if( !CHAR_CHECKINDEX( toindex) )
continue;
if( CHAR_getInt( toindex , CHAR_WHICHTYPE ) != CHAR_TYPEPLAYER )
continue;
2017-01-13 23:37:03 +08:00
if( master_floor != CHAR_getInt( toindex, CHAR_FLOOR ) ) //是否在赌场
2016-12-24 08:45:52 +08:00
continue;
2017-01-13 23:37:03 +08:00
if( CHAR_getWorkInt( toindex, CHAR_WORKSTAKEFLAG) == FALSE ) //是否有下注
2016-12-24 08:45:52 +08:00
continue;
2017-01-13 23:37:03 +08:00
//是否赌中
2016-12-24 08:45:52 +08:00
GAMBLE_YES = FALSE;
CHAR_setWorkInt( toindex, CHAR_WORKSTAKEFLAG, FALSE);
for( i=0; i<5; i++) {
player_type = CHAR_getWorkInt( toindex, i+CHAR_WORKSTAKETYPE1);
gamble_num = 0;
if( player_type > 0 ) {
2017-01-13 23:37:03 +08:00
if( player_type == EndTypedef[End_type].m_type ) { //中了号码
2016-12-24 08:45:52 +08:00
if( EndTypedef[End_type].m_type == roulette45 ) {
gamble_num += 40;
}else {
gamble_num += 20;
}
GAMBLE_YES = TRUE;
2017-01-13 23:37:03 +08:00
//算钱
2016-12-24 08:45:52 +08:00
Codef_Gold( meindex, toindex, gamble_num, 0, EndTypedef[End_type].str_type );
2017-01-13 23:37:03 +08:00
}else if( player_type == EndTypedef[End_type].m_RG ) { //中了红绿
2016-12-24 08:45:52 +08:00
gamble_num += 1;
GAMBLE_YES = TRUE;
Codef_Gold( meindex, toindex, gamble_num, 0, buf2 );
2017-01-13 23:37:03 +08:00
}else if( player_type == EndTypedef[End_type].m_EO ) { //中了单双
2016-12-24 08:45:52 +08:00
gamble_num += 1;
GAMBLE_YES = TRUE;
Codef_Gold( meindex, toindex, gamble_num, 0, buf1 );
2017-01-13 23:37:03 +08:00
}else if( player_type == EndTypedef[End_type].m_SI ) { //横列
2016-12-24 08:45:52 +08:00
gamble_num += 2;
GAMBLE_YES = TRUE;
2017-01-13 23:37:03 +08:00
sprintf( token,"%s%d", "横列", EndTypedef[End_type].m_SI-100 );
2016-12-24 08:45:52 +08:00
Codef_Gold( meindex, toindex, gamble_num, 0, token );
}else if( player_type == EndTypedef[End_type].m_IN ) { //1-10 11-20
gamble_num += 1;
GAMBLE_YES = TRUE;
if( (EndTypedef[End_type].m_IN - 100 ) == 11 ) {
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff),"");
2016-12-24 08:45:52 +08:00
}else if( (EndTypedef[End_type].m_IN - 100 ) == 12 ) {
2017-01-13 23:37:03 +08:00
snprintf( buff, sizeof( buff),"");
2016-12-24 08:45:52 +08:00
}
2017-01-13 23:37:03 +08:00
sprintf( token,"%s%s", "范围", buff );
2016-12-24 08:45:52 +08:00
Codef_Gold( meindex, toindex, gamble_num, 0, token );
2017-01-13 23:37:03 +08:00
}else { //没中 扣积分
2016-12-24 08:45:52 +08:00
if( (player_type>>16) == EndTypedef[End_type].m_type ||
(player_type&0xffff) == EndTypedef[End_type].m_type
2017-01-13 23:37:03 +08:00
) { //中双号
2016-12-24 08:45:52 +08:00
gamble_num += 10;
GAMBLE_YES = TRUE;
2017-01-13 23:37:03 +08:00
sprintf( token,"%s%s", "双号-", EndTypedef[End_type].str_type );
2016-12-24 08:45:52 +08:00
Codef_Gold( meindex, toindex, gamble_num, 0, token );
2017-01-13 23:37:03 +08:00
}else if( player_type > 0 ) { //72 73 74 75 没中 扣积分
2016-12-24 08:45:52 +08:00
strcpy( token, "\0");
2017-01-13 23:37:03 +08:00
if( player_type >= roulette41 && player_type <= roulette44 ) { //红绿单双
sprintf( token,"%s", "押注 红绿单双 没中");
}else if( player_type == roulette45 ) { //数字00
sprintf( token,"%s", "押注 数字00 没中");
}else if( player_type >= roulette51 && player_type <= roulette53 ) { //横列
sprintf( token,"%s", "押注 横列 没中");
}else if( player_type >= roulette61 && player_type <= roulette62 ) { //范围
sprintf( token,"%s", "押注 范围 没中");
}else if( player_type > (1<<16) ) { //双号
sprintf( token,"%s", "押注 双号 没中");
}else { //数字
sprintf( token,"%s", "押注 数字 没中");
2016-12-24 08:45:52 +08:00
}
gamble_num -= 1;
Codef_Gold( meindex, toindex, gamble_num, 1, token );
}
}
}
2017-01-13 23:37:03 +08:00
//清空
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( toindex, i+CHAR_WORKSTAKETYPE1, 0);
}
if( CHAR_getInt( toindex, CHAR_GAMBLENUM) < 0 ) {
CHAR_setInt( toindex, CHAR_GAMBLENUM, 0 );
}else if( CHAR_getInt( toindex, CHAR_GAMBLENUM) > 10000 ) {
CHAR_setInt( toindex, CHAR_GAMBLENUM, 10000 );
}
2017-01-13 23:37:03 +08:00
sprintf( token, "你的游乐场积分累计为%d分。", CHAR_getInt( toindex, CHAR_GAMBLENUM));
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW);
if( GAMBLE_YES == FALSE ) {
2017-01-13 23:37:03 +08:00
sprintf( token, "你所有押注都没中奖!");
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( toindex, meindex, token, CHAR_COLORYELLOW);
continue;
}
}
return;
}
void Codef_Gold( int meindex, int toindex, int stone,int flg, char *token)
{
char buf1[256];
int dnum=-1;
int Master_gnum=0;
Master_gnum = CHAR_getWorkInt( meindex, NPC_WORK_MASTERSTONE);
Master_gnum += stone;
if( !flg ) {
2017-01-13 23:37:03 +08:00
sprintf( buf1,"恭喜你中了:%s可拿得 %d 点积分", token, stone);
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW);
#ifdef _FIX_GAMBLENUM
2017-01-13 23:37:03 +08:00
stone += 1; //加上一开始下注扣的积分
2016-12-24 08:45:52 +08:00
#endif
CHAR_setInt( toindex, CHAR_GAMBLENUM, CHAR_getInt( toindex, CHAR_GAMBLENUM) + stone);
}else {
dnum = stone;
if( stone < 0 ) {
dnum = (dnum*(-1));
}
2017-01-13 23:37:03 +08:00
sprintf( buf1,"%s扣 %d 点积分", token, dnum);
2016-12-24 08:45:52 +08:00
CHAR_talkToCli( toindex, meindex, buf1, CHAR_COLORYELLOW);
#ifdef _FIX_GAMBLENUM
#else
CHAR_setInt( toindex, CHAR_GAMBLENUM, CHAR_getInt( toindex, CHAR_GAMBLENUM) + stone);
#endif
}
LogGamble(
CHAR_getChar( toindex, CHAR_NAME ),
CHAR_getChar( toindex, CHAR_CDKEY ),
"ROULETTE",
CHAR_getInt( toindex, CHAR_FLOOR),
CHAR_getInt( toindex, CHAR_X ),
CHAR_getInt( toindex, CHAR_Y ),
CHAR_getInt( toindex, CHAR_GOLD),
stone,
0,
CHAR_getInt( toindex, CHAR_GAMBLENUM ),
1
);
2017-01-13 23:37:03 +08:00
//纪录盈亏
2016-12-24 08:45:52 +08:00
if( Master_gnum > 5000000 ) Master_gnum = 5000000;
if( Master_gnum < 0 ) Master_gnum = 0;
CHAR_setWorkInt( meindex, NPC_WORK_MASTERSTONE, Master_gnum);
return;
}
2017-01-13 23:37:03 +08:00
//重置 错误处理
2016-12-24 08:45:52 +08:00
void NPC_GAMBLEMASTER_RESET( int meindex)
{
2017-01-13 23:37:03 +08:00
//错误处理
print("\n 错误处理");
CHAR_setWorkInt( meindex, NPC_WORK_GAMEFLG, 0);//0 null 1 准备 2 跑
2016-12-24 08:45:52 +08:00
CHAR_setWorkInt( meindex, NPC_WORK_MODE, 0);
2017-01-13 23:37:03 +08:00
showString( meindex, "本回合不算!等5分钟後重新开始!!", 1);
2016-12-24 08:45:52 +08:00
NPC_MAPCLEANGOLD( meindex , CHAR_getInt( meindex, CHAR_FLOOR ));
//defPlayerGold( meindex , FALSE);
CHAR_setWorkInt( meindex, NPC_WORK_SYSTIME, NowTime.tv_sec + ROULETTE_ERRTIME);
}
#endif