def setUpClass(cls): M = GameMaker() # Create a 'bedroom' room. R1 = M.new_room("bedroom") R2 = M.new_room("kitchen") M.set_player(R2) path = M.connect(R1.east, R2.west) path.door = M.new(type='d', name='wooden door') path.door.add_property("closed") carrot = M.new(type='f', name='carrot') lettuce = M.new(type='f', name='lettuce') R1.add(carrot) R1.add(lettuce) # Add a closed chest in R2. chest = M.new(type='c', name='chest') chest.add_property("open") R2.add(chest) # The goals commands = [ "open wooden door", "go west", "take carrot", "go east", "drop carrot" ] cls.eventA = M.new_event_using_commands(commands) commands = [ "open wooden door", "go west", "take lettuce", "go east", "insert lettuce into chest" ] cls.eventB = M.new_event_using_commands(commands) cls.losing_eventA = Event(conditions={M.new_fact("eaten", carrot)}) cls.losing_eventB = Event(conditions={M.new_fact("eaten", lettuce)}) cls.questA = Quest(win_events=[cls.eventA], fail_events=[cls.losing_eventA]) cls.questB = Quest(win_events=[cls.eventB], fail_events=[cls.losing_eventB]) cls.questC = Quest(win_events=[], fail_events=[cls.losing_eventA, cls.losing_eventB]) commands = ["open wooden door", "go west", "take carrot", "eat carrot"] cls.eating_carrot = M.new_event_using_commands(commands) commands = [ "open wooden door", "go west", "take lettuce", "eat lettuce" ] cls.eating_lettuce = M.new_event_using_commands(commands) commands = [ "open wooden door", "go west", "take lettuce", "go east", "insert lettuce into chest" ] M.quests = [cls.questA, cls.questB, cls.questC] cls.game = M.build()
def setUpClass(cls): M = GameMaker() room = M.new_room("room") M.set_player(room) carrot = M.new(type='f', name='carrot') lettuce = M.new(type='f', name='lettuce') room.add(carrot) room.add(lettuce) chest = M.new(type='c', name='chest') chest.add_property("open") room.add(chest) # The goals commands = ["take carrot", "insert carrot into chest"] cls.eventA = M.new_event_using_commands(commands) commands = ["take lettuce", "insert lettuce into chest", "close chest"] event = M.new_event_using_commands(commands) cls.eventB = Event(actions=event.actions, conditions={ M.new_fact("in", lettuce, chest), M.new_fact("closed", chest) }) cls.fail_eventA = Event(conditions={M.new_fact("eaten", carrot)}) cls.fail_eventB = Event(conditions={M.new_fact("eaten", lettuce)}) cls.quest = Quest(win_events=[cls.eventA, cls.eventB], fail_events=[cls.fail_eventA, cls.fail_eventB]) commands = ["take carrot", "eat carrot"] cls.eating_carrot = M.new_event_using_commands(commands) commands = ["take lettuce", "eat lettuce"] cls.eating_lettuce = M.new_event_using_commands(commands) commands = ["take lettuce", "insert lettuce into chest"] M.quests = [cls.quest] cls.game = M.build()
def setUpClass(cls): M = GameMaker() # The goal commands = ["take carrot", "insert carrot into chest"] R1 = M.new_room("room") M.set_player(R1) carrot = M.new(type='f', name='carrot') R1.add(carrot) # Add a closed chest in R2. chest = M.new(type='c', name='chest') chest.add_property("open") R1.add(chest) cls.event = M.new_event_using_commands(commands) cls.actions = cls.event.actions cls.conditions = {M.new_fact("in", carrot, chest)} cls.game = M.build() commands = ["take carrot", "eat carrot"] cls.eating_carrot = M.new_event_using_commands(commands)
def setUpClass(cls): M = GameMaker() # The goal commands = ["go east", "insert carrot into chest"] # Create a 'bedroom' room. R1 = M.new_room("bedroom") R2 = M.new_room("kitchen") M.set_player(R1) path = M.connect(R1.east, R2.west) path.door = M.new(type='d', name='wooden door') path.door.add_property("open") carrot = M.new(type='f', name='carrot') M.inventory.add(carrot) # Add a closed chest in R2. chest = M.new(type='c', name='chest') chest.add_property("open") R2.add(chest) cls.eventA = M.new_event_using_commands(commands) cls.eventB = Event(conditions={ M.new_fact("at", carrot, R1), M.new_fact("closed", path.door) }) cls.eventC = Event(conditions={M.new_fact("eaten", carrot)}) cls.eventD = Event(conditions={ M.new_fact("closed", chest), M.new_fact("closed", path.door) }) cls.quest = Quest(win_events=[cls.eventA, cls.eventB], fail_events=[cls.eventC, cls.eventD], reward=2) M.quests = [cls.quest] cls.game = M.build() cls.inform7 = Inform7Game(cls.game)
def build_and_compile_super_hero_game(): M = GameMaker() roomA = M.new_room("Room A") alley = M.new_room("Alley") bank1 = M.new_room("Bank1") bank2 = M.new_room("Bank2") bank3 = M.new_room("Bank3") corridor = M.connect(roomA.east, alley.west) corridor1 = M.connect(alley.east, bank1.west) corridor1 = M.connect(alley.north, bank2.south) corridor1 = M.connect(alley.south, bank3.north) M.set_player(roomA) roomA.infos.desc = "You are in a road. Some mobs are planning to rob a bank. You need to stop them. Go east to the alley. You can find a person in the alley who has information about the roberry. Collect information from him and prevent the roberry." alley.infos.desc = "This is an alley. There is a person beside the table. He knows about the bank roberry." bank2.infos.desc = "This is the north bank. Some robbers are going to rob the bank. You can call the police and try to capture them or convince them to surrender. Or you can also shoot them to stop the robbery." money = M.new(type="o", name = 'money') money.infos.desc = "it is money" M.inventory.add(money) person = M.new(type="pr", name = "informant") person.infos.desc = "This person knows about the bank roberry. Do a favor for him. He will help you." M.add_fact("not_asked", person) M.add_fact("not_given", person) alley.add(person) robber = M.new(type="rbr", name = "joker") bank2.add(robber) M.add_fact("not_stopped", robber) M.add_fact("not_conflict", robber) M.add_fact("not_allowed", robber) police = M.new(type="pl", name = "police") bank2.add(police) M.add_fact("not_called", police) # asking quest qst_event_asking = Event(conditions={M.new_fact("asked", person)}) quest_asking = Quest(win_events=[qst_event_asking], reward=2) # the wining quest qst_event_stopped_rob = Event(conditions={M.new_fact("asked", person), M.new_fact("stopped", robber)}) win_quest = Quest(win_events=[qst_event_stopped_rob], reward=2) # 1st failure condition failed_cmds1 = ["go east", "go south"] failed_event1 = M.new_event_using_commands(failed_cmds1) failed_quest_1 = Quest(win_events=[], fail_events=[failed_event1]) # 2nd failure condition failed_cmds2 = ["go east", "go east"] failed_event2 = M.new_event_using_commands(failed_cmds2) failed_quest_2 = Quest(win_events=[], fail_events=[failed_event2]) # 3rd failure condition failed_event3 = Event(conditions={ M.new_fact("not_asked", person), M.new_fact("at", M._entities['P'], bank2)}) failed_quest_3 = Quest(win_events=[], fail_events=[failed_event3]) failed_event4 = Event(conditions={ M.new_fact("allowed", robber)}) failed_quest_4 = Quest(win_events=[], fail_events=[failed_event4]) M.quests = [win_quest, quest_asking, failed_quest_1, failed_quest_2, failed_quest_3, failed_quest_4] game = M.build() game.main_quest = win_quest game_file = _compile_test_game(game) return game, game_file