some fixes to voting, closes #7

master
Nathan Salapat 2021-01-09 10:22:12 -06:00
parent 9979ba5ae9
commit e30c000685
4 changed files with 44 additions and 14 deletions

View File

@ -1,9 +1,11 @@
Thanks for your interest in contributing to the project. In an attempt to keep things semi-cohesive throught here are a few things to keep in mind.
!!!AT THIS TIME NO TASKS ARE BEING ACCEPTED!!!
Thanks for your interest in contributing to the project. In an attempt to keep things semi-cohesive throughout here are a few things to keep in mind.
Code/Media
1. This isn't a resource collecting game, and there is no crafting, so recipes and craft items aren't needed.
2. Textures should be 32PX, please use global textures where possible. (check out lobby/nodes_passive.lua if you aren't sure what that looke like.)
2. Textures should be 32PX, please use global textures where possible. (check out lobby/nodes_passive.lua if you aren't sure what that looks like.)
3. 95% of all content will be in levels. This will hold all the building blocks save for the ones used in the lobby mod.
4. Task related content will go in the tasks mod. (Currently not accepting any tasks.)
4. Task related content will go in the tasks mod.
5. Lighting nodes go in the lights mod.
Game Levels
When building levels keep in mind that players don't know how much XP completing tasks yields. If you're putting the same task node in multiple places on the map please set them all to yield the same XP.

View File

@ -11,6 +11,15 @@ function lobby.send(name, msg)
return true
end
function lobby.message_to_level(map_id, message)
for _, player in pairs(minetest.get_connected_players()) do
local rname = player:get_player_name()
if lobby.game[rname] == map_id then
minetest.chat_send_player(rname, message)
end
end
end
minetest.register_on_chat_message(function(name, msg)
return lobby.send(name, msg)
end)
@ -24,7 +33,7 @@ minetest.register_chatcommand('survivors', {
end
})
minetest.register_chatcommand('msg', {
minetest.register_chatcommand('msg', { --Should only prevent private messages when playing, in lobby is fine.
description = 'prevents people from chatting',
func = function(name)
minetest.chat_send_player(name, 'Private messages are disabled here.')
@ -39,6 +48,21 @@ minetest.register_chatcommand('kick', {
local survivors = lobby.players_on_level(map_id)
local actual_votes = lobby.votes[map_id] or 0
if not lobby.voted[name] then
lobby.vote_timer[map_id] = 1800
minetest.register_globalstep(function(dtime)
print (lobby.vote_timer[map_id])
lobby.vote_timer[map_id] = lobby.vote_timer[map_id] - 1
if lobby.vote_timer[map_id] == 0 then
lobby.message_to_level(map_id, 'Voting time is over.')
lobby.vote(map_id, true)
elseif lobby.vote_timer[map_id] == 300 then
lobby.message_to_level(map_id, 'Thirty seconds left to vote.')
elseif lobby.vote_timer[map_id] == 600 then
lobby.message_to_level(map_id, 'One minute left to vote.')
elseif lobby.vote_timer[map_id] == 1200 then
lobby.message_to_level(map_id, 'Two minutes left to vote')
end
end)
if params == 'skip' then --players opts to not vote
minetest.chat_send_player(name, 'You skipped voting this round.')
lobby.voted[name] = true
@ -51,9 +75,9 @@ minetest.register_chatcommand('kick', {
lobby.votes[map_id] = actual_votes + 1
lobby.suspect[params] = lobby.suspect[params] + 1
lobby.vote(map_id)
else --player votes for an invalid username
minetest.chat_send_player(name, 'Check your spelling and try again.')
end
else --player votes for an invalid username
minetest.chat_send_player(name, 'Check your spelling and try again.')
end
else
minetest.chat_send_player(name, 'You can\'t vote right now.')

View File

@ -49,10 +49,10 @@ function lobby.update_maps(map_name)
end
end
function lobby.vote(map_id)
function lobby.vote(map_id, force)
local needed_votes = lobby.map[map_id] - 1
local actual_votes = lobby.votes[map_id]
if actual_votes >= needed_votes then
if actual_votes >= needed_votes or force then
--Reset vote status and kick player with the highest score.
local high_score = 0
local kick = ''
@ -67,21 +67,23 @@ function lobby.vote(map_id)
end
lobby.suspect[rname] = 0
player:set_physics_override({speed=1})
minetest.chat_send_player(rname, 'The votes are in, '..kick..' will be kicked.')
if kick == traitor then
lobby.team_win(map_id)
elseif needed_votes == 1 and kick ~= traitor then
elseif needed_votes == 2 and kick ~= traitor then
lobby.traitor_win(traitor, map_id)
end
end
end
player = minetest.get_player_by_name(kick)
if player ~= nil then
if kick ~= '' then
lobby.message_to_level(map_id, 'The votes are in, '..kick..' will be kicked.')
player = minetest.get_player_by_name(kick)
player:setpos({x=0, y=0, z=0})
local player_inv = player:get_inventory()
player_inv:set_list('main', {})
lobby.game[kick] = 'lobby'
lobby.update_maps(map_id)
else
lobby.message_to_level(map_id, 'Nobody was kicked this round.')
end
end
end
@ -104,6 +106,7 @@ function lobby.team_win(map_id)
end
function lobby.traitor_win(traitor, map_id)
local player = minetest.get_player_by_name(traitor)
lobby.corpse_removal(map_id)
minetest.chat_send_all('The traitor won this round on '..map_id..'.')
minetest.chat_send_player(traitor, 'CONGRATULATIONS!!! You killed all the crew!')

View File

@ -7,6 +7,7 @@ lobby.game = {} --Holds player names and what map they are on.
lobby.xp = {} --The current XP amount for each level.
lobby.traitors = {} --
lobby.corpses = {}
lobby.vote_timer = {}
--Yes I know these table names are not very clear.
--[[