-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-main.js
More file actions
160 lines (134 loc) Β· 6.1 KB
/
debug-main.js
File metadata and controls
160 lines (134 loc) Β· 6.1 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
const chalk = require('chalk');
console.log('π DEBUGGING MAIN FUNCTION EXECUTION');
function displayKoiiAnimation() {
console.log('π displayKoiiAnimation() called');
console.clear();
// Koii evolution stages
const koiiStages = [
'KOII',
'KO',
'-K--',
'K--O',
'K-°°)',
'K--°°)',
'K{{{°°)',
'K{{{{°°)',
'K{{{{{°°)',
'K{{{{{{°°)'
];
let currentStage = 0;
let animationPhase = 'swimming';
let cycles = 0;
let swimPosition = 5;
let seaweedOffset = 0;
console.log('π Animation variables initialized');
// Function to generate ocean floor with moving seaweed
const generateOceanFloor = (offset) => {
const floorLength = 60;
const seaweedPositions = [15, 25, 35, 45];
let floor = '_'.repeat(floorLength);
seaweedPositions.forEach(pos => {
const adjustedPos = (pos + offset) % floorLength;
if (adjustedPos >= 0 && adjustedPos < floor.length) {
floor = floor.substring(0, adjustedPos) + '}' + floor.substring(adjustedPos + 1);
}
});
return floor;
};
// Function to redraw the scene
const redrawScene = (message, creature, position) => {
console.log(`π redrawScene called: ${message}`);
console.clear();
// Header
console.log(chalk.cyan.bold('\nββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ'));
console.log(chalk.cyan.bold('β KOII TASK CLI - LOADING... β'));
console.log(chalk.cyan.bold('ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\n'));
// Message
console.log(chalk.magenta.bold(message.padEnd(60)));
// Creature
const spaces = ' '.repeat(Math.max(0, position));
console.log(chalk.yellow.bold(`${spaces}${creature}`));
// Ocean floor
const oceanFloor = generateOceanFloor(seaweedOffset);
console.log(chalk.green.bold(oceanFloor));
};
console.log('π About to call initial redrawScene');
// Initial display
redrawScene('A wild Koii appears in the ocean!', 'KOII', swimPosition);
console.log('π About to create setInterval');
const animationInterval = setInterval(() => {
console.log(`π setInterval callback executed - cycle ${cycles + 1}`);
cycles++;
seaweedOffset += 1;
switch (animationPhase) {
case 'swimming':
console.log(`π Swimming phase - cycles: ${cycles}/20`);
if (cycles < 20) {
if (swimPosition < 20) swimPosition += 1;
const swimMessage = swimPosition < 20 ? 'The Koii swims through the ocean...' : 'The Koii stops and the ocean flows around it...';
redrawScene(swimMessage, 'KOII', swimPosition);
} else {
console.log('π Transitioning to waking phase');
animationPhase = 'waking';
cycles = 0;
}
break;
case 'waking':
console.log(`π Waking phase - cycles: ${cycles}/8`);
if (cycles < 8) {
redrawScene('The Koii is waking up!', 'KOII', swimPosition);
} else {
console.log('π Transitioning to evolving phase');
animationPhase = 'evolving';
cycles = 0;
currentStage = 1;
}
break;
case 'evolving':
console.log(`π Evolving phase - cycles: ${cycles}/30`);
if (cycles < 30) {
if (cycles % 3 === 0 && currentStage < koiiStages.length - 1) {
currentStage++;
console.log(`π Evolved to stage: ${koiiStages[currentStage]}`);
}
const isFlashing = cycles % 2 === 0;
const displayStage = isFlashing ? koiiStages[currentStage] : 'β¨β¨β¨';
redrawScene(`EVOLUTION! The Koii is now level ${Math.floor(currentStage/2) + 1}!`, displayStage, swimPosition);
} else {
console.log('π Animation complete - clearing interval');
clearInterval(animationInterval);
console.clear();
console.log(chalk.cyan.bold('\nββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ'));
console.log(chalk.cyan.bold('β KOII TASK CLI - READY! β'));
console.log(chalk.cyan.bold('ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\n'));
console.log(chalk.green.bold('π The Koii has evolved into its final form! Ready to create tasks! π'));
console.log(chalk.cyan.bold(`Final Form: ${koiiStages[currentStage]}`));
console.log('');
setTimeout(() => {
console.log('π Animation complete - would call continueWithMain()');
console.log('β
DEBUG: Animation function completed successfully!');
}, 2000);
}
break;
}
}, 200);
console.log('π setInterval created, returning from displayKoiiAnimation');
}
async function main() {
console.log('π main() function called');
displayKoiiAnimation();
console.log('π main() function returning');
return; // The animation will call continueWithMain() after completion
}
console.log('π About to call main()');
main().then(
() => {
console.log('π main() promise resolved');
// Don't exit immediately - let the animation run
console.log('π Keeping process alive for animation...');
},
(err) => {
console.error('π main() promise rejected:', err);
process.exit(-1);
},
);