- ;;--------------------------------------------------------------------------------
- ; Mtg-Temple Judge Script v1.0.0.1
- ; © LordHawk
- ; Last updated: 27.12.2008
- ;--------------------------------------------------------------------------------
- ; Updating
- ; You should update only if the Build specified in the header of the script
- ; differs from the one you are running.
- ; The updating is easy:
- ; 1. Back up any changes you've done to messages/colors/etc
- ; 2. Simply replace the script
- ; 3. Apply the backup changes
- ; 4. Run /initVars in irc
- ;--------------------------------------------------------------------------------
- ;--------------------------------------------------------------------------------
- ; This is Judge Script v1.0.0.1 menu which pops up when you right-click on the channel
- ; We specify "channel" menu, because it works with that 'popup' (click Popup tab
- ; and see View menu for more common 'popups'
- ; Syntax: [{<dropdown menu level>}<menu line>{:<alias>}]
- ; No dot means top-level, [.] is first level of dropdown menu [..] second, etc.
- ; Menu line is either a [-] horizontal delimiter or string or variable/expression
- ; that outputs a string/submenu. If that string is null, line is not displayed.
- ; Alias is a function, if its present and you click on that line, it would
- ; execute the alias, if no alias is specified, mIRC expects that line to be a
- ; title of following drop down menu
- ;--------------------------------------------------------------------------------
- menu channel {
- Mtg-Temple Judge Script v1.0.0.1
- .Start a New Tournament: createTournament
- .-
- .Start Quick Tournament
- ..$submenu($startQuickDisplay($1))
- .-
- .$submenu($startPresetsDisplay($1))
- .-
- .$submenu($extendEntriesDisplay($1))
- .-
- .$submenu($roundStartDisplay($1))
- .-
- .$submenu($extendRoundDisplay($1))
- .-
- .$submenu($remainingTimeDisplay($1))
- .-
- .$submenu($cancelTournamentDisplay($1))
- .-
- .$submenu($informNonReportedDisplay($1))
- .-
- .Continue Tournament (take over): continueTournament
- }
- ;--------------------------------------------------------------------------------
- ; Init alias (it is executed only once, when you click "Start a New Tournament")
- ; Syntax: [set %<variable name> <value>]; you should edit only values
- ; If you want to customize, edit statements below, save then type /initVars
- ;--------------------------------------------------------------------------------
- alias initVars {
- ; Formats
- ; There should be as many [%TCformat<number>] variables as %formats specifies
- set %TCformats 4
- set %TCformat1 Standard (T2)
- set %TCformat2 Extended (T1.X)
- set %TCformat3 Legacy (T1.5)
- set %TCformat4 Vintage (T1)
- set %TCformat5 Myos
- ; Default format (choose number from the above) when creating tournaments
- set %TCdefaultFormat 1
- ; Default gaming application 5=OCTGN, 6=OPT, 7=MWS
- set %TCdefaultApplication 7
- ; Default K-Value 9=Mini, 10=Temple Challenge, 11=Temple Open
- set %TCdefaultKValue 9
- ; Default maximum amount of participants 13=4, 14=8, 15=32 16=64 17=No Max
- set %TCdefaultMaxParticipants 13
- ; Default entires time 19=10, 20=15, 21=20 22=30
- set %TCdefaultEntriesTime 21
- ; Default tournament type 25=Single Elimination, 26=RFT
- set %TCdefaultTournamentType 25
- ; Default format category 28=Constructed 29=Sealed
- set %TCdefaultformatCategory 28
- ; Default time to repeat entries announcement (usually every 3 minutes)
- set %TCdefaultRepeatEntriesTime $calc(3 * 60)
- ; Default round length 31=45 32=50 33=60
- set %TCdefaultRoundLength 31
- ; Messages
- ; Feel free to change colors and text, do not touch the variables though
- ; If you are to set background (use comma in n,n) in %entriesNotice (or other
- ; such notices) you have to use variable (just like %entriesColor),
- ; because otherwise double evaluation would mess it up
- ; Footer
- ; set %poweredNotice 8,5Powered by Judge Script V1.0.0.1
- ; Entries are open
- set %entriesColor 1,4
- set %entriesNotice $+(%,entriesColor) Entries are open for a 8>>0 $+(%, tournamentName) 8<<1 Entries are open for $+(%,timeLeft) minutes or until the maximum amount of participants is reached. Join this tournament on the Home page of www.Magic-Temple.com! $+(%,poweredNotice)
- ; Cancelled tournament
- set %cancelledColor 15,5
- set %cancelledNotice $+(%,cancelledColor) Attention! 8>>0 $+(%, tournamentName) 8<<15 has been cancelled. Sorry for caused inconvenience. $+(%,poweredNotice)
- ; player vs player
- set %vsmessage 5*1 $+(%,player1) 5VS1 $+(%,player2) 5*
- ; player got a bye
- set %byemessage 5*1 $+(%,player1) got a bye 5*
- ; Round notices color
- set %roundColor 4,1
- ; Round timers
- set %roundBegin $+(%roundColor) You may begin playing the $+(%,roundName) of the 2>>1 $+(%, tournamentName) 2<<12 Check the pairings on the Home page of www.Magic-Temple.com. The round is $+(%,timeLeft) minutes long. You can type !Time in this channel to find out how much time there's left in the round. $+(%,poweredNotice)
- set %roundFinals $+(%roundColor) You may begin playing the Finals of the 2>>1 $+(%, tournamentName) 2<<12 Check the pairings on the Home page of www.Magic-Temple.com. The finals are untimed. $+(%,poweredNotice)
- set %roundgameloss $+(%roundColor) You have won game one of the $+(%,roundName) if your opponent hasn't shown up! 2>>1 $+(%, tournamentName) 2<<12 Questions -> 1#TempleJudge12. Please report result on the Home page of www.Magic-Temple.com! $+(%,poweredNotice)
- set %roundmatchloss $+(%roundColor) You have won the match of the $+(%,roundName) if your opponent hasn't shown up! 2>>1 $+(%, tournamentName) 2<<12 Questions -> 1#TempleJudge12. Please report result on the Home page of www.Magic-Temple.com! $+(%,poweredNotice)
- set %round20left $+(%roundColor) There are 20 minutes remaining in the $+(%,roundName) of the 2>>1 $+(%, tournamentName) 2<<12 Questions -> 1#TempleJudge12. Please report result on the Home page of www.Magic-Temple.com! $+(%,poweredNotice)
- set %round10left $+(%roundColor) There are 10 minutes remaining in the $+(%,roundName) of the 2>>1 $+(%, tournamentName) 2<<12 Questions -> 1#TempleJudge12. Please report result on the Home page of www.Magic-Temple.com! $+(%,poweredNotice)
- set %round5left $+(%roundColor) There are 5 minutes remaining in the $+(%,roundName) of the 2>>1 $+(%, tournamentName) 2<<12 Questions -> 1#TempleJudge12. Please report result on the Home page of www.Magic-Temple.com! $+(%,poweredNotice)
- set %roundTimeColor 4,1
- set %roundTime $+(%,roundTimeColor) TIME TIME TIME is over in the $+(%,roundName) of the 0>>8 $+(%, tournamentName) 0<<11 Active player finish turn and report result on the Home page of www.Magic-Temple.com! Questions -> 15#TempleJudge11 $+(%,poweredNotice)
- ; !time message
- set %timeLeftNoticeColor 15,5
- set %timeLeftNotice $+(%,timeLeftNoticeColor) There are $+(%,timeLeft) minutes remaining in the $+(%,roundName) of the 8>>0 $+(%, tournamentName) 8<<15 $+(%,poweredNotice)
- set %reportPleaseMessage 2,8 TIME IS OVER Start your 5 extra turns, Report when Finished!
- set %TCinit true
- ; Message that appears when you take over a tournament
- set %takeOverColor 15,5
- set %takeOverNotice $+(%,takeOverColor) Attention! 8>>0 $+(%, tournamentName) 8<<15 has been passed to new TC: $+($, me). $+(%,poweredNotice)
- }
- ;--------------------------------------------------------------------------------
- ; This alias displays "Tournament Options" dialog box and creates tournament
- ;--------------------------------------------------------------------------------
- alias createTournament {
- ; If init alias haven't been run yet, do so
- if (%TCinit != true) {
- initVars
- }
- ; Unset some temporary variables (in case something messed up)
- unset %tempCustomEntriesTime
- unset %tempChannel
- unset %tempCounter
- unset %tempCustomRoundLength
- ; Fetch channel we are clicking on
- set %tempChannel $chan
- ; Invoke tournament creation dialog window using table tournamentOptions
- var %result = $dialog(newTournamentDialog, tournamentOptions)
- ; Outputs the open entries message via timer
- if (%tempCreated == true) {
- unset %tempCreated
- entriesTimer %TCtournamentId
- }
- }
- ;--------------------------------------------------------------------------------
- ; Handles the entries timer
- ;--------------------------------------------------------------------------------
- alias entriesTimer {
- var %prefix = $+(%, TC, tournament, $1)
- var %timerId = $+(., timer, Entries, $1)
- var %entriesTime = $+(%prefix, entriesTime)
- displayEntries %channel $1
- ; Starts the countdown
- dec -z $eval(%entriesTime)
- var %repeatitions = $floor($calc(%entriesTime / %TCdefaultRepeatEntriesTime))
- if (%repeatitions > 0) {
- ; Invoke timer
- $eval(%timerId) %repeatitions %TCdefaultRepeatEntriesTime displayEntries $1
- }
- }
- ;--------------------------------------------------------------------------------
- ; Merely displays the open entries notice
- ;--------------------------------------------------------------------------------
- alias displayEntries {
- var %prefix = $+(%, TC, tournament, $1)
- var %tournamentName = $eval($+(%prefix, name), 2)
- var %channel = $eval($+(%prefix, channel), 2)
- var %timeLeft = $ceil($calc($eval($+(%prefix, entriesTime), 2) / 60))
- notice %channel $eval(%entriesNotice, 2)
- }
- ;--------------------------------------------------------------------------------
- ; "Tournament Options" dialog table (simply a layout scheme).
- ; Stuff here is mostly self-explanatory
- ;--------------------------------------------------------------------------------
- dialog tournamentOptions {
- title "Tournament Options"
- ; Coordinates, x = -1 y = -1 means its centered
- ; Next two coordinates determine width and height
- size -1 -1 121 184
- option dbu
- ; Syntax: [<element> "<text>", <element id>, <coordinates>{,<option>}]
- box "Specify or pick playing format", 1, 0 0 121 20
- edit "", 2, 1 8 59 11, autohs
- combo 3, 61 8 59 70, drop
- box "Choose application", 4 , 0 22 60 34, group
- radio "OCTGNv2", 5, 1 30 58 8
- radio "OPT", 6, 1 38 58 8
- radio "Magic Workstation", 7, 1 46 58 8
- box "K-Value", 8 , 61 22 60 34, group
- radio "Mini (K16)", 9, 62 30 58 8
- radio "Temple Challenge (K24)", 10, 62 38 58 8
- radio "Temple Open (K32)", 11, 62 46 58 8
- box "Maximum Participants", 12 , 0 56 60 50, group
- radio "4 Max", 13, 1 64 58 8
- radio "8 Max", 14, 1 72 58 8
- radio "32 Max", 15, 1 80 58 8
- radio "64 Max", 16, 1 88 58 8
- radio "No Max", 17, 1 96 58 8
- box "Entries open for:", 18 , 61 56 60 50, group
- radio "10 minutes", 19, 62 64 58 8
- radio "15 minutes", 20, 62 72 58 8
- radio "20 minutes", 21, 62 80 58 8
- radio "30 minutes", 22, 62 88 58 8
- radio "Custom", 23, 62 96 58 8
- box "Tournament Type", 24 , 0 106 60 26, group
- radio "Single Elimination", 25, 1 114 58 8
- radio "RFT", 26, 1 122 58 8
- box "Format Category", 27 , 61 106 60 26, group
- radio "Constructed", 28, 62 114 58 8
- radio "Sealed", 29, 62 122 58 8
- box "Round Length", 30 , 0 132 121 26, group
- radio "45 minutes", 31, 1 140 58 8
- radio "50 minutes", 32, 1 148 58 8
- radio "60 minutes", 33, 62 140 58 8
- radio "Custom", 34, 62 148 58 8
- check "Save as quick tournament", 35, 1 158 120 10
- button "Open entries", 36, 0 168 121 16
- }
- ;--------------------------------------------------------------------------------
- ; This event occurs "Tournament Options" dialog is created
- ; and assigns a couple of default variables to that dialog
- ;--------------------------------------------------------------------------------
- on *:dialog:newTournamentDialog:init:0: {
- ; step counter
- var %i = 1
- ; Simply step through all the format variables
- while (%i <= %TCformats) {
- ; Syntax: did -[flags] <dialog name> <element id> {number} {<value>}
- ; this alias modifies given element of given dialog with given value
- ; -a flag means add a line
- ; Value here is format variable, its composed using step counter, evaluated
- ; and then added to the dropdown list in "Tournament Options" dialog
- did -a newTournamentDialog 3 $eval($+(%, TCformat, %i), 2)
- ; increment step counter
- inc %i
- }
- ; Sets default format
- did -c newTournamentDialog 3 %TCdefaultFormat
- ; Sets default gaming application
- did -c newTournamentDialog %TCdefaultApplication
- ; Sets default tournament type
- did -c newTournamentDialog %TCdefaultKValue
- ; Sets default maximum amount of participants
- did -c newTournamentDialog %TCdefaultMaxParticipants
- ; Sets default entries time
- did -c newTournamentDialog %TCdefaultEntriesTime
- ; Sets default tournament type
- did -c newTournamentDialog %TCdefaultTournamentType
- ; Sets default format category
- did -c newTournamentDialog %TCdefaultFormatCategory
- ; Sets default round length
- did -c newTournamentDialog %TCdefaultRoundLength
- }
- ;--------------------------------------------------------------------------------
- ; This event occurs when you click on custom entries time radio button
- ; that asks you to enter value inbetween 4-60 minutes
- ;--------------------------------------------------------------------------------
- on *:dialog:newTournamentDialog:sclick:23: {
- ; Using local variable here, because while loop wouldn't work with global
- var %time = $$?="Specify entries time (4-60 minutes)"
- while (%time !isnum 4-60) {
- var %time = $$?="Specify entries time (4-60 minutes)"
- }
- ; Settting global after we're out of loop
- set %tempCustomEntriesTime %time
- }
- ;--------------------------------------------------------------------------------
- ; This event occurs when you click on custom entries round button
- ; that asks you to enter value inbetween 30-120 minutes
- ;--------------------------------------------------------------------------------
- on *:dialog:newTournamentDialog:sclick:34: {
- var %time = $$?="Specify round length (minutes)"
- while (%time !isnum 30-120) {
- var %time = $$?="Specify entries time (30-120 minutes)"
- }
- set %tempCustomRoundLength %time
- }
- ;--------------------------------------------------------------------------------
- ; This event occurs when you click on sealed radio button. It brings up a dialog
- ; that asks you to enter value inbetween 15-20 minutes
- ;--------------------------------------------------------------------------------
- on *:dialog:newTournamentDialog:sclick:29: {
- var %time = $$?="Specify deckbuilding time (15-20 minutes)"
- while (%time !isnum 15-20) {
- var %time = $$?="Specify deckbuilding time (15-20 minutes)"
- }
- set %TCsealedDeckbuildingTime %time
- }
- ;--------------------------------------------------------------------------------
- ; This event occurs when you click on Open Entries button
- ; It saves the data about tournament
- ;--------------------------------------------------------------------------------
- on *:dialog:newTournamentDialog:sclick:36: {
- ; As we created a new tournament, we increment the tournament counter and
- ; tournament id counter
- inc %TCtournaments
- inc %TCtournamentId
- ; Fetch selected (specified) format
- var %format = $iif($did(2).text, $did(2).text, $did(3).text)
- ; Fetch application
- var %i = 5
- while ( %i <= 7) {
- if ($did(%i).state == 1) {
- var %application = $did(%i ).text
- break
- }
- inc %i
- }
- ; Fetch K-Value
- var %i = 9
- while ( %i <= 11) {
- if ($did(%i).state == 1) {
- var %kvalue = $did(%i).text
- }
- inc %i
- }
- ; Fetch maximum participants
- var %i = 13
- while ( %i <= 17) {
- if ($did(%i).state == 1) {
- var %max = $did(%i).text
- }
- inc %i
- }
- ; Save tournament name string
- var %prefix = $+(%, TC, tournament, %TCtournamentId)
- var %tournamentName = $+(%prefix, name)
- var %name = %format %max %application %kvalue
- set $eval(%tournamentName) %name
- ; Save tournament type
- var %tournamentType = $+(%prefix, type)
- var %type = $iif($did(25).state, $did(25).text, $did(26).text)
- set $eval(%tournamentType) %type
- ; Save format category
- var %formatCategory = $+(%prefix, category)
- var %category = $iif($did(28).state, $did(28).text, $did(29).text)
- set $eval(%formatCategory) %category
- ; Save channel where tournament is created
- var %channel = $+(%prefix, channel)
- set $eval(%channel) %tempChannel
- ; Fetch entries time
- var %entriesTime = $+(%prefix, entriesTime)
- var %i = 19
- while (%i <= 22) {
- if ($did(%i).state == 1) {
- ; Convert string to integer and multiply it by 60 (minutes --> seconds)
- set $eval(%entriesTime) $calc($abs($did(%i).text) * 60)
- }
- inc %i
- }
- if ($did(23).state == 1) {
- if (%tempCustomEntriesTime) set $eval(%entriesTime) $calc(%tempCustomEntriesTime * 60)
- else set $eval(%entriesTime) $calc(15 * 60)
- unset %tempCustomEntriesTime
- }
- ; Fetch round length
- var %roundLength = $+(%prefix, roundLength)
- var %i = 31
- while (%i <= 33) {
- if ($did(%i).state == 1) {
- set $eval(%roundLength) $calc($abs($did(%i).text))
- }
- inc %i
- }
- if ($did(34).state == 1) {
- if (%tempCustomRoundLength) set $eval(%roundLength) $calc(%tempCustomRoundLength * 60)
- else set $eval(%roundLength) 45
- unset %tempCustomRoundLength
- }
- ; If "Save as Quick Tournament" checkbox clicked do so
- if ($did(35).state == 1) {
- inc %TCquickPresets
- var %prefix = $+(%, TC, tournament, Quick, %TCquickPresets)
- var %tournamentName = $+(%prefix, name)
- set $eval(%tournamentName) %name
- var %tournamentType = $+(%prefix, type)
- set $eval(%tournamentType) %type
- var %formatCategory = $+(%prefix, category)
- set $eval(%formatCategory) %category
- var %channel = $+(%prefix, channel)
- set $eval(%channel) %tempChannel
- var %time = $+(%prefix, entriesTime)
- set $eval(%time) $eval(%entriesTime, 2)
- var %length = $+(%prefix, roundLength)
- set $eval(%length) $eval(%roundLength, 2)
- }
- ; No longer needed
- unset %tempChannel
- ; Closes dialog with flag -x
- dialog -x newTournamentDialog tournamentOptions
- ; Temporary variable to inform startTournament alias that button was pressed
- set %tempCreated true
- }
- ;--------------------------------------------------------------------------------
- ; This alias outputs the submenu that displays the tournaments which entries have
- ; expired and may need the extension
- ;--------------------------------------------------------------------------------
- alias extendEntriesDisplay {
- if ($1 == begin) return -
- var %i = 1
- while (%i <= %TCtournamentId) {
- var %prefix = $+(%, TC, tournament, %i)
- var %round = $+(%prefix, round)
- var %name = $+(%prefix, name)
- var %timerId = $+(Entries, %i)
- if ($1 == %i) && ($eval(%name, 2)) && (!$timer(%timerId)) && (!$eval(%round, 2)) return [# $+ %i $+ ] Extend entries for $eval(%name) $+ : extendEntries %i
- else if ($1 == %i) return -
- inc %i
- }
- if ($1 == end) return -
- }
- ;--------------------------------------------------------------------------------
- ; Extends the entries
- ;--------------------------------------------------------------------------------
- alias extendEntries {
- var %time = $$?="Extend for (4-60 minutes)"
- while (%time !isnum 4-60) {
- var %time = $$?="Extend for (4-60 minutes)"
- }
- var %entriesTime = $+(%, TC, tournament, $1, entriesTime)
- set $eval(%entriesTime) $calc(%time * 60)
- entriesTimer $1
- }
- ;--------------------------------------------------------------------------------
- ; This alias outputs the submenu that displays the tournaments cancellation
- ;--------------------------------------------------------------------------------
- alias cancelTournamentDisplay {
- if ($1 == begin) return -
- var %i = 1
- while (%i <= %TCtournamentId) {
- var %prefix = $+(%, TC, tournament, %i)
- var %name = $+(%prefix, name)
- var %round = $+(%prefix, round)
- if (!$eval(%round, 2)) var %action Cancel
- else var %action End
- if ($1 == %i) && ($eval(%name, 2)) return [# $+ %i $+ ] %action $eval(%name) $+ : cancelTournament %i %action
- else if ($1 == %i) return -
- inc %i
- }
- if ($1 == end) return -
- }
- ;--------------------------------------------------------------------------------
- ; Cancels/ends the tournament
- ; Note that cancelling on entries step would cause the message to be displayed
- ; to players in the channel
- ;--------------------------------------------------------------------------------
- alias cancelTournament {
- ; Display the dialog asking confirmation
- if (!$input(Are you sure to $iif($2 == Cancel, cancel, end) this tournament?)) halt
- ; If its the latest created tournament decrement id counter
- if ($1 == %TCtournamentId) dec %TCtournamentId
- ; Decrement the amount tournaments counter
- dec %TCtournaments
- ; If there are no tournaments id goes to 0 too
- if (%TCtournaments == 0) set %TCtournamentId 0
- var %prefix = $+(%, TC, tournament, $1)
- var %tournamentName = $eval($+(%prefix, name), 2)
- if ($2 == Cancel) {
- ; Disable Entries timers
- var %timerId = $+(., timer, Entries, $1)
- $eval(%timerId) off
- ; Display the notice to players
- var %channel = $eval($+(%prefix, channel), 2)
- notice %channel $eval(%cancelledNotice, 2)
- }
- if ($2 == End) {
- ; Disable round timers
- var %timerId = $+(., timer, tournament, $1, round)
- $eval(%timerId) off
- ; Disable finals timers if so
- var %timerId = $+(., timer, tournament, $1, finals)
- $eval(%timerId) off
- echo -a 0,3* You have ended the >> %tournamentName << Don't forget to end it on the Home page of www.Magic-Temple.com too! *
- }
- var %prefix = $+(%, TC, tournament, $1, *)
- ; Unset everything that starts with a prefix
- unset $eval(%prefix)
- }
- ;--------------------------------------------------------------------------------
- ; This alias outputs the line that lets you start Quick Tournament (if its set)
- ;--------------------------------------------------------------------------------
- alias startQuickDisplay {
- if ($1 == begin) return -
- var %i = 1
- while (%i <= %TCquickPresets) {
- var %name = $+(%, TC, tournament, Quick, %i, name)
- if ($1 == %i) return Start $eval(%name) $+ : startQuickTournament %i
- else if ($1 == %i) return -
- inc %i
- }
- if ($1 == %i) && (%TCquickPresets) return ..Clear quick tournaments: ClearQuickTournaments
- if ($1 == end) return -
- }
- ;--------------------------------------------------------------------------------
- ; Starts quick tournament
- ;--------------------------------------------------------------------------------
- alias startQuickTournament {
- inc %TCtournaments
- inc %TCtournamentId
- var %prefix = $+(%, TC, tournament, %TCtournamentId)
- var %prefixQ = $+(%, TC, tournament, Quick, $1)
- var %tournamentQuickName = $+(%prefixQ, name)
- var %tournamentName = $+(%prefix, name)
- set $eval(%tournamentName) $eval(%tournamentQuickName, 2)
- var %tournamentQuickType = $+(%prefixQ, type)
- var %tournamentType = $+(%prefix, type)
- set $eval(%tournamentType) $eval(%tournamentQuickType, 2)
- var %tournamentQuickCategory = $+(%prefixQ, category)
- var %tournamentCategory = $+(%prefix, category)
- set $eval(%tournamentCategory) $eval(%tournamentQuickCategory, 2)
- var %channel = $+(%prefix, channel)
- set $eval(%channel) $chan
- var %tournamentQuickEntriesTime = $+(%prefixQ, entriesTime)
- var %tournamentEntriesTime = $+(%prefix, entriesTime)
- set $eval(%tournamentEntriesTime) $eval(%tournamentQuickEntriesTime, 2)
- var %tournamentQuickRoundLength = $+(%prefixQ, roundLength)
- var %tournamentRoundLength = $+(%prefix, roundLength)
- set $eval(%tournamentRoundLength) $eval(%tournamentQuickRoundLength, 2)
- entriesTimer %TCtournamentId
- }
- ;--------------------------------------------------------------------------------
- ; Erases every saved preset
- ;--------------------------------------------------------------------------------
- alias clearQuickTournaments {
- var %prefix = $+(%, TC, tournament, Quick, *)
- unset $eval(%prefix)
- unset %TCquickPresets
- }
- ;--------------------------------------------------------------------------------
- ; This alias displays the start round option
- ;--------------------------------------------------------------------------------
- alias roundStartDisplay {
- if ($1 == begin) return -
- var %i = 1
- while (%i <= %TCtournamentId) {
- var %prefix = $+(%, TC, tournament, %i)
- var %name = $+(%prefix, name)
- var %round = $+(%prefix, round)
- var %roundName = $eval($+(%prefix, roundName), 2)
- if ($1 == %i) && ($eval(%name, 2)) && (%roundName != Finals) return [# $+ %i $+ ] Start Round $calc(%round + 1) for $eval(%name, 2) $+ : roundStart %i
- else if ($1 == %i) return -
- inc %i
- }
- if ($1 == end) return -
- }
- ;--------------------------------------------------------------------------------
- ; Starts the round (posts pairings, executes timers)
- ;--------------------------------------------------------------------------------
- alias roundStart {
- var %prefix = $+(%, TC, tournament, $1)
- var %category = $eval($+(%prefix, category), 2)
- var %round = $+(%prefix, round)
- var %pairs = $+(%prefix, pairs)
- var %roundN $+(%prefix, roundName)
- ; Check if pairings are correct
- if ($eval(%round, 2)) || (%category != Sealed) {
- if (%type != Swiss) && ($eval(%pairs, 2)) {
- if ($eval(%pairs, 2) <= $cb(0)) {
- var %noPairings = true
- }
- }
- var %reg ([\w-\[\]]+)\svs\.\s([\w-\[\]]+)
- var %i = 1
- while (%i <= $cb(0)) {
- if (!$regex(match, $cb(%i), %reg)) {
- var %noPairings = true
- }
- inc %i
- }
- }
- ; Disable Entries timers if needed
- if (!$eval(%round, 2)) {
- var %entries = $+(%prefix, entriesTime)
- unset $eval(%entries)
- var %timerId = $+(., timer, Entries, $1)
- $eval(%timerId) off
- }
- ; Disable previous round timers if needed
- if ($eval(%round, 2)) {
- var %timerId = $+(., timer, tournament, $1, round)
- $eval(%timerId) off
- }
- ; Special deckbuilding round
- if (!$eval(%round, 2)) && (%category == Sealed) {
- set $eval(%roundN) Deckbuilding Round
- roundTimer $1 %TCsealedDeckbuildingTime
- }
- ; Regular round
- if ($eval(%round, 2)) || (%category != Sealed) {
- var %roundLength = $eval($+(%prefix, roundLength), 2)
- var %type = $eval($+(%prefix, type), 2)
- if (%category == Sealed) var %roundName Round $eval(%round, 2)
- else var %roundName Round $calc($eval(%round, 2) + 1)
- if (%type != Swiss) && (%noPairings != true) {
- if ($cb(0) <= 4) var %roundName Quaterfinals
- if ($cb(0) <= 2) var %roundName Semifinals
- if ($cb(0) == 1) var %roundName Finals
- set $eval(%pairs) $cb(0)
- }
- set $eval(%roundN) %roundName
- roundTimer $1 %roundLength
- ; Paste pairings in the channel
- set %tempCounter 1
- ; Using timer for antikick for flood
- if (%noPairings != true) .timerpairings -m $ceil($calc($cb(0) / 4)) 50 pairing $1
- }
- ; Round++
- inc $eval(%round)w
- unset %tempCounter
- }
- ;--------------------------------------------------------------------------------
- ; Anti-flood measure. This alias outputs pairings
- ;--------------------------------------------------------------------------------
- alias pairing {
- var %reg ([\w-\[\]]+)\svs\.\s([\w-\[\[]+)
- var %prefix = $+(%, TC, tournament, $1)
- var %channel = $eval($+(%prefix, channel), 2)
- var %i = 0
- while (%i <= 4) {
- var %regexp = $regex(match, $cb($calc(%tempCounter)), %reg)
- var %player1 = $regml(match, 1)
- var %player2 = $regml(match, 2)
- ; Anti excess floood measure
- if (%regexp) {
- if (%player2 != Bye) msg %channel $eval(%vsmessage, 2)
- else msg %channel $eval(%byemessage, 2)
- }
- inc %i
- inc %tempCounter
- }
- }
- ;--------------------------------------------------------------------------------
- ; Handles the round timer
- ;--------------------------------------------------------------------------------
- alias roundTimer {
- var %prefix = $+(%, TC, tournament, $1)
- var %roundCountdown = $+(%prefix, roundCountdown)
- var %tournamentName = $eval($+(%prefix, name), 2)
- var %channel = $eval($+(%prefix, channel), 2)
- var %timeLeft = $2
- var %roundName = $eval($+(%prefix, roundName), 2)
- if (%roundName != Finals) {
- var %timerId = $+(., timer, tournament, $1, round)
- set $eval(%roundCountdown) $2
- notice %channel $eval(%roundBegin, 2)
- ; Invoke timer call every minute
- $eval(%timerId) $2 $calc(1 * 60) roundNotices $1 %roundName
- }
- if (%roundName == Finals) {
- var %timerId = $+(., timer, tournament, $1, finals)
- set $eval(%roundCountdown) 15
- notice %channel $eval(%roundFinals, 2)
- $eval(%timerId) 15 $calc(1 * 60) roundFinals $1 %roundName
- }
- }
- ;--------------------------------------------------------------------------------
- ; Merely displays the round notices
- ;--------------------------------------------------------------------------------
- alias roundNotices {
- var %prefix = $+(%, TC, tournament, $1)
- var %tournamentName = $eval($+(%prefix, name), 2)
- var %channel = $eval($+(%prefix, channel), 2)
- var %roundLength = $eval($+(%prefix, roundLength), 2)
- dec $eval($+(%prefix, roundCountdown))
- var %timeLeft = $eval($+(%prefix, roundCountdown), 2)
- var %roundName = $eval($+(%prefix, roundName), 2)
- if ($calc(%roundLength - %timeleft) == 10) && (%roundLength > 29) notice %channel $eval(%roundgameloss, 2)
- if ($calc(%roundLength - %timeleft) == 15) && (%roundLength > 29) notice %channel $eval(%roundmatchloss, 2)
- if (%timeLeft == 20) notice %channel $eval(%round20left, 2)
- if (%timeLeft == 10) notice %channel $eval(%round10left, 2)
- if (%timeLeft == 5) notice %channel $eval(%round5left, 2)
- if (%timeLeft == 0) notice %channel $eval(%roundTime, 2)
- }
- ;--------------------------------------------------------------------------------
- ; Handles the finals notices
- ;--------------------------------------------------------------------------------
- alias roundFinals {
- var %prefix = $+(%, TC, tournament, $1)
- var %tournamentName = $eval($+(%prefix, name), 2)
- var %channel = $eval($+(%prefix, channel), 2)
- var %roundLength = $eval($+(%prefix, roundLength), 2)
- dec $eval($+(%prefix, roundCountdown))
- var %timeLeft = $eval($+(%prefix, roundCountdown), 2)
- var %roundName = $eval($+(%prefix, roundName), 2)
- if (%timeLeft == 5) {
- notice %channel $eval(%roundgameloss, 2)
- }
- if (%timeLeft == 0) {
- notice %channel $eval(%roundmatchloss, 2)
- endFinals $1
- }
- }
- ;--------------------------------------------------------------------------------
- ; Ends the finals
- ;--------------------------------------------------------------------------------
- alias endFinals {
- ; If its the latest created tournament decrement id counter
- if ($1 == %TCtournamentId) dec %TCtournamentId
- ; Decrement the amount tournaments counter
- dec %TCtournaments
- ; If there are no tournaments id goes to 0 too
- if (%TCtournaments == 0) set %TCtournamentId 0
- var %prefix = $+(%, TC, tournament, $1, *)
- ; Unset everything that starts with a prefix
- unset $eval(%prefix)
- ; Display that it ended
- echo -a 0,3* You have ended the tournament. Don't forget to end it on the Home page of www.Mtg-Temple.com too! *
- }
- ;--------------------------------------------------------------------------------
- ; Displays the time left if player types !time
- ;--------------------------------------------------------------------------------
- on 1:TEXT:!time:#:{
- var %i = 1
- while (%i <= %TCtournamentId) {
- var %prefix = $+(%, TC, tournament, %i)
- var %tournamentName = $eval($+(%prefix, name), 2)
- var %roundName = $eval($+(%prefix, roundName), 2)
- var %roundCountdown = $eval($+(%prefix, roundCountdown), 2)
- var %timeLeft = %roundCountdown
- var %channel = $eval($+(%prefix, channel), 2)
- var %timerId = $+(tournament, %i, round)
- if (%tournamentName) && ($chan == %channel) && ($timer(%timerId)) .notice $nick $eval(%timeLeftNotice, 2)
- inc %i
- }
- }
- ;--------------------------------------------------------------------------------
- ; Show remaining time
- ;--------------------------------------------------------------------------------
- alias showRemainingTime {
- var %i = 1
- while (%i <= %TCtournamentId) {
- var %prefix = $+(%, TC, tournament, %i)
- var %tournamentName = $eval($+(%prefix, name), 2)
- var %roundName = $eval($+(%prefix, roundName), 2)
- var %roundCountdown = $eval($+(%prefix, roundCountdown), 2)
- var %timeLeft = %roundCountdown
- var %timerId = $+(tournament, %i, round)
- if (%tournamentName) && ($timer(%timerId)) echo -a $eval(%timeLeftNotice, 2)
- inc %i
- }
- }
- ;--------------------------------------------------------------------------------
- ; This alias outputs the submenu that displays the tournaments which round
- ; expired and may need the extension
- ;--------------------------------------------------------------------------------
- alias extendRoundDisplay {
- if ($1 == begin) return -
- var %i = 1
- while (%i <= %TCtournamentId) {
- var %prefix = $+(%, TC, tournament, %i)
- var %round = $+(%prefix, round)
- var %name = $+(%prefix, name)
- var %timerId = $+(tournament, %i, round)
- var %timerFinalsId = $+(tournament, %i, finals)
- if ($1 == %i) && ($eval(%name, 2)) && (!$timer(%timerId)) && (!$timer(%timerFinalsId)) && ($eval(%round, 2)) return [# $+ %i $+ ] Extend round for $eval(%name) $+ : extendRound %i
- else if ($1 == %i) return -
- inc %i
- }
- if ($1 == end) return -
- }
- ;--------------------------------------------------------------------------------
- ; Extends the round
- ;--------------------------------------------------------------------------------
- alias extendRound {
- var %time = $$?="Extend for (1-25 minutes)"
- while (%time !isnum 1-25) {
- var %time = $$?="Extend for (1-25 minutes)"
- }
- var %prefix = $+(%, TC, tournament, $1)
- var %roundName = $+(%prefix, roundName)
- set $eval(%roundName) $eval(%roundName, 2) Extension
- roundTimer $1 %time
- }
- ;--------------------------------------------------------------------------------
- ; Displays submenu that lets you check the remaining time in all active
- ; tournaments
- ;--------------------------------------------------------------------------------
- alias remainingTimeDisplay {
- if ($1 == begin) return -
- var %prefix = $+(%, TC, tournament, %i)
- var %i = 1
- while (%i <= %TCtournamentId) {
- var %timerId = $+(tournament, %i, round)
- if ($timer(%timerId)) {
- var %active = true
- break
- }
- inc %i
- }
- if ($1 == 1) && (%active == true) return Show Remaining Time: showRemainingTime
- if ($1 == end) return -
- }
- ;--------------------------------------------------------------------------------
- ; This alias outputs the submenu that displays if you can trod the players
- ; who didn't report (just copy paste table from site)
- ;--------------------------------------------------------------------------------
- alias informNonReportedDisplay {
- if ($1 == begin) return -
- var %i = 1
- while (%i <= %TCtournamentId) {
- var %prefix = $+(%, TC, tournament, %i)
- var %round = $+(%prefix, round)
- var %name = $+(%prefix, name)
- var %timerId = $+(tournament, %i, round)
- var %timerFinalsId = $+(tournament, %i, finals)
- if ($1 == %i) && ($eval(%name, 2)) && (!$timer(%timerId)) && (!$timer(%timerFinalsId)) && ($eval(%round, 2)) return Inform the nonreported: informNonReported | break
- else if ($1 == %i) return -
- inc %i
- }
- if ($1 == end) return -
- }
- ;--------------------------------------------------------------------------------
- ; Parses the clipboard and messages all the players who did not report
- ;--------------------------------------------------------------------------------
- alias informNonReported {
- var %reg [\s]*[\w-\[\]]+[\s]*\(([\w-\[\]]+)\)[\s]*vs\.[\s]*[\w-\[\]]+[\s]*\(([\w-\[\]]+)\)[\s]*-[\s]*(TC|both|[\w-\[\]]+|)[\s]*
- var %i = 1
- while (%i <= $cb(0)) {
- if ($regex(match, $cb(%i), %reg)) {
- var %player1 = $regml(match, 1)
- var %player2 = $regml(match, 2)
- var %reportStatus = $regml(match, 3)
- if (%reportStatus != TC) && (%reportStatus != both) {
- if (%reportStatus == %player1) {
- .msg %player2 %reportPleaseMessage
- }
- if (%reportStatus == %player2) {
- .msg %player1 %reportPleaseMessage
- }
- if (%reportStatus != %player1) && (%reportStatus != %player2) {
- .msg %player2 %reportPleaseMessage
- .msg %player1 %reportPleaseMessage
- }
- }
- }
- inc %i
- }
- }
- ;--------------------------------------------------------------------------------
- ; This alias is rather simple and lets you to take over someone's tournament
- ;--------------------------------------------------------------------------------
- alias continueTournament {
- var %name = $$?="Specify tournament name"
- var %round = $$?="Specify round (1-n)"
- while (%round !isnum 1-30) {
- var %round = $$?="Specify round (1-n)"
- }
- var %timeLeft = $$?="Specify time left till end of round (1-45)"
- while (%timeLeft !isnum 1-45) {
- var %timeLeft = $$?="Specify time left till end of round (1-45)"
- }
- inc %TCtournaments
- inc %TCtournamentId
- var %prefix = $+(%, TC, tournament, %TCtournamentId)
- var %tournamentName = $+(%prefix, name)
- var %tournamentRound = $+(%prefix, round)
- var %roundCountdown = $+(%prefix, roundCountdown)
- var %roundName = $+(%prefix, roundName)
- var %roundLength = $+(%prefix, roundLength)
- var %channel = $+(%prefix, channel)
- set $eval(%tournamentName) %name
- set $eval(%tournamentRound) %round
- set $eval(%roundCountdown) %timeLeft
- set $eval(%channel) $chan
- set $eval(%roundLength) 45
- set $eval(%roundName) Round %round
- var %tournamentName = %name
- notice $chan $eval(%takeOverNotice, 2)
- var %timerId = $+(., timer, tournament, %TCtournamentId, round)
- ; Invoke timer call every minute
- $eval(%timerId) %timeLeft $calc(1 * 60) roundNotices %TCtournamentId %name
- }
