1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792
|
#include <string> #define version "1.0.1" #define ut 10000000ll #define inf 2147483647 using namespace std;
int tempi; bool isathome; unsigned int foodchosen; unsigned int luckchosen; unsigned int usechosen; bool settled; map <int,int> w;
class { public: unsigned long long outtime,lasttime; string name; };
class game{ public: frog yourfrog; unsigned int clover; unsigned int lottery; unsigned int things[40]; unsigned int lasttime; };
unsigned int chosen[40]={0}; string tn[40]={"葡萄干司康","鹅肠菜三明治","南瓜百吉饼","乳蛋饼","艾蒿小麦饼", "胡葱炸面包","胡萝卜饼干","南瓜饼干","毛豆饼干","牛奶饼干","牛蒡饼干", "草莓金平糖","柠檬金平糖","葡萄金平糖","蜜瓜金平糖","四叶草", "黄色护身符","白色护身符","红色护身符","蓝色护身符","桃色护身符", "东国车票","西国车票","南国车票","北国车票","幸运之铃", "头巾(地)","头巾(木)","头巾(装)","天然帐篷","时髦帐篷","高档帐篷", "透明的碗","木碗","漆器","蜡烛","手提灯笼","欧式提灯"}; unsigned int price[40]={10,20,50,80,100, 100,inf,inf,inf,inf,inf, inf,inf,inf,inf,inf, inf,inf,inf,inf,inf, inf,inf,inf,inf,3000, 150,250,400,300,450,750, 450,700,1200,600,900,1500};
game yourgame;
void save(){ FILE * out=fopen("tabikaeru.txt","w"); fprintf(out,"%sn",yourgame.yourfrog.name.c_str()); fprintf(out,"%llun%llun",yourgame.yourfrog.outtime,yourgame.yourfrog.lasttime); fprintf(out,"%un%un",yourgame.clover,yourgame.lottery); fprintf(out,"%dn%un%un%un",settled,foodchosen,luckchosen,usechosen); for (int i=0;i<39;i++) fprintf(out,"%un",yourgame.things[i]); fprintf(out,"%un",yourgame.lasttime); fprintf(out,"%dn",isathome); fclose(out); }
void read(){ ifstream in("tabikaeru.txt"); in>>yourgame.yourfrog.name>>yourgame.yourfrog.outtime>>yourgame.yourfrog.lasttime>>yourgame.clover>>yourgame.lottery; in>>settled>>foodchosen>>luckchosen>>usechosen; for (int i=0;i<39;i++) in>>yourgame.things[i]; in>>yourgame.lasttime; in>>isathome; in.close(); }
void delay(long long t){ for (int i=0;i<t;i++); }
void welcome(){ cout<<"旅行青蛙 version"<<version<<" by Flokirie"<<endl; delay(40*ut); for (int i=0;i<=100;i++){ printf("加载中…… %d%%r",i); delay(2*ut); } delay(30*ut); cout<<endl<<endl<<"加载完成!"<<endl; delay(60*ut); }
string input(string s){ cout<<">>>"; cin>>s; return s; }
int input(int i){ cout<<">>>"; cin>>i; return i; }
int result(int num){ if (num>32000) { return 1; } else if (num>30000){ return 2; } else if (num>24000){ return 3; } else if (num>14000){ return 4; } else return 5; }
void init(){ cout<<endl<<"这里是你的花园。"; delay(75*ut); cout<<endl<<"去家里看看吧。"; delay(75*ut); cout<<endl<<"这是你家的青蛙。"; delay(60*ut); cout<<endl<<"它可是一只爱旅行的青蛙。"; delay(80*ut); cout<<endl<<"给它取个名字吧(最大5文字):n※以后还可以更改"<<endl; yourgame.yourfrog.name=input(yourgame.yourfrog.name); delay(40*ut); cout<<yourgame.yourfrog.name<<"正在收拾行囊,看起来很开心。"<<endl; delay(55*ut); cout<<"让我们再次来到花园。"<<endl; delay(50*ut); cout<<"看那些三叶草啊!"<<endl; delay(50*ut); cout<<"快去收割它们吧。"<<endl; delay(35*ut); cout<<"n选项n1.收割三叶草"<<endl; delay(28*ut); while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } delay(35*ut); cout<<"三叶草 19 已获得"<<endl; delay(35*ut); yourgame.clover+=19; cout<<"还获得了 四叶草 1"<<endl; delay(50*ut); cout<<"现在,去商店为"<<yourgame.yourfrog.name<<"做些准备吧。"<<endl; delay(32*ut); cout<<"n选项n1.商店"<<endl; while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } delay(50*ut); cout<<"现在也没什么可买的,我们买个葡萄干司康吧。"<<endl; delay(55*ut); cout<<"n购买:n1.葡萄干司康(10 三叶草)n"; delay(30*ut); while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } yourgame.clover-=10; delay(27*ut); cout<<"好,去帮"<<yourgame.yourfrog.name<<"准备行囊吧:" ; delay(50*ut); cout<<"nn选项:n1.回家n"; delay(30*ut); while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } delay(30*ut); cout<<"n选项:n1.收拾行囊n"; delay(30*ut); while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } delay(30*ut); cout<<"n行囊:n1.便当n"; delay(30*ut); while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } delay(28*ut); cout<<"n便当:n1.葡萄干司康 (所持 1)n"; delay(30*ut); while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } delay(28*ut); cout<<"n行囊:n1.幸运物n"; delay(30*ut); while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } delay(27*ut); cout<<"n幸运物:n1.四叶草 (所持 1)n"; delay(30*ut); while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } delay(30*ut); cout<<"n行囊:n1.确定n"; delay(30*ut); while (input(tempi)!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); } delay(35*ut); cout<<"你已经为"<<yourgame.yourfrog.name<<"完成了旅行准备。"<<endl; cout<<"※由于这是教程,所以"<<yourgame.yourfrog.name<<"会在重启本程序后踏上旅程。"; yourgame.yourfrog.outtime=time(0)+1; yourgame.yourfrog.lasttime=1800; yourgame.lasttime=time(0)+1; save(); }
void play(); void shop(); void garden(); void home(); void bedroom(); void prize(); void buy();
int main(){ srand(time(0)); welcome(); FILE * in=fopen("tabikaeru.txt","r"); if (in==NULL){ init(); } else{ read(); play(); save(); } return 0; }
void play(){ if (isathome==0 &&(unsigned long long)(time(0))>yourgame.yourfrog.outtime+yourgame.yourfrog.lasttime){ cout<<yourgame.yourfrog.name<<"已经回来了"<<endl; isathome=1; delay(80*ut); } else if (isathome){ cout<<yourgame.yourfrog.name<<"在家里。"<<endl; } else if ((unsigned long long)(time(0))>yourgame.yourfrog.outtime) { cout<<yourgame.yourfrog.name<<"已经踏上旅程"<<endl; isathome=0; delay(80*ut); } else isathome=0; garden(); return; }
void shop(){ delay(40*ut); cout<<"n这里是商店。"<<endl<<endl; delay(35*ut); cout<<"选项:n1.抽奖n2.买东西n3.回家n4.去花园n"; delay(30*ut); tempi=input(tempi); while(tempi>4 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(30*ut); switch(tempi){ case 1: prize(); break; case 2: buy(); break; case 3: home(); break; case 4: garden(); break; } }
void garden(){ delay(40*ut); cout<<"n这是你的花园。"<<endl<<endl; delay(35*ut); a: cout<<"选项:n1.收割三叶草n2.回家n3.去商店n4.去里屋n5.充值n6.保存并退出n"; delay(30*ut); tempi=input(tempi); while(tempi>6 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(30*ut); switch(tempi){ case 2: home(); break; case 3: shop(); break; case 4: bedroom(); break; case 5: cout<<"就这C++版旅行青蛙还想充值?"<<endl; delay(35*ut); goto a; case 6: save(); break; case 1: int numb=max(min((int)((time(0)-yourgame.lasttime)/500),20),0); int four=0; for (int i=0;i<numb;i++){ if (rand()%300==0) four++; } if (four) four=1; cout<<"三叶草 "<<numb-four<<" 已获得"<<endl; delay(35*ut); yourgame.clover+=numb-four; if (four) { cout<<"还获得了 四叶草 1"<<endl; yourgame.things[15]++; } yourgame.lasttime=time(0)+1; delay(28); goto a; break; } }
void home(){ delay(30*ut); cout<<"这里是你的家。"<<endl; delay(32*ut); if (!isathome){ c: cout<<"选项:n1.去花园n2.去商店n3.去里屋n4.保存并退出n"; delay(30*ut); tempi=input(tempi); while(tempi>4 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(30*ut); switch(tempi){ case 1: garden(); break; case 2: shop(); break; case 3: bedroom(); break; case 4: save(); break; } } else{ cc: cout<<"选项:n1.去花园n2.去商店n3.去里屋n4.给蛙改名n5.收拾行囊n6.保存并退出n"; delay(30*ut); tempi=input(tempi); while(tempi>6 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(30*ut); switch(tempi){ case 1: garden(); break; case 2: shop(); break; case 3: bedroom(); break; case 4: cout<<"请输入蛙的新名字(最大5文字):"<<endl; delay(35*ut); yourgame.yourfrog.name=input(yourgame.yourfrog.name); goto cc; break; case 5: if (settled){ cout<<"行囊已经准备好了!"<<endl; delay(40*ut); goto c; } d: cout<<"n行囊:n1.便当n2.幸运物n3.用具n4.确认n5.返回选项n"; delay(40*ut); tempi=input(tempi); while(tempi>5 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(30*ut); switch (tempi){ case 1:{ cout<<endl<<"便当:"<<endl; int order=1; for (int i=0;i<15;i++){ if (yourgame.things[i]){ cout<<order++<<"."<<tn[i]<<" (所持 "<<yourgame.things[i]<<")"<<endl; } } cout<<order<<".不保存并返回上一级"<<endl; delay(35*ut); tempi=input(tempi); while(tempi>order || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } if (tempi==order) goto d; int i=0,j=0; do{ if (yourgame.things[i]) j++; i++; }while(j<order); if (foodchosen==1) { cout<<"便当已装满!"<<endl; goto d; } foodchosen=!foodchosen; chosen[i]=!chosen[i]; cout<<"已成功选择。"<<endl; delay(45*ut); goto d; break; } case 2:{ cout<<endl<<"幸运物:"<<endl; int order=1; for (int i=15;i<26;i++){ if (yourgame.things[i]){ cout<<order++<<"."<<tn[i]<<" (所持 "<<yourgame.things[i]<<")"<<endl; } } cout<<order<<".不保存并返回上一级"<<endl; delay(35*ut); tempi=input(tempi); while(tempi>order || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } if (tempi==order) goto d; int i=16,j=0; do{ if (yourgame.things[i]) j++; i++; }while(j<order); if (luckchosen==1) { cout<<"幸运物已装满!"<<endl; goto d; } luckchosen=!luckchosen; chosen[i]=!chosen[i]; cout<<"已成功选择。"<<endl; delay(45*ut); goto d; break; } case 3:{ cout<<endl<<"用品:"<<endl; int order=1; for (int i=26;i<39;i++){ if (yourgame.things[i]){ cout<<order++<<"."<<tn[i]<<" (所持 "<<yourgame.things[i]<<")"<<endl; } } cout<<order<<".不保存并返回上一级"<<endl; delay(35*ut); tempi=input(tempi); while(tempi>order || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } if (tempi==order) goto d; int i=26,j=0; do{ if (yourgame.things[i]) j++; i++; }while(j<order); if (usechosen==2) { cout<<"用品已装满!"<<endl; goto d; } if (chosen[i]) usechosen--; else usechosen++; chosen[i]=!chosen[i]; cout<<"已成功选择。"<<endl; delay(45*ut); goto d; break; } case 4:{ settled=1; for (int i=0;i<25;i++){ if (chosen[i]) yourgame.things[i]-=1; } cout<<"成功收拾好行囊。"<<endl; yourgame.yourfrog.outtime=time(0)+1000+rand()%1000; yourgame.yourfrog.lasttime=10000+rand()%10000+rand()%10000; delay(50*ut); } goto cc; } case 6: save(); break; } } }
void bedroom(){ delay(20*ut); cout<<"这里并没有什么功能。"<<endl; delay(25*ut); cout<<"选项:n1.回家"<<endl; tempi=input(tempi); while(tempi!=1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } home(); }
void prize(){ delay(36*ut); cout<<"这里是摇奖店。"<<endl; delay(30*ut); b: cout<<"5张奖券转一次,你有"<<yourgame.lottery<<"张奖券。"<<endl; delay(35*ut); cout<<"选项:n1.抽奖n2.奖品一览n3.去商店n4.回家n"; delay(30*ut); tempi=input(tempi); while(tempi>4 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(90*ut); switch(tempi){ case 1: if (yourgame.lottery<5){ cout<<"对不起,奖券不足,您现在不能抽奖!"<<endl; delay(36*ut); goto b; } yourgame.lottery-=5; switch (result(rand())){ case 1: cout<<endl<<"黄玉 出来了"<<endl; delay(45*ut); cout<<endl<<"请选择奖品:"<<endl; delay(30*ut); cout<<endl<<"1.东国车票n2.西国车票n3.南国车票n4.北国车票n"; delay(60*ut); tempi=input(tempi); while(tempi>4 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(30*ut); switch (tempi){ case 1: cout<<"获得了 东国车票"<<endl; break; case 2: cout<<"获得了 西国车票"<<endl; break; case 3: cout<<"获得了 南国车票"<<endl; break; case 4: cout<<"获得了 北国车票"<<endl; break; } yourgame.things[21+tempi]++; delay(35*ut); break; case 2: cout<<endl<<"红玉 出来了"<<endl; delay(45*ut); cout<<endl<<"请选择奖品:"<<endl; delay(30*ut); cout<<endl<<"1.草莓金平糖n2.柠檬金平糖n3.葡萄金平糖n4.蜜瓜金平糖n"; delay(60*ut); tempi=input(tempi); while(tempi>4 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(30*ut); switch (tempi){ case 1: cout<<"获得了 草莓金平糖"<<endl; break; case 2: cout<<"获得了 柠檬金平糖"<<endl; break; case 3: cout<<"获得了 葡萄金平糖"<<endl; break; case 4: cout<<"获得了 蜜瓜金平糖"<<endl; break; } yourgame.things[10+tempi]++; delay(35*ut); break; case 3: cout<<endl<<"绿玉 出来了"<<endl; delay(45*ut); cout<<endl<<"请选择奖品:"<<endl; delay(30*ut); cout<<endl<<"1.胡萝卜饼干n2.南瓜饼干n3.毛豆饼干n4.牛奶饼干n5.牛蒡饼干"; delay(60*ut); tempi=input(tempi); while(tempi>5 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(30*ut); switch (tempi){ case 1: cout<<"获得了 胡萝卜饼干"<<endl; break; case 2: cout<<"获得了 南瓜饼干"<<endl; break; case 3: cout<<"获得了 毛豆饼干"<<endl; break; case 4: cout<<"获得了 牛奶饼干"<<endl; break; case 5: cout<<"获得了 牛蒡饼干"<<endl; break; } yourgame.things[5+tempi]++; delay(35*ut); break; case 4: cout<<endl<<"青玉 出来了"<<endl; delay(45*ut); cout<<endl<<"请选择奖品:"<<endl; delay(30*ut); cout<<endl<<"1.黄色护身符n2.白色护身符n3.红色护身符n4.蓝色护身符n5.桃色护身符n"; delay(60*ut); tempi=input(tempi); while(tempi>5 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(30*ut); switch (tempi){ case 1: cout<<"获得了 黄色护身符"<<endl; break; case 2: cout<<"获得了 白色护身符"<<endl; break; case 3: cout<<"获得了 红色护身符"<<endl; break; case 4: cout<<"获得了 蓝色护身符"<<endl; break; case 5: cout<<"获得了 桃色护身符"<<endl; break; } yourgame.things[16+tempi]++; delay(35*ut); break; case 5: cout<<endl<<"白玉 出来了"<<endl; delay(45*ut); cout<<"获得了 抽奖券"<<endl; yourgame.lottery++; delay(35*ut); break; } goto b; break; case 2: cout<<"黄玉 车票n红玉 金平糖n绿玉 饼干n青玉 护身符n白玉 抽奖券n"; delay(45*ut); goto b; break; case 3: shop(); break; case 4: home(); break; } }
void buy(){ ee:delay(35*ut); cout<<endl<<"商品一览:"<<endl; delay(35*ut); for (int i=0,j=0;i<38;i++){ if (price[i]!=inf){ w[++j]=i; cout<<j<<". "<<tn[i]<<" (三叶草 "<<price[i]<<")"; if (i>=25 && i<=37 && yourgame.things[i]) cout<<" 【已售罄】"; cout<<endl; delay(4*ut); } } cout<<endl<<"你所持有的三叶草数: "<<yourgame.clover<<endl; delay(36*ut); cout<<endl; delay(40*ut); cout<<"选项:"<<endl<<"(1~19).输入商品编号以购买"<<endl; cout<<"20.回家"<<endl<<"21.去花园"<<endl<<"22.回到“商店”界面"<<endl; delay(28*ut); tempi=input(tempi); while(tempi>22 || tempi<1){ cout<<"输入有误!请重新输入:"<<endl; delay(25*ut); tempi=input(tempi); } delay(27*ut); if (tempi<=19){ if (yourgame.clover<price[w[tempi]]){ cout<<"您持有的三叶草不足!"<<endl; } else if (w[tempi]>=25 && w[tempi]<=37 && yourgame.things[w[tempi]]) { cout<<tn[w[tempi]]<<"真的已经售罄了!"<<endl<<endl; } else{ yourgame.clover-=price[w[tempi]]; yourgame.things[w[tempi]]++; cout<<"已成功购买"<<tn[w[tempi]]<<",剩余三叶草数: "<<yourgame.clover<<endl<<endl; if (rand()<500){ cout<<endl<<"还获得了 抽奖券 1"<<endl; delay(30); yourgame.lottery++; } } goto ee; } else if (tempi==20){ home(); } else if (tempi==21){ garden(); } else{ shop(); } }
|
近期评论