#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
void pause(void){printf("ENTER> ");fflush(stdout);fgetc(stdin);}int d100(void){return rand()%100;}
int main(void){int hp=20,lv=1,exp=0,hour=0,day=1,mode=1,d,e_hp,e_lv;char s[256],*e_name;srand
(time(NULL));printf("You're a Sword Master wannabee.\nFight and get experienced!\n");pause();
while(lv<6&&hp>0&&!feof(stdin)){printf("\nStatus: HP=%d, Lv=%d, Exp=%d\n",hp,lv,exp,day);
printf("Command? ");fflush(stdout);fgets(s,256,stdin);switch(mode){case 0:/*FIGHTING*/
if(!strncmp(s,"attack",6)){d=d100();if(d<lv*2+50){if(d<5+lv){printf("CRITICAL HIT!!\n");
d=lv*10+d100()%10;}else{printf("Hit!!\n");d=lv+d100()%5;}printf("You gave %d point%s of damage to the %s!!\n",
d,d>1?"s":"",e_name);e_hp-=d;if(e_hp<=0){pause();printf("You defeated the %s!\n",e_name);pause();
d=d100()%e_lv+5;printf("You got %d point%s of experience!!\n",d,d>1?"s":"");exp+=d;if(lv==exp/20){pause();
printf("LEVEL UP!!\n");pause();lv++;if(lv<6)printf("You're now Sword Master wannabee Level %d!! (max HP=%d)\n",
lv,lv*20);}mode=1;break;}}else{printf("Missed!!\n");}enemy:pause();if(e_hp>0){printf("The %s's attack!!\n",
e_name);pause();d=d100();if(d<e_lv*3+28){printf("Hit!!\n");pause();d=d100()%(e_hp/2+1)+e_lv;