diff --git a/README.md b/README.md index 4b04d21..38fcfc7 100644 --- a/README.md +++ b/README.md @@ -16,14 +16,11 @@ Apart from the pure lua dependencies that are present in the repository, the gam These dependencies may have dependencies of their own. ## Building -There is a `CMakeLists.txt` for installing most of the dependencies and building the c code for the video export. It requires the following dependencies to work: +There is a `CMakeLists.txt` for building the c code for the video export. It requires the following dependencies to work: - cmake - make - gcc -- git -- libsodium - pkg config -- lua 5.1 - ffmpeg On debian-based distributions they can be installed with this command: @@ -33,9 +30,7 @@ apt install \ make \ g++ \ git \ - libsodium-dev \ pkg-config \ - liblua5.1-dev \ libavformat-dev \ libavcodec-dev \ libswresample-dev \ @@ -46,7 +41,7 @@ apt install \ On arch based distributions they can be installed with this line: ``` -pacman -S cmake make gcc git libsodium pkgconf lua51 ffmpeg +pacman -S cmake make gcc libsodium pkgconf ffmpeg ``` Then you can proceed with building ``` @@ -57,8 +52,6 @@ make install ``` The last command will put the libraries inside the repository folder where the game will find them (it will not attempt to put files in standard system directories). -Instead of `cmake ..` you may also run `cmake -DVIDEO_EXPORT=0 ..` to skip building the video encoder. - ## Server If you want to run a server with the web api you also need to install other dependencies. To install openssl headers on a debian-based distribution execute: `apt install libssl-dev`. @@ -66,7 +59,3 @@ On an arch based distribution you can use `pacman -S openssl`. Then install the lua modules using luarocks: `luarocks --lua-version 5.1 install luasec` To run the web api server with tls you need to set the environment variables `TLS_KEY` and `TLS_CERT` to point to their respective .pem files. - -## Tests -Run tests with `luajit test/main.lua` in the source directory. -Generate coverage statistics with `luajit test/main.lua --coverage` diff --git a/test/main.lua b/test/main.lua deleted file mode 100644 index ec414a6..0000000 --- a/test/main.lua +++ /dev/null @@ -1,32 +0,0 @@ -local search_names = { - "liblove-11.5.so", - "liblove.so", - "liblove-11.5.dll", - "liblove.dll", -} -local found = false -for i = 1, #search_names do - package.preload.love = package.loadlib(search_names[i], "luaopen_love") - if package.preload.love ~= nil then - found = true - break - end -end -assert(found, "could not find liblove") -package.preload.luv = package.loadlib("lib/luv.so", "luaopen_luv") - or package.loadlib("lib/luv.dll", "luaopen_luv") - or package.loadlib("lib/luv.dylib", "luaopen_luv") -require("love") -require("love.filesystem") -love.filesystem.init("ohtest") -love.filesystem.setIdentity("ohtest") -require("love.arg") -require("love.timer") -require("love.keyboard") -require("love.thread") -local newarg = { "test", "--pattern", "lua", "--exclude-pattern", "main.lua" } -for i = 1, #arg do - newarg[#newarg + 1] = arg[i] -end -arg = newarg -require("busted.runner")({ standalone = false }) diff --git a/test/replay.lua b/test/replay.lua deleted file mode 100644 index 06ec484..0000000 --- a/test/replay.lua +++ /dev/null @@ -1,75 +0,0 @@ -local Replay = require("game_handler.replay") - -describe("Replay files", function() - it("can be created", function() - local rp = Replay:new() - rp:set_game_data(21, { invincible = true }, true, "player", "somepack", "somelevel", { somesetting = 10 }) - rp:record_seed(2323) - rp:record_seed(23232) - rp:save("test_replay") - end) - it("can be loaded", function() - local rp = Replay:new("test_replay") - assert.is.equal(rp.game_version, 21) - assert.is_true(rp.data.config.invincible) - assert.is.equal(rp.data.level_settings.somesetting, 10) - assert.is.equal(rp.player_name, "player") - assert.is.equal(rp.pack_id, "somepack") - assert.is.equal(rp.level_id, "somelevel") - assert.is.equal(rp.data.seeds[1], 2323) - assert.is.equal(rp.data.seeds[2], 23232) - assert.is_true(rp.first_play) - end) - it("can save and load inputs", function() - local rp = Replay:new() - rp:set_game_data(192, { debug = true }, false, "player", "somepack", "somelevel", { somesetting = false }) - local to_record = { - [10] = { - left = true, - }, - [11] = { - right = true, - }, - [12] = { - right = false, - }, - [20] = { - left = false, - }, - [30] = { - right = true, - left = true, - }, - [35] = { - right = false, - left = false, - }, - } - -- order needs to be right - local keys = { 10, 11, 12, 20, 30, 35 } - for i = 1, #keys do - local time = keys[i] - local state = to_record[time] - for key, bool in pairs(state) do - rp:record_input(key, bool, time) - end - end - rp:save("test_replay") - local loaded_rp = Replay:new("test_replay") - assert.is.equal(loaded_rp.game_version, 192) - assert.is_true(loaded_rp.data.config.debug) - assert.is_false(loaded_rp.data.level_settings.somesetting) - assert.is.equal(loaded_rp.player_name, "player") - assert.is.equal(loaded_rp.pack_id, "somepack") - assert.is.equal(loaded_rp.level_id, "somelevel") - assert.is_false(loaded_rp.first_play) - for time, state in pairs(to_record) do - local state_changes = loaded_rp:get_key_state_changes(time) - for key, bool in pairs(state) do - local rp_key, rp_bool = state_changes() - assert.is.equal(key, rp_key) - assert.is.equal(bool, rp_bool) - end - end - end) -end)