mirror of
https://github.com/mt-mods/playerfactions.git
synced 2024-11-26 01:03:48 +01:00
add mtt support
This commit is contained in:
parent
607c6f8d1f
commit
b6f312b9db
15
.github/workflows/test.yml
vendored
Normal file
15
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
name: test
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: buckaroobanzay/mtt@main
|
||||||
|
with:
|
||||||
|
modname: playerfactions
|
||||||
|
git_dependencies: |
|
||||||
|
https://github.com/minetest-mods/areas.git
|
@ -4,5 +4,7 @@ globals = {
|
|||||||
|
|
||||||
read_globals = {
|
read_globals = {
|
||||||
"minetest",
|
"minetest",
|
||||||
"table"
|
"dump", "dump2",
|
||||||
|
"table",
|
||||||
|
"mtt",
|
||||||
}
|
}
|
||||||
|
7
init.lua
7
init.lua
@ -1,6 +1,9 @@
|
|||||||
-- Translation support
|
-- Translation support
|
||||||
local S = minetest.get_translator("playerfactions")
|
local S = minetest.get_translator("playerfactions")
|
||||||
|
|
||||||
|
-- For integration testing
|
||||||
|
local do_mtt = minetest.get_modpath("mtt") and mtt.enabled
|
||||||
|
|
||||||
-- Data
|
-- Data
|
||||||
factions = {}
|
factions = {}
|
||||||
-- This variable "version" can be used by other mods to check the compatibility of this mod
|
-- This variable "version" can be used by other mods to check the compatibility of this mod
|
||||||
@ -541,4 +544,8 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if do_mtt then
|
||||||
|
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/mtt.lua")
|
||||||
|
end
|
||||||
|
|
||||||
print("[playerfactions] loaded")
|
print("[playerfactions] loaded")
|
||||||
|
1
mod.conf
1
mod.conf
@ -1,2 +1,3 @@
|
|||||||
name = playerfactions
|
name = playerfactions
|
||||||
min_minetest_version = 5.9.0
|
min_minetest_version = 5.9.0
|
||||||
|
optional_depends = mtt
|
||||||
|
111
mtt.lua
Normal file
111
mtt.lua
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
local pd = function(...) print(dump(table.pack(...))) end
|
||||||
|
|
||||||
|
mtt.register('join players', function(callback)
|
||||||
|
pd(
|
||||||
|
mtt.join_player('Endor'),
|
||||||
|
mtt.join_player('Albert'),
|
||||||
|
mtt.join_player('Gandalf'),
|
||||||
|
mtt.join_player('HanSolo')
|
||||||
|
)
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
|
||||||
|
mtt.register('some players leave', function(callback)
|
||||||
|
pd(
|
||||||
|
mtt.leave_player('Albert'),
|
||||||
|
mtt.leave_player('Gandalf')
|
||||||
|
)
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
|
||||||
|
mtt.register('make factions with backend', function(callback)
|
||||||
|
pd(
|
||||||
|
factions.register_faction('Endorian', 'Endor', 'eEe'),
|
||||||
|
factions.register_faction('Alberian', 'Albert', 'a'),
|
||||||
|
factions.register_faction('Gandalfian', 'Gandalf', 'GgG♥💩☺')
|
||||||
|
)
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
|
||||||
|
mtt.register('basic db checks', function(callback)
|
||||||
|
local facts = factions.get_facts()
|
||||||
|
assert('table' == type(facts))
|
||||||
|
assert('table' == type(facts.Alberian))
|
||||||
|
assert('Albert' == facts.Alberian.owner)
|
||||||
|
assert('Alberian' == facts.Alberian.name)
|
||||||
|
assert('table' == type(facts.Alberian.members))
|
||||||
|
assert(true == facts.Alberian.members.Albert)
|
||||||
|
assert('8b2713b352c6fa2d22272a91612fba2f87d0c01885762a1522a7b4aec5592a80'
|
||||||
|
== facts.Endorian.password256)
|
||||||
|
assert('ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb'
|
||||||
|
== facts.Alberian.password256)
|
||||||
|
assert('3bfe911604e3fb079ad535a0c359a8457aea39d663bb4f21648842e3a4eaccf9'
|
||||||
|
== facts.Gandalfian.password256)
|
||||||
|
assert(nil == facts.Gandalfian.password)
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
|
||||||
|
mtt.register('backend functions', function(callback)
|
||||||
|
-- player_is_in_faction
|
||||||
|
assert(false == factions.player_is_in_faction(
|
||||||
|
'notExistingFaction', 'notExistingPlayer'))
|
||||||
|
assert(false == factions.player_is_in_faction(
|
||||||
|
'notExistingFaction', 'Gandalf'))
|
||||||
|
assert(false == factions.player_is_in_faction(
|
||||||
|
'Gandalfian', 'notExistingPlayer'))
|
||||||
|
assert(nil == factions.player_is_in_faction(
|
||||||
|
'Gandalfian', 'Albert'))
|
||||||
|
assert(true == factions.player_is_in_faction(
|
||||||
|
'Gandalfian', 'Gandalf'))
|
||||||
|
|
||||||
|
-- get_player_faction (depricated)
|
||||||
|
assert(false == factions.get_player_faction('notExistingPlayer'))
|
||||||
|
assert(nil == factions.get_player_faction('HanSolo'))
|
||||||
|
assert('Alberian' == factions.get_player_faction('Albert'))
|
||||||
|
|
||||||
|
-- get_player_factions
|
||||||
|
assert(false == factions.get_player_factions(nil))
|
||||||
|
assert(false == factions.get_player_factions(42))
|
||||||
|
assert(false == factions.get_player_factions('notExistingPlayer'))
|
||||||
|
assert(false == factions.get_player_factions('HanSolo'))
|
||||||
|
assert('Alberian' == factions.get_player_factions('Albert')[1])
|
||||||
|
|
||||||
|
-- get_owned_factions
|
||||||
|
assert(false == factions.get_owned_factions(nil))
|
||||||
|
assert(false == factions.get_owned_factions(42))
|
||||||
|
assert(false == factions.get_owned_factions('notExistingPlayer'))
|
||||||
|
assert(false == factions.get_owned_factions('HanSolo'))
|
||||||
|
assert('Alberian' == factions.get_owned_factions('Albert')[1])
|
||||||
|
|
||||||
|
-- get_administered_factions
|
||||||
|
-- get_owner
|
||||||
|
-- chown
|
||||||
|
-- register_faction (partly tested in setup)
|
||||||
|
-- disband_faction (partly tested in setup)
|
||||||
|
-- hash_password (tested in basic db checks)
|
||||||
|
-- valid_password
|
||||||
|
-- get_password (depricated)
|
||||||
|
-- set_password
|
||||||
|
-- join_faction
|
||||||
|
-- leave_faction
|
||||||
|
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
|
||||||
|
mtt.register('intermediate db checks', function(callback)
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
|
||||||
|
mtt.register('frontend functions', function(callback)
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
|
||||||
|
mtt.register('final db checks', function(callback)
|
||||||
|
callback()
|
||||||
|
end)
|
||||||
|
|
||||||
|
mtt.register('foo bar', function(callback)
|
||||||
|
pd(factions.get_facts())
|
||||||
|
print('total success')
|
||||||
|
callback()
|
||||||
|
end)
|
Loading…
Reference in New Issue
Block a user