-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
1822 lines (1590 loc) · 70.1 KB
/
main.cpp
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
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <winsock2.h>
#include <windows.h>
#include <commctrl.h>
#include <iostream>
#include <fstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <map>
//#include <stdio.h>
//#include <math.h>
//#include <iomanip>
#include "MHGdataHandle.h"
#include "MHGcombat.h"
#include "MHGguiHandle.h"
using namespace std;
using namespace MHGdataHandle; //from MHGdataHandle.h
using namespace MHGcombat; //from MHGcombat.h, #included header in MHGdataHandle.h
using namespace MHGtextDisplay; //from MHGtextDisplay.h, #included header in MHGcombat.h
using namespace MHGsounds; //from MHGsounds.h, #included header in MHGcombat.h
using namespace MHGguiHandle; //from MHGguiHandle.h
int version;
int tpass, prevt=time(nullptr);
int k, m, t, x=2;
int page=1;
int hours, mins, secs;
int sd16=0,sd17=0,sd18=0,sd19=0,sd20=0,sd21=0,sd22=0,sd23=0,sd24=0,total=0;
char input[1];
//float fadamage=0, num=0;
int sdata[60]={seed1,seed2,version,coins,lvl,xp,cStage,sword,shield,armour,magic_fsword1,magic_healp2,magicpt,pet,skill_fa1,skill_2,mcnt,prevt,mShards,swordtier,armourtier,
shieldtier,emcnt,dmcnt,sShards,cShards,dcnt,dchance,mWood,oWood,ironOre,pyrogems,equip,skillFB,skillSM,skillGG,magicBB,snowballs,sd16,sd17,sd18,sd19,sd20,sd21,sd22,sd23,sd24,total};
map <string, int> smap, id_map;
map <int, string> itemID;
map <string, int> ::iterator map_it;
string username="";
string code="";
void updateTotal(){
//total excludes seed1, seed2, version, and prevt
total=coins+lvl+xp+cStage+sword+shield+armour+magic_fsword1+magic_healp2+magicpt+pet+skill_fa1+skill_2+mcnt+mShards+swordtier+armourtier+
shieldtier+emcnt+dmcnt+sShards+cShards+dcnt+dchance+mWood+oWood+ironOre+pyrogems+equip+skillFB+skillSM+skillGG+magicBB+snowballs+sd16+sd17+sd18+sd19+sd20+sd21+sd22+sd23+sd24;
}
void loadMaps(){
smap["seed1"]=seed1; smap["seed2"]=seed2; smap["version"]=version; smap["coins"]=coins; smap["lvl"]=lvl; smap["xp"]=xp; smap["cStage"]=cStage; smap["sword"]=sword;
smap["shield"]=shield; smap["armour"]=armour; smap["magic_fsword1"]=magic_fsword1; smap["magic_healp2"]=magic_healp2; smap["magicpt"]=magicpt; smap["pet"]=pet;
smap["skill_fa1"]=skill_fa1; smap["skill_2"]=skill_2; smap["mcnt"]=mcnt; smap["prevt"]=prevt; smap["mShards"]=mShards; smap["swordtier"]=swordtier; smap["armourtier"]=armourtier;
smap["shieldtier"]=shieldtier; smap["emcnt"]=emcnt; smap["dmcnt"]=dmcnt; smap["sShards"]=sShards; smap["cShards"]=cShards; smap["dcnt"]=dcnt; smap["dchance"]=dchance; smap["mWood"]=mWood; smap["oWood"]=oWood;
smap["ironOre"]=ironOre; smap["pyrogems"]=pyrogems; smap["equip"]=equip; smap["skillFB"]=skillFB; smap["skillSM"]=skillSM; smap["skillGG"]=skillGG; smap["magicBB"]=magicBB; smap["snowballs"]=snowballs; smap["sd16"]=sd16;
smap["sd17"]=sd17; smap["sd18"]=sd18; smap["sd19"]=sd19; smap["sd20"]=sd20; smap["sd21"]=sd21; smap["sd22"]=sd22; smap["sd23"]=sd23; smap["sd24"]=sd24; smap["total"]=total;
int i1=0;
for(map_it = smap.begin(); map_it != smap.end(); map_it++){
id_map[map_it->first] = i1;
i1++;
}
itemID[0]="seed1"; itemID[1]="seed2"; itemID[2]="version"; itemID[3]="coins"; itemID[4]="lvl"; itemID[5]="xp"; itemID[6]="cStage";
itemID[7]="sword"; itemID[8]="shield"; itemID[9]="armour"; itemID[10]="magic_fsword1"; itemID[11]="magic_healp2"; itemID[12]="magicpt";
itemID[13]="pet"; itemID[14]="skill_fa1"; itemID[15]="skill_2"; itemID[16]="mcnt"; itemID[17]="prevt"; itemID[18]="mShards";
itemID[19]="swordtier"; itemID[20]="armourtier"; itemID[21]="shieldtier"; itemID[22]="emcnt"; itemID[23]="dmcnt"; itemID[24]="sShards"; itemID[25]="cShards";
itemID[26]="dcnt"; itemID[27]="dchance"; itemID[28]="mWood"; itemID[29]="oWood"; itemID[30]="ironOre"; itemID[31]="pyrogems"; itemID[32]="equip"; itemID[33]="skillFB";
itemID[34]="skillSM"; itemID[35]="skillGG"; itemID[36]="magicBB"; itemID[37]="snowballs"; itemID[38]="sd16"; itemID[39]="sd17"; itemID[40]="sd18"; itemID[41]="sd19";
itemID[42]="sd20"; itemID[43]="sd21"; itemID[44]="sd22"; itemID[45]="sd23"; itemID[46]="sd24";
itemID[47]="total";
}
void updateStoredData(){
datastore.open("MMGameFiles/MMGameData.txt");
if (!datastore) { //unable to find/open txt data file
cout << "Fatal Error! Unable to store data! Please report bug as 'Error4'." << "\n";
system("color 0C");
cout<<'\a';
while(true) Sleep(100);
}
datastore<<seed1<<" "<<seed2<<" "<<version<<" ";
int s2data[60]={seed1,seed2,version,coins,lvl,xp,cStage,sword,shield,armour,magic_fsword1,magic_healp2,magicpt,pet,skill_fa1,skill_2,mcnt,prevt,mShards,swordtier,armourtier,
shieldtier,emcnt,dmcnt,sShards,cShards,dcnt,dchance,mWood,oWood,ironOre,pyrogems,equip,skillFB,skillSM,skillGG,magicBB,snowballs,sd16,sd17,sd18,sd19,sd20,sd21,sd22,sd23,sd24,total};
for(m=3;m<47;m++){
if(m!=17) datastore<<encrypt(s2data[m])<<" "; //encryption
else datastore<<s2data[m]<<" ";
//cout<<s2data[m]<<"/";
}
updateTotal();
datastore<<total<<" ";
datastore<<"\n"<<stringE(petname);
datastore<<"\n"<<stringE(username);
datastore.close();
loadMaps();
pushLoadedMap(smap,id_map,itemID); pushLoadedArray(sdata); pushTexts(petname);
updateDatabase(petname.c_str(), username.c_str());
cout<<"Game progress saved!"<<"\n";
}
void del_PABTC(){//PABTC stands for Press any button to continue
for(int i=0; i<31; i++) cout<<"\b \b";
}
void dungeonResult(char result, HWND hwnd){
if(result == 'S'){
displayDungeon(R, C); dungeonRes();
}
else if(result == 'F'){
textc(12); cout<<"NO!!! You would knock yourself onto the wall!!!\n"; textc(10);
cout<<'\a';
Sleep(2000);
displayDungeon(R, C); dungeonRes();
}
else if(result == 'M'){
bInDMfight=true;
bInDungeon=false;
fighttype=4;
mfight();
mFightRes();
}
else if(result == 'T'){
cout<<"You found "; textc(14); cout<<"treasure"; textc(10); cout<<", ";
cout<<'\a';
dungeonTreasure(); cout<<"\n\n"; SleepTillNextSec(); Sleep(1000);
displayDungeon(R, C); dungeonRes();
}
else if(result == 'E'){
cout<<'\a';
if(MessageBox(hwnd, "Exit the Dungeon?", "Confirmation Message", MB_YESNO | MB_ICONQUESTION) == IDYES){
dungeonExit();
updateStoredData();
bInDungeon=false;
bInMainMenu=true;
}
else{ displayDungeon(R, C); dungeonRes(); }
}
}
/* This is where all the input to the window goes to */
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
switch(Message) {
case WM_CREATE:{
createMenus(hwnd);
/*cout<<" __ __ ____ _ _ _____ _______ ______ _____ _ _ _ _ _ _ _______ ______ _____ \n";
cout<<" C| \\/ |/ __ \\| \\ | |/ ____|__ __| ____| __ \\ | | | | | | | \\ | |__ __| ____| __ \\ G\n";
cout<<" +| \\ / | | | | \\| | (___ | | | |__ | |__) | | |__| | | | | \\| | | | | |__ | |__) |A\n";
cout<<" +| |\\/| | | | | . ` |\\___ \\ | | | __| | _ / | __ | | | | . ` | | | | __| | _ / M\n";
cout<<" | | | | |__| | |\\ |____) | | | | |____| | \\ \\ | | | | |__| | |\\ | | | | |____| | \\ \\ E\n";
cout<<" |_| |_|\\____/|_| \\_|_____/ |_| |______|_| \\_\\ |_| |_|\\____/|_| \\_| |_| |______|_| \\_\\ by HCI Pro-ductions \n";*/
/*cout<<" __ __ _ _ _____\n";
cout<<"C| \\/ | | | | | / ____|\n";
cout<<"+| \\ / | | |__| | | | __\n";
cout<<"+| |\\/| | | __ | | | |_ |\n";
cout<<" | | | | | | | | | |__| |\n";
cout<<" |_| |_| |_| |_| \\_____|by HCI Pro-ductions\n";*/
/*cout<<" MMMMMMMM MMMMMMMM HHHHHHHHH HHHHHHHHH GGGGGGGGGGGGG \n";
cout<<" M:::::::M M:::::::M H:::::::H H:::::::H GGG::::::::::::G \n";
cout<<" M::::::::M M::::::::M H:::::::H H:::::::H GG:::::::::::::::G \n";
cout<<" M:::::::::M M:::::::::M HH::::::H H::::::HH G:::::GGGGGGGG::::G \n";
cout<<" M:::Mon::::M M::::ster::M H:::::H H:::::H G:::::G GGGGGG \n";
cout<<" M:::::::::::M M:::::::::::M H:::::H H:::::H G:::::G \n";
cout<<" M:::::::M::::M M::::M:::::::M H::::::HHHHH::::::H G:::::G \n";
cout<<" M::::::M M::::M M::::M M::::::M H:::::::::::::::::H G:::::G GGGGGGGGGG \n";
cout<<" M::::::M M::::M::::M M::::::M H:::::::Hunt::::::H G:::::G G::::::::G \n";
cout<<" M::::::M M:::::::M M::::::M H::::::HHHHH::::::H G:::::G GGGGG::::G \n";
cout<<" M::::::M M:::::M M::::::M H:::::H H:::::H G:::::G G::G:G \n";
cout<<" M::::::M MMMMM M::::::M H:::::H H:::::H G:::::G G::A:G \n";
cout<<" M::::::M M::::::M HH::::::H H::::::HH G:::::GGGGGGGG::M:G \n";
cout<<" M::::::M M::::::M H:::::::H H:::er::H GG:::::::::::::E:G \n";
cout<<" M::::::M M::::::M H:::::::H H:::::::H GGG::::::GGG:::G \n";
cout<<" MMMMMMMM MMMMMMMM HHHHHHHHH HHHHHHHHH GGGGGG GGGG by HCI Pro-ductions\n";*/
cout<<R"( __ __ ____ _ _ _____ _______ ______ _____ __ __ ______ _ _ _ _____ _ _ ____ _ __ __)"<<"\n";
cout<<R"(| \/ |/ __ \| \ | |/ ____|__ __| ____| __ \ | \/ | ____| | /\ | \ | |/ ____| | | |/ __ \| | \ \ / /)"<<"\n";
cout<<R"(| \ / | | | | \| | (___ | | | |__ | |__) | | \ / | |__ | | / \ | \| | | | |__| | | | | | \ \_/ / )"<<"\n";
cout<<R"(| |\/| | | | | . ` |\___ \ | | | __| | _ / | |\/| | __| | | / /\ \ | . ` | | | __ | | | | | \ / )"<<"\n";
cout<<R"(| | | | |__| | |\ |____) | | | | |____| | \ \ | | | | |____| |____ / ____ \| |\ | |____| | | | |__| | |____| | )"<<"\n";
cout<<R"(|_| |_|\____/|_| \_|_____/ |_| |______|_| \_\ |_| |_|______|______/_/ \_\_| \_|\_____|_| |_|\____/|______|_| by HCI Pro-Ductions)"<<"\n";
srand( (unsigned)time(NULL) );
cout << "Loading...\n";
cout << "Do not click anything just yet!\n" ;
t = time(0);
while(time(0)-t<=1){}
cout << "Tip: Use full screen mode/maximise on this screen (not the Control Panel) to get the best experience!\n";
//cout << "Tip: See the Download Instructions to learn how to get the best experience!\n";
t = time(0);
while(time(0)-t<=1){}
//loading...
//-------------------//version input ------------------------------
//dataget>>seed1>>seed2>>coins>>lvl>>xp>>cStage>>sword>>shield>>armour>>magic_fsword1>>magic_healp2>>magicpt>>pet>>skill_fa1>>skill_2>>mcnt>>prevt>>version;
//getline(pet_dataget, petname);
//encryption: (data*seed1)+(seed2-4)
//decryption: (data-(seed2-4))/seed1 [See MHGdataHandle.h for decrypt function]
cout<<"Connecting to server...\n";
mongoc_init();//Required to initialize libmongoc's internals
if( !phraseURI() ) while(true){};
if( !createClient() ) while(true){};
handleDatabase();
if( !pingDatabase() ) while(true){};
version=0;//2.0.0
dataget.open("MMGameFiles/MMGameData.txt");
dataget>>seed1>>seed2;
dataget.close();
//check if its first time playing
if (seed1>100||seed1<3||seed2>200||seed2<7) {
cout<<"\n"<<R"(Have you created a MHG account yet? (Type "Y" for yes or "N" for no (without the inverted commas) then press enter to answer))" <<"\n";
cout << "Your Response: ";
cin >> input[0];
cout<<"\n";
cout<<"----------------------------------------"<<"\n";
if(input[0]=='N') {
//reset data
seed1=3+rand()%98; //3-100
seed2=7+rand()%194; //7-200
datastore.open("MMGameFiles/MMGameData.txt");
if (!datastore){
cout << "Fatal Error! Unable to store data! Please report bug as 'Error4'." << "\n";
system("color 0C");
cout<<'\a';
while(true){}
}
//cout<<seed1<<" "<<seed2<<" "<<version<<" "<<"\n";
datastore<<seed1<<" "<<seed2<<" "<<version<<" ";
int sdata[60]={seed1,seed2,version,coins,lvl,xp,cStage,sword,shield,armour,magic_fsword1,magic_healp2,magicpt,pet,skill_fa1,skill_2,mcnt,prevt,mShards,swordtier,armourtier,
shieldtier,emcnt,dmcnt,sShards,cShards,dcnt,dchance,mWood,oWood,ironOre,pyrogems,equip,skillFB,skillSM,skillGG,magicBB,snowballs,sd16,sd17,sd18,sd19,sd20,sd21,sd22,sd23,sd24,total};
for(m=3;m<47;m++){
if(m!=17) sdata[m]=encrypt(sdata[m]); //encryption
datastore<<sdata[m]<<" ";
//cout<<sdata[m]<<" ";
}
updateTotal();
datastore<<total<<" ";
datastore<<"\n"<<stringE(petname);
//setup account
cout<<"Please create an account, and refer to the game documentation for details."<<"\n";
string newNamestr;
do{ cout<<"Username>";
cin>>newNamestr;
} while(newNamestr.size()>20);
for(int i=0; i<newNamestr.size(); i++) username += newNamestr[i];
while( scanForUser(username.c_str()) ){
cout<<"Username already taken!"<<"\n";
do{ cout<<"Username>";
cin>>newNamestr;
} while(newNamestr.size()>20);
username="";
for(int i=0; i<newNamestr.size(); i++) username += newNamestr[i];
}
string hashPass = getHashedPassword("Password>");
addNewUser( username, hashPass.c_str() );
datastore<<"\n"<<stringE(username);
datastore.close();
cout<<"\n";
cout<<"Account creation success!"<<"\n";
}
else if(input[0]=='Y'){
//login to account
string newNamestr;
cout<<"Please login into your existing account\n\n";
do{ cout<<"Username>";
cin>>newNamestr;
} while(newNamestr.size()>20);
for(int i=0; i<newNamestr.size(); i++) username += newNamestr[i];
while( !scanForUser(username.c_str()) ){
cout<<"Username not found!"<<"\n";
do{ cout<<"Username>";
cin>>newNamestr;
} while(newNamestr.size()>20);
username="";
for(int i=0; i<newNamestr.size(); i++) username += newNamestr[i];
}
string hashPass = getHashedPassword("Password>");
cout<<"Verifying Password..."<<endl<<"\n";
while( !verifyUser(username.c_str(), hashPass.c_str()) ){
cout<<"Password Incorrect!"<<"\n";
hashPass = getHashedPassword("Password>");
cout<<"Verifying Password..."<<endl<<"\n";
}
loadMaps();
pushLoadedMap(smap,id_map,itemID); pushTexts(petname);
readDatabase(username.c_str());
if(true){//for collapsing this block of code in IDEs
coins=DHmap[itemID[3]]; lvl=DHmap[itemID[4]]; xp=DHmap[itemID[5]]; cStage=DHmap[itemID[6]]; sword=DHmap[itemID[7]];
shield=DHmap[itemID[8]]; armour=DHmap[itemID[9]]; magic_fsword1=DHmap[itemID[10]]; magic_healp2=DHmap[itemID[11]];
magicpt=DHmap[itemID[12]]; pet=DHmap[itemID[13]]; skill_fa1=DHmap[itemID[14]]; skill_2=DHmap[itemID[15]]; mcnt=DHmap[itemID[16]];
prevt=DHmap[itemID[17]]; mShards=DHmap[itemID[18]]; swordtier=DHmap[itemID[19]]; armourtier=DHmap[itemID[20]]; shieldtier=DHmap[itemID[21]];
emcnt=DHmap[itemID[22]]; dmcnt=DHmap[itemID[23]]; sShards=DHmap[itemID[24]]; cShards=DHmap[itemID[25]]; dcnt=DHmap[itemID[26]];
dchance=DHmap[itemID[27]]; mWood=DHmap[itemID[28]]; oWood=DHmap[itemID[29]]; ironOre=DHmap[itemID[30]]; pyrogems=DHmap[itemID[31]]; equip=DHmap[itemID[32]];
skillFB=DHmap[itemID[33]]; skillSM=DHmap[itemID[34]]; skillGG=DHmap[itemID[35]]; magicBB=DHmap[itemID[36]]; snowballs=DHmap[itemID[37]]; sd16=DHmap[itemID[38]];
sd17=DHmap[itemID[39]]; sd18=DHmap[itemID[40]]; sd19=DHmap[itemID[41]]; sd20=DHmap[itemID[42]]; sd21=DHmap[itemID[43]]; sd22=DHmap[itemID[44]];
sd23=DHmap[itemID[45]]; sd24=DHmap[itemID[46]];
total=DHmap[itemID[47]];
}
updateStoredData();
cout<<"Account login success!"<<"\n";
}
else{
cin.ignore();
textc(12);
cout<<"Invalid response, rerun the programme to try again."<<"\n";
while(true){}
}
}
dataget.open("MMGameFiles/MMGameData.txt");
if (!dataget) {
cout << "Fatal Error! Unable to retrieve data! Please report bug as 'Error3'." << "\n";
system("color 0C");
cout<<'\a';
while(true){}
}
dataget>>seed1>>seed2>>version;
for(m=3;m<47;m++){//decryption and read data into program variables
dataget>>sdata[m];
if(m!=17) sdata[m]=decrypt(sdata[m],m,true);
//cout<<sdata[m]<<" ";
}
int check=0;
dataget>>total;
for(m=3;m<47;m++){//get the current total value (store into check)
if(m!=17) check=check+sdata[m];
}
if(true){//for collapsing this block of code in IDEs
coins=sdata[3]; lvl=sdata[4];
xp=sdata[5]; cStage=sdata[6]; sword=sdata[7]; shield=sdata[8]; armour=sdata[9]; magic_fsword1=sdata[10]; magic_healp2=sdata[11]; magicpt=sdata[12]; pet=sdata[13];
skill_fa1=sdata[14]; skill_2=sdata[15]; mcnt=sdata[16]; prevt=sdata[17]; mShards=sdata[18]; swordtier=sdata[19]; armourtier=sdata[20]; shieldtier=sdata[21];
emcnt=sdata[22]; dmcnt=sdata[23]; sShards=sdata[24]; cShards=sdata[25]; dcnt=sdata[26]; dchance=sdata[27]; mWood=sdata[28]; oWood=sdata[29]; ironOre=sdata[30]; pyrogems=sdata[31]; equip=sdata[32]; skillFB=sdata[33];
skillSM=sdata[34]; skillGG=sdata[35]; magicBB=sdata[36]; snowballs=sdata[37]; sd16=sdata[38]; sd17=sdata[39]; sd18=sdata[40]; sd19=sdata[41]; sd20=sdata[42]; sd21=sdata[43];
sd22=sdata[44]; sd23=sdata[45]; sd24=sdata[46];
total=sdata[47];
}
dataget.ignore(10,'\n');
petname=""; username="";
char cx;
while(dataget.get(cx) && cx!='\n') petname+=cx;
//cout<<petname;
petname = stringD(petname);//a possible defalut encrypted petname is CIPVY99$07i#0',
while(dataget.get(cx) && cx!='\n') username+=cx;
//cout<<username<<"\n";
username = stringD(username);
//cout<<"decrypted petname:"<<petname<<"\n";
//cout<<"decrypted username:"<<username<<"\n";
dataget.close();
if(rand()%2==1){//random seed change (50% chance)
seed1=3+rand()%98; //3-100
seed2=7+rand()%194; //7-200
//
datastore.open("MMGameFiles/MMGameData.txt");
if (!datastore) {
cout << "Fatal Error! Unable to store data! Please report bug as 'Error4'." << "\n";
system("color 0C");
cout<<'\a';
while(true){}
}
cout<<"Seed changing...";
//cout<<seed1<<" "<<seed2<<"Seed changing "<<version<<" "<<"\n";
//cout<<"Version 1."<<version<<"\n";
datastore<<seed1<<" "<<seed2<<" "<<version<<" ";
int sdata[50]={seed1,seed2,version,coins,lvl,xp,cStage,sword,shield,armour,magic_fsword1,magic_healp2,magicpt,pet,skill_fa1,skill_2,mcnt,prevt,mShards,swordtier,armourtier,
shieldtier,emcnt,dmcnt,sShards,cShards,dcnt,dchance,mWood,oWood,ironOre,pyrogems,equip,skillFB,skillSM,skillGG,magicBB,snowballs,sd16,sd17,sd18,sd19,sd20,sd21,sd22,sd23,sd24,total};
for(m=3;m<47;m++){
if(m!=17)sdata[m]=encrypt(sdata[m]); //encryption
datastore<<sdata[m]<<" ";
//cout<<sdata[m]<<" ";
}
updateTotal();
datastore<<total<<" ";
//cout<<petname<<"-"<<username<<"\n";
datastore<<"\n"<<stringE(petname);
datastore<<"\n"<<stringE(username);
datastore.close();
//cout<<"\n";
}
loadMaps();
pushLoadedMap(smap,id_map,itemID);
pushLoadedArray(sdata);
pushTexts(petname);
cout<<"\n";
cout<<"You are logging in to the account with username \""<<username<<"\"\n";
string hashPass = getHashedPassword("Password>");
cout<<"Verifying Password..."<<endl<<"\n";
while( !verifyUser(username.c_str(), hashPass.c_str()) ){
cout<<"Password Incorrect!"<<"\n";
hashPass = getHashedPassword("Password>");
cout<<"Verifying Password..."<<endl<<"\n";
}
cout<<"Login Success!"<<"\n\n";
updateDatabase(petname.c_str(), username.c_str());
//readDatabase(username.c_str());
updateLeaderboard(username.c_str(), lvl);
loadLvlUp();
php=getPlayerHP();
system("color 0A");
cout <<'\a';
cout << "Loading complete!\n";
cout << "Welcome to Monster Melancholy!\n";
cout << "To exit the game simply close the Control Panel!\n";
//cout << "Press h then enter for help, or s for stats, or c for combat stats!\n";
cout << "Use the Control Panel to play the game!\n";
cout << "Get started by clicking \"Explore\"!"<<"\n";
checkForEvents();
if(eventChristmas){textc(15); cout<<"\nMerry Christmas!!!\n\n"; textc(10);}
break;
}
case WM_CTLCOLORSTATIC:{
SetTextColor( (HDC)wParam, RGB(0,255,0));//green text colour
SetBkColor( (HDC)wParam, RGB(0,0,0));//black *text* background colour
return (INT_PTR)hBrushBlack; //black *text space* colour
}
case WM_CTLCOLOREDIT:{
SetTextColor( (HDC)wParam, RGB(0,255,0));//dark green text colour
SetBkColor( (HDC)wParam, RGB(0,0,0));//black *text* background colour
return (INT_PTR)hBrushBlack; //black *text space* colour
}
case WM_CTLCOLORBTN:{
SetTextColor( (HDC)wParam, RGB(0,0,0));//black text colour
SetBkColor( (HDC)wParam, RGB(0,200,0));//green *text* background colour
SelectObject( (HDC)wParam, (HGDIOBJ)hf);
return (INT_PTR)hBrushDarkGreen;
}
case WM_DRAWITEM: {//owner draw
ownerDraw(lParam, wParam);
return TRUE;
}
case WM_PAINT:{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hwnd, &ps);
SetDCBrushColor(hdc, RGB(0, 200, 0));//dark green
SetDCPenColor(hdc, RGB(0, 200, 0));
SelectObject(hdc, GetStockObject(DC_BRUSH) );
SelectObject(hdc, GetStockObject(DC_PEN) );
// All painting occurs here, between BeginPaint and EndPaint.
FillRect(hdc, &ps.rcPaint, (HBRUSH)hBrushBlack);
//RoundRect(hdc, -10, -3, 700, 3, 5, 5);
EndPaint(hwnd, &ps);
}
/* Upon destruction, tell the main thread to stop */
case WM_COMMAND:{
updateOnlineStatus(username.c_str());
switch(LOWORD(wParam)){
/*case ID_Test:{
char out1[30]="abc";
SetWindowText(hStatus,out1);
break;
}
case ID_Test2:{
char out2[30]="def";
SetWindowText(hStatus,out2);
break;
}*/
case ID_ProfileMenu1://view profile
if(bInMainMenu){
textc(10);
viewProfile(smap, petname, prefix, xpToLvlUp, getPlayerHP());
}
else MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
break; //ID_ProfileMenu1 break
case ID_ProfileMenu2://leaderboard
if(bInMainMenu){
textc(10);
cout<<"\n";
displayLeaderboard(loadLeaderboard(), username, hConsole);
}
else MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
break; //ID_ProfileMenu2 break
case ID_ProfileMenu3://online players
if(bInMainMenu){
textc(10);
cout<<"\n";
displayOnlinePlayers();
}
else MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
break; //ID_ProfileMenu3 break
case ID_ProfileMenu4://daily reward
if(bInMainMenu){
tpass=time(0)-prevt;
if(tpass>=86400){
if(swordtier>=2) cout<<"You have claimed your daily reward! "<<lvl*1000<<" coins and "<<1<<" Magic Essence granted!!!"<<"\n";
if(swordtier<2) cout<<"You have claimed your daily reward! "<<lvl*1000<<" coins and "<<0<<" Magic Essence granted!!!"<<"\n";
cout<<"Your daily Dungeon attempts have also reset to 5."<<"\n\n";
cout<<'\a';
dchance=5;
coins=coins+lvl*1000;
if(swordtier>=2) magicpt++;
tpass=0;
prevt=time(0);
updateStoredData();
}
else{
tpass=time(0)-prevt;
hours=23-(tpass/3600);
mins=1439-(tpass/60)-(hours*60);
secs=86399-tpass-(mins*60)-(hours*3600);
if(tpass<=82800)
cout<<"You still have "<<hours<<" hours, "<<mins<<" minutes and "<<secs<<" seconds left to your next daily reward!"<<"\n"<<"\n";
if(tpass>=82800)
cout<<"You still have "<<mins<<" minutes and "<<secs<<" seconds left to your next daily reward!"<<"\n"<<"\n";
}
cout<<"You are still at Home..."<<"\n"<<"\n";
}
else MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
break; //ID_ProfileMenu4 break
case ID_ProfileMenu5://monster encyclopedia
if(bInMainMenu){
page=1;
bInMainMenu=false;
bInMonEn=true;
displayMonsterEn(page);
updateGUIstatus();
}
else MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
break; //ID_ProfileMenu5 break
case ID_ProfileMenu6://redeem code
if(bInMainMenu){
textc(10);
bInMainMenu=false;
bInRedeemCode=true;
cout<<"\nPlease enter the code into the textbox on the control panel\n";
updateGUIstatus();
}
else MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
break; //ID_ProfileMenu6 break
case ID_MonMenu1:{
if(bInMainMenu){
textc(10);
fighttype=1;
bInMainMenu=false;
bInWMfight=true;
updateGUIstatus();
mfight();
if(randomNo!=100) mFightRes();
else{
bInMainMenu=true;
bInWMfight=false;
updateGUIstatus();
}
}
else{
MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
}
break;//ID_MonMenu1 case break
}
case ID_MonMenu2:{
if(bInMainMenu){
fighttype=2;
bInMainMenu=false;
bInEMfight=true;
updateGUIstatus();
mfight();
if(randomNo!=100) mFightRes();
else{
bInMainMenu=true;
bInEMfight=false;
updateGUIstatus();
}
}
else{
MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
}
break;//ID_MonMenu2 case break
}
case ID_MonMenu3:{
if(bInMainMenu){
textc(10);
fighttype=3;
bInMainMenu=false;
bInCMfight=true;
updateGUIstatus();
mfight();
mFightRes();
}
else{
MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
}
break;//ID_MonMenu3 case break
}
case ID_MonMenu4:
if(bInMainMenu){
if(dchance>0){
textc(10);
fighttype = 4;
bInMainMenu = false;
bInDungeon = true;
updateGUIstatus();
generateDungeon();
dungeonRes();
}
else{
MessageBox(hwnd, "You have run out of Dungeon attempts for today.", "Cannot Perform Action", MB_ICONINFORMATION);
}
}
else{
MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
}
break;//ID_MonMenu4 case break
case ID_ShopMenu1:{ //Equipment Shop
if(bInMainMenu){
textc(10);
Shop::equip(smap);
bInMainMenu=false;
bInShopE=true;
updateGUIstatus();
playerRes();
}
else{
MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
}
break;//ID_ShopMenu1 case break
}
case ID_ShopMenu2:{//Skills Shop
if(bInMainMenu){
textc(10);
Shop::skill(smap);
bInMainMenu=false;
bInShopS=true;
updateGUIstatus();
playerRes();
}
else{
MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
}
break;//ID_ShopMenu2 case break
}
case ID_ShopMenu3:{//Magic Altar
if(bInMainMenu){
textc(10);
Shop::magic(coins,magicpt, magic_fsword1, magic_healp2, pet, petname);
bInMainMenu=false;
bInShopM=true;
updateGUIstatus();
playerRes();
}
else{
MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
}
break;//ID_ShopMenu3 case break
}
case ID_ShopMenu4://Smithing Shop
if(bInMainMenu){
textc(10);
Shop::smith(smap);
bInMainMenu=false;
bInShopSM=true;
updateGUIstatus();
playerRes();
}
else{
MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
}
break;//ID_ShopMenu4 case break
case ID_ShopMenu5://Pyrogems Shop
if(bInMainMenu){
textc(10);
Shop::create(smap);
bInMainMenu=false;
bInShopC=true;
updateGUIstatus();
playerRes();
}
else{
MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
}
break;//ID_ShopMenu5 case break
case ID_ItemMenu1://Inventory
if(bInMainMenu||bInDungeon){
textc(10);
displayInv();
}
break;//ID_ItemMenu1 case break
case ID_ItemMenu2://Chest at Home
if(bInMainMenu){
textc(10);
displayChest(smap);
}
break;//ID_ItemMenu1 case break
case ID_CombatMenu1://Toggle shield
if(bInMainMenu || bInDungeon){
if(shield>0 && equip==0){
equip=1; cout<<"\nShield equipped!\n";
}
else if(shield>0 && equip==0){
equip=0; cout<<"\nShield unequipped!\n";
}
else if(shield==0){
cout<<"\nYou do not have a shield yet!\n";
}
}
else MessageBox(hwnd, "Please exit a fight before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
break; //ID_CombatMenu1 case break
case ID_SettingsMenu1:
if(bInMainMenu){
textc(10);
displayCredits();
}
else MessageBox(hwnd, "Please return Home before performing this action.", "Cannot Perform Action", MB_ICONINFORMATION);
break; //ID_SettingsMenu1 case break
case ID_BUTTON1:
//MessageBox(hwnd, "button has been clicked", "Pop-up", MB_ICONINFOMATION);
if(bInWMfight || bInEMfight || bInCMfight || bInDMfight){//choice: fight
mfight_choice(1);
if(fightover){
fightover=false;
if(bInWMfight || bInEMfight || bInCMfight) bInMainMenu=true;
else if(bInDMfight && fightwin){ bInDungeon=true; displayDungeon(R, C); }
else if(bInDMfight && !fightwin) bInMainMenu=true;
if(bInWMfight) bInWMfight=false;
if(bInEMfight) bInEMfight=false;
if(bInCMfight) bInCMfight=false;
if(bInDMfight) bInDMfight=false;
updateStoredData();
updateGUIstatus();
updateLeaderboard(username.c_str(), lvl);
}
}
if(bInShopE){//Sword upgrade
cout<<"1\n";
cout<<"Are you sure you want to upgrade your sword from level "<<sword<<" to "<<"level "<<sword+1;
if( (sword+1)%10 != 0) cout<<" with "<<sword*100<<" coins";
cout<<"?"<<" You have "<<coins<<" coins."<<"\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
bSwordYesNo=true;
bInShopE=false;
}
if(bInShopS){//First Ace Skill Upgrade
cout<<"1\n";
if(skill_fa1==0) {
cout<<"Are you sure you want to unlock First Ace "<<" with "<<"1000"<<" coins?"<<" You have "<<coins<<" coins."<<"\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
is_skillfa1yesno=true;
bInShopS=false;
}
if(skill_fa1>0&&skill_fa1<5){
cout<<"Are you sure you want to upgrade First Ace from level "<<skill_fa1<<" to "<<"level "<<skill_fa1+1<< " with ";
cout<<(skill_fa1+1)*(skill_fa1+1)*1000<<" coins?"<<" You have "<<coins<<" coins."<<"\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
is_skillfa1yesno=true;
bInShopS=false;
}
if(skill_fa1>=5){
cout<<"First Ace Skill is already at max level!"<<"\n"<<"\n";
Shop::skill(smap);
playerRes();
}
}
if(bInShopM){//Blaze Blade Upgrade
cout<<"1\n";
if(magic_fsword1==0) cout<<"Are you sure you want to unlock Blaze Blade with 50.0k coins?"<<" You have "<<coins<<" coins."<<"\n";
if(magic_fsword1>0) cout<<"Are you sure you want to upgrade Blaze Blade from level "<<magic_fsword1<<" to "<<"level "<<magic_fsword1+1
<< " with "<<magic_fsword1*5<<" Magic Essence?"<<" You have "<<magicpt<<" Magic Essence."<<"\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
is_magicfs1yesno=true;
bInShopM=false;
}
if(bInShopSM){//SwordTier upgrade
cout<<"1\n";
cout<<"Are you sure you want to improve your Sword's Prestige Level from "; tierd(swordtier, 2);
cout<<" to "; tierd(swordtier, 2); cout<<" with "<<tcosts[swordtier]<<" Mysterious Shards, "
<<tcosts2[swordtier]<<" Shiny Shards, and "<<tcosts2[swordtier]<<" Crystal Shards?\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
bSwordTierYesNo=true;
bInShopSM=false;
}
if(bInShopC){//Item Creation
cout<<"1\n";
cout<<"Are you sure you want to use your UR power, plus 5 Pyrogems, and cast Item Creation I?\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
bItemCreateIYesNo=true;
bInShopC=false;
}
if(bInMonEn){
if(page>1){
page--; displayMonsterEn(page);
}
}
break;//ID_BUTTON1 case break
case ID_BUTTON2:{
if(bInDMfight){//cannot run away
cout<<"2\n";
textc(12); cout<<"You cannot run from Dungeon Fights!!!\n\n"; textc(10);
cout<<'\a';
Sleep(2000);
mFightRes();
}
if(bInWMfight || bInEMfight || bInCMfight){//Monster try to run away
mt19937 rdm(time(0)); uniform_int_distribution<int> range100(1, 100); int random = range100(rdm);
int HpPercent = tempPhp*100/php;
if( (HpPercent+10) >= random) { // run success (chance is 10% + current % health, if >100%, then sure can run away)
cout << "2\n"; cout << "\n";
cout << "----------------------------------------\n";
cout << "You ran away! Back to Home...\n\n";
textc(10);
php = getPlayerHP();
fightover = false; fightwin = false;
bInMainMenu = true;
if (bInWMfight) bInWMfight = false; if (bInEMfight) bInEMfight = false; if (bInCMfight) bInCMfight = false;
updateGUIstatus();
}
else{ //fail to run, so fight
cout << "2\n"; cout << "\n";
cout << "----------------------------------------\n";
cout<<'\a'; textc(12); cout << "You could not run away... so you stood and fought\n\n"; textc(10);
Sleep(1000);
//same as button 1 fight choice
mfight_choice(1);
if(fightover){
fightover=false;
if(bInWMfight || bInEMfight || bInCMfight) bInMainMenu=true; else if(bInDMfight && fightwin){ bInDungeon=true; displayDungeon(R, C); } else if(bInDMfight && !fightwin) bInMainMenu=true;
if(bInWMfight) bInWMfight=false; if(bInEMfight) bInEMfight=false; if(bInCMfight) bInCMfight=false; if(bInDMfight) bInDMfight=false;
updateStoredData(); updateGUIstatus(); updateLeaderboard(username.c_str(), lvl);
}
}
}
if(bInDungeon){
cout<<"2\n";
cout<<"\n";
cout<<"----------------------------------------\n";
char result;
result = dungeonMove(2);
dungeonResult(result, hwnd);
}
if(bInShopE){//Armour Upgrade
cout<<"2\n";
cout<<"Are you sure you want to upgrade your Armour from level "<<armour<<" to "<<"level "<<armour+1;
if( (armour+1)%10 != 0) cout<< " with "<<(armour+1)*100<<" coins";
cout<<"?"<<" You have "<<coins<<" coins."<<"\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
bArmourYesNo=true;
bInShopE=false;
}
if(bInShopS){//Superior Willpower
cout<<"2\n";
if(lvl<10){
cout<<"Your level is too low!"<<"\n"<<"\n";
Shop::skill(smap);
playerRes();
}
else if(lvl>=10 && skill_2==0) {
cout<<"Are you sure you want to unlock Superior Willpower"<<" with "<<"1000"<<" coins?"<<" You have "<<coins<<" coins."<<"\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
}
else if(skill_2>0&&skill_2<10){
cout<<"Are you sure you want to upgrade Superior Willpower from level "<<skill_2<<" to "<<"level "<<skill_2+1<< " with ";
cout<<skill2costs[skill_2]<<" coins?"<<" You have "<<coins<<" coins."<<"\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
}
else if(skill_2>=10){
cout<<"Superior Willpower is already at max level!"<<"\n"<<"\n";
Shop::skill(smap);
playerRes();
}
if(lvl>=10 && skill_2<20) bSkill2YesNo=true;
if(lvl>=10 && skill_2<20) bInShopS=false;
}
if(bInShopM){//Heal Pulse Upgrade
cout<<"2\n";
if(magic_healp2<10){
if(magic_healp2==0) cout<<"Are you sure you want to unlock Heal Pulse Magic with 100k coins?"<<" You have "<<coins<<" coins."<<"\n";
if(magic_healp2>0) cout<<"Are you sure you want to upgrade Heal Pulse Magic from level "<<magic_healp2<<" to "<<"level "<<magic_healp2+1
<< " with "<<3+magic_healp2*2<<" Magic Essence?"<<" You have "<<magicpt<<" Magic Essence."<<"\n";
if(magic_healp2>=10) cout<<"Heal Pulse Magic at is already Max Level!"<<"\n"<<"\n";
cout<<"Press the Yes/No button"<<"\n"<<"\n";
cout<< "Your response: ";
is_magichp2yesno=true;
bInShopM=false;
}
if(magic_healp2>=10) {
cout<<"Heal Pulse Magic at is already Max Level!"<<"\n"<<"\n";
Shop::magic(coins,magicpt, magic_fsword1, magic_healp2, pet, petname);
playerRes();
}
}
if(bInShopSM){//ArmourTier upgrade
cout<<"2\n";