Example #1
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):

        stats = Stats()
        #    stats.R_HUMAN.turrets = [ stats.T_SOLAR_0 ]
        #    stats.R_HUMAN.missiles = []
        #    stats.R_HUMAN.ships = []
        stats.PlayableShips = {}

        steps = []
        for i in xrange(8):
            steps.append(
                Step(goal=lambda self, game: not filter(
                    lambda ship: ship.alive, self.ennemyShips),
                     onBegin=lambda self, game, stepNbr=i + 1: self.
                     stepFunction(game, stepNbr),
                     failure=lambda self, game: not self.player.flagship or
                     not self.player.flagship.alive,
                     texts=[(1, "Clear the area.")]))

        Scenario.__init__(self, game, steps=steps, stats=stats)

        self.sol = Sun(game.stats.S_SOL, 4000, 0)

        for i in range(75):  # asteroids
            asteroid = Asteroid(game, -2000, 0, 800)
            game.harvestables.append(asteroid)

        game.astres = [self.sol]

        self.player = None
        self.startingPoint = (-1000, 0)

        self.ennemyPosition = (-2000, 0)
        self.ennemy = Faction(game.stats.R_EXTRA, "Unknown")
        game.addPlayer(self.ennemy)

        self.infestedAsteroid = Asteroid(game, self.ennemyPosition[0],
                                         self.ennemyPosition[1], 0)
        game.harvestables.append(self.infestedAsteroid)

        self.ennemyShips = []
Example #2
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
    
        stats = Stats()
    #    stats.R_HUMAN.turrets = [ stats.T_SOLAR_0 ]
    #    stats.R_HUMAN.missiles = []
    #    stats.R_HUMAN.ships = []
        stats.PlayableShips = {}
        
        steps = []
        for i in xrange( 8 ):
            steps.append( Step( 
                goal=lambda self, game: not filter( lambda ship: ship.alive, self.ennemyShips ),
                onBegin=lambda self, game, stepNbr=i+1: self.stepFunction( game, stepNbr ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (1,"Clear the area.")] )
                )
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
        
        self.sol = Sun( game.stats.S_SOL, 4000, 0 )

        for i in range( 75 ): # asteroids
            asteroid = Asteroid( game, -2000, 0, 800 )
            game.harvestables.append( asteroid )
            
        game.astres = [ self.sol ]
        
        self.player = None
        self.startingPoint = ( -1000, 0 )
        
        self.ennemyPosition = ( -2000, 0 )
        self.ennemy = Faction( game.stats.R_EXTRA, "Unknown" )
        game.addPlayer( self.ennemy )
        
        self.infestedAsteroid = Asteroid( game, self.ennemyPosition[0], self.ennemyPosition[1], 0 )
        game.harvestables.append( self.infestedAsteroid )
        
        self.ennemyShips = []
Example #3
0
    def render_user_stats(page, u_id):
        Design_dev.render_menu(page)
        stats, _ = Stats.calc_user_stats(page, u_id)

        hspace = "<div style='display:inline-block;padding-left:6px;padding-right:6px;'> </div>"
        page.add_lines(
            "<table style='border: none; border-collapse: collapse;'>")
        page.add_lines("<tr><td style='text-align:left'>{}Oblast{}</td> ".format(hspace, hspace) + \
                "<td style='text-align:left'>{}Tema{}</td> ".format(hspace, hspace) + \
                "<td style='text-align:center'>{}Svi zadaci{}</td> ".format(hspace, hspace) + \
                "<td style='text-align:center'>{}1 zvezda{}</td> ".format(hspace, hspace) + \
                "<td style='text-align:center'>{}2 zvezde{}</td> ".format(hspace, hspace) + \
                "<td style='text-align:center'>{}3 zvezde{}</td> ".format(hspace, hspace) + \
                "</tr>\n")
        Design_dev._render_user_one_cat_rec(page, stats, "Svi", 0)
        page.add_lines("</table><br>")
Example #4
0
    def __init__(self, game, steps=None, stats=None):
        self.steps = steps

        if self.steps:
            self.step = None
            self.stepsIter = iter(steps)

        self.failed = False
        self.over = False
        self.msgs = []
        self.lastStepAt = 0

        if stats == None:
            #  stats.setDefaults()
            game.stats = Stats()
        else:
            game.stats = stats
Example #5
0
    def render_page_stats(page):
        Design_dev.render_menu(page)

        try:
            stats = Stats.calc_question_stats()

            for folder in stats.keys():
                page.add_lines("<h2> {} </h2><br>\n".format(folder))
                page.add_lines(
                    "<table style='border: 1px solid black; border-collapse: collapse; border-spacing: 10px 0;'>"
                )

                page.add_lines("  <tr style='border: 1px solid black'>")
                page.add_lines(
                    "    <th style='border: 1px solid black'>Pitanje</th>")
                page.add_lines(
                    "    <th style='border: 1px solid black'>Ukupno odgovora</th>"
                )
                page.add_lines(
                    "    <th colspan='{}' style='border: 1px solid black'> Statistika po podpitanjima</th>"
                    .format(stats[folder]["width"]))
                page.add_lines("  </tr>")

                for q in stats[folder]["content"]:
                    hspace = "<div style='display:inline-block;padding-left:6px;padding-right:6px;'> </div>"
                    page.add_lines("  <tr style='border: 1px solid black'>")
                    page.add_lines(
                        "<th style='border: 1px solid black'>{}{}{}</th>".
                        format(hspace, q["q_id"], hspace))
                    page.add_lines(
                        "<th style='border: 1px solid black'>{}{}{}</th>".
                        format(hspace, q["total"], hspace))
                    #line = "<br><b>{}</b>: ukupno odgovora {}, tacno po pitanjima ".format(q_id, total)
                    for s in q["correct"]:
                        page.add_lines(
                            "<th style='border: 1px solid black'>{}{:3d}%{}</th>"
                            .format(hspace, int(100 * s / q["total"]), hspace))
                    for s in range(0,
                                   stats[folder]["width"] - len(q["correct"])):
                        page.add_lines(
                            "<th style='border: 1px solid black'></th>")
                    page.add_lines("<tr>\n")
                page.add_lines("</table><br>")
        except:
            page.add_lines("There was a problem generating stats.")
            pass
Example #6
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
        
        stats = Stats()
        stats.R_HUMAN.turrets = [ stats.T_LASER_SR_1, stats.T_LASER_SR_0,
stats.T_MASS_SR_1, stats.T_MASS_SR_0, stats.T_MASS_MR_0 ]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = [ stats.HARVESTER ]
        stats.PlayableShips = {}
        
        steps = [
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.asteroid, 300 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
             #   onBegin=lambda self, game: self.player.flagship.ore = 500,
                texts = [ (0, "We need some materials."),
                            (4*config.fps, "There is an asteroid close to the Moon."),
                            (8*config.fps, "Get close to it.") ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.ai.launching[ self.player.race.defaultHarvester.img ],
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Begin collecting raw ore."),
     (4*config.fps, "To do so, launch your harvester by pressing the blue arrow button at the bottom of the screen.") ] ),
            Step(
                goal=lambda self, game: self.player.flagship.oreProcess,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Now wait for them to bring back the ore."),
                (6*config.fps, "Don't worry about the ships following you around."),
                (10*config.fps, "They are civilian and while they are under your protection they speed up building processes.") ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.ore >= 100,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "They have now added the raw ore to the processing queue."),
                (4*config.fps, "Wait a little while and it will be transformed into usable materials."),
                (8*config.fps, "Keep harvesting and processing the ore until you reach 100 material."),
                (12*config.fps, "Notice the moving bars at the bottom right corner of the screen..."),
                (14*config.fps, "they represents the ore being processed."),
                (18*config.fps, "once they reach the right, they are usable!"),
                (22*config.fps, "They will then be added to the ore stock indicated by the blue gage in the bottom right corner."), ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.shipyards[ self.player.race.defaultHarvester.img ].getCount() >= 4,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "You now have enough material to build a new harvester and speed it up!"),
    (2*config.fps, "To do so, click on the icon of the harvester at the bottom of the screen, under the launch button.") ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.ore >= 300,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Keep harvesting and processing ore util you reach 300 material."),
                (4*config.fps, "It will follow the orders the others already received."),
                (8*config.fps, "Notice the blue bar in the upper right corner and the green one in the bottm right..."),
                (12*config.fps, "the blue one represents your shield and the green one your hull.") ] ),
            Step( 
                goal=lambda self, game: len( filter( lambda turret: turret.install, self.player.flagship.turrets ) ) >= 3,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "There are rumors of pirates in the area."),
                (4*config.fps, "Build one more mass cannon turret on your ship."),
                (8*config.fps, "To do so, click on an empty slot on the right of the screen and select an affordable turret."), ] ),
            Step( 
                goal=lambda self, game: not self.ennemyShip.alive,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                onBegin=lambda self, game: (self.addAttackingEnnemy( game, (self.moon.xp-1500,self.moon.yp-800), self.player.flagship, "Pirate lambda" ), game.setRelationBetween( self.player, self.ennemy, 1 )),
                texts = [ (0, "Defend yourself from the incoming pirate ship."),
                (4*config.fps, "To attack it, simply left-click on it once."),
                (8*config.fps, "Your crew will aim and fire the turrets."),
                (12*config.fps, "You can still help them by manoeuvering the ship so that the ennemy is in range of the turrets.") ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.orbitalbase, 100 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, "Well done!"),
                (2*config.fps, "Recall your harvester and return to the orbital base.") ] ),
            ]
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
    
        ### redefining stats, dangerous
        
        
        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        self.venus = Planet( game.stats.P_VENUS, 5000, 2300 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2300 )
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -13000, -4800 )
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )
        
        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth
        
        # asteroids over the moon, vital to scenario
        for i in xrange( 1 ):
            self.asteroid = Asteroid( game, self.moon.xp-200, self.moon.yp+150, 10 )
            game.harvestables.append( self.asteroid )
        
        for i in xrange( 3 ): # civilians around self.earth
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (self.earth.xp+dist*cos(angle), self.earth.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon ]
        
        dist = self.earth.stats.maxRadius*1.5
        angle = 5*pi/8
        self.orbitalbase = OrbitalBase( None, game.stats.HUMAN_BASE_MINING, None, self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append( self.orbitalbase )
        
        self.player = None
Example #7
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
    
        stats = Stats()
        stats.R_HUMAN.turrets = [ stats.T_SOLAR_0 ]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = []
        stats.PlayableShips = {}
        
        steps = [
            Step( 
                goal=lambda self, game: game.tick-9*config.fps>=self.lastStepAt and self.player.inputs.xc and not utils.distLowerThan( (self.player.inputs.xc+self.player.inputs.wc/2, self.player.inputs.yc+self.player.inputs.hc/2 ), self.player.flagship.pos, 200 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Look around your ship a bit.")),
    (config.fps*3, _("To move the camera, either use the arrow keys...")),
    (config.fps*6, _("or click on the radar in the upper left corner."))] ),
            Step( 
                goal=lambda self, game: game.tick-6*config.fps>=self.lastStepAt and utils.distLowerThan( (self.player.inputs.xc+self.player.inputs.wc/2, self.player.inputs.yc+self.player.inputs.hc/2 ), self.player.flagship.pos, 2 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Good, now stick the camera to your ship.")),
    (config.fps*3, _("To do so, click on the center of the radar.")),] ),
            Step( 
                goal=lambda self, game:  game.tick-9*config.fps>=self.lastStepAt and not utils.distLowerThan( self.startingPoint, self.player.flagship.pos, 100 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Now move away from the orbital station.")),
      (3*config.fps, _("To move the ship, left-click on the destination and your crew will manoeuver towards there.") ),
      (6*config.fps, _("To give the order to stop, left-click on the ship.") ) ] ),
            Step( 
                goal=lambda self, game: filter( lambda turret: turret.building==stats.T_SOLAR_0, self.player.flagship.turrets ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Let's prepare ourselves before going out to explore.")),
          (3*config.fps, _("Jumping uses a lot of energy, so first build 2 solar arrays on your ship.") ),
          (6*config.fps, _("To do so, left-click on one of the black circle at the right of the screen.") ),           
          (9*config.fps, _("Then select the solar array from the list.") ) ] ),
            Step( 
                goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_SOLAR_0, self.player.flagship.turrets ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Well done, it will take a little while for it to be completed.")),
                          (3*config.fps, _("Begin building the second one right away.") ),
                          (9*config.fps, _("Notice the green bar in the top right corner...") ),
                          (12*config.fps, _("it indicates the proportion of energy in your battery.") ),
                          (15*config.fps, _("The quantity is indicated in green text next to it..") ) ] ),
            Step( 
                goal=lambda self, game: len(filter( lambda turret: turret.install and turret.install.stats==stats.T_SOLAR_0, self.player.flagship.turrets ) ) >= 2 and game.tick-6*config.fps>=self.lastStepAt,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("Every ship benefits from solar energy the closer they are to a sun.") ),
                    (3*config.fps,_("A solar array will capture even more solar energy but will consume a little when in deep space.") ) ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0,_("We still need to fill the battery before jumping.")),
                          (3*config.fps, _("Use the long-range sensor in fullscreen mode to see our destination.") ),
                          (6*config.fps, _("Left-click on the Radar button in the upper-left corner.") ),
                          (12*config.fps, _("Notice your poition over Earth. It will be useful to come back.") ),
                          (15*config.fps, _("Mars is the 4th planet from the sun.") ),
                          (18*config.fps, _("You can see it on the right of the asteroid field down left from you.")),
                          (21*config.fps, _("To execute the jump, left-click on the blue button at the top of the screen") ),
                          (24*config.fps, _("the left-click on the destination, the planet Mars.") ), ] ),
            Step( 
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                onBegin=lambda self, game: self.addEnnemyShip( game, self.ennemyPosition ),
                texts = [ ( 0, _("Know that you can change the destination of the jump while it charges.") ),
                          (3*config.fps, _("Go back to normal view by clicking on the radar button again.") ), ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThan( self.ennemyPosition, self.player.flagship.pos, 500 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( config.fps, _("Now head for the asteroid field.") ),
                    ( 4*config.fps, _("Reports are that there is a anormal rotating asteroid towards the bottom of the field.") ),
                    ( 7*config.fps, _("Investigate it.") ) ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThan( self.ennemyPosition, self.player.flagship.pos, 200 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 0, _("It may be dangerous but get closer to gather data.") ) ] ),
            Step( 
                goal=lambda self, game: self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 0, _("What ever it is. It is hostile!") ),
                    ( 1*config.fps, _("Enough data collected.") ),
                    ( 2*config.fps, _("Jump away now!") ) ] ),
            Step( 
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 0, _("Don't worry, your shield and hull should be able to handle the hits for a little longer.") ) ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.orbitalbase, 2000 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ ( 1, _("Head back to Earth.") ) ] ),
            Step( 
                goal=lambda self, game: utils.distLowerThanObjects( self.player.flagship, self.orbitalbase, 100 ),
                failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
                texts = [ (0, _("Return to the orbital station.")),
                    ( 3*config.fps, _("Collected data will be useful if they ever try to get closer to Earth.") ) ] ),
                ]
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
        
        ### redefining stats, dangerous
        
        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        self.venus = Planet( game.stats.P_VENUS, 5000, 2300 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2300 )
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -13000, -4800 )
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )
        
        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth
        

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        for i in range( 60 ): # asteroids between self.saturn and self.neptune
            dist = 15000
            angle = (1-2*random())*pi/10+pi/7
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )
            
        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon ]
        
        dist = self.earth.stats.maxRadius*1.5
        angle = 5*pi/8
        self.orbitalbase = OrbitalBase( None, game.stats.HUMAN_BASE_MINING, None, self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append( self.orbitalbase )
        
        self.player = None
        self.startingPoint = ( self.orbitalbase.xp+50, self.orbitalbase.yp+60 )
        
        dist = 9000
        angle = pi*9/8+pi/8*2/3
        self.ennemyPosition = ( self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle) )
Example #8
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):

        stats = Stats()
        stats.R_HUMAN.turrets = [
            stats.T_LASER_SR_1, stats.T_LASER_SR_0, stats.T_MASS_SR_1,
            stats.T_MASS_SR_0, stats.T_MASS_MR_0
        ]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = [stats.HARVESTER]
        stats.PlayableShips = {}

        steps = [
            Step(
                goal=lambda self, game: utils.distLowerThanObjects(
                    self.player.flagship, self.asteroid, 300),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                #   onBegin=lambda self, game: self.player.flagship.ore = 500,
                texts=[(0, "We need some materials."),
                       (4 * config.fps,
                        "There is an asteroid close to the Moon."),
                       (8 * config.fps, "Get close to it.")]),
            Step(
                goal=lambda self, game: self.player.flagship.ai.launching[
                    self.player.race.defaultHarvester.img],
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, "Begin collecting raw ore."),
                 (4 * config.fps,
                  "To do so, launch your harvester by pressing the blue arrow button at the bottom of the screen."
                  )]),
            Step(
                goal=lambda self, game: self.player.flagship.oreProcess,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, "Now wait for them to bring back the ore."),
                 (6 * config.fps,
                  "Don't worry about the ships following you around."),
                 (10 * config.fps,
                  "They are civilian and while they are under your protection they speed up building processes."
                  )]),
            Step(
                goal=lambda self, game: self.player.flagship.ore >= 100,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=[
                    (0,
                     "They have now added the raw ore to the processing queue."
                     ),
                    (4 * config.fps,
                     "Wait a little while and it will be transformed into usable materials."
                     ),
                    (8 * config.fps,
                     "Keep harvesting and processing the ore until you reach 100 material."
                     ),
                    (12 * config.fps,
                     "Notice the moving bars at the bottom right corner of the screen..."
                     ),
                    (14 * config.fps,
                     "they represents the ore being processed."),
                    (18 * config.fps,
                     "once they reach the right, they are usable!"),
                    (22 * config.fps,
                     "They will then be added to the ore stock indicated by the blue gage in the bottom right corner."
                     ),
                ]),
            Step(
                goal=lambda self, game: self.player.flagship.shipyards[
                    self.player.race.defaultHarvester.img].getCount() >= 4,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  "You now have enough material to build a new harvester and speed it up!"
                  ),
                 (2 * config.fps,
                  "To do so, click on the icon of the harvester at the bottom of the screen, under the launch button."
                  )]),
            Step(
                goal=lambda self, game: self.player.flagship.ore >= 300,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  "Keep harvesting and processing ore util you reach 300 material."
                  ),
                 (4 * config.fps,
                  "It will follow the orders the others already received."),
                 (8 * config.fps,
                  "Notice the blue bar in the upper right corner and the green one in the bottm right..."
                  ),
                 (12 * config.fps,
                  "the blue one represents your shield and the green one your hull."
                  )]),
            Step(
                goal=lambda self, game: len(
                    filter(lambda turret: turret.install, self.player.flagship.
                           turrets)) >= 3,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=[
                    (0, "There are rumors of pirates in the area."),
                    (4 * config.fps,
                     "Build one more mass cannon turret on your ship."),
                    (8 * config.fps,
                     "To do so, click on an empty slot on the right of the screen and select an affordable turret."
                     ),
                ]),
            Step(
                goal=lambda self, game: not self.ennemyShip.alive,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                onBegin=lambda self, game: (self.addAttackingEnnemy(
                    game, (self.moon.xp - 1500, self.moon.yp
                           - 800), self.player.flagship, "Pirate lambda"
                ), game.setRelationBetween(self.player, self.ennemy, 1)),
                texts=
                [(0, "Defend yourself from the incoming pirate ship."),
                 (4 * config.fps,
                  "To attack it, simply left-click on it once."),
                 (8 * config.fps,
                  "Your crew will aim and fire the turrets."),
                 (12 * config.fps,
                  "You can still help them by manoeuvering the ship so that the ennemy is in range of the turrets."
                  )]),
            Step(goal=lambda self, game: utils.distLowerThanObjects(
                self.player.flagship, self.orbitalbase, 100),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0, "Well done!"),
                     (2 * config.fps,
                      "Recall your harvester and return to the orbital base.")
                 ]),
        ]

        Scenario.__init__(self, game, steps=steps, stats=stats)

        ### redefining stats, dangerous

        self.sol = Sun(game.stats.S_SOL, 0, 0)
        self.mercury = Planet(game.stats.P_MERCURY, -4100, 1400)
        self.venus = Planet(game.stats.P_VENUS, 5000, 2300)
        self.earth = Planet(game.stats.P_EARTH, -3100, 6700)
        self.mars = Planet(game.stats.P_MARS_1, -7800, -2300)
        self.moon = Planet(game.stats.P_MOON, -3900, 6400)
        self.jupiter = Planet(game.stats.P_JUPITER, -13000, -4800)
        self.saturn = Planet(game.stats.P_SATURN, 13000, 2500)
        self.neptune = Planet(game.stats.P_NEPTUNE, 15000, 7000)

        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth

        # asteroids over the moon, vital to scenario
        for i in xrange(1):
            self.asteroid = Asteroid(game, self.moon.xp - 200,
                                     self.moon.yp + 150, 10)
            game.harvestables.append(self.asteroid)

        for i in xrange(3):  # civilians around self.earth
            dist = randint(100, 800)
            angle = 2 * pi * random()

            (x, y) = (self.earth.xp + dist * cos(angle),
                      self.earth.yp + dist * sin(angle))
            s = Ship(game.stats.CIVILIAN_0, AiCivilian(), x, y, -20)
            game.objects.append(s)

        for i in range(50):  # asteroids outer self.mars
            dist = 9000
            angle = (1 - 2 * random()) * pi / 8 + pi * 9 / 8
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        game.astres = [
            self.sol, self.mercury, self.venus, self.earth, self.moon,
            self.mars, self.jupiter, self.saturn, self.neptune, self.moon
        ]

        dist = self.earth.stats.maxRadius * 1.5
        angle = 5 * pi / 8
        self.orbitalbase = OrbitalBase(None, game.stats.HUMAN_BASE_MINING,
                                       None, self.earth.xp + dist * cos(angle),
                                       self.earth.yp + dist * sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append(self.orbitalbase)

        self.player = None
Example #9
0
    def forRun( self ):
        yield self.verbose( "Commons", 0 )
        yield self.verbose( "ids integrity", level=1 )
        from common import ids
        #TODO compare unique ids to detect repetition, not vital but may be useful for debugging

        if self.testClient:
            yield self.verbose( "Client", 0 )

            yield self.verbose( "Client sound mixer", level=1 )
            from client.mixer import Mixer
            mixer = Mixer()
            
            yield self.verbose( "Setting volume to mute", level=2 )
            mixer.setVolume(0)
            
            yield self.verbose( "Client displays", level=1 )
            for name in self.displayNames:
                yield self.verbose( name.capitalize(), level=2 )
                exec( "from client.displays.%s import %s as Display"%( name, name.capitalize() ) )
                #from client.display import Display
                display = Display( resolution=(100,100) )
                
                
                yield self.verbose( "Clearing", level=3 )
                display.beginDraw()
                display.clear( (0,255,0) )
                display.finalizeDraw()
                
                yield self.verbose( "Text", level=3 )
                display.beginDraw()
                display.drawText( "test", (4,4) )
                display.finalizeDraw()
                
                yield self.verbose( "Line", level=3 )
                display.beginDraw()
                display.drawLine( (255,255,255), (0,100), (100,0) )
                display.drawLine( (255,255,255), (0,0), (100,100) )
                display.finalizeDraw()
                
                yield self.verbose( "Circle", level=3 )
                display.beginDraw()
                display.drawCircle( (255,255,255), (50,50), 45 )
                display.finalizeDraw()
                
                yield self.verbose( "Loading image", level=3 )
                img = display.load( self.testImgPath )
                
                yield self.verbose( "Drawing image", level=3 )
                img = display.load( self.testImgPath )
                display.beginDraw()
                display.draw( img, (0,0) )
                display.finalizeDraw()
                
                yield self.verbose( "Drawing image rotated", level=3 )
                img = display.load( self.testImgPath )
                display.beginDraw()
                display.drawRo( img, (0,0), pi/3 )
                display.finalizeDraw()

            yield self.verbose( "Client resources", level=1 )

            yield self.verbose( "Images", level=2 )
            from client.imgs import Imgs, Image, Animation
            imgs = Imgs( display )
            yield self.verbose( "Loading images", level=3 )
            for p in imgs.loadAll( display ):
                pass
                
            yield self.verbose( "Drawing images", level=3 )
            import pygame # To be removed for other implementation
            for k, v in imgs.__dict__.items():
                if isinstance( v, Image ) or isinstance( v, pygame.Surface ):
                    display.beginDraw()
                    if isinstance( v, Image ):
                        display.draw( imgs[k], (0,0) )
                    if  isinstance( v, pygame.Surface ):
                        display.draw( v, (0,0) )
                    display.finalizeDraw()
                    
            yield self.verbose( "Drawing animations", level=3 )
            for k, v in imgs.__dict__.items():
                if isinstance( v, Animation ):
                    for j in xrange( 0, 500 ):
                        imgs.updateAnimations()
                        display.beginDraw()
                        display.draw( v, (0,0) )
                        display.finalizeDraw()

            yield self.verbose( "Sounds", level=2 )
            from client.snds import Snds
            
            yield self.verbose( "Loading sounds", level=3 )
            snds = Snds( mixer )
            for p in snds.loadAll( mixer ):
                pass
                
            yield self.verbose( "Playing sounds", level=3 )
            for k, v in snds.__dict__.items():
                if isinstance( v, pygame.mixer.Sound ):
                    mixer.play( v )

            yield self.verbose( "Texts", level=2 )
            from client.texts import Texts
            texts = Texts()
            for p in texts.loadAll():
                pass

        if self.testServer:
            yield self.verbose( "Server", 0 )
            yield self.verbose( "Server stats", level=1 )
            from server.stats import Stats
            stats = Stats()

            yield self.verbose( "Game from Scenarios", level=1 )
            from server.game import Game
            games = []

            yield self.verbose( "Scenarios", level=1 )
            
            yield self.verbose( "Loading empty scenario", level=2 )
            exec( "from scenarios import Scenario as Scenario" )
            games.append( Game( Scenario ) )

            for name in self.scenarioNames:
                yield self.verbose( "Loading scenario %s"%name, level=2 )
                exec( "from scenarios.%s import %s as Scenario"%( name, name.capitalize() ) )
                games.append( Game( Scenario ) )

            # yield self.verbose( "Game from Sol", level=1 )
            # from server.game import Game
            # game = Game( Scenario )
                
            yield self.verbose( "Players", level=1 )
            from server.players import Player

            yield self.verbose( "Computer", level=2 )
            from server.players import Computer
            playerComputer0 = Computer( stats.R_HUMAN, "computer human" )

            yield self.verbose( "Faction", level=2 )
            from server.players import Faction
            playerFaction0 = Faction( stats.R_AI, "faction ai" )

            yield self.verbose( "Human players", level=2 )
            from server.players import Human
            playerHuman0 = Human( stats.R_NOMAD, "human nomad" )



            yield self.verbose( "Objects", level=1 )
            from server.objects import Object

            yield self.verbose( "Asteroid", level=2 )
            from server.objects import Asteroid
            asteroids = []
            while len( asteroids ) < 100:
                asteroids.append( Asteroid( games[0], 0, 0, 100 ) )

            yield self.verbose( "Planet", level=2 )
            from server.objects import Planet
            planet0 = Planet( stats.P_EARTH, 100, 0 )

            yield self.verbose( "Sun", level=2 )
            from server.objects import Sun
            sun0 = Sun( stats.S_SOL, 5000, 0 )

            yield self.verbose( "Nebula", level=2 )
            from server.objects import Nebula
            nebula0 = Nebula( stats.A_NEBULA, -1000, 0 )

            yield self.verbose( "Blackhole", level=2 )
            from server.objects import BlackHole 
            blackhole0 = BlackHole( stats.BH_0, 0, 10000 )


            yield self.verbose( "Ships", level=2 )

            yield self.verbose( "Simple ship", level=3 )
            from server.ships import Ship
            ship0 = Ship( stats.HUMAN_FIGHTER, None, 0, 0 )

            yield self.verbose( "ShipWithTurrets", level=3 )
            from server.ships import ShipWithTurrets
            ship0 = ShipWithTurrets( None, stats.HARVESTER, None, 0, 0 )

         #   yield self.verbose( "Turret instanciation", level=1 )

         #   yield self.verbose( "Turret building", level=1 )

         #   yield self.verbose( "Turret fire", level=1 )

         #   yield self.verbose( "AIs", level=1 )

            yield self.verbose( "Server", level=1 )
            from server.server import Server
            server = Server( scenarioName="Sol", force=True, adminPassword="******" )

            yield True
Example #10
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):

        stats = Stats()
        stats.R_HUMAN.turrets = [stats.T_SOLAR_0]
        stats.R_HUMAN.missiles = []
        stats.R_HUMAN.ships = []
        stats.PlayableShips = {}

        steps = [
            Step(goal=lambda self, game: game.tick - 9 * config.fps >= self.
                 lastStepAt and self.player.inputs.xc and not utils.
                 distLowerThan((self.player.inputs.xc + self.player.inputs.wc /
                                2, self.player.inputs.yc + self.player.inputs.
                                hc / 2), self.player.flagship.pos, 200),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0, _("Look around your ship a bit.")),
                     (config.fps * 3,
                      _("To move the camera, either use the arrow keys...")),
                     (config.fps * 6,
                      _("or click on the radar in the upper left corner."))
                 ]),
            Step(goal=lambda self, game: game.tick - 6 * config.fps >= self.
                 lastStepAt and utils.distLowerThan(
                     (self.player.inputs.xc + self.player.inputs.wc / 2, self.
                      player.inputs.yc + self.player.inputs.hc / 2), self.
                     player.flagship.pos, 2),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0, _("Good, now stick the camera to your ship.")),
                     (config.fps * 3,
                      _("To do so, click on the center of the radar.")),
                 ]),
            Step(
                goal=lambda self, game: game.tick - 9 * config.fps >= self.
                lastStepAt and not utils.distLowerThan(
                    self.startingPoint, self.player.flagship.pos, 100),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, _("Now move away from the orbital station.")),
                 (3 * config.fps,
                  _("To move the ship, left-click on the destination and your crew will manoeuver towards there."
                    )),
                 (6 * config.fps,
                  _("To give the order to stop, left-click on the ship."))]),
            Step(
                goal=lambda self, game: filter(
                    lambda turret: turret.building == stats.T_SOLAR_0, self.
                    player.flagship.turrets),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Let's prepare ourselves before going out to explore.")),
                 (3 * config.fps,
                  _("Jumping uses a lot of energy, so first build 2 solar arrays on your ship."
                    )),
                 (6 * config.fps,
                  _("To do so, left-click on one of the black circle at the right of the screen."
                    )),
                 (9 * config.fps,
                  _("Then select the solar array from the list."))]),
            Step(
                goal=lambda self, game: filter(
                    lambda turret: turret.install and turret.install.stats ==
                    stats.T_SOLAR_0, self.player.flagship.turrets),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Well done, it will take a little while for it to be completed."
                    )),
                 (3 * config.fps,
                  _("Begin building the second one right away.")),
                 (9 * config.fps,
                  _("Notice the green bar in the top right corner...")),
                 (12 * config.fps,
                  _("it indicates the proportion of energy in your battery.")),
                 (15 * config.fps,
                  _("The quantity is indicated in green text next to it.."))]),
            Step(
                goal=lambda self, game: len(
                    filter(
                        lambda turret: turret.install and turret.install.stats
                        == stats.T_SOLAR_0, self.player.flagship.turrets)
                ) >= 2 and game.tick - 6 * config.fps >= self.lastStepAt,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Every ship benefits from solar energy the closer they are to a sun."
                    )),
                 (3 * config.fps,
                  _("A solar array will capture even more solar energy but will consume a little when in deep space."
                    ))]),
            Step(
                goal=lambda self, game: self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=[
                    (0,
                     _("We still need to fill the battery before jumping.")),
                    (3 * config.fps,
                     _("Use the long-range sensor in fullscreen mode to see our destination."
                       )),
                    (6 * config.fps,
                     _("Left-click on the Radar button in the upper-left corner."
                       )),
                    (12 * config.fps,
                     _("Notice your poition over Earth. It will be useful to come back."
                       )),
                    (15 * config.fps,
                     _("Mars is the 4th planet from the sun.")),
                    (18 * config.fps,
                     _("You can see it on the right of the asteroid field down left from you."
                       )),
                    (21 * config.fps,
                     _("To execute the jump, left-click on the blue button at the top of the screen"
                       )),
                    (24 * config.fps,
                     _("the left-click on the destination, the planet Mars.")),
                ]),
            Step(
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                onBegin=lambda self, game: self.addEnnemyShip(
                    game, self.ennemyPosition),
                texts=[
                    (0,
                     _("Know that you can change the destination of the jump while it charges."
                       )),
                    (3 * config.fps,
                     _("Go back to normal view by clicking on the radar button again."
                       )),
                ]),
            Step(
                goal=lambda self, game: utils.distLowerThan(
                    self.ennemyPosition, self.player.flagship.pos, 500),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(config.fps, _("Now head for the asteroid field.")),
                 (4 * config.fps,
                  _("Reports are that there is a anormal rotating asteroid towards the bottom of the field."
                    )), (7 * config.fps, _("Investigate it."))]),
            Step(goal=lambda self, game: utils.distLowerThan(
                self.ennemyPosition, self.player.flagship.pos, 200),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[
                     (0,
                      _("It may be dangerous but get closer to gather data."))
                 ]),
            Step(goal=lambda self, game: self.player.flagship.jumping,
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[(0, _("What ever it is. It is hostile!")),
                        (1 * config.fps, _("Enough data collected.")),
                        (2 * config.fps, _("Jump away now!"))]),
            Step(
                goal=lambda self, game: not self.player.flagship.jumping,
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0,
                  _("Don't worry, your shield and hull should be able to handle the hits for a little longer."
                    ))]),
            Step(goal=lambda self, game: utils.distLowerThanObjects(
                self.player.flagship, self.orbitalbase, 2000),
                 failure=lambda self, game: not self.player.flagship or
                 not self.player.flagship.alive,
                 texts=[(1, _("Head back to Earth."))]),
            Step(
                goal=lambda self, game: utils.distLowerThanObjects(
                    self.player.flagship, self.orbitalbase, 100),
                failure=lambda self, game: not self.player.flagship or not self
                .player.flagship.alive,
                texts=
                [(0, _("Return to the orbital station.")),
                 (3 * config.fps,
                  _("Collected data will be useful if they ever try to get closer to Earth."
                    ))]),
        ]

        Scenario.__init__(self, game, steps=steps, stats=stats)

        ### redefining stats, dangerous

        self.sol = Sun(game.stats.S_SOL, 0, 0)
        self.mercury = Planet(game.stats.P_MERCURY, -4100, 1400)
        self.venus = Planet(game.stats.P_VENUS, 5000, 2300)
        self.earth = Planet(game.stats.P_EARTH, -3100, 6700)
        self.mars = Planet(game.stats.P_MARS_1, -7800, -2300)
        self.moon = Planet(game.stats.P_MOON, -3900, 6400)
        self.jupiter = Planet(game.stats.P_JUPITER, -13000, -4800)
        self.saturn = Planet(game.stats.P_SATURN, 13000, 2500)
        self.neptune = Planet(game.stats.P_NEPTUNE, 15000, 7000)

        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth

        for i in range(50):  # asteroids outer self.mars
            dist = 9000
            angle = (1 - 2 * random()) * pi / 8 + pi * 9 / 8
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        for i in range(60):  # asteroids between self.saturn and self.neptune
            dist = 15000
            angle = (1 - 2 * random()) * pi / 10 + pi / 7
            asteroid = Asteroid(game, self.sol.xp + dist * cos(angle),
                                self.sol.yp + dist * sin(angle), 300)
            game.harvestables.append(asteroid)

        game.astres = [
            self.sol, self.mercury, self.venus, self.earth, self.moon,
            self.mars, self.jupiter, self.saturn, self.neptune, self.moon
        ]

        dist = self.earth.stats.maxRadius * 1.5
        angle = 5 * pi / 8
        self.orbitalbase = OrbitalBase(None, game.stats.HUMAN_BASE_MINING,
                                       None, self.earth.xp + dist * cos(angle),
                                       self.earth.yp + dist * sin(angle))
        self.orbitalbase.ri = -0.013
        game.objects.append(self.orbitalbase)

        self.player = None
        self.startingPoint = (self.orbitalbase.xp + 50,
                              self.orbitalbase.yp + 60)

        dist = 9000
        angle = pi * 9 / 8 + pi / 8 * 2 / 3
        self.ennemyPosition = (self.sol.xp + dist * cos(angle),
                               self.sol.yp + dist * sin(angle))
Example #11
0
    def __init__(self, game, steps=None, name=None, description=None, year=0):
    
        stats = Stats()
        stats.R_HUMAN.turrets = [ stats.T_LASER_SR_1, stats.T_LASER_SR_0, stats.T_LASER_MR_0,
    stats.T_MASS_SR_1, stats.T_MASS_SR_0, stats.T_MASS_LR, stats.T_MASS_MR_0,
    stats.T_MISSILE_1, stats.T_MISSILE_0,
    stats.T_PULSE, stats.T_MINER, 
    stats.T_SOLAR_0,  ]
        stats.R_HUMAN.missiles = [ids.M_NORMAL, ids.M_PULSE, ids.M_MINER]
        stats.R_HUMAN.ships = [ stats.HARVESTER, stats.HUMAN_FIGHTER ]
        stats.PlayableShips = {}
        
        
        steps = []
        
        ### missiles
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_MISSILE_0, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: self.addEnnemyShip( game, (self.player.flagship.xp+stats.T_MASS_MR_0.weapon.maxRange+100, self.player.flagship.yp), None ),
            texts = [(0,"There's an ennemy ship on the other side of Earth, directly to your right."),
                (config.fps*4, "It is too far away to reach with your current weapons."),
                (config.fps*8, "Select an empty turret, on the right of the screen, and build a missile launcher."),
                (config.fps*16, "It would also be a good idea to begin harvesting the asteroid close by."),
                (config.fps*20, "Build more harvester if you feel that it's necessary." )] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.missiles[ids.M_NORMAL].amount >= 10,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0,"Now that the launcher is ready you will need some missiles!"),
                (config.fps*4, "Click on the missile icon at the botom of the screen to start building them."),
                (config.fps*8, "10 should be enough to initiate the combat.") ] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemyShip.alive,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            texts = [(0,"Now attack it!"),
                (config.fps*4, "It is the blue dot on the radar screen, left-click on it to begin the attack." ) ] ) )
            
        ### mass turret / upgrading
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_MASS_LR, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: self.addEnnemyShip( game, (self.player.flagship.xp+stats.T_MASS_LR.weapon.maxRange-400, self.player.flagship.yp), None ),
            texts = [(0,"One appeared even further away!"),
                (config.fps*4, "Upgrade at least one of your mass cannon to a mass driver turret." ) ] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemyShip.alive,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            text = "Now that you can reach it, attack it!" ) )
            
        ### fighters
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.shipyards[ ids.S_HUMAN_FIGHTER ].getCount() >= 5,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: self.addEnnemyShips( game, (self.player.flagship.xp+stats.T_MASS_LR.weapon.maxRange+1000, self.player.flagship.yp), 200, count=2 ),
            texts = [(0,"There's another one too far away for your turrets."),
            (config.fps*4, "You need to build at leats 5 fighters."),
            (config.fps*8, "To do so, click on the fighter icon, at the bottom of the screen next to the harvester." )] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.ai.launching[ ids.S_HUMAN_FIGHTER ],
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0,"Launch your fighters."),
            (config.fps*4, "To do so, press the blue arrow button at the bottom of the screen." )] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemy.flagships,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            text = "Now order your fighters to attack it by left-clicking on it." ) )
         
         ### mines
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_MINER, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0, "The pirates always come from the same direction."),
                (config.fps*4, "Let's think ahead and build a mine field."),
                (config.fps*8, "First, build a mine layer turret."),
                (config.fps*12, "It would be a good idea to recall your fighters before laying the mine field."),
                (config.fps*16, "To do so, press  onthe green arrow over the fighter icon." )] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.missiles[ids.M_MINER].amount >= 1,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "Build 8 or more miner missiles.\nThe button appeared next to the missile button." ) )
        steps.append( Step( 
            goal=lambda self, game: filter( lambda obj: isinstance( obj, MinerMissile ), game.objects.objects ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "A missile is ready.\nShoot it by clicking on the red targetting button over its icon.",
            texts= [
    (config.fps*4,"Then click on the target, in this case target at a little distance to the right of the station."),
    (config.fps*8,"You can always cancel the launch of a missile by right clicking on the screen when targetting.")
                    ] ) )
        steps.append( Step( 
            goal=lambda self, game: len( filter( lambda obj: isinstance( obj, Mine ), game.objects.objects ) ) >= stats.T_MINER.specialValue[1]*8,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "Build and deploy a total of at least 8 missiles." ) )
            
         ### pulse
        steps.append( Step( 
            goal=lambda self, game: filter( lambda turret: turret.install and turret.install.stats==stats.T_PULSE, self.player.flagship.turrets ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
           onBegin=lambda self, game: self.addEnnemyShips( game, (self.player.flagship.xp+stats.T_MASS_LR.weapon.maxRange+200, self.player.flagship.yp), 200, count=4 ),
            texts = [(0, "A group of pirates can now be seen far away."),
            (config.fps*4, "To trap them and give us a head start let's hit them with an EMP weapon first!"),
            (config.fps*8, "Build a pulse launcher.") ] ) )
        steps.append( Step( 
            goal=lambda self, game: self.player.flagship.missiles[ids.M_PULSE].amount >= 1,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "Build at least one pulse missile." ) )
        steps.append( Step( 
            goal=lambda self, game: filter( lambda obj: isinstance( obj, PulseMissile ), game.objects.objects ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            text = "A missile is ready.\nShoot it in the middle of the pirates." ) )
        steps.append( Step( 
            goal=lambda self, game: not filter( lambda obj: isinstance( obj, PulseMissile ), game.objects.objects ),
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            onBegin=lambda self, game: (game.setRelationBetween( self.player, self.ennemy, 1 ), game.setRelationBetween( self.ennemy, self.player, 1 )),
            texts = [(0,"Wait for them to get hit."),
            (config.fps*4, "Every ship caught in the explosion will have its engines disabled for a few seconds..."),
            (config.fps*8, "its shield will also be badly hit.")] ) )
        steps.append( Step( 
            goal=lambda self, game: not self.ennemy.flagships,
            failure=lambda self, game: not self.player.flagship or not self.player.flagship.alive,
            texts = [(0,"Wait for them to recover from the EMP and to get caught in the mine field!"),
                (config.fps*4, "Then finish them.")] ) )
            
        
        Scenario.__init__(self, game, steps=steps, stats=stats )
        
        
        self.sol = Sun( game.stats.S_SOL, 0, 0 )
        self.mercury = Planet( game.stats.P_MERCURY, -4100, 1400 )
        self.venus = Planet( game.stats.P_VENUS, 5000, 2300 )
        self.earth = Planet( game.stats.P_EARTH, -3100, 6700 )
        self.mars = Planet( game.stats.P_MARS_1, -7800, -2300 )
        self.moon = Planet( game.stats.P_MOON, -3900, 6400 )
        self.jupiter = Planet( game.stats.P_JUPITER, -13000, -4800 )
        self.saturn = Planet( game.stats.P_SATURN, 13000, 2500 )
        self.neptune = Planet( game.stats.P_NEPTUNE, 15000, 7000 )
        
        self.moon.zp = -50
        self.moon.yi = 0.1
        self.moon.orbiting = self.earth
        
        # asteroids near the station
        for i in xrange( 1 ):
            asteroid = Asteroid( game, self.moon.xp+200, self.moon.yp+430, 0 )
            game.harvestables.append( asteroid )
        
        for i in xrange( 10 ): # civilians around self.earth
            dist = randint( 100, 800 )
            angle = 2*pi*random()

            (x,y) = (self.earth.xp+dist*cos(angle), self.earth.yp+dist*sin(angle))
            s = Ship( game.stats.CIVILIAN_0, AiCivilian(), x, y, -20 )
            game.objects.append( s )

        for i in range( 50 ): # asteroids outer self.mars
            dist = 9000
            angle = (1-2*random())*pi/8+pi*9/8
            asteroid = Asteroid( game, self.sol.xp+dist*cos(angle), self.sol.yp+dist*sin(angle), 300 )
            game.harvestables.append( asteroid )

        game.astres = [self.sol, self.mercury, self.venus, self.earth, self.moon, self.mars, self.jupiter, self.saturn, self.neptune, self.moon ]
        
      #  dist = self.earth.stats.maxRadius*1.2
      #  angle = 7/8*pi
     #   self.orbitalbase = OrbitalBase( None, game.stats.HUMAN_BASE, None, self.earth.xp+dist*cos(angle),self.earth.yp+dist*sin(angle))
      #  self.orbitalbase.ri = -0.013
      #  game.objects.append( self.orbitalbase )
        
        self.player = None