Added ability to define a 'target time' for levels which is taken into consideration...
[supertux.git] / src / supertux / level.cpp
index 598ca89..9b179bc 100644 (file)
 
 #include "supertux/level.hpp"
 
+#include "badguy/goldbomb.hpp"
 #include "lisp/list_iterator.hpp"
 #include "lisp/parser.hpp"
-#include "object/block.hpp"
+#include "object/bonus_block.hpp"
 #include "object/coin.hpp"
 #include "supertux/sector.hpp"
 #include "supertux/tile_manager.hpp"
 #include "supertux/tile_set.hpp"
 #include "trigger/secretarea_trigger.hpp"
 
+#include <sstream>
+#include <stdexcept>
+
 using namespace std;
 
 Level::Level() :
   name("noname"), 
   author("Mr. X"), 
+  contact(),
+  license(),
+  filename(),
+  on_menukey_script(),
+  sectors(),
+  stats(),
+  target_time(),
   tileset(NULL), 
   free_tileset(false)
 {
@@ -110,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;
       }
@@ -192,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;