void GameFlow::ProcessInput(char action) { int x; int y; Battle b; int level; int r; vector<string> monsters; Monster monster; Player* player; int tag=0; string input; bool alive; string fname; string tempname; switch(Process) { case MAINMENU: { switch(action) { case NEWGAMECHAR://New Game { system("cls"); cout<<"Enter map size(12-24): "; int size; cin>>size; while(size<12||size>24) { system("cls"); cout<<"Invalid Size\nEnter map size(12-24): "; cin>>size; } int seed=time(NULL); Map=new WorldMap(size,size,seed); WorldMap::Map=Map; Map->BuildWorld(); Map->SetCharacter(CreateCharacter()); Process=WORLDMAP; GetAvailableActions(); system("cls"); Map->Draw(); } break; case LOADGAMECHAR: cout<<"Enter the filename you wish to load: "; cin>>fname; getline(cin,tempname); fname+=tempname; if(Map->Load(fname)) { Map=WorldMap::Map; Process=WORLDMAP; GetAvailableActions(); system("cls"); Map->Draw(); } else { system("cls"); cout<<"Welcome to TextRPG"<<endl; } break; case TUTORIALCHAR: cout<<"Tips: "<<endl; cout<<"-Change the size of the font to 8x8, and the window size to 80x60"<<endl; cout<<"-Don't die, it'll close the game and put you back to your last save."<<endl; cout<<"-Qulz is the currency."<<endl; cout<<"-To heal, buy some potions or rest at an inn."<<endl; cout<<"-You gain a skill point at lvl 5,10,15,etc."<<endl; cout<<"-You can't escape from battle, so be careful."<<endl; cout<<"-To win, defeat a lvl 30 dungeon (Their level increases by 2 every time they're reset)."<<endl; system("pause"); system("cls"); cout<<"Welcome to TextRPG"<<endl; break; }//end switch Action }//end case break; case WORLDMAP: { switch(action) { case INVENTORYCHAR: system("cls"); Process=PAUSEMENU; Map->GetCharacter()->PrintInventory(); break; case EXPLORECHAR://Explore Map->Explore(); break; case TRAINCHAR://Train Printer::pout<<"#014Battle!"<<endl; system("pause"); system("cls"); //random level level=Map->GetCurrentTile()->GetLevel()+rand()%3-1; if(level<=0) level=1; b=Battle(Map->GetCharacter(),Monster(Monster::GetRandomMonster(level),level),true); b.Run(); system("pause"); system("cls"); Map->Draw(); break; case ENTERTILECHAR://Enter town Process=TILECONTAINER; //system("pause"); system("cls"); Map->GetCharacter()->PrintInfo(); Map->GetCurrentTile()->GetContainer()->DrawInfo(); break; case TRAVELNORTHCHAR://Travel North x=Map->GetCharacter()->GetX(); y=Map->GetCharacter()->GetY(); Map->MoveCharacter(0,-1); Map->UpdateTile(x,y); Map->UpdateTile(Map->GetCharacter()->GetX(),Map->GetCharacter()->GetY()); Map->UpdateTileInfo(); break; case TRAVELSOUTHCHAR://Travel South x=Map->GetCharacter()->GetX(); y=Map->GetCharacter()->GetY(); Map->MoveCharacter(0,1); Map->UpdateTile(x,y); Map->UpdateTile(Map->GetCharacter()->GetX(),Map->GetCharacter()->GetY()); Map->UpdateTileInfo(); break; case TRAVELEASTCHAR://Travel East x=Map->GetCharacter()->GetX(); y=Map->GetCharacter()->GetY(); Map->MoveCharacter(1,0); Map->UpdateTile(x,y); Map->UpdateTile(Map->GetCharacter()->GetX(),Map->GetCharacter()->GetY()); Map->UpdateTileInfo(); break; case TRAVELWESTCHAR://Travel West x=Map->GetCharacter()->GetX(); y=Map->GetCharacter()->GetY(); Map->MoveCharacter(-1,0); Map->UpdateTile(x,y); Map->UpdateTile(Map->GetCharacter()->GetX(),Map->GetCharacter()->GetY()); Map->UpdateTileInfo(); break; }//end switch Action }//end case break; case TILECONTAINER: { if(CurrentActions[action]=="Leave") { Process=WORLDMAP; system("cls"); Map->Draw(); } else if(CurrentActions[action].substr(0,CurrentActions[action].find('('))=="Rest at Inn") { int paren=CurrentActions[action].find('('); int end=CurrentActions[action].find(' ',paren+1); int cost=Printer::StringToInt(CurrentActions[action].substr(paren+1,end))-Map->GetCharacter()->GetStat(CHARISMA)*5; if(Map->GetCharacter()->GetQulz()>=cost) { Map->GetCharacter()->FullRestore(); Printer::pout<<"#014Health and Mana fully restored!"<<endl; Map->GetCharacter()->AddQulz(-cost); //SAVE THE GAME! Map->Save(); Printer::pout<<"#011Game saved!"<<endl; } else { Printer::pout<<"#012Not enough Qulz to rest at Inn!"<<endl; } Process=TILECONTAINER; system("pause"); system("cls"); Map->GetCharacter()->PrintInfo(); Map->GetCurrentTile()->GetContainer()->DrawInfo(); } else if(CurrentActions[action]=="Shop at Market") { //Do market things, like draw items you can buy. system("cls"); Shop(); Process=TILECONTAINER; system("cls"); Map->GetCharacter()->PrintInfo(); Map->GetCurrentTile()->GetContainer()->DrawInfo(); } else if(CurrentActions[action]=="Get Quest from Guild HQ") { Map->GetCharacter()->AssignQuest(Quest::RandomQuest(Map->GetCharacter())); Process=TILECONTAINER; system("pause"); system("cls"); Map->GetCharacter()->PrintInfo(); Map->GetCurrentTile()->GetContainer()->DrawInfo(); } else if(CurrentActions[action]=="Reset Dungeon") { Map->GetCurrentTile()->ResetExploration(); if(Map->GetCurrentTile()->GetLevel()<30) Map->GetCurrentTile()->SetLevel(Map->GetCurrentTile()->GetLevel()+2); Process=WORLDMAP; system("cls"); Map->Draw(); } } break; case PAUSEMENU: { switch(action) { case EQUIPCHAR://Equipment while(tag!=-1) { cout<<"Enter the item you wish to equip(-1 to exit): "; cin>>input; tag=Printer::StringToInt(input); while((tag<-1)||(tag>=(signed int)Map->GetCharacter()->GetInventory().size())||cin.fail()) { Printer::MoveBackLine(); Printer::ClearLine(); cout<<"Enter the item you wish to equip(-1 to exit): "; cin>>input; tag=Printer::StringToInt(input); } if(tag!=-1) { if(Map->GetCharacter()->EquipItem(Map->GetCharacter()->GetInventory()[tag])==true) { Map->GetCharacter()->RemoveItem(tag); } } system("pause"); system("cls"); Map->GetCharacter()->PrintInventory(); } system("cls"); Process=PAUSEMENU; Map->GetCharacter()->PrintInventory(); break; case USEITEMCHAR://Use Item while(tag!=-1) { cout<<"Enter the item you wish to equip(-1 to exit): "; cin>>input; tag=Printer::StringToInt(input); while((tag<-1)||(tag>=(signed int)Map->GetCharacter()->GetInventory().size())||cin.fail()) { Printer::MoveBackLine(); Printer::ClearLine(); cout<<"Enter the item you wish to equip(-1 to exit): "; cin>>input; tag=Printer::StringToInt(input); } if(tag!=-1) { if(Map->GetCharacter()->UseItem(Map->GetCharacter()->GetInventory()[tag])==true) { Map->GetCharacter()->RemoveItem(tag); } } system("pause"); system("cls"); Map->GetCharacter()->PrintInventory(); } system("cls"); Process=PAUSEMENU; Map->GetCharacter()->PrintInventory(); break; case STATSCHAR://stats tag=0; while(tag!=-1) { cout<<"Enter the number of the stat you wish to upgrade (-1 to exit): "; cin>>input; tag=Printer::StringToInt(input); while((tag<-1)||(tag>=(signed int)Map->GetCharacter()->GetStats().size()-1)) { Printer::MoveBackLine(); Printer::ClearLine(); cout<<"Enter the number of the stat you wish to upgrade (-1 to exit): "; cin>>input; tag=Printer::StringToInt(input); } if(tag!=-1) { if(Map->GetCharacter()->GetStatPoints()>0) { if(Map->GetCharacter()->UpgradeStat(tag)==true) { Printer::pout<<"#014You've upgraded: "; Printer::pout<<Player::IntToStrStats(tag)<<endl; Map->GetCharacter()->AddStatPoints(-1); } } else { Printer::pout<<"#012You don't have enough stat points."<<endl; } } system("pause"); system("cls"); Map->GetCharacter()->PrintInventory(); }//end while system("cls"); Process=PAUSEMENU; Map->GetCharacter()->PrintInventory(); break; case SKILLSCHAR://skills system("cls"); tag=0; while(tag!=-1) { //get the available skills map<string,PlayerSkill> skills=Map->GetCharacter()->GetSkills(); map<string,PlayerSkill>::iterator it=skills.begin(); map<string,PlayerSkill> availableSkillsMap; vector<PlayerSkill> availableSkills; PlayerSkillNode* root=Map->GetCharacter()->GetClass().GetSkills(); while(it!=skills.end()) { if(it->second.GetName()!="nullskill") { vector<PlayerSkillNode*> temp=root->FindSkillChildren(it->first); for(unsigned int i=0;i<temp.size();i+=1) { availableSkillsMap[temp[i]->GetSkill()->GetName()]=*temp[i]->GetSkill(); } } it++; } it=availableSkillsMap.begin(); while(it!=availableSkillsMap.end()) { if(Map->GetCharacter()->GetSkill(it->first).GetName()=="nullskill") availableSkills.push_back(it->second); it++; } cout<<"Available SkillPoints: "<<Map->GetCharacter()->GetSkillPoints()<<endl; cout<<"Available skills: "<<endl; for(int i=0;i<(signed int)availableSkills.size();i+=1) { if(availableSkills[i].GetType()==ACTIVE) { cout<<i<<". "<<availableSkills[i].GetName()<<": Damage mult.: "<<availableSkills[i].GetValue()<<"x"; Printer::pout<<Player::IntToStrStats(availableSkills[i].GetActiveEffectType()+2)<<" Mana cost: "<<availableSkills[i].GetManaCost()<<endl; } else { cout<<i<<". "<<availableSkills[i].GetName()<<": Upgrade: "<<availableSkills[i].GetValue()<<" "; Printer::pout<<Player::IntToStrStats(availableSkills[i].GetPassiveEffectType())<<endl; } } cout<<"Enter the number of the skill you wish to gain (-1 to exit): "; cin>>input; tag=Printer::StringToInt(input); while((tag<-1)||(tag>=(signed int)availableSkills.size())) { Printer::MoveBackLine(); Printer::ClearLine(); cout<<"Enter the number of the skill you wish to gain (-1 to exit): "; cin>>input; tag=Printer::StringToInt(input); } if(tag!=-1) { if(Map->GetCharacter()->GetSkillPoints()>0) Map->GetCharacter()->AddSkill(availableSkills[tag]); else Printer::pout<<"#012You don't have enough skill points."<<endl; } system("pause"); system("cls"); }//end while Process=PAUSEMENU; Map->GetCharacter()->PrintInventory(); break; case 'X': Process=WORLDMAP; system("cls"); Map->Draw(); break; } } }//end switch Process }