forked from tgstation/tgstation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_vote.dm
59 lines (45 loc) · 1.72 KB
/
custom_vote.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/// The max amount of options someone can have in a custom vote.
#define MAX_CUSTOM_VOTE_OPTIONS 10
/datum/vote/custom_vote/single
name = "Custom Standard"
message = "Click here to start a custom vote (one selection per voter)"
/datum/vote/custom_vote/multi
name = "Custom Multi"
message = "Click here to start a custom multi vote (multiple selections per voter)"
count_method = VOTE_COUNT_METHOD_MULTI
// Custom votes ares always accessible.
/datum/vote/custom_vote/is_accessible_vote()
return TRUE
/datum/vote/custom_vote/reset()
default_choices = null
override_question = null
return ..()
/datum/vote/custom_vote/can_be_initiated(mob/by_who, forced = FALSE)
. = ..()
if(!.)
return FALSE
// Custom votes can only be created if they're forced to be made.
// (Either an admin makes it, or otherwise.)
return forced
/datum/vote/custom_vote/create_vote(mob/vote_creator)
override_question = tgui_input_text(vote_creator, "What is the vote for?", "Custom Vote")
if(!override_question)
return FALSE
default_choices = list()
for(var/i in 1 to MAX_CUSTOM_VOTE_OPTIONS)
var/option = tgui_input_text(vote_creator, "Please enter an option, or hit cancel to finish. [MAX_CUSTOM_VOTE_OPTIONS] max.", "Options", max_length = MAX_NAME_LEN)
if(!vote_creator?.client)
return FALSE
if(!option)
break
default_choices += capitalize(option)
if(!length(default_choices))
return FALSE
return ..()
/datum/vote/custom_vote/initiate_vote(initiator, duration)
. = ..()
. += "\n[override_question]"
// There are no winners or losers for custom votes
/datum/vote/custom_vote/get_winner_text(list/all_winners, real_winner, list/non_voters)
return "[span_bold("Did not vote:")] [length(non_voters)]"
#undef MAX_CUSTOM_VOTE_OPTIONS