diff --git a/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp b/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp index c4baa54..3dacedc 100644 --- a/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp +++ b/ChallengeLeaguePointSolver/ChampionsLeaguePointSolver.cpp @@ -53,25 +53,40 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine std::vector>player1Score,player2Score,player3Score; std::vectorcases; std::vector bestComboA,bestComboB; - int calculationStep=0; + int calculationStep=0; void Evaluate(int caseInd,bool ASet){ - auto ChooseSong = [](SongCombinations&combinations,std::vector&dat,int index){ + auto ChooseSong = [&](SongCombinations&combinations,std::vector&dat,int index){ if(combinations.remainingA>0&&combinations.p1Picked.count(index)==0&&combinations.p2Picked.count(index)==0&&combinations.p3Picked.count(index)==0){ combinations.remainingA--; - combinations.totalEX+=dat[index].ex1; - combinations.p1.push_back(std::pair{index,dat[index].ex1}); + if(ASet){ + combinations.totalEX+=player1Score[index].first; + combinations.p1.push_back(std::pair{index,player1Score[index].first}); + }else{ + combinations.totalEX+=player1Score[index].second; + combinations.p1.push_back(std::pair{index,player1Score[index].second}); + } combinations.p1Picked.insert(index); }else if(combinations.remainingB>0&&combinations.p1Picked.count(index)==0&&combinations.p2Picked.count(index)==0&&combinations.p3Picked.count(index)==0){ combinations.remainingB--; - combinations.totalEX+=dat[index].ex2; - combinations.p2.push_back(std::pair{index,dat[index].ex2}); + if(ASet){ + combinations.totalEX+=player2Score[index].first; + combinations.p1.push_back(std::pair{index,player2Score[index].first}); + }else{ + combinations.totalEX+=player2Score[index].second; + combinations.p1.push_back(std::pair{index,player2Score[index].second}); + } combinations.p2Picked.insert(index); }else if(combinations.remainingC>0&&combinations.p1Picked.count(index)==0&&combinations.p2Picked.count(index)==0&&combinations.p3Picked.count(index)==0){ combinations.remainingC--; - combinations.totalEX+=dat[index].ex3; - combinations.p3.push_back(std::pair{index,dat[index].ex3}); + if(ASet){ + combinations.totalEX+=player3Score[index].first; + combinations.p1.push_back(std::pair{index,player3Score[index].first}); + }else{ + combinations.totalEX+=player3Score[index].second; + combinations.p1.push_back(std::pair{index,player3Score[index].second}); + } combinations.p3Picked.insert(index); } }; @@ -172,6 +187,7 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine calculationStep++; } public: + int highestEX=0; struct SongElement{ SongElement(QuickGUI::Manager&manager,std::string songName,vf2d pos){ label=new QuickGUI::Label(manager,songName,pos,{164,12}); @@ -228,9 +244,9 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine stoi(GetNext(marker,line)), stoi(GetNext(marker,line)), stoi(GetNext(marker,line))}; - player1Score.push_back(std::pair{dat.ex1,0}); - player2Score.push_back(std::pair{dat.ex2,0}); - player3Score.push_back(std::pair{dat.ex3,0}); + player1Score.push_back(std::pair{0,0}); + player2Score.push_back(std::pair{0,0}); + player3Score.push_back(std::pair{0,0}); dataA.push_back(dat); songs.push_back(SongElement{gui,dat.song.substr(0,dat.song.find(',')),{4.f,2.f+12*i+16}}); } @@ -247,9 +263,9 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine stoi(GetNext(marker,line)), stoi(GetNext(marker,line)), stoi(GetNext(marker,line))}; - player1Score[i].second=dat.ex1; - player2Score[i].second=dat.ex2; - player3Score[i].second=dat.ex3; + player1Score[i].second=0; + player2Score[i].second=0; + player3Score[i].second=0; dataB.push_back(dat); songs.push_back(SongElement{gui,dat.song.substr(0,dat.song.find(',')),{4.f,2.f+12*(i+13)+16}}); } @@ -286,13 +302,24 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine if(calculateButton->bPressed&&!calculating){ calculateButton->Enable(false); + int index=0; for(SongElement&element:songs){ element.p1Score->Enable(false); element.p2Score->Enable(false); element.p3Score->Enable(false); element.p1Score->bHasBackground=element.label->bHasBackground=false; + if(index<12){ + player1Score[index].first=element.p1Score->sText.length()>0?stoi(element.p1Score->sText):0; + player2Score[index].first=element.p2Score->sText.length()>0?stoi(element.p2Score->sText):0; + player3Score[index].first=element.p3Score->sText.length()>0?stoi(element.p3Score->sText):0; + }else{ + player1Score[index-12].second=element.p1Score->sText.length()>0?stoi(element.p1Score->sText):0; + player2Score[index-12].second=element.p2Score->sText.length()>0?stoi(element.p2Score->sText):0; + player3Score[index-12].second=element.p3Score->sText.length()>0?stoi(element.p3Score->sText):0; + } element.p2Score->bHasBackground=element.label->bHasBackground=false; element.p3Score->bHasBackground=element.label->bHasBackground=false; + index++; } calculating=true; calculationStep=0; @@ -302,6 +329,11 @@ class ChampionsLeaguePointSolver : public olc::PixelGameEngine } gui.Update(this); gui.Draw(this); + + if(highestEX!=0){ + DrawString({108,2},std::to_string(highestEX)+" EX",YELLOW); + } + if(calculating){ if(calculationStepGetTextSizeProp(sText); - pge->DrawStringProp(olc::vf2d(vPos.x + 2.0f, vPos.y + (vSize.y - vText.y) * 0.5f), sText, bHasBackground?olc::GREEN:m_manager.colText); + if(!m_bTextEdit&&sText.length()==0){ + pge->DrawStringProp(olc::vf2d(vPos.x + 2.0f, vPos.y + (vSize.y - vText.y) * 0.5f), "0", bHasBackground?olc::GREEN:olc::DARK_GREY); + }else{ + pge->DrawStringProp(olc::vf2d(vPos.x + 2.0f, vPos.y + (vSize.y - vText.y) * 0.5f), sText, bHasBackground?olc::GREEN:m_manager.colText); + } } diff --git a/ChallengeLeaguePointSolver/pixelGameEngine_wasm.o b/ChallengeLeaguePointSolver/pixelGameEngine_wasm.o index 6e7d63e..74d0630 100644 Binary files a/ChallengeLeaguePointSolver/pixelGameEngine_wasm.o and b/ChallengeLeaguePointSolver/pixelGameEngine_wasm.o differ