Example #1
0
    def test_compatible(self):
        assert TWInform7.compatible(self.gamefile_ulx)
        assert TWInform7.compatible(self.gamefile_z8)

        # To be compatible, a game needs the .json alongside its z8/ulx file.
        gamefile_json = self.gamefile_z8.replace(".z8", ".json")
        shutil.move(gamefile_json, gamefile_json + ".bkp")
        assert not TWInform7.compatible(self.gamefile_ulx)
        assert not TWInform7.compatible(self.gamefile_z8)
        shutil.move(gamefile_json + ".bkp", gamefile_json)
    def test_missing_game_infos_file(self):
        with make_temp_directory() as tmpdir:
            for ext, env_class in [(".ulx", GitGlulxEnv), (".z8", JerichoEnv)]:
                gamefile = pjoin(tmpdir, "tmp" + ext)
                with open(gamefile, "w"):
                    pass  # Empty file

                env = TWInform7(env_class())
                npt.assert_raises(MissingGameInfosError, env.load, gamefile)
    def test_no_quest_game(self):
        game_name = "tw-no_quest_game"
        with make_temp_directory(prefix=game_name) as tmpdir:
            for ext, env_class in [(".ulx", GitGlulxEnv), (".z8", JerichoEnv)]:
                options = textworld.GameOptions()
                options.path = pjoin(tmpdir, game_name + ext)

                game, gamefile = testing.build_and_compile_no_quest_game(options)

                env = TWInform7(env_class())
                env.load(gamefile)
                game_state = env.reset()

                assert not game_state.game_ended
                game_state, _, done = env.step("look")
                assert not done
                assert not game_state.game_ended
Example #4
0
    def setUp(self):
        self.env_z8 = TWInform7(JerichoEnv(self.infos))
        self.env_z8.load(self.gamefile_z8)

        self.env_ulx = TWInform7(GitGlulxEnv(self.infos))
        self.env_ulx.load(self.gamefile_ulx)