Remove GUI1 MP tests

This commit is contained in:
Celtic Minstrel 2016-11-11 17:28:21 -05:00
parent c630ee2fc1
commit 5c57f25ce7
3 changed files with 0 additions and 296 deletions

123
host.lua
View file

@ -1,123 +0,0 @@
-- host.lua --
-- Try to host a game called "Test"
local function plugin()
local function log(text)
std_print("host: " .. text)
end
local counter = 0
local events, context, info
local helper = wesnoth.require("lua/helper.lua")
local function idle_text(text)
counter = counter + 1
if counter >= 100 then
counter = 0
log("idling " .. text)
end
end
log("hello world")
wesnoth.preferences.new_mp_ui = false
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for titlescreen or lobby")
until info.name == "titlescreen" or info.name == "Multiplayer Lobby"
local tries = 0
while info.name == "titlescreen" and tries < 100 do
context.play_multiplayer({})
tries = tries + 1
log("playing multiplayer...")
events, context, info = coroutine.yield()
end
if info.name == "titlescreen" then
context.exit({code = 1})
coroutine.yield()
end
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for lobby")
until info.name == "Multiplayer Lobby"
context.chat({message = "hosting"})
log("creating a game")
context.create({})
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for create")
until info.name == "Multiplayer Create"
context.select_type({type = "scenario"})
local s = info.find_level({id = "test1"})
if s.index < 0 then
log(" error: Could not find scenario with id=test1")
end
context.select_level({index = s.index})
events, context, info = coroutine.yield()
log("configuring a game")
context.create({})
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for configure")
until info.name == "Multiplayer Configure"
context.set_name({name = "Test"})
log("hosting a game")
context.launch({})
ready = nil
repeat
events, context, info = coroutine.yield()
for i,v in ipairs(events) do
if v[1] == "chat" then
std_print(events[i][2])
if v[2].message == "ready" then
ready = true
end
end
end
idle_text("in " .. info.name .. " waiting for ready in chat")
until ready
log("starting game...")
context.chat({message = "starting"})
context.launch({})
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for game")
until info.name == "Game"
log("got to a game context...")
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for not game")
until info.name ~= "Game"
log("left a game context...")
repeat
context.quit({})
log("quitting a " .. info.name .. " context...")
events, context, info = coroutine.yield()
until info.name == "titlescreen"
context.exit({code = 0})
coroutine.yield()
end
return plugin

152
join.lua
View file

@ -1,152 +0,0 @@
-- join.lua --
-- Try to join a game called "Test"
local function plugin()
local function log(text)
std_print("join: " .. text)
end
local counter = 0
local events, context, info
local helper = wesnoth.require("lua/helper.lua")
local function find_test_game(info)
local g = info.game_list()
if g then
local gamelist = helper.get_child(g, "gamelist")
if gamelist then
for i = 1, #gamelist do
local t = gamelist[i]
if t[1] == "game" then
local game = t[2]
if game.scenario == "Test" then
return game.id
end
end
end
end
end
return nil
end
local function idle_text(text)
counter = counter + 1
if counter >= 100 then
counter = 0
log("idling " .. text)
end
end
log("hello world")
wesnoth.preferences.new_mp_ui = false
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for titlescreen or lobby")
until info.name == "titlescreen" or info.name == "Multiplayer Lobby"
local tries = 0
while info.name == "titlescreen" and tries < 100 do
context.play_multiplayer({})
tries = tries + 1
log("playing multiplayer...")
events, context, info = coroutine.yield()
end
if info.name == "titlescreen" then
context.exit({code = 1})
coroutine.yield()
end
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for lobby")
until info.name == "Multiplayer Lobby"
events, context, info = coroutine.yield()
context.chat({message = "waiting for test game to join..."})
local test_game = nil
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for test game")
for i,v in ipairs(events) do
if v[1] == "chat" then
std_print("chat:", v[2].message)
end
end
test_game = find_test_game(info)
until test_game
log("found a test game, joining... id = " .. test_game)
context.chat({message = "found test game"})
context.select_game({id = test_game})
events, context, info = coroutine.yield()
context.join({})
events, context, info = coroutine.yield()
while not (info.name == "Dialog" or info.name == "Multiplayer Wait") do
if context.join then
context.join({})
else
std_print("did not find join...")
end
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for leader select dialog")
end
if info.name == "Dialog" then
log("got a leader select dialog...")
context.skip_dialog({})
events, context, info = coroutine.yield()
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for mp wait")
until info.name == "Multiplayer Wait"
end
log("got to multiplayer wait...")
context.chat({message = "ready"})
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for game")
until info.name == "Game"
log("got to a game context...")
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for the last scenario")
until info.scenario_name ~= nil and info.scenario_name().scenario_name == "Multiplayer Unit Test test2"
repeat
events, context, info = coroutine.yield()
idle_text("in " .. info.name .. " waiting for not game")
until info.name ~= "Game"
log("left a game context...")
repeat
context.quit({})
log("quitting a " .. info.name .. " context...")
events, context, info = coroutine.yield()
until info.name == "titlescreen"
context.exit({code = 0})
coroutine.yield()
end
return plugin

View file

@ -1,21 +0,0 @@
#!/bin/bash
set -e #Error if any line errors
set -m #Enable job control
set -v #Print shell commands as they are read
./wesnothd --port 12345 --log-debug=server --log-warning=config &
serverpid=$!
./wesnoth --plugin=host.lua --server=localhost:12345 --username=host --nogui --mp-test --noaddons &
hostpid=$!
./wesnoth --plugin=join.lua --server=localhost:12345 --username=join --nogui --mp-test --noaddons &
joinpid=$!
wait $hostpid
wait $joinpid
kill $serverpid
exit 0