- Updated ingame polling to allow for polls that ask for player-entered text. This allows for more complex answers than a pick from a list.

- Added simple bump teleporters.
- Updated 3.0.0 some more, including the draft of a new Centcom.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4826 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
baloh.matevz
2012-10-07 21:08:23 +00:00
parent 8b5aaeb3b9
commit 2bf2f7bef8
4 changed files with 4378 additions and 3419 deletions

View File

@@ -230,10 +230,16 @@
src.poll_player(pollid)
return
if(href_list["votepollid"] && href_list["voteoptionid"])
if(href_list["votepollid"] && href_list["votetype"])
var/pollid = text2num(href_list["votepollid"])
var/optionid = text2num(href_list["voteoptionid"])
vote_on_poll(pollid, optionid)
var/votetype = href_list["votetype"]
switch(votetype)
if("OPTION")
var/optionid = text2num(href_list["voteoptionid"])
vote_on_poll(pollid, optionid)
if("TEXT")
var/replytext = href_list["replytext"]
log_text_poll_reply(pollid, replytext)
proc/IsJobAvailable(rank)
var/datum/job/job = job_master.GetJob(rank)

View File

@@ -111,18 +111,20 @@
dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
if(dbcon.IsConnected())
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question FROM erro_poll_question WHERE id = [pollid]")
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid]")
select_query.Execute()
var/pollstarttime = ""
var/pollendtime = ""
var/pollquestion = ""
var/polltype = ""
var/found = 0
while(select_query.NextRow())
pollstarttime = select_query.item[1]
pollendtime = select_query.item[2]
pollquestion = select_query.item[3]
polltype = select_query.item[4]
found = 1
break
@@ -130,57 +132,103 @@
usr << "\red Poll question details not found."
return
var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM erro_poll_vote WHERE pollid = [pollid] AND ckey = '[usr.ckey]'")
voted_query.Execute()
switch(polltype)
//Polls that have enumerated options
if("OPTION")
var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM erro_poll_vote WHERE pollid = [pollid] AND ckey = '[usr.ckey]'")
voted_query.Execute()
var/voted = 0
var/votedoptionid = 0
while(voted_query.NextRow())
votedoptionid = text2num(voted_query.item[1])
voted = 1
break
var/voted = 0
var/votedoptionid = 0
while(voted_query.NextRow())
votedoptionid = text2num(voted_query.item[1])
voted = 1
break
var/list/datum/polloption/options = list()
var/list/datum/polloption/options = list()
var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM erro_poll_option WHERE pollid = [pollid]")
options_query.Execute()
while(options_query.NextRow())
var/datum/polloption/PO = new()
PO.optionid = text2num(options_query.item[1])
PO.optiontext = options_query.item[2]
options += PO
var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM erro_poll_option WHERE pollid = [pollid]")
options_query.Execute()
while(options_query.NextRow())
var/datum/polloption/PO = new()
PO.optionid = text2num(options_query.item[1])
PO.optiontext = options_query.item[2]
options += PO
dbcon.Disconnect()
dbcon.Disconnect()
var/output = "<div align='center'><B>Player poll</B>"
output +="<hr>"
output += "<b>Question: [pollquestion]</b><br>"
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
var/output = "<div align='center'><B>Player poll</B>"
output +="<hr>"
output += "<b>Question: [pollquestion]</b><br>"
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
if(!voted) //Only make this a form if we have not voted yet
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
output += "<input type='hidden' name='src' value='\ref[src]'>"
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
if(!voted) //Only make this a form if we have not voted yet
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
output += "<input type='hidden' name='src' value='\ref[src]'>"
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
output += "<input type='hidden' name='votetype' value='OPTION'>"
output += "<table><tr><td>"
for(var/datum/polloption/O in options)
if(O.optionid && O.optiontext)
if(voted)
if(votedoptionid == O.optionid)
output += "<b>[O.optiontext]</b><br>"
else
output += "[O.optiontext]<br>"
output += "<table><tr><td>"
for(var/datum/polloption/O in options)
if(O.optionid && O.optiontext)
if(voted)
if(votedoptionid == O.optionid)
output += "<b>[O.optiontext]</b><br>"
else
output += "[O.optiontext]<br>"
else
output += "<input type='radio' name='voteoptionid' value='[O.optionid]'> [O.optiontext]<br>"
output += "</td></tr></table>"
if(!voted) //Only make this a form if we have not voted yet
output += "<p><input type='submit' value='Vote'>"
output += "</form>"
output += "</div>"
src << browse(output,"window=playerpoll;size=500x250")
//Polls with a text input
if("TEXT")
var/DBQuery/voted_query = dbcon.NewQuery("SELECT replytext FROM erro_poll_textreply WHERE pollid = [pollid] AND ckey = '[usr.ckey]'")
voted_query.Execute()
var/voted = 0
var/vote_text = ""
while(voted_query.NextRow())
vote_text = voted_query.item[1]
voted = 1
break
var/output = "<div align='center'><B>Player poll</B>"
output +="<hr>"
output += "<b>Question: [pollquestion]</b><br>"
output += "<font size='2'>Feedback gathering runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
if(!voted) //Only make this a form if we have not voted yet
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
output += "<input type='hidden' name='src' value='\ref[src]'>"
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
output += "<input type='hidden' name='votetype' value='TEXT'>"
output += "<font size='2'>Please provide feedback below. You can use any letters of the English alphabet, numbers and the symbols: . , ! ? : ; -</font><br>"
output += "<textarea name='replytext' cols='50' rows='14'></textarea>"
output += "<p><input type='submit' value='Submit'>"
output += "</form>"
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
output += "<input type='hidden' name='src' value='\ref[src]'>"
output += "<input type='hidden' name='votepollid' value='[pollid]'>"
output += "<input type='hidden' name='votetype' value='TEXT'>"
output += "<input type='hidden' name='replytext' value='ABSTAIN'>"
output += "<input type='submit' value='Abstain'>"
output += "</form>"
else
output += "<input type='radio' name='voteoptionid' value='[O.optionid]'> [O.optiontext]<br>"
output += "</td></tr></table>"
output += "[vote_text]"
if(!voted) //Only make this a form if we have not voted yet
output += "<p><input type='submit' value='Vote'>"
output += "</form>"
output += "</div>"
src << browse(output,"window=playerpoll;size=500x250")
src << browse(output,"window=playerpoll;size=500x500")
return
/mob/new_player/proc/vote_on_poll(var/pollid = -1, var/optionid = -1)
@@ -200,12 +248,14 @@
dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
if(dbcon.IsConnected())
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime")
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime")
select_query.Execute()
var/validpoll = 0
while(select_query.NextRow())
if(select_query.item[4] != "OPTION")
return
validpoll = 1
break
@@ -248,4 +298,70 @@
insert_query.Execute()
usr << "\blue Vote successful."
usr << browse(null,"window=playerpoll")
/mob/new_player/proc/log_text_poll_reply(var/pollid = -1, var/replytext = "")
if(pollid == -1 || replytext == "")
return
if(!isnum(pollid) || !istext(replytext))
return
var/user = sqlfdbklogin
var/pass = sqlfdbkpass
var/db = sqlfdbkdb
var/address = sqladdress
var/port = sqlport
var/DBConnection/dbcon = new()
dbcon.Connect("dbi:mysql:[db]:[address]:[port]","[user]","[pass]")
if(dbcon.IsConnected())
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime")
select_query.Execute()
var/validpoll = 0
while(select_query.NextRow())
if(select_query.item[4] != "TEXT")
return
validpoll = 1
break
if(!validpoll)
usr << "\red Poll is not valid."
return
var/alreadyvoted = 0
var/DBQuery/voted_query = dbcon.NewQuery("SELECT id FROM erro_poll_textreply WHERE pollid = [pollid] AND ckey = '[usr.ckey]'")
voted_query.Execute()
while(voted_query.NextRow())
alreadyvoted = 1
break
if(alreadyvoted)
usr << "\red You already sent your feedback for this poll."
return
var/adminrank = "Player"
if(usr && usr.client && usr.client.holder)
adminrank = usr.client.holder.rank
replytext = dd_replacetext(replytext, "%BR%", "")
replytext = dd_replacetext(replytext, "\n", "%BR%")
var/text_pass = reject_bad_text(replytext,8000)
replytext = dd_replacetext(replytext, "%BR%", "<BR>")
if(!text_pass)
usr << "The text you entered was blank, contained illegal characters or was too long. Please correct the text and submit again."
return
var/DBQuery/insert_query = dbcon.NewQuery("INSERT INTO erro_poll_textreply (id ,datetime ,pollid ,ckey ,ip ,replytext ,adminrank) VALUES (null, Now(), [pollid], '[usr.ckey]', '[usr.client.address]', '[replytext]', '[adminrank]')")
insert_query.Execute()
usr << "\blue Feedback logging successful."
usr << browse(null,"window=playerpoll")