-
Notifications
You must be signed in to change notification settings - Fork 0
/
newDay.js
89 lines (79 loc) · 2.43 KB
/
newDay.js
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
async function calculateWeather(tables) {
let generalTable = game.tables.contents.find(t => t.name === tables.general);
let precipitationTable = game.tables.contents.find(t => t.name === tables.precipitation);
let windTable = game.tables.contents.find(t => t.name === tables.wind);
let generalRoll = await generalTable.roll()
let generalResult = generalRoll.results[0].data.text
let precipitationResult = null
if (
generalResult === "Rain" ||
generalResult === "Hail" ||
generalResult === "Thunderstorm" ||
generalResult === "Snow"
) {
let precipitationRoll = await precipitationTable.roll()
precipitationResult = precipitationRoll.results[0].data.text
}
let windRoll = await windTable.roll()
let windResult = windRoll.results[0].data.text
if (!precipitationResult) {
precipitationResult = "N/A"
}
let message = `
<h2> Weather for the new day </h2>
<br/>
<p>General - <strong>${generalResult}</strong></p>
<br/>
<p>Precipitation level - <strong>${precipitationResult}</strong></p>
<br/>
<p>Wind speed - <strong>${windResult}</strong></p><br/>`
let chatData = {
user: game.user.id,
content: message,
}
ChatMessage.create(chatData, {})
}
let weatherTables = {
Autumn: {
general: "General Weather - Autumn",
precipitation: "Precipitation - Autumn",
wind: "Wind - Autumn",
},
"Extreme Summer (Desert)": {
general: "General Weather - Extreme Summer (Desert)",
precipitation: "Precipitation - Extreme Summer (Desert)",
wind: "Wind - Extreme Summer (Desert)",
},
"Extreme Winter (North/Ice plains)": {
general: "General Weather - Extreme Winter (North/Ice plains)",
precipitation: "Precipitation - Extreme Winter (North/Ice plains)",
wind: "Wind - Extreme Winter (North/Ice plains)",
},
Spring: {
general: "General Weather - Spring",
precipitation: "Precipitation - Spring",
wind: "Wind - Spring",
},
Summer: {
general: "General Weather - Summer",
precipitation: "Precipitation - Summer",
wind: "Wind - Summer",
},
Winter: {
general: "General Weather - Winter",
precipitation: "Precipitation - Winter",
wind: "Wind - Winter",
}
}
let buttons = {}
for (const key in weatherTables) {
buttons[key] = {
label: key,
callback: () => calculateWeather(weatherTables[key])
}
}
new Dialog({
title: "What is the season/location?",
buttons,
}).render(true)
SimpleCalendar.api.changeDate({ day: 1 })