RP Voting System
From OtherVerse Wiki
This system was coded using PennMUSH.
Part 1: Global System
@create Voting System 2.00
@link Voting System 2.00 = #0
@set Voting System 2.00 = ROYALTY
@set Voting System 2.00 = SAFE
@set Voting System 2.00 = WIZARD
@power Voting System 2.00 = Cemit
&BACKUP_CMD_SHEET Voting System 2.00=$+vote/sheet *:@select [setq(0,pmatch(%0))][u(fn_isadmin,%#)][t(%q0)] = 0*,{@pemit %#=[u(MSG_DENIED)]},10*,{@pemit %#=[u(MSG_NOTFOUND)]},11,{@pemit %#=[u(fn_line,Voting Details for [name(%q0)])]%R[u(fn_line,Commendations)][iter(u(fn_strip,get(v(V_DB)/COMMEND_%q0)),%R[ansi(hw,name(##))] [rest(elements(get(v(V_DB)/COMMEND_%q0),#@,|))])]%R[u(fn_line,Coaches)][iter(u(fn_strip,get(v(V_DB)/COACH_%q0)),%R[ansi(hw,name(##))] [rest(elements(get(v(V_DB)/COACH_%q0),#@,|))])]%R[u(fn_version)]
@set Voting System 2.00/BACKUP_CMD_SHEET=no_command
&CMD_ADMIN Voting System 2.00=$+vote/admin:@pemit %#=[if(u(fn_isadmin,%#),u(help_admin),Permission Denied)]
&CMD_BAN Voting System 2.00=$+vote/ban *:@select [setq(0,pmatch(%0))][u(fn_isadmin,%#)][t(%q0)] = 0*,{@pemit %#=[u(MSG_DENIED)]},10*,{@pemit %#=[u(MSG_NOTFOUND)]},11,{@pemit %#=[ansi(y,You have)] [ansi(r,banned)] [ansi(hy,name(%q0))] [ansi(y,from the voting system!)];&v_banned me=[setunion(v(V_BANNED),%q0)][u(fn_vreport,BAN,%#,%q0)]}
&CMD_BANNED Voting System 2.00=$+vote/banned:@pemit %#=[if(u(fn_isadmin,%#),The following players are banned from voting:%R[iter(v(V_BANNED),%R[ansi(hw,name(##))] ##)],[u(MSG_DENIED)])]
&CMD_CLEARCOACH Voting System 2.00=$+vote/clearcoach *:@select [setq(0,pmatch(%0))][u(fn_isadmin,%#)][t(%q0)] = 0*,{@pemit %#=[u(MSG_DENIED)]},10*,{@pemit %#=[u(MSG_NOTFOUND)]},11,{@pemit %#=[ansi(y,You have cleared all of the coaching data for)] [ansi(hy,name(%q0))][ansi(y,.)][u(fn_vreport,CLEARCOACH,%#,%q0)];@wipe [v(V_DB)]/COACH_%q0}
&CMD_COACH Voting System 2.00=$+vote/coach:@pemit %#=[ansi(y,Who do you want to coach?)]
&CMD_COACH2 Voting System 2.00=$+vote/coach *=*:@select [setq(0,pmatch(%0))][setq(1,edit(%1,|,%B))][setq(2,get(v(V_DB)/COACH_%q0))][t(%q0)][u(fn_canvote,%#)][u(fn_eligible,%q0)][not(u(fn_hascoached,%#,%q0))] = 1,{@pemit %#=[u(MSG_NOTFOUND)]},10*,{@pemit %#=[u(MSG_NOVOTE,%#)]},110*,{@pemit %#=[u(MSG_ELIGIBLE,%q0)]},1110*,{@pemit %#=[ansi(y,You have altered your coaching comment for)] [ansi(hy,name(%q0))] [ansi(y,to:)] [ansi(hy,%q1)].;&COACH_%q0 [v(V_DB)] = [replace(%q2,match(iter(%q2,first(##),|),%#),%# %q1,|)][u(fn_vreport,COACH_CHANGE,%#,%q0,%q1)]},1111,{@pemit %#=[ansi(y,You have coached)] [ansi(hy,name(%q0))] [ansi(y,with the following comment attached:)] [ansi(hy,%q1)];&COACH_%q0 [v(V_DB)] = [setunion(%q2,%# %q1,|)][u(fn_vreport,COACH,%#,%q0,%q1)]}
&CMD_COACHES Voting System 2.00=$+vote/coaches:@pemit %#=[setq(0,lattr(v(V_DB)/COACH_*))][setq(1,sortby(FN_VOTESORT,%q0))][if(u(fn_isadmin,%#),[iter(%q1,[ifelse(mod(dec(#@),2),,%r)][ljust([ansi(hg,words(get(v(V_DB)/##),|))] [ansi(hw,name(rest(##,_)))]<[rest(##,_)]>,30)])][if(not(%q0),ansi(hw,No coaches recorded.))],[u(msg_denied)])]
&CMD_COMMEND Voting System 2.00=$+vote/commend:@pemit %#=[ansi(y,Who do you want to commend?)]
&CMD_COMMEND2 Voting System 2.00=$+vote/commend *:@select [setq(0,pmatch(secure(%0)))][t(%q0)][u(fn_canvote,%#)][u(fn_eligible,%q0,%#)][not(u(fn_hascommended,%#,%q0))] = 1,{@pemit %#=[u(MSG_NOTFOUND)]},10*,{@pemit %#=[u(MSG_NOVOTE,%#)]},110*,{@pemit %#=[u(MSG_ELIGIBLE,%q0)]},1110*,{@pemit %#=[u(MSG_TWICE)]},1111,{@pemit %#=[ansi(y,You have voted for)] [ansi(hy,name(%q0))];&COMMEND_%q0 [v(V_DB)]=[setunion(get(v(V_DB)/COMMEND_%q0),%#,|)][u(fn_vreport,COMMEND,%#,%q0)];@mail %q0=You have received a vote for outstanding roleplay.}
&CMD_COMMEND3 Voting System 2.00=$+vote/commend *=*:@select [setq(0,pmatch(%0))][setq(1,edit(%1,|,%B))][setq(2,get(v(V_DB)/COMMEND_%q0))][t(%q0)][u(fn_canvote,%#)][u(fn_eligible,%q0,%#)][not(u(fn_hascommended,%#,%q0))] = 1,{@pemit %#=[u(MSG_NOTFOUND)]},10*,{@pemit %#=[u(MSG_NOVOTE,%#)]},110*,{@pemit %#=[u(MSG_ELIGIBLE,%q0)]},1110*,{@pemit %#=[ansi(y,You have altered your comment for)] [ansi(hy,name(%q0))] [ansi(y,to:)] [ansi(hy,%q1)].;&COMMEND_%q0 [v(V_DB)] = [replace(%q2,match(iter(%q2,first(##),|),%#),%# %q1,|)][u(fn_vreport,COMMEND_CHANGE,%#,%q0,%q1)]},1111,{@pemit %#=[ansi(y,You have voted for)] [ansi(hy,name(%q0))] [ansi(y,with the following comment attached:)] [ansi(hy,%q1)];&COMMEND_%q0 [v(V_DB)] = [setunion(%q2,%# %q1,|)][u(fn_vreport,COMMEND,%#,%q0,%q1)];@mail %q0=You have received a vote for outstanding roleplay.}
&CMD_COMMENDS Voting System 2.00=$+vote/commends:@pemit %#=[setq(0,lattr(v(V_DB)/COMMEND_*))][if(u(fn_isadmin,%#),[iter(%q0,[ifelse(mod(dec(#@),4),,%r)][ljust([ansi(hg,words(get(v(V_DB)/##),|))] [ansi(hw,name(rest(##,_)))],19)])],[u(msg_denied)])]
&CMD_CYCLESYSTEM Voting System 2.00=$+vote/cyclesystem:@select [hasflag(%#,WIZARD)] = 0,{@pemit %#=[u(MSG_DENIED)]},1,{@pemit %#=[u(fn_line,Cycling System\, [time()])];@dolist [setunion(iter(lattr(v(V_DB)),rest(##,_)),)] = {@pemit %#=[name(##)]: [words(get(v(V_DB)/COMMEND_##),|)] commends\, [words(get(v(V_DB)/COACH_##),|)] coaches: +[u(fn_reward,##)] XP \([get(##/SS_XP)]\);@mail ##=[time()] Voting Details/[u(fn_mail,##)];&SS_XP ##=[add(get(##/SS_XP),u(fn_reward,##))];@wipe [v(V_DB)]/COACH_##;@wipe [v(V_DB)]/COMMEND_##};@pemit %#=[u(fn_version)][u(fn_vreport,CYCLESYSTEM,%#,[num(me)])]}
&CMD_HELP Voting System 2.00=$+vote/help:@pemit %#=[u(fn_line,Help)]%r%r[ansi(w,The voting system is intended to ensure that outstanding roleplaying%Ris commended, and poor roleplaying pointed out and improved. Comments %Rshould be of substance. Only administrators and directors can view%Rwho you voted for. At the end of a voting cycle, your comments %R(but not the author) are visible to the person you commented on.)]%R[ansi(r,Please do not vote for your own characters.)]%R%R[ansi(hw,+vote/commend <player>%R+vote/commend <player>=<comment>)]%RPraise someone else for outstanding roleplaying. If a comment is%Rincluded, it counts as two votes. Use a player's alias (shown in <>%ron the who list and also listed in their +finger info) to +vote for%ra player with two-word names.%r[ansi(hw,+vote/uncommend <player>)]%rIn case you mistakingly commended someone with an inconveniently similar alias.%R%R[ansi(hw,+vote/coach <player>=<comment>)]%RRecommend coaching for poor roleplaying. A comment is required. Use a%rplayer's alias (shown in <> on the who list and also listed in their%r+finger info) to +vote for a player with two-word names.%r[ansi(hw,+vote/uncoach <player>)]%rIn case you mistakingly coached someone with an inconveniently similar alias.%R%R[ansi(hw,+vote/history)]%RSee your voting history for this cycle.%R[if(u(fn_isadmin,%#),%R[ansi(hw,+vote/admin)]%RView administrative commands.)]%R[u(fn_version)]
&CMD_HISTORY Voting System 2.00=$+vote/history:@pemit %#=[u(fn_line,Voting History for %N \(This Cycle\))]%R[u(fn_line,Commendations)][ulocal(fn_commends,%#)]%R[u(fn_line,Coaches)][ulocal(fn_coaches,%#)]%R[u(fn_version)]
&CMD_HISTORY2 Voting System 2.00=$+vote/history *:@select [setq(0,pmatch(%0))][u(fn_isadmin,%#)][t(%q0)] = 0*,{@pemit %#=[u(MSG_DENIED)]},10*,{@pemit %#=[u(MSG_NOTFOUND)]},11,{@pemit %#=[u(fn_line,Voting History for [name(%q0)] \(This Cycle\))]%R[u(fn_line,Commendations)][ulocal(fn_commends,%q0)]%R[u(fn_line,Coaches)][ulocal(fn_coaches,%q0)]%R[u(fn_version)]
&CMD_REVOKE Voting System 2.00=$+vote/revoke *:@select [setq(0,pmatch(%0))][setq(1,v(V_DB))][u(fn_isadmin,%#)][t(%q0)] = 0*,{@pemit %#=[u(MSG_DENIED)]},10*,{@pemit %#=[u(MSG_NOTFOUND)]},11,{@pemit %#=[ansi(y,You have)] [ansi(r,revoked)] [ansi(y,all of the votes cast by:)] [ansi(hy,name(%q0))][u(fn_vreport,REVOKE,%#,%q0)][iter(lattr(%q1),set(%q1,##:[ldelete(get(%q1/##),match(u(fn_strip,get(%q1/##)),%q0),|)]))]}
&CMD_SHEET Voting System 2.00=$+vote/sheet *:@select [setq(0,pmatch(%0))][u(fn_isadmin,%#)][t(%q0)] = 0*,{@pemit %#=[u(MSG_DENIED)]},10*,{@pemit %#=[u(MSG_NOTFOUND)]},11,{@pemit %#=[u(fn_line,Voting Details for [name(%q0)])]%R[u(fn_line,Commendations)][iter(ulocal(fn_strip,[get(v(V_DB)/COMMEND_%q0)]),%R[ansi(hw,name(##))] [rest(elements(escape(get(v(V_DB)/COMMEND_%q0)),#@,|))])]%R[u(fn_line,Coaches)][iter(ulocal(fn_strip,get(v(V_DB)/COACH_%q0)),%R[ansi(hw,name(##))] [rest(elements(get(v(V_DB)/COACH_%q0),#@,|))])]%R[u(fn_version)]
&CMD_UNBAN Voting System 2.00=$+vote/unban *:@select [setq(0,pmatch(%0))][u(fn_isadmin,%#)][t(%q0)] = 0*,{@pemit %#=[u(MSG_DENIED)]},10*,{@pemit %#=[u(MSG_NOTFOUND)]},11,{@pemit %#=[ansi(y,You have)] [ansi(g,unbanned)] [ansi(hy,name(%q0))][ansi(y,.)];&v_banned me=[setdiff(v(V_BANNED),%q0)][u(fn_vreport,UNBAN,%#,%q0)]}
&CMD_UNCOACH Voting System 2.00=$+vote/uncoach *:[setq(0,pmatch(%0))][if([not(%q0)],[pemit(%#,u(msg_notfound))],[setq(1,get(v(v_db)/coach_%q0))][setq(2,elements(%q1,match(%q1,%# *,|),|))][set(v(v_db),coach_%q0:[setdiff(%q1,%q2,|)])][pemit(%#,[ansi(y,You have wiped any coaching comments you may have made for [ansi(hy,name(%q0))].)])])]
&CMD_UNCOMMEND Voting System 2.00=$+vote/uncommend *:[setq(0,pmatch(%0))][if([not(%q0)],[pemit(%#,u(msg_notfound))],[setq(1,get(v(v_db)/commend_%q0))][setq(2,elements(%q1,match(%q1,%# *,|),|))][set(v(v_db),commend_%q0:[setdiff(%q1,%q2,|)])][pemit(%#,[ansi(y,You have wiped any commending comments you may have made for [ansi(hy,name(%q0))].)])])]
&CMD_VOTE Voting System 2.00=$+vote *:@pemit %#=[ansi(y,The command to vote for someone is +vote/commend <player>. See +vote/help.)]
&FN_BANNED Voting System 2.00=t(grab(v(V_BANNED),%0))
&FN_CANVOTE Voting System 2.00=not(or(hasflag(%0,UNREGISTERED),haspower(%0,Guest),t(grab(v(V_BANNED),%0))))
&FN_COACHES Voting System 2.00=[iter(lattr(v(V_DB)/COACH_*),[setq(0,get(v(V_DB)/##))][setq(1,u(fn_strip,%q0))][setq(2,match(%q1,%0))][if(t(%q2),%R[ansi(hw,name(rest(##,_)))] [rest(elements(%q0,%q2,|))])])]
&FN_COMMENDS Voting System 2.00=[iter(lattr(v(V_DB)/COMMEND_*),[setq(0,get(v(V_DB)/##))][setq(1,ulocal(fn_strip,%q0))][setq(2,match(%q1,%0))][if(t(%q2),%R[ansi(hw,name(rest(##,_)))] [rest(elements(%q0,%q2,|))])])]
&FN_COMMEND_VALUES Voting System 2.00=iter(%0,words([lit(##)]),|)
&FN_ELIGIBLE Voting System 2.00=and(not(or(hasflag(%0,WIZARD),hasflag(%0,ROYAL),hasflag(%0,UNREGISTERED),haspower(%0,guest))),not(match(%q0,%#)))
&FN_FIRST Voting System 2.00=first(%0)
&FN_HASCOACHED Voting System 2.00=[t(match(iter(get(v(V_DB)/COACH_%1),first([lit(##)]),|),%0))]
&FN_HASCOMMENDED Voting System 2.00=[t(match(iter(get(v(V_DB)/COMMEND_%1),first([lit(##)]),|),%0))]
&FN_ISADMIN Voting System 2.00=orflags(%0,Wr)
&FN_LINE Voting System 2.00=[ansi(g,==)] [ansi(hw,%0)] [ansi(g,[repeat(=,sub(66,strlen(%0)))])]
&FN_MAIL Voting System 2.00=[if(hasattr(v(V_DB),COMMEND_%0),A total of [ansi(hw,[words(get(v(V_DB)/COMMEND_%0),|)])] player\(s\) have voted for you. You have earned a prize of [ansi(hw,u(fn_reward,%0))] experience points. All comments are included\, but names are not listed: %R[iter(ulocal(fn_strip,[get(v(V_DB)/COMMEND_%0)]),%R[ansi(hw,#@)]: [rest(elements(escape(get(v(V_DB)/COMMEND_%0)),#@,|))])])]%R%R[if(hasattr(v(V_DB),COACH_%0),You have been recommended for coaching by [ansi(hw,[words(get(v(V_DB)/COACH_%0),|)])] player\(s\) with the following comments: %R[iter(ulocal(fn_strip,get(v(V_DB)/COACH_%0)),%R[ansi(hw,#@)]: [rest(elements(get(v(V_DB)/COACH_%0),#@,|))])])]%RThis is an automated message. If you have any questions\, talk to a member of the staff.
&FN_REWARD Voting System 2.00=[setq(0,0)][setq(1,iter([ulocal(fn_commend_values,[get(v(v_db)/COMMEND_%0)])],[setq(0,add(%q0,if(gt(##,1),5,2)))]))][squish(%q0)]
&FN_RLINE Voting System 2.00=[ansi(g,[repeat(=,sub(66,strlen(%0)))])] [ansi(hw,%0)] [ansi(g,==)]
&FN_STRIP Voting System 2.00=[iter(%0,[first([lit(##)])],|)]
&FN_VERSION Voting System 2.00=[u(fn_rline,name(me))]
&FN_VOTESORT Voting System 2.00=[comp(words(get(v(V_DB)/%0),|),words(get(v(V_DB)/%1,|))]
&FN_VREPORT Voting System 2.00=[cemit(voting,[ansi(c,<)][ansi(g,Voting)][ansi(c,>)] [ansi(hc,%0:)] [name(%1)] <[ansi(hw,%1)]> -> [name(%2)] <[ansi(hw,%2)]>[if(%3,\: %3)]
&HELP_ADMIN Voting System 2.00=[u(fn_line,Administrative Commands)]%RIt is important that the staff supervise this system to prevent abuse.%R[u(fn_line,Informational Commands)]%R[ansi(hw,+vote/sheet <player>)]%RSee who has voted for or against a player.%R%R[ansi(hw,+vote/history <player>)]%RView a player's voting history.%R%R[ansi(hw,+vote/commends)]%R[ansi(hw,+vote/coaches)]%RView a numerically sorted summary of all votes.%R%R[ansi(hw,+vote/banned)]%RView the list of banned players.%R[u(fn_line,Utility Commands)]%R[ansi(hw,+vote/revoke <player>)]%RUndo all of a player's votes.%R%R[ansi(hw,+vote/ban <player>)]%R[ansi(hw,+vote/unban <player>)]%RBanned players cannot vote -- a consequence of system abuse.%R%R[ansi(hw,+vote/cyclesystem)]%RDole out rewards for commendations and clear them.%R%R[ansi(hw,+vote/clearcoach <player>)]%RClear all of the coaches on player. Use when they are 'dealt with'.%R[u(fn_version)]
@MAILCURF Voting System 2.00=0
@set Voting System 2.00/MAILCURF=no_command wizard locked
&MSG_DENIED Voting System 2.00=[ansi(y,Permission Denied.)]
&MSG_ELIGIBLE Voting System 2.00=[ansi(hy,name(%0))] [ansi(y,is not eligible for voting.)]
&MSG_NOTFOUND Voting System 2.00=[ansi(y,Player not found.)]
&MSG_NOVOTE Voting System 2.00=[if(u(fn_banned,%0),[ansi(y,You have been banned from voting!)],[ansi(y,Only registered characters and staff may vote.)])]
&MSG_TWICE Voting System 2.00=[ansi(y,You cannot vote for or against someone twice! You can, however change your comment.)]
@set Voting System 2.00/V_BANNED=no_command
&V_DB Voting System 2.00=<DBREF # of object that holds the +vote comments.>
Part 2: +Vote Database
@create Voting DB
@tel Voting DB=<DBREF # of Voting System object>
