diff --git a/application.cpp b/application.cpp index 0e3f8619a10870f2c8788c7354d4393d826fbc46..9092de27083c0c30f7251aeae84764bf4d6e1360 100644 --- a/application.cpp +++ b/application.cpp @@ -68,12 +68,14 @@ void Application::event_loop() } std::set<int> aura_halmaz = _game->aura(focus); + // std::set<int> aura_ertekek; for (int i=0; i<widgets.size(); i++) { if (aura_halmaz.find(i) != aura_halmaz.end()) { action("aura",i,1); + } else { diff --git a/fe1.txt b/feladat.txt similarity index 100% rename from fe1.txt rename to feladat.txt diff --git a/field.cpp b/field.cpp index bc9316502f03ff2034f961e932881c4ea5b00492..096456dfe270e0238f1a987db642632935c35f37 100644 --- a/field.cpp +++ b/field.cpp @@ -4,10 +4,10 @@ using namespace genv; Field::Field(Application* parent, int x, int y, int meret, int index, int ertek): - Widget(parent, x, y, meret, meret), _index(index), _ertek(ertek) + Widget(parent, x, y, meret, meret), _index(index), _ertek(ertek), + _fix(ertek), _aura(false), _helytelen(false) { - _fix=_ertek; - _aura=false; + } void Field::rajzol() const @@ -69,10 +69,16 @@ void Field::rajzol() const gout << move_to(_x, _y+_mag-2) << line(_szel,0); // szoveg + + if (_helytelen) + gout << color(255,0,0); + + gout << font("LiberationSans-Regular.ttf",_szel/3); if (_ertek) { - gout << move_to(_x+(_szel-gout.twidth(std::to_string(_ertek)))/2, - _y+(_mag+gout.cascent())/2) + gout << move_to(_x+ (_szel-gout.twidth(std::to_string(_ertek)))/2, + _y+(_mag-gout.cascent()-gout.cdescent())/2) + << text(std::to_string(_ertek)); //gout << text(" ") << text(std::to_string(_aura)); diff --git a/field.hpp b/field.hpp index cd020825c3d11ae56aac502ccfbe38f51068abf7..bff9f318a6b51b3cfcb1beaf3bb88a65715218a9 100644 --- a/field.hpp +++ b/field.hpp @@ -19,10 +19,11 @@ class Field : public Widget protected: int _ertek; - bool _fix; - bool _aura; int _index; + bool _fix; + bool _aura; + bool _helytelen; }; #endif // FIELD_HPP diff --git a/gamemaster.cpp b/gamemaster.cpp index 3f95118d369537474aee9ef58ec5c4dd205c5ace..15d814b0de55b7c39252db426b0657806d374fda 100644 --- a/gamemaster.cpp +++ b/gamemaster.cpp @@ -6,13 +6,13 @@ using namespace std; GameMaster::GameMaster(Application* parent, std::string mo, std::string fe) : - _parent(parent), _fajl_megoldas(mo), _fajl_feladat(fe) + _parent(parent), _fajl_megoldas(mo), _fajl_feladat(fe), _fajl_save("save.txt") { _parent->register_gm(this); + _megoldas = fajl_beolvasas(_fajl_megoldas); _feladat = fajl_beolvasas(_fajl_feladat); - _save = _feladat; - _fajl_save = "save.txt"; + _save = fajl_beolvasas(_fajl_save); // megmondja hogy melyik indexek melyik nagy negyzethez tartoznak _negyzetek.resize(9); @@ -94,11 +94,16 @@ void GameMaster::save(int sorszam, int ertek) save_fajlba(); } -bool GameMaster::szabalyos_e(Index jelenlegi) +bool GameMaster::szabalyos_e(int jelenlegi_ertek, set<int> ertekek) { } +std::vector<int> GameMaster::get_feladat() +{ + return _feladat; +} + std::vector<int> GameMaster::get_save() { return _save; diff --git a/gamemaster.hpp b/gamemaster.hpp index 99bcadb35fc6e7ec77c596e4fe985f2ab1c3e1d9..88cbbbc209662f0c4023bb04cb2e6835aa49086f 100644 --- a/gamemaster.hpp +++ b/gamemaster.hpp @@ -16,12 +16,13 @@ class GameMaster void fajl_kiiras(std::string fajlnev, std::vector<int> v) const; void save_fajlba(); + std::vector<int> get_feladat(); std::vector<int> get_save(); virtual void save(int,int); std::set<int> aura(Index); virtual int negyzet_szama(Index); - virtual bool szabalyos_e(Index); + virtual bool szabalyos_e(int,std::set<int>); protected: diff --git a/main.cpp b/main.cpp index 5b495895181ea0e7931f8c607b0bf52629e637e4..eeb7ce945ff3c34b3a4f2f91796e252575e02d20 100644 --- a/main.cpp +++ b/main.cpp @@ -6,6 +6,8 @@ #include <vector> +#define sorszam_i 9*j+i + using namespace std; class MyApp : public Application @@ -13,15 +15,20 @@ class MyApp : public Application public: MyApp(int szel, int mag) : Application(szel,mag) { - game = new GameMaster(this,"mo1.txt","fe1.txt"); - vector<int> game_kezdo = game->get_save(); + game = new GameMaster(this,"megoldas.txt","feladat.txt"); + vector<int> game_feladat = game->get_feladat(); + vector<int> game_save = game->get_save(); for (int j=0; j<9; j++) // sor { for (int i=0; i<9; i++) // oszlop { - Field *f = new Field(this,i*78,j*78,78,9*j+i,game_kezdo[9*j+i]); + Field *f = new Field(this,i*78,j*78,78,sorszam_i,game_feladat[sorszam_i]); palya.push_back(f); + if (game_feladat[sorszam_i] == 0) + { + palya[sorszam_i]->set_ertek(game_save[sorszam_i]); + } } } } diff --git a/mo1.txt b/megoldas.txt similarity index 100% rename from mo1.txt rename to megoldas.txt diff --git a/save.txt b/save.txt new file mode 100644 index 0000000000000000000000000000000000000000..e49992eb27e4272f9a48e6a69a27308168181335 --- /dev/null +++ b/save.txt @@ -0,0 +1 @@ +0 8 5 6 0 1 0 0 0 0 0 6 5 4 0 0 2 1 0 0 0 0 3 0 0 0 0 8 0 7 9 0 4 1 0 0 0 3 0 5 0 7 9 8 6 1 9 0 8 0 0 0 0 0 0 0 3 0 7 0 6 0 0 0 2 0 0 8 5 3 0 0 7 0 8 3 0 6 0 0 0