Пример #1
0
    def __init__(self):
        super(ShipGame, self).__init__()
        self.introduction = '''
Welcome to Ship Adventure. You are the captain of a star ship.
        '''

        bridge = Place('Bridge', 
            "You are on the bridge of a spaceship, sitting in the captain's chair.", 
            (
            Event(0.01, 'An intruder beams onto the bridge and shoots you.', -50, maxOccur = 1),
            Event(0.1, "The ship's doctor gives you a health boost.", 30),
            ))

        readyRoom = Place('Ready Room', "You are in the captain's ready room.", ())

        lift = Place('Lift', 'You have entered the turbolift.', (
            Event(.05, "The ship's android says hello to you.", 0),
        ))

        lounge = Place('Lounge', 'Welcome to the lounge.', (
            Event(1, 'Relaxing in the lounge improves your health.', 10),
        ))

        bridge.transitions = (readyRoom, lift)
        readyRoom.transitions = (bridge,)
        lift.transitions = (bridge,lounge)
        lounge.transitions = (lift,)

        self.location = bridge
Пример #2
0
 def generate_objects(self):
     for name, obj in self.data.items():
         if type(obj) is dict:
             if obj["type"] == "event":
                 del obj["type"]
                 self.events[name] = self.objects[name] = Event(**obj)
             elif obj["type"] == "battle":
                 del obj["type"]
                 self.battles[name] = self.objects[name] = Battle(**obj)
             elif obj["type"] == "place":
                 del obj["type"]
                 self.places[name] = self.objects[name] = Place(**obj)
             elif obj["type"] == "action":
                 del obj["type"]
                 self.actions[name] = self.objects[name] = Action(**obj)
Пример #3
0
    def game(self):
        self.introduction = '''
Welcome to test.
'''

        home = Place('House', "Welcome to your home.", ())
        outside = Place('Backyard', "Welcome to your backyard.", ())
        home.transitions = (outside,)
        outside.transitions = (home,)

        self.location = home
Пример #4
0
    def __init__(self):
        super(ShipGame, self).__init__()
        self.introduction = '''
Welcome to Ship Adventure. You are the captain of a star ship.
'''
        intruder = Event('Intruder', 0.8,'An intruder enters and attacks you', 1)
        
        bridge = Place('Bridge',"You are on the bridge of a spaceship, sitting in the captain's chair.", ())
        readyRoom = Place('Ready Room', "You are in the captain's ready room.", (intruder,))
        lift = Place('Lift', 'You have entered the turbolift.', ())
        lounge = Place('Lounge', 'Welcome to the lounge.', ())

        
        bridge.transitions = (readyRoom, lift)
        readyRoom.transitions = (bridge,)
        lift.transitions = (bridge,lounge)
        lounge.transitions = (lift,)

        self.location = bridge
Пример #5
0
    def __init__(self):
        super(ShipGame, self).__init__()
        self.introduction = '''
Welcome to Ship Adventure. You are the captain of a star ship. '''

        bridge = Place(
            'Bridge',
            "You are on the bridge of a spaceship, sitting in the captain's chair.",
            (
                Event(0.01,
                      'An intruder beams onto the bridge and shoots you.',
                      -50,
                      maxOccur=1),
                Event(0.1, "The ship's doctor gives you a health boost.", 30),
            ))

        readyRoom = Place('Ready Room', "You are in the captain's ready room.",
                          ())

        lift = Place(
            'Lift', 'You have entered the turbolift.',
            (Event(.05, "The ship's android says hello to you.", 0), ))

        lounge = Place(
            'Lounge', 'Welcome to the lounge.',
            (Event(1, 'Relaxing in the lounge improves your health.', 10), ))

        bridge.transitions = (readyRoom, lift)
        readyRoom.transitions = (bridge, )
        lift.transitions = (bridge, lounge)
        lounge.transitions = (lift, )

        self.location = bridge
Пример #6
0
    def __init__(self):
        super(ShipGame, self).__init__()
        self.introduction = 'Welcome to Ship Adventure. You are the captain of a star ship.'

        bridge = Place(
            'Bridge',
            "You are on the bridge of a spaceship, sitting in the captain's chair.",
            (
                Event(0.01,
                      'An intruder beams onto the bridge and shoots you.',
                      -50,
                      max_occurrences=1),
                Event(0.1, "The ship's doctor gives you a health boost.", 30),
            ))

        ready_room = Place('Ready Room',
                           "You are in the captain's ready room.",
                           (Event(.5,
                                  'The fish in the aquarium turn to watch you',
                                  0,
                                  max_occurrences=1), ))

        lift = Place('Lift', 'You have entered the turbolift.',
                     (Event(.1, "The ship's android says hello to you.", 1), ))

        lounge = Place(
            'Lounge', 'Welcome to the lounge.',
            (Event(1, 'Relaxing in the lounge improves your health.', 10), ))

        space_suit = InventoryItem('Spacesuit')

        storage_room = Place('Storage Room',
                             'You enter the storage room',
                             inventory_items=[space_suit])

        transporter_room = Place(
            'Transporter Room',
            'The transporter room looks cool with all its blinking lights and sliders.'
        )

        planet = Place('Planet', 'You have beamed down to the planet.',
                       (Event(.3, 'You found the experience relaxing', +10), ))

        def mt(places):  # Make Transitions
            return [T(place) for place in places]

        bridge.transitions = mt((ready_room, lift))
        ready_room.transitions = mt((bridge, ))
        lift.transitions = mt((bridge, lounge, storage_room, transporter_room))
        lounge.transitions = mt((lift, ))
        storage_room.transitions = mt((lift, ))
        transporter_room.transitions = (T(planet, (space_suit, )), T(lift))
        planet.transitions = mt((transporter_room, ))

        self.location = bridge
Пример #7
0
    def game(self):
        self.introduction = '''
Welcome to Ship Adventure. You are the captain of a star ship.
'''
        alien_fight = Battle(self)
        holobattle = Battle(self, 100, 6, 0)

        bridge = Place(
            'Bridge',
            "You are on the bridge of a spaceship, sitting in the captain's chair.",
            (
                Event(
                    0.01,
                    'An intruder beams onto the bridge and shoots you.\nIt starts to fight you.',
                    -50,
                    maxOccur=1,
                    battle=alien_fight),
                Event(0.1, "The ship's doctor gives you a health boost.", 30),
            ))

        readyRoom = Place('Ready Room', "You are in the captain's ready room.",
                          ())

        quarters = Place('Captain\'s Quarters', 'Welcome to your quarters.', (
            Event(1, 'Relaxing in your quarters improves your health.', 20),
            Event(
                0.1,
                'But you are paged to return to the bridge and you don\'t get to relax.\n You go to the bridge.',
                -20,
                go=bridge),
        ))

        broken_lift = Place(
            'Lift', 'The turbolift is stuck',
            (Event(0.1,
                   "The turbolift powers up.\nYou go to your quarters",
                   0,
                   go=quarters), ))

        lift = Place('Lift', 'You have entered the turbolift.', (
            Event(0.05, "The ship's android says hello to you.", 0),
            Event(
                0.05,
                "The turbolift breaks down and goes falling through the shaft.\nYou break a rib",
                -25,
                go=broken_lift,
                maxOccur=1),
        ))

        lounge = Place(
            'Lounge', 'Welcome to the lounge.',
            (Event(1, 'Relaxing in the lounge improves your health.', 10), ))

        turboshaft = Place('Turbo Shaft', 'You climb down the ladder',
                           (Event(0.6, 'Your rib throbs.', -2), ))

        vent = Place(
            'A vent',
            'You climb into the vent.\nYou can fit into the entrance but not the rest.',
            (Event(
                0.4,
                'The floor of the vent collapses, and you fall into your quarters.\nYour rib throbs painfully.',
                -10,
                go=quarters), ))

        sickbay = Place(
            'Sickbay', "You are in Sickbay.",
            (Event(0.8, "The ship's doctor gives you a health boost.", 30), ))

        engine = Place("Engineering", "You are in Engineering.", (Event(
            0.05,
            "There is a warp core breach.\nYou are scalded by anti-matter.\nYou fall unconscious, and you are taken to Sickbay",
            -60,
            go=sickbay,
            maxOccur=1), ))

        holodeck_on = Place(
            "Holodeck", "You are in a holodeck program",
            (Event(0.99,
                   "A man steps out of the shadows and shoots you.",
                   0,
                   battle=holobattle), ))

        holodeck = Place(
            'Holodeck', "Welcome to the Holodeck",
            (Event(0.8, "The Holodeck program begins", 0, go=holodeck_on), ))

        holodeck_arch = Place(
            "Stop Program", "Welcome to the Holodeck",
            (Event(1, "The Holodeck program stops", 0, go=holodeck), ))

        cafe = Place(
            "Starbucks", "You are in a cafe from the early 21st century",
            (Event(
                1,
                "Drinking a cup of coffee warms you up and improves your health",
                10),
             Event(0.02,
                   "A man steps out of the shadows and shoots you.",
                   0,
                   battle=holobattle)))
        bridge.transitions = (readyRoom, lift)
        readyRoom.transitions = (bridge, )
        lift.transitions = (bridge, lounge, quarters, sickbay, engine,
                            holodeck)
        lounge.transitions = (lift, )
        quarters.transitions = (lift, )
        broken_lift.transitions = (turboshaft, )
        turboshaft.transitions = (broken_lift, vent)
        vent.transitions = (turboshaft, )
        sickbay.transitions = (lift, )
        engine.transitions = (lift, )
        holodeck.transitions = (lift, )
        holodeck_on.transitions = (holodeck_arch, cafe)
        cafe.transitions = (holodeck_arch, holodeck_on)

        self.location = bridge
Пример #8
0
    def __init__(self):
        super(ShipGame, self).__init__()
        self.introduction = 'Welcome to Ship Adventure. You are the captain of a star ship.'

        bridge = Place('Bridge',
            "You are on the bridge of a spaceship, sitting in the captain's chair.", (
                Event(0.01, 'An intruder beams onto the bridge and shoots you.', -50, max_occurrences=1),
                Event(0.1, "The ship's doctor gives you a health boost.", 30),
            ))

        ready_room = Place('Ready Room', "You are in the captain's ready room.", (
            Event(.5, 'The fish in the aquarium turn to watch you', 0, max_occurrences=1),
        ))

        lift = Place('Lift', 'You have entered the turbolift.', (
            Event(.1, "The ship's android says hello to you.", 1),
        ))

        lounge = Place('Lounge', 'Welcome to the lounge.', (
            Event(1, 'Relaxing in the lounge improves your health.', 10),
        ))

        space_suit = InventoryItem('Spacesuit')

        storage_room = Place('Storage Room', 'You enter the storage room',
            inventory_items=[space_suit])

        transporter_room = Place('Transporter Room',
            'The transporter room looks cool with all its blinking lights and sliders.')

        planet = Place('Planet', 'You have beamed down to the planet.', (
            Event(.3, 'You found the experience relaxing', +10),
        ))

        def mt(places):  # Make Transitions
            return [T(place) for place in places]

        bridge          .transitions = mt((ready_room, lift))
        ready_room      .transitions = mt((bridge,))
        lift            .transitions = mt((bridge, lounge, storage_room, transporter_room))
        lounge          .transitions = mt((lift,))
        storage_room    .transitions = mt((lift,))
        transporter_room.transitions = (T(planet, (space_suit,)), T(lift))
        planet          .transitions = mt((transporter_room,))

        self.location = bridge