Added ability to define a 'target time' for levels which is taken into consideration...
[supertux.git] / src / supertux / level.cpp
index 3b69137..9b179bc 100644 (file)
@@ -16,6 +16,7 @@
 
 #include "supertux/level.hpp"
 
+#include "badguy/goldbomb.hpp"
 #include "lisp/list_iterator.hpp"
 #include "lisp/parser.hpp"
 #include "object/bonus_block.hpp"
@@ -25,6 +26,9 @@
 #include "supertux/tile_set.hpp"
 #include "trigger/secretarea_trigger.hpp"
 
+#include <sstream>
+#include <stdexcept>
+
 using namespace std;
 
 Level::Level() :
@@ -36,6 +40,7 @@ Level::Level() :
   on_menukey_script(),
   sectors(),
   stats(),
+  target_time(),
   tileset(NULL), 
   free_tileset(false)
 {
@@ -116,6 +121,8 @@ Level::load(const std::string& filepath)
         Sector* sector = new Sector(this);
         sector->parse(*(iter.lisp()));
         add_sector(sector);
+      } else if(token == "target-time") {
+        iter.value()->get(target_time);
       } else {
         log_warning << "Unknown token '" << token << "' in level file" << std::endl;
       }
@@ -198,18 +205,19 @@ Level::get_total_coins()
       {
         if (block->contents == BonusBlock::CONTENT_COIN)
         {
-          total_coins++;
+          total_coins += block->hit_counter;
           continue;
-        }
-#if 0
-        // FIXME: do we want this? q.v. src/object/oneup.cpp
-        else if (block->contents == BonusBlock::CONTENT_1UP)
-        {
-          total_coins += 100;
+        } else if (block->contents == BonusBlock::CONTENT_RAIN) {
+          total_coins += 10;
+          continue;
+        } else if (block->contents == BonusBlock::CONTENT_EXPLODE) {
+          total_coins += 10;
           continue;
         }
-#endif
       }
+      GoldBomb *goldbomb = dynamic_cast<GoldBomb*> (*o);
+      if(goldbomb)
+        total_coins += 10;
     }
   }
   return total_coins;