gglang 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -2
- package/docs/DOCUMENTATION.md +1 -2
- package/examples/adventure.gg +315 -0
- package/examples/fibonacci.gg +14 -0
- package/examples/fizzbuzz.gg +15 -0
- package/examples/hello.gg +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
```
|
|
2
2
|
██████╗ ██████╗ ██╗ █████╗ ███╗ ██╗ ██████╗
|
|
3
3
|
██╔════╝ ██╔════╝ ██║ ██╔══██╗████╗ ██║██╔════╝
|
|
4
4
|
██║ ███╗██║ ███╗██║ ███████║██╔██╗ ██║██║ ███╗
|
|
@@ -155,4 +155,3 @@ For the complete language reference, syntax guide, and example programs, see the
|
|
|
155
155
|
## 📄 License
|
|
156
156
|
|
|
157
157
|
This project is licensed under the **MIT License** — do whatever you want with it. GG! 🎮
|
|
158
|
-
]]>
|
package/docs/DOCUMENTATION.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# 📖 GGLang — Complete Language Documentation
|
|
2
2
|
|
|
3
3
|
> **Version 1.0** · The Gaming-Themed Programming Language
|
|
4
4
|
|
|
@@ -901,4 +901,3 @@ adventure.gg
|
|
|
901
901
|
---
|
|
902
902
|
|
|
903
903
|
*GG! 🎮 — Happy coding with GGLang!*
|
|
904
|
-
]]>
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// ============================================================
|
|
2
|
+
// ⚔️ THE DUNGEON OF GLITCHES — A GGLang Mini Adventure ⚔️
|
|
3
|
+
// ============================================================
|
|
4
|
+
// This program demonstrates most GGLang features:
|
|
5
|
+
// - equip / artifact (variables / constants)
|
|
6
|
+
// - skill / loot (functions / return)
|
|
7
|
+
// - quest / side_quest / retreat (if / else if / else)
|
|
8
|
+
// - grind / rage_quit / respawn (while / break / continue)
|
|
9
|
+
// - boss_fight / revive / glitch (try / catch / throw)
|
|
10
|
+
// - broadcast / interact (output / input)
|
|
11
|
+
// - victory / defeat / phantom (true / false / null)
|
|
12
|
+
// ============================================================
|
|
13
|
+
|
|
14
|
+
spawn {
|
|
15
|
+
|
|
16
|
+
// ── Constants: permanent game rules ──────────────────────
|
|
17
|
+
artifact maxHealth = 100;
|
|
18
|
+
artifact potionHeal = 25;
|
|
19
|
+
artifact critMultiplier = 2;
|
|
20
|
+
|
|
21
|
+
// ── Utility skills ──────────────────────────────────────
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
* Clamp a value between a min and max.
|
|
25
|
+
* Used to keep health within valid bounds.
|
|
26
|
+
*/
|
|
27
|
+
skill clamp(value, min, max) {
|
|
28
|
+
quest (value < min) {
|
|
29
|
+
loot min;
|
|
30
|
+
}
|
|
31
|
+
quest (value > max) {
|
|
32
|
+
loot max;
|
|
33
|
+
}
|
|
34
|
+
loot value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Calculate damage dealt to an enemy.
|
|
39
|
+
* Every 3rd hit is a critical strike!
|
|
40
|
+
*/
|
|
41
|
+
skill calculateDamage(baseDamage, hitCount) {
|
|
42
|
+
quest (hitCount % 3 == 0) {
|
|
43
|
+
broadcast("💥 CRITICAL HIT!");
|
|
44
|
+
loot baseDamage * critMultiplier;
|
|
45
|
+
}
|
|
46
|
+
loot baseDamage;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* Display a health bar using emoji.
|
|
51
|
+
*/
|
|
52
|
+
skill showHealthBar(name, current, max) {
|
|
53
|
+
equip percentage = (current * 100) / max;
|
|
54
|
+
equip bar = name + " HP: [";
|
|
55
|
+
|
|
56
|
+
equip filled = 0;
|
|
57
|
+
grind (filled < 10) {
|
|
58
|
+
quest (filled * 10 < percentage) {
|
|
59
|
+
bar = bar + "❤️";
|
|
60
|
+
} retreat {
|
|
61
|
+
bar = bar + "🖤";
|
|
62
|
+
}
|
|
63
|
+
filled = filled + 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
bar = bar + "] " + current + "/" + max;
|
|
67
|
+
broadcast(bar);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ── Character Creation ──────────────────────────────────
|
|
71
|
+
|
|
72
|
+
broadcast("╔══════════════════════════════════════╗");
|
|
73
|
+
broadcast("║ ⚔️ THE DUNGEON OF GLITCHES ⚔️ ║");
|
|
74
|
+
broadcast("╠══════════════════════════════════════╣");
|
|
75
|
+
broadcast("║ A GGLang Mini Text Adventure ║");
|
|
76
|
+
broadcast("╚══════════════════════════════════════╝");
|
|
77
|
+
broadcast("");
|
|
78
|
+
|
|
79
|
+
equip playerName = interact("🎮 Enter your character name: ");
|
|
80
|
+
broadcast("");
|
|
81
|
+
broadcast("Welcome, " + playerName + "! Your adventure begins...");
|
|
82
|
+
broadcast("");
|
|
83
|
+
|
|
84
|
+
// Choose a class — affects base damage
|
|
85
|
+
broadcast("Choose your class:");
|
|
86
|
+
broadcast(" 1) 🗡️ Warrior (base damage: 20)");
|
|
87
|
+
broadcast(" 2) 🧙 Mage (base damage: 15, bonus crit)");
|
|
88
|
+
broadcast(" 3) 🏹 Ranger (base damage: 18)");
|
|
89
|
+
|
|
90
|
+
equip classChoice = interact("Enter 1, 2, or 3: ");
|
|
91
|
+
equip baseDamage = 15;
|
|
92
|
+
equip className = "Adventurer";
|
|
93
|
+
|
|
94
|
+
quest (classChoice == "1") {
|
|
95
|
+
baseDamage = 20;
|
|
96
|
+
className = "Warrior";
|
|
97
|
+
broadcast("🗡️ You chose Warrior! Strength is your ally.");
|
|
98
|
+
} side_quest (classChoice == "2") {
|
|
99
|
+
baseDamage = 15;
|
|
100
|
+
className = "Mage";
|
|
101
|
+
broadcast("🧙 You chose Mage! Arcane power flows through you.");
|
|
102
|
+
} side_quest (classChoice == "3") {
|
|
103
|
+
baseDamage = 18;
|
|
104
|
+
className = "Ranger";
|
|
105
|
+
broadcast("🏹 You chose Ranger! Swift and precise.");
|
|
106
|
+
} retreat {
|
|
107
|
+
broadcast("🤷 Invalid choice. You're a confused peasant with a stick.");
|
|
108
|
+
baseDamage = 10;
|
|
109
|
+
className = "Peasant";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
broadcast("");
|
|
113
|
+
|
|
114
|
+
// ── Player stats ────────────────────────────────────────
|
|
115
|
+
equip playerHealth = maxHealth;
|
|
116
|
+
equip potions = 3;
|
|
117
|
+
equip gold = 0;
|
|
118
|
+
equip enemiesSlain = 0;
|
|
119
|
+
|
|
120
|
+
// ── The Dungeon: a combat grind ─────────────────────────
|
|
121
|
+
broadcast("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
122
|
+
broadcast("You descend into the Dungeon of Glitches...");
|
|
123
|
+
broadcast("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
124
|
+
broadcast("");
|
|
125
|
+
|
|
126
|
+
// Enemy roster
|
|
127
|
+
equip enemyNames = "Slime,Skeleton,Goblin,Dark Knight,Glitch Dragon";
|
|
128
|
+
equip enemyHealths = "30,45,40,70,120";
|
|
129
|
+
equip enemyDamages = "5,10,8,15,25";
|
|
130
|
+
equip enemyGold = "10,20,15,50,200";
|
|
131
|
+
|
|
132
|
+
equip currentEnemy = 0;
|
|
133
|
+
equip totalEnemies = 5;
|
|
134
|
+
equip gameOver = defeat;
|
|
135
|
+
|
|
136
|
+
grind (currentEnemy < totalEnemies && gameOver == defeat) {
|
|
137
|
+
|
|
138
|
+
// ── Determine enemy stats ─────────────────────────────
|
|
139
|
+
// (Simulating array access with conditional lookup)
|
|
140
|
+
equip eName = "Unknown";
|
|
141
|
+
equip eHealth = 30;
|
|
142
|
+
equip eDamage = 5;
|
|
143
|
+
equip eGold = 10;
|
|
144
|
+
|
|
145
|
+
quest (currentEnemy == 0) {
|
|
146
|
+
eName = "🟢 Slime";
|
|
147
|
+
eHealth = 30;
|
|
148
|
+
eDamage = 5;
|
|
149
|
+
eGold = 10;
|
|
150
|
+
} side_quest (currentEnemy == 1) {
|
|
151
|
+
eName = "💀 Skeleton";
|
|
152
|
+
eHealth = 45;
|
|
153
|
+
eDamage = 10;
|
|
154
|
+
eGold = 20;
|
|
155
|
+
} side_quest (currentEnemy == 2) {
|
|
156
|
+
eName = "👺 Goblin";
|
|
157
|
+
eHealth = 40;
|
|
158
|
+
eDamage = 8;
|
|
159
|
+
eGold = 15;
|
|
160
|
+
} side_quest (currentEnemy == 3) {
|
|
161
|
+
eName = "🖤 Dark Knight";
|
|
162
|
+
eHealth = 70;
|
|
163
|
+
eDamage = 15;
|
|
164
|
+
eGold = 50;
|
|
165
|
+
} side_quest (currentEnemy == 4) {
|
|
166
|
+
eName = "🐉 Glitch Dragon";
|
|
167
|
+
eHealth = 120;
|
|
168
|
+
eDamage = 25;
|
|
169
|
+
eGold = 200;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
broadcast("══════════════════════════════════════");
|
|
173
|
+
broadcast("⚔️ A wild " + eName + " appears!");
|
|
174
|
+
broadcast("══════════════════════════════════════");
|
|
175
|
+
|
|
176
|
+
equip hitCount = 0;
|
|
177
|
+
|
|
178
|
+
// ── Combat loop ───────────────────────────────────────
|
|
179
|
+
grind (eHealth > 0 && playerHealth > 0) {
|
|
180
|
+
|
|
181
|
+
broadcast("");
|
|
182
|
+
showHealthBar(playerName, playerHealth, maxHealth);
|
|
183
|
+
showHealthBar(eName, eHealth, eHealth + hitCount * 10);
|
|
184
|
+
broadcast("");
|
|
185
|
+
|
|
186
|
+
broadcast("What will you do?");
|
|
187
|
+
broadcast(" 1) ⚔️ Attack");
|
|
188
|
+
broadcast(" 2) 🧪 Use Potion (" + potions + " left)");
|
|
189
|
+
broadcast(" 3) 🏃 Run Away");
|
|
190
|
+
|
|
191
|
+
equip action = interact("Choose action (1/2/3): ");
|
|
192
|
+
|
|
193
|
+
quest (action == "1") {
|
|
194
|
+
// ── Attack with error handling ────────────────────
|
|
195
|
+
boss_fight {
|
|
196
|
+
hitCount = hitCount + 1;
|
|
197
|
+
equip dmg = calculateDamage(baseDamage, hitCount);
|
|
198
|
+
|
|
199
|
+
// Mages get bonus on every 2nd hit
|
|
200
|
+
quest (className == "Mage" && hitCount % 2 == 0) {
|
|
201
|
+
dmg = dmg + 5;
|
|
202
|
+
broadcast("✨ Arcane bonus! +5 damage");
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
eHealth = eHealth - dmg;
|
|
206
|
+
broadcast("🗡️ You hit " + eName + " for " + dmg + " damage!");
|
|
207
|
+
|
|
208
|
+
quest (eHealth <= 0) {
|
|
209
|
+
broadcast("🎉 " + eName + " has been defeated!");
|
|
210
|
+
gold = gold + eGold;
|
|
211
|
+
enemiesSlain = enemiesSlain + 1;
|
|
212
|
+
broadcast("💰 You earned " + eGold + " gold! (Total: " + gold + ")");
|
|
213
|
+
} retreat {
|
|
214
|
+
// Enemy strikes back
|
|
215
|
+
equip enemyHit = eDamage;
|
|
216
|
+
playerHealth = playerHealth - enemyHit;
|
|
217
|
+
playerHealth = clamp(playerHealth, 0, maxHealth);
|
|
218
|
+
broadcast("🔥 " + eName + " hits you for " + enemyHit + " damage!");
|
|
219
|
+
}
|
|
220
|
+
} revive (err) {
|
|
221
|
+
broadcast("⚠️ A glitch occurred in combat: " + err);
|
|
222
|
+
broadcast("The matrix resets... you take 5 damage.");
|
|
223
|
+
playerHealth = playerHealth - 5;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
} side_quest (action == "2") {
|
|
227
|
+
// ── Use potion ────────────────────────────────────
|
|
228
|
+
quest (potions > 0) {
|
|
229
|
+
potions = potions - 1;
|
|
230
|
+
equip oldHealth = playerHealth;
|
|
231
|
+
playerHealth = clamp(playerHealth + potionHeal, 0, maxHealth);
|
|
232
|
+
equip healed = playerHealth - oldHealth;
|
|
233
|
+
broadcast("🧪 You used a potion! Healed " + healed + " HP.");
|
|
234
|
+
broadcast(" Potions remaining: " + potions);
|
|
235
|
+
|
|
236
|
+
// Enemy still attacks while you heal!
|
|
237
|
+
playerHealth = playerHealth - eDamage;
|
|
238
|
+
playerHealth = clamp(playerHealth, 0, maxHealth);
|
|
239
|
+
broadcast("🔥 " + eName + " hits you while healing for " + eDamage + " damage!");
|
|
240
|
+
} retreat {
|
|
241
|
+
broadcast("❌ No potions left! You fumble around uselessly.");
|
|
242
|
+
// Wasted turn — enemy attacks
|
|
243
|
+
playerHealth = playerHealth - eDamage;
|
|
244
|
+
playerHealth = clamp(playerHealth, 0, maxHealth);
|
|
245
|
+
broadcast("🔥 " + eName + " punishes your mistake for " + eDamage + " damage!");
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
} side_quest (action == "3") {
|
|
249
|
+
// ── Run away ──────────────────────────────────────
|
|
250
|
+
broadcast("🏃 You flee from " + eName + "!");
|
|
251
|
+
broadcast("Cowardice has a price... -10 gold.");
|
|
252
|
+
quest (gold >= 10) {
|
|
253
|
+
gold = gold - 10;
|
|
254
|
+
} retreat {
|
|
255
|
+
gold = 0;
|
|
256
|
+
}
|
|
257
|
+
// Skip to next enemy (don't get loot)
|
|
258
|
+
respawn;
|
|
259
|
+
|
|
260
|
+
} retreat {
|
|
261
|
+
broadcast("🤔 Invalid action. You hesitate and the enemy strikes!");
|
|
262
|
+
playerHealth = playerHealth - eDamage;
|
|
263
|
+
playerHealth = clamp(playerHealth, 0, maxHealth);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// ── Check player death ──────────────────────────────
|
|
267
|
+
quest (playerHealth <= 0) {
|
|
268
|
+
broadcast("");
|
|
269
|
+
broadcast("💀 " + playerName + " has fallen in battle!");
|
|
270
|
+
broadcast("══════════════════════════════════════");
|
|
271
|
+
gameOver = victory;
|
|
272
|
+
rage_quit;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
currentEnemy = currentEnemy + 1;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// ── Game Over / Victory Screen ──────────────────────────
|
|
280
|
+
broadcast("");
|
|
281
|
+
broadcast("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
282
|
+
|
|
283
|
+
quest (gameOver == victory) {
|
|
284
|
+
// Player died
|
|
285
|
+
broadcast(" 💀 GAME OVER 💀");
|
|
286
|
+
broadcast("");
|
|
287
|
+
broadcast(" " + playerName + " the " + className);
|
|
288
|
+
broadcast(" fell in the dungeon.");
|
|
289
|
+
broadcast(" Enemies slain: " + enemiesSlain);
|
|
290
|
+
broadcast(" Gold collected: " + gold);
|
|
291
|
+
} retreat {
|
|
292
|
+
// Player survived all enemies!
|
|
293
|
+
broadcast(" 🏆 VICTORY! 🏆");
|
|
294
|
+
broadcast("");
|
|
295
|
+
broadcast(" " + playerName + " the " + className);
|
|
296
|
+
broadcast(" conquered the Dungeon of Glitches!");
|
|
297
|
+
broadcast(" Enemies slain: " + enemiesSlain);
|
|
298
|
+
broadcast(" Gold collected: " + gold);
|
|
299
|
+
broadcast(" Health remaining: " + playerHealth + "/" + maxHealth);
|
|
300
|
+
|
|
301
|
+
quest (potions > 0) {
|
|
302
|
+
broadcast(" Unused potions: " + potions);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
quest (playerHealth == maxHealth) {
|
|
306
|
+
broadcast("");
|
|
307
|
+
broadcast(" 🌟 PERFECT RUN — Not a scratch! 🌟");
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
broadcast("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
|
312
|
+
broadcast("");
|
|
313
|
+
broadcast("Thanks for playing The Dungeon of Glitches!");
|
|
314
|
+
broadcast("GG! 🎮");
|
|
315
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
spawn {
|
|
2
|
+
equip i = 1;
|
|
3
|
+
grind (i <= 30) {
|
|
4
|
+
quest (i % 15 == 0) {
|
|
5
|
+
broadcast("FizzBuzz");
|
|
6
|
+
} side_quest (i % 3 == 0) {
|
|
7
|
+
broadcast("Fizz");
|
|
8
|
+
} side_quest (i % 5 == 0) {
|
|
9
|
+
broadcast("Buzz");
|
|
10
|
+
} retreat {
|
|
11
|
+
broadcast(i);
|
|
12
|
+
}
|
|
13
|
+
i = i + 1;
|
|
14
|
+
}
|
|
15
|
+
}
|