Source

Fat x Fast / FatxFast / modes / scoredmode.py

Full commit
# This file is part of FatxFast.
#
#    FatxFast is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    FatxFast is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with FatxFast.  If not, see <http://www.gnu.org/licenses/>.

# Versioning based on: 
# http://en.wikipedia.org/wiki/Versioning#Designating_development_stage
__author__ = "dryatu (c) 2013"
__version__ = "1.2.5"


from FatxFast.modes import mode

class ScoredMode(mode.GameMode):

    def end(self, player, text=""):
        points = player.points
        if (self.scene.game.hsmanager.add_score(points, 
            int(self.scene.time/1000), self.__class__.__name__)):
                text += """New HighScore! Score: {0} Points""".format(points)
        else:
                text += """Game finished! Score: {0} Points""".format(points)
        super(ScoredMode, self).end(player, text)

    def level_up(self, player):
        self.scene.pointsystem.increase_points(player)
        super(ScoredMode, self).level_up(player)
        self.scene.manager.push_scene("popupscene",
            text="""{0} completed maze level. 
Next level: {1}
Press 'enter' to continue""".format(player.name, self.scene.levelsystem.level))