forked from Azure-Peak/Azure-Peak
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_statpacks.dm
More file actions
75 lines (64 loc) · 2.43 KB
/
_statpacks.dm
File metadata and controls
75 lines (64 loc) · 2.43 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
GLOBAL_LIST_EMPTY(statpacks)
/datum/statpack
/// Name of the statpack
var/name
/// Flavor description of the statpack (don't include stat totals in this, we'll render them automatically)
var/desc
/// An associative list of only the stats we're altering. The value can also be a list to signify a range of values - maximum length of 2 for these.
var/list/stat_array = list()
var/virtuous = FALSE
/datum/statpack/proc/get_stat_array(mob/living/carbon/human/recipient, mob/dead/new_player/new_player)
return stat_array
/datum/statpack/proc/apply_to_human(mob/living/carbon/human/recipient, mob/dead/new_player/new_player)
var/list/assigned_stat_array = get_stat_array(recipient, new_player)
if (recipient && recipient.mind)
var/list/applied_stats = list()
for (var/stat in assigned_stat_array)
if (!islist(assigned_stat_array[stat]))
var/value = assigned_stat_array[stat]
recipient.change_stat(stat, value)
applied_stats[stat] = value
else
var/list/stat_range = assigned_stat_array[stat]
var/value = rand(stat_range[1], stat_range[2])
recipient.change_stat(stat, value)
applied_stats[stat] = value
post_apply(recipient, new_player, applied_stats)
record_featured_object_stat(FEATURED_STATS_STATPACKS, name)
return TRUE
return FALSE
/datum/statpack/proc/post_apply(mob/living/carbon/human/recipient, mob/dead/new_player/new_player, list/applied_stats)
return
/datum/statpack/proc/description_string()
var/blurb = generate_modifier_string()
if (blurb)
return "[desc]<br> <i>[blurb]</i>"
else
return "[desc]"
/datum/statpack/proc/generate_modifier_string()
/// Generates a blurb string for use in preferences, programatically, based on our desc and stat alterations.
var/result
var/list/concat = list()
if (!LAZYLEN(stat_array))
return FALSE
for (var/stat in stat_array)
if (!islist(stat_array[stat]))
var/value = stat_array[stat]
var/modifier = ""
if (value >= 1)
modifier = "+"
var/statlabel = uppertext(copytext(stat, 1, 4))
var/blockstring = "[modifier][value] [statlabel]"
concat += blockstring
else
var/list/stat_range = stat_array[stat]
var/list/chunk_string = list()
for (var/sub_range in stat_range)
var/modifier = ""
if (sub_range >= 1)
modifier = "+"
chunk_string += "[modifier][sub_range]"
var/statlabel = uppertext(copytext(stat, 1, 4))
concat += "[chunk_string.Join(" to ")] [statlabel]"
result = "([concat.Join(", ")])"
return result