pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r4156 - branches/pingus-hanusz/src


From: grumbel
Subject: [Pingus-CVS] r4156 - branches/pingus-hanusz/src
Date: Mon, 16 May 2011 15:24:24 +0200

Author: grumbel
Date: 2011-05-16 15:24:23 +0200 (Mon, 16 May 2011)
New Revision: 4156

Modified:
   branches/pingus-hanusz/src/action_holder.cpp
   branches/pingus-hanusz/src/action_holder.hpp
   branches/pingus-hanusz/src/game_session.cpp
   branches/pingus-hanusz/src/statistics.cpp
   branches/pingus-hanusz/src/statistics.hpp
Log:
Added counting of used actions


Modified: branches/pingus-hanusz/src/action_holder.cpp
===================================================================
--- branches/pingus-hanusz/src/action_holder.cpp        2011-05-16 13:06:36 UTC 
(rev 4155)
+++ branches/pingus-hanusz/src/action_holder.cpp        2011-05-16 13:24:23 UTC 
(rev 4156)
@@ -25,7 +25,8 @@
 
 using namespace Actions;
 
-ActionHolder::ActionHolder(const PingusLevel& plf)
+ActionHolder::ActionHolder(const PingusLevel& plf) :
+  m_actions_used(0)
 {
   const std::map<std::string, int>& actions = plf.get_actions();
 
@@ -62,6 +63,9 @@
 {
   if (!Cheat::unlimited_actions)
     available_actions[name]++;
+
+  m_actions_used -= 1;
+  std::cout << "ActionsUsed: " << m_actions_used << std::endl;
 }
 
 bool
@@ -78,6 +82,10 @@
       if (avail > 0)
         {
           --avail;
+
+          m_actions_used += 1;
+          std::cout << "ActionsUsed: " << m_actions_used << std::endl;
+
           return true;
         }
       else

Modified: branches/pingus-hanusz/src/action_holder.hpp
===================================================================
--- branches/pingus-hanusz/src/action_holder.hpp        2011-05-16 13:06:36 UTC 
(rev 4155)
+++ branches/pingus-hanusz/src/action_holder.hpp        2011-05-16 13:24:23 UTC 
(rev 4156)
@@ -44,6 +44,8 @@
    */
   std::map<Actions::ActionName, int> available_actions;
 
+  int m_actions_used;
+
 public:
   /** Create an action holder from the number of actions given in a
       Pingus Level file */
@@ -75,6 +77,8 @@
    */
   int get_available (Actions::ActionName name);
 
+  int get_actions_used() const { return m_actions_used; }
+
 private:
   ActionHolder (const ActionHolder&);
   ActionHolder& operator= (const ActionHolder&);

Modified: branches/pingus-hanusz/src/game_session.cpp
===================================================================
--- branches/pingus-hanusz/src/game_session.cpp 2011-05-16 13:06:36 UTC (rev 
4155)
+++ branches/pingus-hanusz/src/game_session.cpp 2011-05-16 13:24:23 UTC (rev 
4156)
@@ -125,7 +125,7 @@
       }
 
       {
-        Statistics::instance()->save_result(result);
+        Statistics::instance()->save_result(result, 
server->get_action_holder()->get_actions_used());
       }
 
       if (show_result_screen)

Modified: branches/pingus-hanusz/src/statistics.cpp
===================================================================
--- branches/pingus-hanusz/src/statistics.cpp   2011-05-16 13:06:36 UTC (rev 
4155)
+++ branches/pingus-hanusz/src/statistics.cpp   2011-05-16 13:24:23 UTC (rev 
4156)
@@ -45,7 +45,7 @@
 }
 
 void
-Statistics::save_result(const Result& result)
+Statistics::save_result(const Result& result, int actions_used)
 {
   //m_out << "# username, levelname, saved, killed, time, success" << 
std::endl;
   std::ofstream m_out(m_filename.c_str(), std::ios::app);
@@ -60,6 +60,7 @@
           << result.saved << ";"
           << result.killed << ";"
           << result.used_time << ";"
+          << actions_used << ";"
           << (result.success()?"success":"failure") << std::endl;
   }
 }

Modified: branches/pingus-hanusz/src/statistics.hpp
===================================================================
--- branches/pingus-hanusz/src/statistics.hpp   2011-05-16 13:06:36 UTC (rev 
4155)
+++ branches/pingus-hanusz/src/statistics.hpp   2011-05-16 13:24:23 UTC (rev 
4156)
@@ -42,7 +42,7 @@
   ~Statistics();
 
   void set_username(const std::string& username);
-  void save_result(const Result& result);
+  void save_result(const Result& result, int actions_used);
 
 private:
   Statistics(const Statistics&);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]