From 6fdb74b7d38d179fb11f335a9f050f785fabbeeb Mon Sep 17 00:00:00 2001
From: Monoki Dorina <mondo1@cortex.itk.ppke.hu>
Date: Sat, 18 May 2024 14:56:33 +0200
Subject: [PATCH] set_aura fuggveny valtoztatasa

---
 field.cpp      | 11 +++--------
 field.hpp      |  3 +--
 gamemaster.cpp | 12 ++++++++++--
 myapp.cpp      | 16 ++++++++--------
 4 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/field.cpp b/field.cpp
index 096456d..75c1aec 100644
--- a/field.cpp
+++ b/field.cpp
@@ -73,7 +73,7 @@ void Field::rajzol() const
     if (_helytelen)
         gout << color(255,0,0);
 
-    gout << font("LiberationSans-Regular.ttf",_szel/3);
+    gout << font("LiberationSans-Regular.ttf",(_mag/5)*3);
     if (_ertek)
     {
          gout << move_to(_x+ (_szel-gout.twidth(std::to_string(_ertek)))/2,
@@ -101,12 +101,7 @@ void Field::set_ertek(int uj)
         _ertek=uj;
 }
 
-void Field::set_aura_true()
+void Field::set_aura(bool be)
 {
-    _aura=true;
-}
-
-void Field::set_aura_false()
-{
-    _aura=false;
+    _aura=be;
 }
diff --git a/field.hpp b/field.hpp
index bff9f31..bcc9593 100644
--- a/field.hpp
+++ b/field.hpp
@@ -14,8 +14,7 @@ class Field : public Widget
         virtual int get_ertek();
 
         virtual void set_ertek(int);
-        virtual void set_aura_true();
-        virtual void set_aura_false();
+        virtual void set_aura(bool);
 
     protected:
         int _ertek;
diff --git a/gamemaster.cpp b/gamemaster.cpp
index f826558..574e5cd 100644
--- a/gamemaster.cpp
+++ b/gamemaster.cpp
@@ -95,9 +95,17 @@ void GameMaster::save(int sorszam, int ertek)
     save_fajlba();
 }
 
-bool GameMaster::szabalyos_e(int jelenlegi_ertek, set<int> ertekek)
+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()
diff --git a/myapp.cpp b/myapp.cpp
index 73f0587..06375e4 100644
--- a/myapp.cpp
+++ b/myapp.cpp
@@ -37,11 +37,11 @@ int MyApp::action(std::string id, genv::event ev, int focus)
         {
             if (aura_halmaz.find(i) != aura_halmaz.end())
             {
-                palya[i]->set_aura_true();
+                palya[i]->set_aura(true);
             }
             else
             {
-                palya[i]->set_aura_false();
+                palya[i]->set_aura(false);
             }
         }
     }
@@ -84,11 +84,11 @@ int MyApp::action(std::string id, genv::event ev, int focus)
             {
                 if (aura_halmaz.find(i) != aura_halmaz.end())
                 {
-                    palya[i]->set_aura_true();
+                    palya[i]->set_aura(true);
                 }
                 else
                 {
-                    palya[i]->set_aura_false();
+                    palya[i]->set_aura(false);
                 }
             }
         }
@@ -96,14 +96,14 @@ int MyApp::action(std::string id, genv::event ev, int focus)
         if (ev.keycode >= 49 && ev.keycode <= 57)
         {
             palya[focus]->set_ertek(ev.keycode-48);
+            _game->save(focus,palya[focus]->get_ertek());
         }
 
         if (ev.keycode==key_delete || ev.keycode==key_backspace)
         {
             palya[focus]->set_ertek(0);
+            _game->save(focus,palya[focus]->get_ertek());
         }
-
-        _game->save(focus,palya[focus]->get_ertek());
     }
 
     if (id=="mouse")
@@ -126,11 +126,11 @@ int MyApp::action(std::string id, genv::event ev, int focus)
             {
                 if (aura_halmaz.find(i) != aura_halmaz.end())
                 {
-                    palya[i]->set_aura_true();
+                    palya[i]->set_aura(true);
                 }
                 else
                 {
-                    palya[i]->set_aura_false();
+                    palya[i]->set_aura(false);
                 }
             }
         }
-- 
GitLab