forked from Darkest-Teddy/DynamicMarioBros
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelationships.js
More file actions
256 lines (215 loc) Β· 6.28 KB
/
Copy pathrelationships.js
File metadata and controls
256 lines (215 loc) Β· 6.28 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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
// relationships.js - Three character relationship system
window.GameRelationships = {
scores: {
toad: 0,
goomba: 0,
koopa: 0,
},
init: function () {
const saved = localStorage.getItem("fsm_relationships");
if (saved) {
try {
this.scores = JSON.parse(saved);
console.log("β
Relationships loaded from storage:", this.scores);
} catch (e) {
console.error("Failed to parse saved relationships:", e);
this.scores = { toad: 0, goomba: 0, koopa: 0 };
}
} else {
console.log("β
Relationships initialized (no saved data):", this.scores);
}
},
update: function (character, delta) {
character = character.toLowerCase();
console.log(
"Attempting to update:",
character,
"Current scores:",
this.scores
);
if (!this.scores.hasOwnProperty(character)) {
console.error(
"β Unknown character:",
character,
"Available:",
Object.keys(this.scores)
);
return;
}
this.scores[character] = Math.max(
-100,
Math.min(100, this.scores[character] + delta)
);
localStorage.setItem("fsm_relationships", JSON.stringify(this.scores));
console.log(
`π ${character} relationship: ${this.scores[character]} (${
delta > 0 ? "+" : ""
}${delta})`
);
},
get: function (character) {
character = character.toLowerCase();
return this.scores[character] || 0;
},
getAll: function () {
return { ...this.scores };
},
/**
* Get the status of a specific character
* Returns: 'allied', 'enemy', or 'neutral'
*/
getCharacterStatus: function (character) {
const score = this.get(character);
if (score >= 30) {
return "allied";
} else if (score <= -30) {
return "enemy";
} else {
return "neutral";
}
},
/**
* Get all character statuses as an object
* Returns: { toad: 'allied', goomba: 'enemy', koopa: 'neutral' }
*/
getAllStatuses: function () {
const statuses = {};
for (const character in this.scores) {
statuses[character] = this.getCharacterStatus(character);
}
return statuses;
},
isHostile: function (character) {
return this.get(character) < -30;
},
isAllied: function (character) {
return this.get(character) > 30;
},
isEnemy: function (character) {
return this.get(character) <= -30;
},
setStatus: function (character, status) {
character = character.toLowerCase();
if (!this.scores.hasOwnProperty(character)) {
console.error("β Unknown character:", character);
return;
}
let newScore = 0;
if (status === "allied") {
newScore = 50;
} else if (status === "enemy") {
newScore = -50;
} else if (status === "neutral") {
newScore = 0;
}
this.scores[character] = newScore;
localStorage.setItem("fsm_relationships", JSON.stringify(this.scores));
console.log(`β
${character} status set to ${status} (score: ${newScore})`);
},
reset: function () {
this.scores = { toad: 0, goomba: 0, koopa: 0 };
localStorage.removeItem("fsm_relationships");
console.log("π Relationships reset:", this.scores);
},
// TOAD CONSEQUENCE MODIFIERS
getPlatformMultiplier: function () {
const score = this.get("toad");
if (score < -50) return 0.6;
if (score < -30) return 0.75;
if (score > 30) return 1.25;
if (score > 50) return 1.4;
return 1.0;
},
getItemChance: function () {
const score = this.get("toad");
if (score < -50) return 0.3;
if (score < -30) return 0.5;
if (score > 30) return 1.0;
if (score > 50) return 1.0;
return 0.8;
},
getEnemyMultiplier: function () {
const score = this.get("toad");
if (score < -50) return 1.5;
if (score < -30) return 1.3;
if (score > 30) return 0.8;
if (score > 50) return 0.6;
return 1.0;
},
getEnemySpeedMultiplier: function () {
const score = this.get("toad");
if (score < -50) return 1.3;
if (score < -30) return 1.15;
return 1.0;
},
shouldEnemiesBeAggressive: function () {
return this.get("toad") < -30;
},
shouldUpgradeItems: function () {
return this.get("toad") > 50;
},
// GOOMBA CONSEQUENCE MODIFIERS
getGoombaSpawnMultiplier: function () {
const score = this.get("goomba");
if (score < -50) return 2.0; // Enemy: Double Goomba spawns
if (score < -30) return 1.5; // Enemy: 50% more Goombas
if (score > 30) return 0.0; // Allied: No Goombas
if (score > 50) return 0.0; // Allied: No Goombas
return 1.0;
},
shouldSuppressGoombas: function () {
return this.get("goomba") > 30;
},
getGoombaPowerUpBonus: function () {
const score = this.get("goomba");
if (score > 50) return 3; // Extra fire flowers
if (score > 30) return 2; // Some fire flowers
return 0;
},
shouldGoombasMultiply: function () {
return this.get("goomba") < -30;
},
// KOOPA CONSEQUENCE MODIFIERS
getKoopaSpawnMultiplier: function () {
const score = this.get("koopa");
if (score < -50) return 1.8; // Enemy: More Koopas
if (score < -30) return 1.4; // Enemy: Extra Koopas
if (score > 30) return 0.7; // Allied: Fewer Koopas
if (score > 50) return 0.5; // Allied: Much fewer Koopas
return 1.0;
},
shouldRevealSecrets: function () {
return this.get("koopa") > 30;
},
getKoopaSecretCount: function () {
const score = this.get("koopa");
if (score > 50) return 5; // Many secrets revealed
if (score > 30) return 3; // Some secrets revealed
return 0;
},
shouldHideBlocks: function () {
return this.get("koopa") < -30;
},
getKoopaSpringBonus: function () {
const score = this.get("koopa");
if (score > 50) return 3; // Extra springs
if (score > 30) return 2; // Some springs
return 0;
},
shouldAddFalseBlocks: function () {
return this.get("koopa") < -30;
},
getKoopaHighCoinBonus: function () {
const score = this.get("koopa");
if (score > 50) return 7; // Many high coins
if (score > 30) return 5; // Some high coins
return 0;
},
};
// Auto-initialize on load
if (window.GameRelationships) {
window.GameRelationships.init();
console.log("β
GameRelationships loaded and initialized");
} else {
console.error("β GameRelationships failed to load!");
}