Pokemon_server / dist /server /room-minor-activity.js.map
Jofthomas's picture
Jofthomas HF staff
Upload 4781 files
5c2ed06 verified
{
"version": 3,
"sources": ["../../server/room-minor-activity.ts"],
"sourcesContent": ["/**\n * Minor activities\n * Pokemon Showdown - http://pokemonshowdown.com/\n *\n * Minor activities are representations of non-game activities that rooms\n * regularly use, such as polls and announcements. Rooms are limited to\n * one minor activity at a time.\n *\n * Minor activities keep track of users in the form of userids and IPs.\n * If a player votes for a poll under one IP, they cannot vote for the same\n * poll again.\n *\n * The user-tracking system is not implemented at the base level: Announcements\n * do not have a reason to keep track of users' IPs/IDs because they're just used\n * to broadcast a message to a room.\n *\n * @license MIT\n */\n\nexport interface MinorActivityData {\n\treadonly activityid: 'announcement' | 'poll';\n\tactivityNumber?: number;\n\tsource?: string;\n\ttimeoutMins?: number;\n\ttimerEnd?: number;\n\tquestion: string;\n\tsupportHTML: boolean;\n\tmultiPoll: boolean;\n\tpendingVotes?: { [userid: string]: number[] };\n\tvoters?: { [k: string]: number[] };\n\tvoterIps?: { [k: string]: number[] };\n\ttotalVotes?: number;\n\tisQuiz?: boolean;\n\tanswers: string[] | { name: string, votes: number, correct?: boolean }[];\n}\n\n// globally Rooms.MinorActivity\nexport abstract class MinorActivity {\n\tabstract activityid: ID;\n\tabstract name: string;\n\n\ttimeout: NodeJS.Timeout | null;\n\ttimeoutMins: number;\n\ttimerEnd: number;\n\troomid: RoomID;\n\troom: Room;\n\tsupportHTML: boolean;\n\tconstructor(room: Room) {\n\t\tthis.timeout = null;\n\t\tthis.timeoutMins = 0;\n\t\tthis.timerEnd = 0;\n\t\tthis.roomid = room.roomid;\n\t\tthis.room = room;\n\t\tthis.supportHTML = false;\n\t}\n\n\tsetTimer(options: { timeoutMins?: number, timerEnd?: number }) {\n\t\tif (this.timeout) clearTimeout(this.timeout);\n\n\t\tthis.timeoutMins = options.timeoutMins || 0;\n\t\tif (!this.timeoutMins) {\n\t\t\tthis.timerEnd = 0;\n\t\t\tthis.timeout = null;\n\t\t\treturn;\n\t\t}\n\n\t\tconst now = Date.now();\n\t\tthis.timerEnd = options.timerEnd || now + this.timeoutMins * 60000;\n\t\tthis.timeout = setTimeout(() => {\n\t\t\tconst room = this.room;\n\t\t\tif (!room) return; // someone forgot to `.destroy()`\n\n\t\t\tthis.end(room);\n\t\t}, this.timerEnd - now);\n\t\tthis.save();\n\t}\n\n\tend(room: Room, MinorActivityClass?: new (...args: any[]) => any) {\n\t\troom.minorActivity?.destroy();\n\t\tif (room.minorActivityQueue?.length) {\n\t\t\tconst pollData = room.minorActivityQueue.shift()!;\n\t\t\tif (!room.minorActivityQueue.length) room.clearMinorActivityQueue();\n\t\t\tif (!room.settings.minorActivityQueue?.length) {\n\t\t\t\tdelete room.settings.minorActivityQueue;\n\t\t\t\troom.saveSettings();\n\t\t\t}\n\n\t\t\tif (pollData.activityid !== 'poll') throw new Error(`Unexpected Minor Activity (${pollData.activityid}) in queue`);\n\n\t\t\troom.add(`|c|~|/log ${room.tr`The queued poll was started.`}`).update();\n\t\t\troom.modlog({\n\t\t\t\taction: 'POLL',\n\t\t\t\tnote: '(queued)',\n\t\t\t});\n\n\t\t\tif (!MinorActivityClass) {\n\t\t\t\tif (pollData.activityid === 'poll') {\n\t\t\t\t\tconst { Poll } = require('./chat-plugins/poll');\n\t\t\t\t\troom.setMinorActivity(new Poll(room, pollData));\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\troom.setMinorActivity(new MinorActivityClass(room, pollData));\n\t\t\t}\n\t\t}\n\t}\n\n\tendTimer() {\n\t\tif (!this.timeout) return false;\n\t\tclearTimeout(this.timeout);\n\t\tthis.timeoutMins = 0;\n\t\tthis.timerEnd = 0;\n\t\treturn true;\n\t}\n\n\tabstract destroy(): void;\n\tabstract display(): void;\n\tonConnect?(user: User, connection: Connection | null): void;\n\tonRename?(user: User, oldid: ID, joining: boolean): void;\n\tabstract toJSON(): AnyObject;\n\tabstract save(): void;\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;A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