Skip to content
Snippets Groups Projects
Commit 16ade703 authored by Monoki Dorina's avatar Monoki Dorina
Browse files

pirossal irja ha rossz

parent 6fdb74b7
Branches
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define APPLICATION_HPP #define APPLICATION_HPP
#include "graphics.hpp" #include "graphics.hpp"
#include <iostream> #include <iostream>
#include <vector> #include <vector>
......
...@@ -5,7 +5,7 @@ using namespace genv; ...@@ -5,7 +5,7 @@ using namespace genv;
Field::Field(Application* parent, int x, int y, int meret, int index, int ertek): 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), _szabalyos(true)
{ {
} }
...@@ -70,7 +70,7 @@ void Field::rajzol() const ...@@ -70,7 +70,7 @@ void Field::rajzol() const
// szoveg // szoveg
if (_helytelen) if (!_szabalyos)
gout << color(255,0,0); gout << color(255,0,0);
gout << font("LiberationSans-Regular.ttf",(_mag/5)*3); gout << font("LiberationSans-Regular.ttf",(_mag/5)*3);
...@@ -105,3 +105,8 @@ void Field::set_aura(bool be) ...@@ -105,3 +105,8 @@ void Field::set_aura(bool be)
{ {
_aura=be; _aura=be;
} }
void Field::set_szabalyos(bool be)
{
_szabalyos=be;
}
...@@ -15,6 +15,7 @@ class Field : public Widget ...@@ -15,6 +15,7 @@ class Field : public Widget
virtual void set_ertek(int); virtual void set_ertek(int);
virtual void set_aura(bool); virtual void set_aura(bool);
virtual void set_szabalyos(bool);
protected: protected:
int _ertek; int _ertek;
...@@ -22,7 +23,7 @@ class Field : public Widget ...@@ -22,7 +23,7 @@ class Field : public Widget
bool _fix; bool _fix;
bool _aura; bool _aura;
bool _helytelen; bool _szabalyos;
}; };
#endif // FIELD_HPP #endif // FIELD_HPP
...@@ -58,6 +58,21 @@ set<int> GameMaster::aura(int jelenlegi_int) ...@@ -58,6 +58,21 @@ set<int> GameMaster::aura(int jelenlegi_int)
return s; return s;
} }
vector<int> GameMaster::szabalytalan(int jelenlegi_ertek, vector<vector<int>> aura_ertekek)
{
vector<int> v;
for (int i=0; i<aura_ertekek.size(); i++)
{
if (aura_ertekek[i][1] == jelenlegi_ertek)
{
v.push_back(aura_ertekek[i][0]);
}
}
return v;
}
int GameMaster::negyzet_szama(Index jelenlegi) int GameMaster::negyzet_szama(Index jelenlegi)
{ {
if (jelenlegi.sor <= 2) if (jelenlegi.sor <= 2)
...@@ -95,19 +110,6 @@ void GameMaster::save(int sorszam, int ertek) ...@@ -95,19 +110,6 @@ void GameMaster::save(int sorszam, int ertek)
save_fajlba(); save_fajlba();
} }
bool GameMaster::szabalyos_e(int jelenlegi_ertek, set<int> aura_ertekek)
{
bool igen=true;
for (int ertek : aura_ertekek)
{
if (ertek == jelenlegi_ertek)
{
igen=false;;
}
}
return igen;
}
std::vector<int> GameMaster::get_feladat() std::vector<int> GameMaster::get_feladat()
{ {
return _feladat; return _feladat;
......
...@@ -21,9 +21,8 @@ class GameMaster ...@@ -21,9 +21,8 @@ class GameMaster
virtual void save(int,int); virtual void save(int,int);
std::set<int> aura(int); std::set<int> aura(int);
std::vector<int> szabalytalan(int,std::vector<std::vector<int>>);
virtual int negyzet_szama(Index); virtual int negyzet_szama(Index);
virtual bool szabalyos_e(int,std::set<int>);
protected: protected:
std::string _fajl_megoldas, _fajl_feladat, _fajl_save; std::string _fajl_megoldas, _fajl_feladat, _fajl_save;
......
...@@ -79,7 +79,6 @@ int MyApp::action(std::string id, genv::event ev, int focus) ...@@ -79,7 +79,6 @@ int MyApp::action(std::string id, genv::event ev, int focus)
palya[focus]->kezel(ev); palya[focus]->kezel(ev);
std::set<int> aura_halmaz = _game->aura(focus); std::set<int> aura_halmaz = _game->aura(focus);
for (int i=0; i<palya.size(); i++) for (int i=0; i<palya.size(); i++)
{ {
if (aura_halmaz.find(i) != aura_halmaz.end()) if (aura_halmaz.find(i) != aura_halmaz.end())
...@@ -96,11 +95,54 @@ int MyApp::action(std::string id, genv::event ev, int focus) ...@@ -96,11 +95,54 @@ int MyApp::action(std::string id, genv::event ev, int focus)
if (ev.keycode >= 49 && ev.keycode <= 57) if (ev.keycode >= 49 && ev.keycode <= 57)
{ {
palya[focus]->set_ertek(ev.keycode-48); palya[focus]->set_ertek(ev.keycode-48);
std::set<int> aura_halmaz = _game->aura(focus);
vector<vector<int>> aura_ertekek;
for (int i=0; i<palya.size(); i++)
{
if (aura_halmaz.find(i) != aura_halmaz.end())
{
aura_ertekek.push_back({i,palya[i]->get_ertek()});
}
}
vector<int> helytelenek = _game->szabalytalan(palya[focus]->get_ertek(),aura_ertekek);
if (helytelenek.size() != 0)
{
palya[focus]->set_szabalyos(false);
for (int i=0; i<helytelenek.size(); i++)
{
palya[helytelenek[i]]->set_szabalyos(false);
}
}
_game->save(focus,palya[focus]->get_ertek()); _game->save(focus,palya[focus]->get_ertek());
} }
if (ev.keycode==key_delete || ev.keycode==key_backspace) if (ev.keycode==key_delete || ev.keycode==key_backspace)
{ {
palya[focus]->set_szabalyos(true);
/*std::set<int> aura_halmaz = _game->aura(focus);
vector<vector<int>> aura_ertekek;
for (int i=0; i<palya.size(); i++)
{
if (aura_halmaz.find(i) != aura_halmaz.end())
{
aura_ertekek.push_back({i,palya[i]->get_ertek()});
}
}
vector<int> helytelenek = _game->szabalytalan(palya[focus]->get_ertek(),aura_ertekek);
if (helytelenek.size() != 0)
{
for (int i=0; i<helytelenek.size(); i++)
{
palya[helytelenek[i]]->set_szabalyos(true);
}
}*/
palya[focus]->set_ertek(0); palya[focus]->set_ertek(0);
_game->save(focus,palya[focus]->get_ertek()); _game->save(focus,palya[focus]->get_ertek());
} }
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "widget.hpp" #include "widget.hpp"
#include "field.hpp" #include "field.hpp"
#include "gamemaster.hpp" #include "gamemaster.hpp"
#include <vector>
class MyApp : public Application class MyApp : public Application
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment