-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdevelopmentSystem.js
More file actions
2039 lines (1746 loc) · 66.2 KB
/
developmentSystem.js
File metadata and controls
2039 lines (1746 loc) · 66.2 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Constants for production phase
const PRODUCTION_MILESTONES = {
DESIGN_REVIEW: 0.25,
FEATURE_COMPLETE: 0.5,
ALPHA: 0.75,
BETA: 0.9
};
const DEVELOPMENT_RISKS = {
SCOPE_CREEP: { probability: 0.15, impact: -10, description: "Feature creep is slowing development" },
TECHNICAL_DEBT: { probability: 0.2, impact: -5, description: "Technical debt is accumulating" },
BREAKTHROUGH: { probability: 0.1, impact: 15, description: "Team made a technical breakthrough!" }
};
const POLISH_PHASES = {
MARKETING: { threshold: 0.25, name: 'Marketing Campaign' },
OPTIMIZATION: { threshold: 0.50, name: 'Final Optimization' },
CERTIFICATION: { threshold: 0.75, name: 'Release Certification' },
LAUNCH_PREP: { threshold: 0.90, name: 'Launch Preparation' }
};
const LAUNCH_WINDOWS = {
IMMEDIATE: {
name: "Immediate Release",
riskFactor: 1.2,
costModifier: 0.8,
description: "Release as soon as possible. Higher risk but lower costs."
},
OPTIMAL: {
name: "Strategic Release",
riskFactor: 1.0,
costModifier: 1.0,
description: "Wait for the best market conditions. Balanced approach."
},
DELAYED: {
name: "Extended Polish",
riskFactor: 0.8,
costModifier: 1.2,
description: "Take extra time for polish. Lower risk but higher costs."
}
};
const PHASE_SEQUENCE = ['planning', 'development', 'testing', 'release'];
const PHASE_REQUIREMENTS = {
planning: {
required: ['features', 'staffAssignments', 'resourceAllocation'],
transition: ['projectPlan', 'teamSetup']
},
development: {
required: ['codeProgress', 'featureProgress', 'teamMorale'],
transition: ['developmentMetrics', 'milestoneProgress']
},
testing: {
required: ['bugsFound', 'qualityMetrics', 'playtestResults'],
transition: ['testingReport', 'optimizationData']
},
release: {
required: ['marketingStrategy', 'launchWindow', 'finalPolish'],
transition: ['releaseStats', 'audienceMetrics']
}
};
// Add this helper function near the top of the file with other utility functions
function capitalizeFirst(str) {
if (!str) return '';
return str.charAt(0).toUpperCase() + str.toLowerCase().slice(1);
}
const QUALITY_IMPACT_WEIGHTS = {
BUG_SEVERITY: {
critical: 0.4, // 40% impact per critical bug
major: 0.2, // 20% impact per major bug
minor: 0.1 // 10% impact per minor bug
},
DEVELOPMENT_DECISIONS: {
quality_focus: 1.2, // Quality priority bonus
speed_focus: 0.8, // Speed priority penalty
balanced: 1.0, // Balanced approach
polish_time: 0.1 // 10% bonus per week of polish
},
RUSH_PENALTIES: {
no_testing: 0.5, // 50% penalty for skipping testing
minimal_testing: 0.7, // 30% penalty for minimal testing
partial_testing: 0.85 // 15% penalty for incomplete testing
}
};
// Add new scoring category constants after existing constants
const SCORING_CATEGORIES = {
gameDesign: {
gameplay: {
name: "Gameplay",
weight: 0.4,
factors: {
core_mechanics: 0.4,
balance: 0.3,
progression: 0.3
}
},
features: {
name: "Features",
weight: 0.3,
factors: {
completeness: 0.4,
polish: 0.3,
variety: 0.3
}
},
innovation: {
name: "Innovation",
weight: 0.3,
factors: {
uniqueness: 0.4,
market_fit: 0.3,
creative_vision: 0.3
}
}
},
technicalQuality: {
bugs: {
name: "Bug Status",
weight: 0.4,
factors: {
severity_ratio: 0.4,
fix_rate: 0.3,
regression_rate: 0.3
}
},
performance: {
name: "Performance",
weight: 0.3,
factors: {
optimization: 0.4,
stability: 0.3,
resource_usage: 0.3
}
},
polish: {
name: "Polish",
weight: 0.3,
factors: {
visual_quality: 0.4,
user_interface: 0.3,
audio_quality: 0.3
}
}
},
playerExperience: {
funFactor: {
name: "Fun Factor",
weight: 0.4,
factors: {
engagement: 0.4,
satisfaction: 0.3,
flow: 0.3
}
},
engagement: {
name: "Engagement",
weight: 0.3,
factors: {
retention: 0.4,
progression: 0.3,
motivation: 0.3
}
},
replayability: {
name: "Replayability",
weight: 0.3,
factors: {
content_variety: 0.4,
branching: 0.3,
emergent_gameplay: 0.3
}
}
}
};
const GENRE_SCORE_WEIGHTS = {
rpg: {
gameDesign: 0.4,
technicalQuality: 0.3,
playerExperience: 0.3,
expectations: 0.8 // Higher expectations
},
puzzle: {
gameDesign: 0.3,
technicalQuality: 0.3,
playerExperience: 0.4,
expectations: 0.6 // Lower expectations
},
adventure: {
gameDesign: 0.4,
technicalQuality: 0.2,
playerExperience: 0.4,
expectations: 0.7
},
simulation: {
gameDesign: 0.3,
technicalQuality: 0.4,
playerExperience: 0.3,
expectations: 0.7
},
sports: {
gameDesign: 0.3,
technicalQuality: 0.4,
playerExperience: 0.3,
expectations: 0.75
},
fighting: {
gameDesign: 0.3,
technicalQuality: 0.4,
playerExperience: 0.3,
expectations: 0.8
},
horror: {
gameDesign: 0.4,
technicalQuality: 0.3,
playerExperience: 0.3,
expectations: 0.7
},
survival: {
gameDesign: 0.35,
technicalQuality: 0.35,
playerExperience: 0.3,
expectations: 0.65
},
racing: {
gameDesign: 0.3,
technicalQuality: 0.4,
playerExperience: 0.3,
expectations: 0.75
},
idle: {
gameDesign: 0.3,
technicalQuality: 0.3,
playerExperience: 0.4,
expectations: 0.5 // Lowest expectations
}
};
const SCORE_FEEDBACK = {
exceptional: {
threshold: 9.5,
messages: [
"A masterpiece that sets new standards for the genre!",
"Revolutionary game design that will influence future titles",
"Technical excellence combined with exceptional gameplay",
"An instant classic that will be remembered for years"
]
},
excellent: {
threshold: 8.5,
messages: [
"Outstanding achievement across all aspects",
"Hugely impressive execution with minimal flaws",
"A must-play title that excels in nearly every way",
"Sets a new bar for quality in multiple areas"
]
},
great: {
threshold: 7.5,
messages: [
"A very strong title with numerous standout features",
"High quality execution with only minor issues",
"Delivers an engaging and polished experience",
"Will certainly please fans of the genre"
]
},
good: {
threshold: 6.5,
messages: [
"A solid game that achieves its core goals",
"Despite some flaws, provides good entertainment",
"Competent execution with room for improvement",
"Fans of the genre will find plenty to enjoy"
]
},
average: {
threshold: 5.5,
messages: [
"A decent but unremarkable experience",
"Has potential but falls short in key areas",
"Functional but lacks distinctive features",
"May appeal to genre enthusiasts despite limitations"
]
},
poor: {
threshold: 4.5,
messages: [
"Significant issues hold back the experience",
"Falls short of basic quality expectations",
"Needs substantial improvement in multiple areas",
"Difficult to recommend in its current state"
]
},
very_poor: {
threshold: 0,
messages: [
"Major problems throughout the experience",
"Fails to deliver on fundamental promises",
"Requires extensive work to meet basic standards",
"Not recommended in its current form"
]
}
};
// Default audience preferences if none found
const DEFAULT_AUDIENCE_PREFERENCES = {
casual: {
preferences: {
puzzle: 1.2,
idle: 1.2,
simulation: 1.1,
sports: 1.0,
adventure: 0.9,
rpg: 0.7,
fighting: 0.6,
survival: 0.7,
racing: 0.9,
horror: 0.5
}
},
hardcore: {
preferences: {
rpg: 1.5,
fighting: 1.3,
survival: 1.2,
racing: 1.1,
horror: 1.2,
sports: 0.9,
simulation: 0.8,
puzzle: 0.7,
idle: 0.6,
adventure: 1.0
}
},
all: {
preferences: {
puzzle: 1.0,
idle: 1.0,
simulation: 1.0,
sports: 1.0,
adventure: 1.0,
rpg: 1.0,
fighting: 1.0,
survival: 1.0,
racing: 1.0,
horror: 1.0
}
}
};
const RANDOM_EVENTS = {
positive: [
{ text: "Team morale is high!", moneyEffect: 0.9, moraleEffect: 5 },
{ text: "Productive work week!", moneyEffect: 0.95, moraleEffect: 3 },
{ text: "Team found efficient solution!", moneyEffect: 0.9, moraleEffect: 4 }
],
neutral: [
{ text: "Normal work week", moneyEffect: 1.0, moraleEffect: 0 },
{ text: "Everything proceeding as usual", moneyEffect: 1.0, moraleEffect: 0 },
{ text: "Team maintaining steady progress", moneyEffect: 1.0, moraleEffect: 0 }
],
negative: [
{ text: "Minor technical setback", moneyEffect: 1.1, moraleEffect: -3 },
{ text: "Team hit a roadblock", moneyEffect: 1.15, moraleEffect: -4 },
{ text: "Some unexpected challenges", moneyEffect: 1.2, moraleEffect: -5 }
]
};
window.RANDOM_EVENTS = RANDOM_EVENTS;
function getRandomEvent() {
// Base event probabilities
const eventChances = {
positive: 0.2, // 20% chance
neutral: 0.6, // 60% chance
negative: 0.2 // 20% chance
};
const roll = Math.random();
let eventType;
if (roll < eventChances.positive) {
eventType = 'positive';
} else if (roll < eventChances.positive + eventChances.neutral) {
eventType = 'neutral';
} else {
eventType = 'negative';
}
// Get random event from chosen type
const events = RANDOM_EVENTS[eventType];
const event = events[Math.floor(Math.random() * events.length)];
// Add market effect if needed (20% chance)
if (Math.random() < 0.2) {
event.marketEffect = {
type: Math.random() < 0.5 ? 'growth' : 'decline',
amount: Math.random() * 0.1 // 0-10% change
};
}
return event;
}
window.getRandomEvent = getRandomEvent;
function calculateProjectProgress(project) {
if (!project) return 0;
// Get base progress
let progress = project.progress || 0;
// Factor in phase-specific progress
switch(project.phase) {
case 'planning':
const planningMilestones = ['features', 'staffAssignments', 'resourceAllocation'].filter(m =>
project.completedMilestones?.includes(m)
).length;
progress = (planningMilestones / 3) * 100;
break;
case 'development':
// Development progress is already tracked in project.progress
break;
case 'testing':
// Calculate testing progress based on completed tests
if (project.testingMetrics?.testsConducted) {
const completedTests = Object.values(project.testingMetrics.testsConducted)
.filter(conducted => conducted).length;
progress = (completedTests / 3) * 100;
}
break;
case 'release':
// Calculate release preparation progress
const requiredDecisions = [
!!project.marketingStrategy,
!!project.launchWindow,
!!project.optimizationFocus
];
progress = (requiredDecisions.filter(Boolean).length / 3) * 100;
break;
}
return Math.min(100, Math.max(0, progress));
}
function calculateQualityGain(fixedBugs) {
const qualityGainFactors = {
critical: 2.0, // Critical bugs have biggest quality impact
major: 1.0, // Major bugs have moderate impact
minor: 0.5 // Minor bugs have smallest impact
};
let totalGain = 0;
Object.entries(fixedBugs).forEach(([severity, count]) => {
totalGain += count * qualityGainFactors[severity];
});
// Cap the maximum quality gain per session
return Math.min(10, totalGain);
}
function handleReleaseCommand(gameState) {
const project = gameState.project;
if (!project || project.phase !== 'release') {
outputToDisplay("Not ready for release yet!");
return;
}
// Show warning if there are remaining bugs
if (project.bugs > 0) {
const severity = project.testingMetrics.bugSeverity;
outputToDisplay("\n=== Release Warning ===");
outputToDisplay("There are still unfixed bugs in the project:");
outputToDisplay(`- Critical: ${severity.critical}`);
outputToDisplay(`- Major: ${severity.major}`);
outputToDisplay(`- Minor: ${severity.minor}`);
outputToDisplay("\nReleasing with bugs will impact:");
outputToDisplay("- Game quality and reviews");
outputToDisplay("- Sales potential");
outputToDisplay("- Company reputation");
outputToDisplay("\nType 'release confirm' to release anyway, or continue fixing bugs.");
return;
}
proceedWithRelease(gameState);
}
function proceedWithRelease(gameState) {
try {
// Validate game state exists
if (!gameState || !gameState.project) {
throw new Error("No active project found");
}
// Set default values if missing
gameState.project.targetAudience = gameState.project.targetAudience || 'all';
gameState.project.marketingStrategy = gameState.project.marketingStrategy || 'balanced';
// Initialize missing metrics if needed
if (!gameState.project.testingMetrics) {
gameState.project.testingMetrics = {
bugSeverity: {
critical: Math.floor((gameState.project.bugs || 0) * 0.2),
major: Math.floor((gameState.project.bugs || 0) * 0.3),
minor: Math.ceil((gameState.project.bugs || 0) * 0.5)
},
bugsFound: gameState.project.bugs || 0,
bugsFixed: 0,
playtestScore: 70 // Default playtest score
};
}
// Ensure reputation data exists
if (!gameState.reputation) {
gameState.reputation = {
casual: { fans: 0, loyalty: 0.5, expectations: 50 },
hardcore: { fans: 0, loyalty: 0.5, expectations: 50 },
critics: { fans: 0, loyalty: 0.5, expectations: 50 },
lastMentions: [],
marketPresence: 0
};
}
// Calculate final metrics
const finalQuality = calculateFinalQuality(gameState);
const releaseStats = calculateReleaseStats(gameState, finalQuality);
if (!releaseStats) {
throw new Error("Failed to calculate release statistics");
}
// Calculate bug impact
const bugImpact = calculateBugImpact(gameState.project);
// Apply bug impacts with validation
releaseStats.successScore = Math.max(0, releaseStats.successScore - (bugImpact?.scoreReduction || 0));
releaseStats.revenue = Math.floor(releaseStats.revenue * (1 - (bugImpact?.revenueLoss || 0)));
// Create completed game record
const completedGame = {
name: gameState.project.name || "Untitled Game",
genre: gameState.project.genre,
subgenre: gameState.project.subgenre,
elements: gameState.project.elements || [],
developmentTime: gameState.weekNumber - (gameState.project.startDate || 0),
quality: finalQuality,
successScore: releaseStats.successScore,
revenue: releaseStats.revenue,
date: gameState.weekNumber,
marketingStrategy: gameState.project.marketingStrategy,
targetAudience: gameState.project.targetAudience || 'all',
reception: releaseStats.reception || {},
bugs: {
total: gameState.project.bugs || 0,
severity: gameState.project.testingMetrics.bugSeverity || {
critical: 0,
major: 0,
minor: 0
}
}
};
// Initialize game history if needed
if (!Array.isArray(gameState.gameHistory)) {
gameState.gameHistory = [];
}
// Add to game history
gameState.gameHistory.push(completedGame);
// Update company reputation
if (typeof updateReputation === 'function') {
updateReputation(gameState, completedGame);
}
// Display results
displayReleaseResults(completedGame, releaseStats, bugImpact);
// Reset project and update UI
gameState.project = null;
if (typeof updatePhaseIndicator === 'function') {
updatePhaseIndicator(null);
}
// Autosave
if (typeof saveGame === 'function') {
saveGame(gameState, null, true);
}
// Important: Hide the phase indicator after successful release
const phaseIndicator = document.getElementById('phase-indicator');
if (phaseIndicator) {
phaseIndicator.classList.add('hidden');
}
return true;
} catch (error) {
console.error('Release failed:', error);
outputToDisplay("\n=== Release Error ===");
outputToDisplay(`Error: ${error.message}`);
outputToDisplay("\nDebug Information:");
outputToDisplay(`Project exists: ${!!gameState?.project}`);
outputToDisplay(`Target audience: ${gameState?.project?.targetAudience}`);
outputToDisplay(`Marketing strategy: ${gameState?.project?.marketingStrategy}`);
outputToDisplay(`Genre: ${gameState?.project?.genre}`);
outputToDisplay("\nRequired settings:");
outputToDisplay("1. Marketing strategy ('marketing [strategy]')");
outputToDisplay("2. Launch window ('launch [window]')");
outputToDisplay("3. Target audience (should be set during development)");
return false;
}
}
function handleBugFixing(gameState) {
const project = gameState.project;
if (!project.bugs || project.bugs <= 0) {
outputToDisplay("No known bugs to fix!");
return;
}
// Initialize bug severity if not set
if (!project.testingMetrics.bugSeverity) {
project.testingMetrics.bugSeverity = {
critical: Math.floor(project.bugs * 0.2),
major: Math.floor(project.bugs * 0.3),
minor: Math.ceil(project.bugs * 0.5)
};
}
// Calculate fix effectiveness
const baseEffectiveness = 0.4;
const teamBonus = Math.max(0.2, calculateTeamEfficiency(gameState)?.efficiency || 0.2);
const fixEffectiveness = baseEffectiveness * teamBonus * (gameState.modifiers.testing_effectiveness || 1);
// Calculate bugs fixed with guaranteed minimums
const fixedBugs = {
critical: Math.max(1, Math.floor(Math.min(project.testingMetrics.bugSeverity.critical, project.testingMetrics.bugSeverity.critical * fixEffectiveness))),
major: Math.max(1, Math.floor(Math.min(project.testingMetrics.bugSeverity.major, project.testingMetrics.bugSeverity.major * fixEffectiveness * 0.8))),
minor: Math.max(1, Math.floor(Math.min(project.testingMetrics.bugSeverity.minor, project.testingMetrics.bugSeverity.minor * fixEffectiveness * 0.6)))
};
// Ensure we don't fix more bugs than exist
fixedBugs.critical = Math.min(fixedBugs.critical, project.testingMetrics.bugSeverity.critical);
fixedBugs.major = Math.min(fixedBugs.major, project.testingMetrics.bugSeverity.major);
fixedBugs.minor = Math.min(fixedBugs.minor, project.testingMetrics.bugSeverity.minor);
// Update bug counts
const totalFixed = fixedBugs.critical + fixedBugs.major + fixedBugs.minor;
project.bugs = Math.max(0, project.bugs - totalFixed);
// Update severity counts
project.testingMetrics.bugSeverity.critical -= fixedBugs.critical;
project.testingMetrics.bugSeverity.major -= fixedBugs.major;
project.testingMetrics.bugSeverity.minor -= fixedBugs.minor;
// Update metrics
if (!project.testingMetrics.bugsFixed) {
project.testingMetrics.bugsFixed = 0;
}
project.testingMetrics.bugsFixed += totalFixed;
// Calculate quality improvement
const qualityGain = calculateQualityGain(fixedBugs);
project.quality = Math.min(100, (project.quality || 0) + qualityGain);
if (!project.initialBugs) {
project.initialBugs = project.bugs + totalFixed;
}
const fixProgress = ((project.initialBugs - project.bugs) / project.initialBugs) * 100;
// Display formatted results
outputToDisplay("\n╔═══════ Bug Fixing Session ═══════╗");
// Progress Section
outputToDisplay(`Total Bugs Fixed: ${totalFixed}`);
const progressBar = createProgressBar(fixProgress);
outputToDisplay(progressBar);
outputToDisplay(`Overall Progress: ${fixProgress.toFixed(1)}%`);
// Results Breakdown
outputToDisplay("\n──── Fixed This Session ────");
outputToDisplay(`Critical: ${fixedBugs.critical} ${renderBugIcon(fixedBugs.critical, '🔴')}`);
outputToDisplay(`Major: ${fixedBugs.major} ${renderBugIcon(fixedBugs.major, '🟡')}`);
outputToDisplay(`Minor: ${fixedBugs.minor} ${renderBugIcon(fixedBugs.minor, '🟢')}`);
outputToDisplay("\n──── Remaining Issues ────");
outputToDisplay(`Critical: ${project.testingMetrics.bugSeverity.critical} ${renderBugIcon(project.testingMetrics.bugSeverity.critical, '🔴')}`);
outputToDisplay(`Major: ${project.testingMetrics.bugSeverity.major} ${renderBugIcon(project.testingMetrics.bugSeverity.major, '🟡')}`);
outputToDisplay(`Minor: ${project.testingMetrics.bugSeverity.minor} ${renderBugIcon(project.testingMetrics.bugSeverity.minor, '🟢')}`);
// Quality Metrics
outputToDisplay("\n──── Quality Metrics ────");
outputToDisplay(`Quality Score: ${Math.floor(project.quality)}% (${qualityGain > 0 ? '+' : ''}${qualityGain.toFixed(1)}%)`);
outputToDisplay(`Total Remaining: ${project.bugs} bugs`);
// Recommendations
if (project.bugs > 0) {
outputToDisplay("\n──── Recommendations ────");
if (project.testingMetrics.bugSeverity.critical > 0) {
outputToDisplay("⚠️ Critical bugs require attention");
outputToDisplay(" (release still possible but risky)");
}
if (project.testingMetrics.bugSeverity.major > 0) {
outputToDisplay("i️ Consider fixing major bugs");
}
if (project.testingMetrics.bugSeverity.minor > 0 &&
project.testingMetrics.bugSeverity.critical === 0 &&
project.testingMetrics.bugSeverity.major === 0) {
outputToDisplay("✓ Only minor bugs remain");
}
outputToDisplay("\nRelease Impact:");
outputToDisplay("• Game quality and reviews");
outputToDisplay("• Sales potential");
outputToDisplay("• Company reputation");
} else {
outputToDisplay("\n✨ All bugs fixed!");
outputToDisplay("Game is ready for release");
}
outputToDisplay("╚═══════════════════════════════╝");
// Update testing progress
updateTestingProgress(project);
}
function renderBugIcon(count, icon) {
return count > 0 ? icon.repeat(Math.min(count, 5)) : '─';
}
function handleTestingPhase(gameState, testType) {
const project = gameState.project;
outputToDisplay("\n╔═══════ Testing Phase ═══════╗");
if (!testType) {
outputToDisplay("──── Available Tests ────");
outputToDisplay("• unit - Basic functionality");
outputToDisplay("• integration - System testing");
outputToDisplay("• playtest - User experience");
outputToDisplay("\nUse: test [type]");
outputToDisplay("╚═══════════════════════════╝");
return;
}
if (project.phase === 'release') {
outputToDisplay("✓ Testing phase complete");
outputToDisplay("Use polish phase commands");
outputToDisplay("╚═══════════════════════════╝");
return;
}
if (!project.testingMetrics) {
project.testingMetrics = {
bugsFound: 0,
bugsFixed: 0,
playtestScore: 0,
testsConducted: {
unit: false,
integration: false,
playtest: false
}
};
}
if (project.testingMetrics.testsConducted[testType]) {
outputToDisplay(`\n⚠️ ${capitalizeFirst(testType)} testing already completed`);
const remainingTests = Object.entries(project.testingMetrics.testsConducted)
.filter(([_, conducted]) => !conducted)
.map(([type]) => type);
if (remainingTests.length > 0) {
outputToDisplay("\n──── Remaining Tests ────");
remainingTests.forEach(test => outputToDisplay(`• ${test}`));
} else {
outputToDisplay("\n✨ All tests completed!");
}
outputToDisplay("╚═══════════════════════════╝");
return;
}
// Calculate test effectiveness
const baseEffectiveness = 0.7;
const teamBonus = calculateTeamEfficiency(gameState)?.efficiency || 1;
const testEffectiveness = baseEffectiveness * teamBonus * (gameState.modifiers.testing_effectiveness || 1);
outputToDisplay(`\n──── ${capitalizeFirst(testType)} Testing ────`);
// Process test results
switch(testType) {
case 'unit':
handleUnitTesting(project, testEffectiveness);
break;
case 'integration':
handleIntegrationTesting(project, testEffectiveness);
break;
case 'playtest':
handlePlaytesting(project, testEffectiveness);
break;
default:
outputToDisplay("❌ Invalid test type");
outputToDisplay("Use: unit, integration, or playtest");
return;
}
// Mark test as completed
project.testingMetrics.testsConducted[testType] = true;
// Show remaining tests
const remainingTests = Object.entries(project.testingMetrics.testsConducted)
.filter(([_, conducted]) => !conducted)
.map(([type]) => type);
if (remainingTests.length > 0) {
outputToDisplay("\n──── Remaining Tests ────");
remainingTests.forEach(test => outputToDisplay(`• ${test}`));
}
outputToDisplay("╚═══════════════════════════╝");
// Update phase progress
updateTestingProgress(project);
}
function updatePolishProgress(gameState) {
const project = gameState.project;
if (!project || project.phase !== 'release') {
return;
}
// Progress is now based solely on bug status
const hasUnfixedBugs = project.bugs > 0;
if (hasUnfixedBugs) {
outputToDisplay("\n=== Polish Phase ===");
outputToDisplay("Bugs remaining: " + project.bugs);
const severity = project.testingMetrics.bugSeverity;
outputToDisplay("Critical: " + severity.critical);
outputToDisplay("Major: " + severity.major);
outputToDisplay("Minor: " + severity.minor);
outputToDisplay("\nOptions:");
outputToDisplay("- 'fix bugs' to continue fixing bugs");
outputToDisplay("- 'release' to release with current bugs");
outputToDisplay("\nNote: Releasing with bugs will impact:");
outputToDisplay("- Game quality and reviews");
outputToDisplay("- Sales potential");
outputToDisplay("- Company reputation");
} else {
outputToDisplay("\n✨ All bugs fixed!");
outputToDisplay("Game is ready for release. Use 'release' command to launch.");
}
}
function isReadyForRelease(project) {
// Game is always ready for release in polish phase, but with consequences for bugs
return project.phase === 'release';
}
function displayReleaseResults(game, stats, bugImpact) {
outputToDisplay("\n╔═══════ Game Release ═══════╗");
// Basic Info
outputToDisplay(`Title: ${game.name}`);
outputToDisplay(`Genre: ${game.genre} (${game.subgenre})`);
outputToDisplay(`Development: ${game.developmentTime} weeks`);
// Quality Section
outputToDisplay("\n──── Quality Metrics ────");
outputToDisplay(`Base Quality: ${game.quality}%`);
// Bug Impact Section
if (game.bugs.total > 0) {
outputToDisplay("\n──── Bug Impact ────");
outputToDisplay(`Total Bugs: ${game.bugs.total}`);
outputToDisplay(`Critical: ${game.bugs.severity.critical} 🔴`);
outputToDisplay(`Major: ${game.bugs.severity.major} 🟡`);
outputToDisplay(`Minor: ${game.bugs.severity.minor} 🟢`);
outputToDisplay(`Quality Loss: -${Math.round(bugImpact.scoreReduction)}`);
}
// Results Section
outputToDisplay("\n──── Final Results ────");
outputToDisplay(`Success Score: ${stats.successScore}/100`);
outputToDisplay(`Revenue: $${stats.revenue}`);
if (bugImpact?.revenueLoss > 0) {
outputToDisplay(`Revenue Impact: -${Math.round(bugImpact.revenueLoss * 100)}%`);
}
// Market Performance
outputToDisplay("\n──── Market Performance ────");
outputToDisplay(`Marketing: ${((stats.marketingImpact - 1) * 100).toFixed(0)}%`);
outputToDisplay(`Timing: ${((stats.timingImpact - 1) * 100).toFixed(0)}%`);
// Reviews Section
const reviews = generateReviews(game, gameState);
outputToDisplay("\n──── Press Reviews ────");
reviews.forEach(review => {
outputToDisplay(`\n${review.reviewer.name} - ${review.reviewer.title}`);
outputToDisplay(`Background: ${review.reviewer.background}`);
outputToDisplay(`Score: ${review.score}/100`);
outputToDisplay(`"${review.mainQuote}"`);
if (review.focusComments.length > 0) {
outputToDisplay("Focus Areas:");
review.focusComments.forEach(comment => outputToDisplay(`- ${comment}`));
}
});
// Special Achievements
if (stats.successScore >= 90) {
outputToDisplay("\n🏆 Masterpiece Achievement!");
} else if (stats.successScore >= 80) {
outputToDisplay("\n🌟 Critical Success!");
} else if (game.bugs.total > 0) {
outputToDisplay("\n⚠️ Released with known issues");
outputToDisplay("May affect long-term reputation");
}
outputToDisplay("╚════════════════════════════╝");
displayFinalScore(game, gameState);
}
function calculateFinalQuality(gameState) {
if (!gameState?.project) return 0;
// Start with existing quality calculation
let quality = gameState.project.quality || 0;
// Preserve existing priority modifications
const priority = gameState.project.priority || 'balanced';
switch(priority) {
case 'quality':
quality *= 1.2;
break;
case 'speed':
quality *= 0.8;
break;
}
// Keep existing team effects
const teamEfficiency = calculateTeamEfficiency(gameState)?.efficiency || 1;
quality *= (0.8 + (teamEfficiency * 0.4));
// Maintain technology effects
quality *= (gameState.modifiers?.quality || 1);
// Preserve optimization focus effects
if (gameState.project.optimizationFocus === 'quality') {
quality *= 1.1;
}
// NEW: Add bug severity impact
if (gameState.project.bugs > 0 && gameState.project.testingMetrics?.bugSeverity) {
const severity = gameState.project.testingMetrics.bugSeverity;
const bugImpact = (
(severity.critical || 0) * QUALITY_IMPACT_WEIGHTS.BUG_SEVERITY.critical +
(severity.major || 0) * QUALITY_IMPACT_WEIGHTS.BUG_SEVERITY.major +
(severity.minor || 0) * QUALITY_IMPACT_WEIGHTS.BUG_SEVERITY.minor
);
quality *= Math.max(0.1, 1 - bugImpact);
}
// NEW: Add development decision impacts
const decisionImpact = QUALITY_IMPACT_WEIGHTS.DEVELOPMENT_DECISIONS[
gameState.project.priority || 'balanced'
] || 1.0;
quality *= decisionImpact;
// NEW: Add rush penalties if applicable
if (gameState.project.testingMetrics?.testsConducted) {
const conducted = gameState.project.testingMetrics.testsConducted;
const testsRun = Object.values(conducted).filter(Boolean).length;
if (testsRun === 0) {
quality *= QUALITY_IMPACT_WEIGHTS.RUSH_PENALTIES.no_testing;
} else if (testsRun === 1) {
quality *= QUALITY_IMPACT_WEIGHTS.RUSH_PENALTIES.minimal_testing;
} else if (testsRun === 2) {
quality *= QUALITY_IMPACT_WEIGHTS.RUSH_PENALTIES.partial_testing;
}
}
// Preserve existing bug impact calculation
if (gameState.project.bugs > 0) {
const bugPenalty = Math.min(0.5, gameState.project.bugs * 0.02);
quality *= (1 - bugPenalty);
}
return Math.min(100, Math.max(0, Math.round(quality)));
}