📄 deathcontend.c
字号:
printf("%s will be send...",CHAR_getChar(i,CHAR_NAME));
if((CHAR_getInt(i,CHAR_PKLISTTEAMNUM) == aB1->teamnum || CHAR_getInt(i,CHAR_PKLISTTEAMNUM) == aB2->teamnum) &&
CHAR_getInt(i,CHAR_FLOOR) != 8250){
printf("send!!\n");
CHAR_warpToSpecificPoint(i,8250,15,15);
}
else printf("has not send!!(teamnum:%d,floor:%d)\n",CHAR_getInt(i,CHAR_PKLISTTEAMNUM),CHAR_getInt(i,CHAR_FLOOR));
}
//if( count >= 2) return count;
return count;
}
}
}
}
return count;
}
void ABATTLE_CheckBattlefromFl(int charindex, int ti,int battleindex)
{
int i = ti, count = 0,floor=0;
//ABFloor[MAXBAHEAD];
//andy_log
print("ABATTLE_CheckBattlefromFl(%d,%d )..\n",ti,battleindex);
//for( i=0; i<MAXBAHEAD; i++){
{
if( ABFloor[i] == -1 ){
CHAR_talkToCli( charindex, -1, "组别不存在", CHAR_COLORYELLOW);
return;
}
floor = ABATTLE_CheckBattlefromFl_sub(charindex, i, ABFloor[i],battleindex);
//if( count < 4 )
// count += ABATTLE_FindBattlefromFl( i, ABFloor[i]);
count = ABATTLE_FindBattlefromFl( i, ABFloor[i]);
ABFloor[i] = floor;
if( ABFloor[i] == -1 ){
FILE *fp=NULL;
if( headABattle[i]->use == 1 && headABattle[i]->teamnum != -1 ){
char token[256];
sprintf( token, "恭喜 %s 队,取得分组优胜,晋级下一阶段。", headABattle[i]->teamname );
PKLIST_shoutToAll( token, -1, 8250);
ABATTLE_RecordBattle( i, headABattle[i]->teamname, "晋级8强", "NULL", "");
}
if( (fp=fopen( "nbattle.txt", "a+")) != NULL ){
fprintf( fp, "%d %d|%s|\n",
i, headABattle[i]->teamnum, headABattle[i]->teamname);
fclose( fp);
}
}
}
}
int ABATTLE_CheckBattlefromFl_sub(int charindex, int ti, int fl, int battleindex)
{
int i = battleindex;
char token[256];
ArrangeBattleC *aBo=NULL;
ArrangeBattleC *aB1=NULL;
ArrangeBattleC *aB2=NULL;
//andy_log
print("CheckBattlefromFl_sub( %d, %d, %d)\n", ti, fl, battleindex);
for( i=0; i<MAXNOWBATTLE; i++){
if( (aBo=NowABattle[ti][fl][i]) == NULL ) continue;
aB1=aBo->next[0];
aB2=aBo->next[1];
if( (aB1 == NULL || aB1->use == 0 ) &&
(aB2 == NULL || aB2->use == 0 ) ){//两队都不成立
if( aB1 != NULL ) free( aB1);
if( aB2 != NULL ) free( aB2);
aBo->next[0] = NULL;
aBo->next[1] = NULL;
continue;
}else if( aB1 == NULL || aB1->use == 0 || aB1->teamnum == -1 ){ //0不成立
ABATTLE_EliminateBattlefromFl( aB1);
aBo->next[0] = NULL;
if( aB2 != NULL && aB2->use != 0 && aB2->type == 0 ){
ABATTLE_EnterBattle( aB2);
}
return fl;
}else if( aB2 == NULL || aB2->use == 0 || aB2->teamnum == -1 ){ //1不成立
ABATTLE_EliminateBattlefromFl( aB2);
aBo->next[1] = NULL;
if( aB1 != NULL && aB1->use != 0 && aB1->type == 0 ){
ABATTLE_EnterBattle( aB1);
}
return fl;
}else{
//andy_log
print("两者成立!.%d.%x[%d,%s] %x[%d,%s]\n", i,
aB1, aB1->teamnum, aB1->teamname,
aB2, aB2->teamnum, aB2->teamname );
return fl;
}
}
return (fl-1);
}
//确认赛程战斗状态 包含时间
BOOL ABATTLE_CheckInABattle( int ti)
{
ArrangeBattleC *aB=NULL;
ArrangeBattleC *aB1=NULL;
ArrangeBattleC *aB2=NULL;
int i;
int playernum = CHAR_getPlayerMaxNum();
char token[256];
if( ti<0 || ti>MAXBATTLEPAGE ) return FALSE;
if( (aB=InBattle[ti]) == NULL ) return FALSE;
aB1=aB->next[0];
aB2=aB->next[1];
switch( aB->type){
case 0:
break;
case 1: //已排入赛程 5分钟後进场
if( aB->time < (int)time(NULL) ){
if( aB1 == NULL || aB1->use == 0 ||
aB2 == NULL || aB2->use == 0 ) return FALSE;
sprintf( token, "%s队 VS %s队,赛程即将开始,请两队做好准备。",
aB1->teamname, aB2->teamname );
//PKLIST_shoutToAll( token, aB1->teamnum, 8250);
PKLIST_shoutToAll( token, aB2->teamnum, 8250);
#ifdef _DEATH_CONTENDTEST
aB->time=(int)time(NULL)+30;
#else
aB->time=(int)time(NULL)+(2*60);
#endif
aB->type=2;
// 把排入赛程的人员传入地图 8250
for(i=0;i<playernum;i++){
if(CHAR_getCharUse(i) == FALSE) continue;
printf("%s will be send...",CHAR_getChar(i,CHAR_NAME));
if((CHAR_getInt(i,CHAR_PKLISTTEAMNUM) == aB1->teamnum || CHAR_getInt(i,CHAR_PKLISTTEAMNUM) == aB2->teamnum) &&
CHAR_getInt(i,CHAR_FLOOR) != 8250){
printf("send!!\n");
CHAR_warpToSpecificPoint(i,8250,15,15);
}
else printf("has not send!!(teamnum:%d,floor:%d)\n",CHAR_getInt(i,CHAR_PKLISTTEAMNUM),CHAR_getInt(i,CHAR_FLOOR));
}
}
break;
case 2: //已排入赛程 进场3分钟 并判断队长是否存在 并广播
{
int playernum = CHAR_getPlayerMaxNum();
for( i=0 ; i<playernum ; i++) {
if( CHAR_getCharUse(i) == FALSE ) continue;
if( aB1!=NULL && !CHAR_CHECKINDEX( aB1->toindex) &&
aB1->teamnum == CHAR_getInt( i, CHAR_PKLISTTEAMNUM) &&
CHAR_getInt( i, CHAR_PKLISTLEADER) == 1 &&
PKLIST_CheckPKSameTeam( i) == TRUE ){
int stime = ((aB->time)-(int)time(NULL));
sprintf( token, "请快找齐你的所有队员,并组好队,%d秒後将进行传送。", (stime<0)?0:stime);
CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW);
aB1->toindex = i;
continue;
}
if( aB2!=NULL && !CHAR_CHECKINDEX( aB2->toindex) &&
aB2->teamnum == CHAR_getInt( i, CHAR_PKLISTTEAMNUM) &&
CHAR_getInt( i, CHAR_PKLISTLEADER) == 1 &&
PKLIST_CheckPKSameTeam( i) == TRUE ){
int stime = ((aB->time)-(int)time(NULL));
sprintf( token, "请快找齐你的所有队员,并组好队,%d秒後将进行传送。", (stime<0)?0:stime);
CHAR_talkToCli( i, -1, token, CHAR_COLORYELLOW);
aB2->toindex = i;
continue;
}
}
}
// 把排入赛程的人员传入地图 8250
for(i=0;i<playernum;i++){
if(CHAR_getCharUse(i) == FALSE) continue;
if((CHAR_getInt(i,CHAR_PKLISTTEAMNUM) == aB1->teamnum || CHAR_getInt(i,CHAR_PKLISTTEAMNUM) == aB2->teamnum) &&
CHAR_getInt(i,CHAR_FLOOR) != 8250) CHAR_warpToSpecificPoint(i,8250,15,15);
}
if( aB->time < (int)time(NULL) ){
char token[256];
sprintf( token, "%s队 VS %s队,赛程开始。", aB1->teamname, aB2->teamname );
PKLIST_shoutToAll( token, -1, 8250);
if( CHAR_CHECKINDEX( aB1->toindex) && CHAR_CHECKINDEX( aB2->toindex) ){
PKLIST_warpOne( aB2->toindex, PK_BATTLEMAP[ti].floor, PK_BATTLEMAP[ti].x+1, PK_BATTLEMAP[ti].y);
PKLIST_warpOne( aB1->toindex, PK_BATTLEMAP[ti].floor, PK_BATTLEMAP[ti].x, PK_BATTLEMAP[ti].y);
#ifdef _DEATH_CONTENDTEST
aB->time=(int)time(NULL)+5;
#else
aB->time=(int)time(NULL)+(20);
#endif
aB->type=3;
return TRUE;
}else if( !CHAR_CHECKINDEX( aB1->toindex) && !CHAR_CHECKINDEX( aB2->toindex) ){
sprintf( token, "%s队(%d),%s队(%d),因队长未在时间内到场,视为弃权。",aB1->teamname,aB1->toindex,
aB2->teamname,aB2->toindex);
ABATTLE_RecordBattle( ti, aB1->teamname, "未", aB2->teamname, "未");
aB1->use = 0;
aB2->use = 0;
}else if( !CHAR_CHECKINDEX( aB1->toindex) ) {
sprintf( token, "%s队(%d),因队长未在时间内到场,视为弃权。",aB1->teamname,aB1->toindex);
aB1->use = 0;
ABATTLE_RecordBattle( ti, aB1->teamname, "未", "NULL", "");
ABATTLE_EnterBattle( aB2);
}else if( !CHAR_CHECKINDEX( aB2->toindex) ){
sprintf( token, "%s队(%d),因队长未在时间内到场,视为弃权。",aB2->teamname,aB2->toindex);
aB2->use = 0;
ABATTLE_RecordBattle( ti, aB2->teamname, "未", "NULL", "");
ABATTLE_EnterBattle( aB1);
}
PKLIST_shoutToAll( token, -1, 8250);
InBattle[ti] = NULL;
return FALSE;
}
break;
case 3: //已排入赛程 队伍到齐 5分钟内 强制战斗
aB->type=4;
aB->time=(int)time(NULL)+(2*60);
break;
case 4:
if( aB->time < (int)time(NULL) ){//强制战斗
if( CHAR_getWorkInt( aB1->toindex, CHAR_WORKBATTLEMODE) == BATTLE_CHARMODE_NONE ){
//andy_log
print("强制战斗 %s vs %s \n", aB1->teamname, aB2->teamname);
BATTLE_CreateVsPlayer( aB1->toindex, aB2->toindex );
aB->type = 5;
}
}
break;
}
return TRUE;
}
void ABATTLE_MakeInABattleString( void)
{
ArrangeBattleC *aB=NULL;
ArrangeBattleC *aB1=NULL;
ArrangeBattleC *aB2=NULL;
char buf1[256], buf[256];
int i, fir=1;
memset( ABattlelist, 0, sizeof(ABattlelist));
for( i=0; i<MAXBATTLEPAGE; i++){
if( (aB=InBattle[i]) == NULL )continue;
if( (aB1=aB->next[0]) == NULL || aB1->use == 0 )continue;
if( (aB2=aB->next[1]) == NULL || aB2->use == 0 )continue;
switch( aB->type){
case 0: continue;
break;
case 1://预定
strcpy( buf, "预定");
break;
case 2://准备
strcpy( buf, "准备");
break;
case 3://开始
case 4:
strcpy( buf, "开始");
break;
}
sprintf( buf1, "%d|%s|%s|%d|%s",
i, aB1->teamname, aB2->teamname, aB->time, buf);
if( fir != 1 ) strcat( ABattlelist, " ");
fir=0;
strcat( ABattlelist, buf1);
}
}
BOOL PKLIST_GetABattlelistDataString( int ti, int *tindex, int *stimes,
char *buf1, char *buf2, char *buf3, int flg)
{
char data[1024], buf[256], buff[256];
switch( flg){
case 3:
{
memset( data, 0, sizeof(data));
if( getStringFromIndexWithDelim( ABattlelist, " ", ti, data, sizeof(data)) == FALSE )
return FALSE;
if( getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)) == FALSE ) return FALSE;
*tindex=atoi( buf);
if( getStringFromIndexWithDelim( data, "|", 2, buf, sizeof( buf))== FALSE) return FALSE;
strcpy( buf1, buf);
if( getStringFromIndexWithDelim( data, "|", 3, buf, sizeof( buf))== FALSE) return FALSE;
strcpy( buf2, buf);
if( getStringFromIndexWithDelim( data, "|", 4, buf, sizeof( buf))== FALSE) return FALSE;
*stimes = atoi( buf);
if( getStringFromIndexWithDelim( data, "|", 5, buf, sizeof( buf))== FALSE ) return FALSE;
strcpy( buf3, buf);
}
break;
case 5:
{
if( getStringFromIndexWithDelim( ABLevelup, " ", ti, data, sizeof(data)) == FALSE )
return FALSE;
if( getStringFromIndexWithDelim( data, "|", 1, buf, sizeof( buf)) == FALSE ) return FALSE;
*tindex=atoi( buf);
if( getStringFromIndexWithDelim( data, "|", 2, buff, sizeof( buff)) == FALSE ) return FALSE;
if( getStringFromIndexWithDelim( data, "|", 3, buf, sizeof( buf)) == FALSE ) return FALSE;
sprintf( buf1, "[%s]%s ", buff, buf);
if( getStringFromIndexWithDelim( data, "|", 4, buff, sizeof( buff)) == FALSE ) return FALSE;
if( getStringFromIndexWithDelim( data, "|", 5, buf, sizeof( buf)) == FALSE ) return FALSE;
sprintf( buf2, "[%s]%s ", buff, buf);
}
break;
}
return TRUE;
}
ArrangeBattleC *ABATTLE_getInBattle( int teamnum)
{
ArrangeBattleC *aB=NULL;
ArrangeBattleC *aBx=NULL;
int i;
for( i=0; i<MAXBATTLEPAGE; i++){
if( (aB=InBattle[i]) == NULL )continue;
if( (aBx=aB->next[0]) != NULL && aBx->use == 1 && aBx->teamnum != -1 ){
if( aBx->teamnum == teamnum )
return aBx;
}
if( (aBx=aB->next[1]) != NULL && aBx->use == 1 && aBx->teamnum != -1 ){
if( aBx->teamnum == teamnum )
return aBx;
}
}
return NULL;
}
ArrangeBattleC *ArrangeBattleC_getNew( void)
{
ArrangeBattleC *MBUF=NULL;
MBUF = (ArrangeBattleC *) calloc( 1, sizeof( struct _tagArrangeBattle) );
if( MBUF == NULL ) return NULL;
MBUF->use = 0;
MBUF->fl = -1;
MBUF->code = -1;
MBUF->teamnum = -1;
MBUF->toindex = -1;
MBUF->type=0;
MBUF->teamname[0]=0;
MBUF->next[0] = NULL;
MBUF->next[1] = NULL;
MBUF->top = NULL;
return MBUF;
}
ArrangeBattleC *ArrangeBattleC_getInBattleArray( int ti)
{
if( ti<0 || ti>MAXBATTLEPAGE ) return NULL;
return InBattle[ti];
}
void ABATTLE_RecordBattle( int ti, char *buf1, char *tstr1,char *buf2, char *tstr2)
{//ABLevelup
char strlog[512];
FILE *fp=NULL;
if( (fp=fopen( "battle.rec", "a+") )==NULL )return;
sprintf( strlog, "%d|%s|%s|%s|%s", ti, tstr1, buf1, tstr2, buf2);
fprintf( fp, "%s\n", strlog);
fclose( fp);
ABATTLE_GetRecordBattle();
}
void remove_r( char *s )
{
int i;
for(i=0;;i++){
if( s[i]=='\r' || s[i]=='\n' )s[i] =0;
if( s[i]==0)break;
}
}
void ABATTLE_GetRecordBattle( void)
{//ABLevelup
char data[512];
FILE *fp=NULL;
memset( ABLevelup, 0, sizeof(ABLevelup));
if( (fp=fopen( "battle.rec", "r") )==NULL )return;
while( fgets( data, sizeof(data)-1, fp) ){
if( strlen( data) <= 0 ) continue;
remove_r( data);
if( strlen( ABLevelup) > 0 ) strcat( ABLevelup, " ");
strcat( ABLevelup, data);
}
fclose( fp);
}
void PKLIST_UpData(char *mycdkey,char *tocdkey,int menum,int tonum,int winer,int flg)
{
int k,meti,toti;
if((meti = PKLIST_GetPkTeamListArray(menum,mycdkey)) == -1){
printf("can't find meteam.teamnum(%d),cdkey(%s)\n",menum,mycdkey);
return;
}
if((toti = PKLIST_GetPkTeamListArray(tonum,tocdkey)) == -1){
printf("can't find toteam.teamnum(%d),cdkey(%s)\n",tonum,tocdkey);
return;
}
if(PkTeamList[meti].use != 1){
printf("meteam not in use.teamnum(%d),cdkey(%s)\n",menum,mycdkey);
return;
}
/*for(k=0;k<MAXBATTLENUM;k++){
if( PkTeamList[meti].BHistory[k].use != 1 ) continue;
if( PkTeamList[meti].BHistory[k].teamnum == tonum ){
return;
}
}*/
if( PkTeamList[toti].use != 1 ){
printf("toteam not in use.teamnum(%d),cdkey(%s)\n",tonum,tocdkey);
return;
}
/*for( k=0; k<MAXBATTLENUM; k++ ){
if( PkTeamList[toti].BHistory[k].use != 1 ) continue;
if( PkTeamList[toti].BHistory[k].teamnum == menum ){
return;
}
}*/
PKLIST_UpdateOnePkTeamData(meti,tonum,(winer==0)?1:0);
PKLIST_UpdateOnePkTeamData(toti,menum,(winer==1)?1:0);
}
int PKLIST_UpdateOnePkTeamData( int ti, int forti, int winerflg)
{
int ret=0;
int battleTi = PKLIST_GetOneBHistory( ti );
if( battleTi == -1){
printf( "ti:%d battleTi:%d err !!\n", ti, battleTi);
return -2;
}
if( winerflg == 1 ){
PkTeamList[ti].win++;
}else{
PkTeamList[ti].lost++;
}
PkTeamList[ti].battleplay++; //场次
PkTeamList[ti].score = (PkTeamList[ti].win*3) - (PkTeamList[ti].lost*1);//积分
if( PkTeamList[ti].score >= 90 ){
PkTeamList[ti].inside = 2; //录取
}else if( PkTeamList[ti].lost > 50*0.4){// 0.7 = (1-胜率3成)*最高场次
PkTeamList[ti].inside = 0;
}else {
PkTeamList[ti].inside = 1;
}
if( PkTeamList[ti].score < 0 ) PkTeamList[ti].score = 0;
ret = PKLIST_SetOneBHistory( ti, battleTi, 1, forti, winerflg);
//PKLIST_SortTheCharts( ti);
return ret;
}
int PKLIST_GetOneBHistory( int ti )
{
int i;
if( ti < 0 || ti >= maxteam ){
printf( "GetOneBHistory(ti:%d) err return -1 !!\n", ti);
return -1;
}
for( i=0; i<MAXBATTLENUM; i++){
if( i>=DEFMAXBATTLENUM ) break;
if( PkTeamList[ti].BHistory[i].use == 0 ){
printf("return BHistory[%d] \n", i) ;
return i;
}
}
printf("BATTLEFULL err !! \n") ;
return -1;
}
int PKLIST_SetOneBHistory( int ti, int hi, int use, int teamnum, int flg )
{
if( ti < 0 || ti >= maxteam ) return -1;
if( hi < 0 || hi >= MAXBATTLENUM ) return -1;
if( PkTeamList[ti].BHistory[hi].use == use ) return -1;
PkTeamList[ti].BHistory[hi].teamnum = teamnum;
PkTeamList[ti].BHistory[hi].flg = flg;
PkTeamList[ti].BHistory[hi].use = use;
return 1;
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -