-
Notifications
You must be signed in to change notification settings - Fork 0
/
textReading.js
165 lines (149 loc) · 7.11 KB
/
textReading.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
document.addEventListener("DOMContentLoaded", function() {
const generateReadingButton = document.getElementById('generate-reading');
generateReadingButton.addEventListener('click', setup);
});
function setup() {
const readingContainer = document.getElementById('reading-container');
const seed = 12345; // Fixed seed for simplicity
const reading = generateReadingFromSeed(seed);
readingContainer.innerText = reading;
}
function generateReadingFromSeed(seed) {
const seed1 = seed;
const seed2 = seed + 1;
const attributes = generateRandomAttributes(seed1, seed2);
return generateReading(
attributes.border,
attributes.flower,
attributes.sky,
attributes.phase,
attributes.clouds,
attributes.architecture,
attributes.symbol
);
}
function seededRandom(seed) {
const x = Math.sin(seed++) * 10000;
return x - Math.floor(x);
}
function getRandomElement(arr, seed) {
const randomIndex = Math.floor(seededRandom(seed) * arr.length);
return arr[randomIndex];
}
function generateRandomAttributes(seed1, seed2) {
const borderColors = Object.keys(borderElements.colors);
const flowers = Object.keys(borderElements.flowers);
const skies = Object.keys(backgroundElements.sky);
const moonPhases = Object.keys(backgroundElements.moonPhases);
const sunPositions = Object.keys(backgroundElements.sunPositions);
const clouds = Object.keys(backgroundElements.clouds);
const architectures = ["internal", "external", "relationship"];
const symbolKeys = Object.keys(symbols);
return {
border: getRandomElement(borderColors, seed1),
flower: getRandomElement(flowers, seed1 + 1),
sky: getRandomElement(skies, seed1 + 2),
phase: getRandomElement(seed1 % 2 === 0 ? moonPhases : sunPositions, seed1 + 3),
clouds: getRandomElement(clouds, seed2),
architecture: getRandomElement(architectures, seed2 + 1),
symbol: getRandomElement(symbolKeys, seed2 + 2)
};
}
const symbols = {
lightning: { meanings: ["chaos"], trait: "negative" },
handsTogether: { meanings: ["intimacy"], trait: "positive" },
handsApart: { meanings: ["distance"], trait: "negative" },
book: { meanings: ["wisdom"], trait: "positive" },
closedBook: { meanings: ["naivety"], trait: "negative" },
swordUp: { meanings: ["strength"], trait: "positive" },
swordDown: { meanings: ["authority"], trait: "neutral" },
swordsCrossed: { meanings: ["conflict"], trait: "negative" },
treeBaby: { meanings: ["new growth", "beginnings"], trait: "positive" },
treeFull: { meanings: ["abundance", "maturity"], trait: "positive" },
deadTree: { meanings: ["endings", "decay"], trait: "negative" },
rose: { meanings: ["love"], trait: "positive" },
roseWithThorns: { meanings: ["love with challenges"], trait: "neutral" },
eyes: { meanings: ["awareness", "perception"], trait: "neutral" },
road: { meanings: ["freedom"], trait: "positive" },
flowerOpen: { meanings: ["openness", "blossoming"], trait: "positive" },
flowerClosed: { meanings: ["protection", "potential"], trait: "neutral" },
scales: { meanings: ["balance"], trait: "positive" },
scalesImbalance: { meanings: ["imbalance"], trait: "negative" },
closedHand: { meanings: ["resistance"], trait: "negative" },
tear: { meanings: ["grief", "sadness"], trait: "negative" },
oliveBranch: { meanings: ["peace", "reconciliation"], trait: "positive" },
butterfly: { meanings: ["transformation", "change"], trait: "positive" },
openHand: { meanings: ["faith", "trust"], trait: "positive" },
key: { meanings: ["security", "restriction"], trait: "neutral" }
};
const backgroundElements = {
sky: {
night: "a long-term journey",
day: "a short-term phase"
},
moonPhases: {
new: "new beginnings",
wax: "building momentum",
full: "culmination of efforts",
wane: "letting go"
},
sunPositions: {
sunrise: "new opportunities",
noon: "maximum energy",
sunset: "bringing things to a close"
},
clouds: {
clear: "clarity",
confusion: "uncertainty and confusion",
storms: "intense turmoil"
}
};
const borderElements = {
colors: {
red: "take action",
blue: "seek wisdom",
green: "embrace growth",
yellow: "stay optimistic",
purple: "explore spirituality",
pink: "show compassion",
turquoise: "communicate clearly",
orange: "be creative"
},
flowers: {
open: "an open heart and opportunities",
closed: "protection and introspection"
}
};
function generateReading(border, flower, sky, phase, clouds, architecture, symbol) {
const symbolData = symbols[symbol];
const symbolMeaning = getRandomElement(symbolData.meanings);
const skyMeanings = ["a fleeting moment", "a brief encounter", "a passing phase"];
const longTermMeanings = ["a lasting journey", "a prolonged path", "an enduring quest"];
const skyMeaning = getRandomElement(sky === "night" ? longTermMeanings : skyMeanings);
const phaseMeaning = sky === "night" ? backgroundElements.moonPhases[phase] : backgroundElements.sunPositions[phase];
const cloudMeaning = backgroundElements.clouds[clouds];
const borderMeaning = borderElements.colors[border];
const flowerMeaning = borderElements.flowers[flower];
const architectureMeanings = {
internal: ["yourself", "your inner world", "your core being"],
external: ["the world around you", "external influences", "your surroundings"],
relationship: ["the balance between your inner and outer worlds", "harmony between yourself and others", "the connection between your heart and the environment"]
};
const architectureMeaning = getRandomElement(architectureMeanings[architecture]);
let reading = "";
if (clouds === "clear") {
if (phase === "new") {
reading += `Embrace new beginnings as the new phase of the moon marks the start of ${skyMeaning} towards ${symbolMeaning}. `;
} else if (phase === "wax") {
reading += `Begin your journey with confidence as the waxing phase of the moon illuminates ${skyMeaning} towards ${symbolMeaning}. `;
} else {
reading += `Reflect on what you’ve learned as the ${phase} phase of the moon illuminates the culmination of ${skyMeaning} towards ${symbolMeaning}. `;
}
} else if (clouds === "confusion") {
reading += `Reflect on what you’ve learned as the ${phase} phase of the moon illuminates the challenges of ${skyMeaning} towards ${symbolMeaning}. Currently, there is ${cloudMeaning}, making it challenging to see the overcoming of challenges clearly. `;
} else if (clouds === "storms") {
reading += `This indicates ${skyMeaning} phase of ${cloudMeaning} towards ${symbolMeaning}. The card is dominated by ${cloudMeaning}, overshadowing the usual guidance from the ${sky === "night" ? "moon phases" : "sun positions"}. `;
}
reading += `By trusting ${architectureMeaning}, you will open yourself up to ${flowerMeaning}. ${borderMeaning}.`;
return reading;
}