MainHud/RandomEventManager.cs

RandomEventManager static class for the game's HUD. It triggers a wide set of randomized in-game events affecting player and AI state, logging messages via GameManager and applying health/attack/defense changes using CombatManager and Player model fields.

NetworkingFile Access
using System;
using System.Collections.Generic;
using System.Linq;
using Sandbox;
using Keyboard_Warriors_.Models;
using Keyboard_Warriors_.Systems;

namespace Keyboard_Warriors_.Managers;

public static class RandomEventManager
{

	public static bool HitJackpot { get; set; } = false;
	private static Random rand = new Random();

	public static void playSoundEffect( string soundEffect )
	{
		// Logs out directly to s&box engine diagnostics buffer
		GameManager.AddLog( soundEffect );
	}

	public static void randomEvent( ref Player player, ref Player ai, ref int playerBuff, ref int aiBuff )
	{
		if ( player == null || ai == null ) return;


		// 10% structural trigger window matching legacy base engine mechanics
		
			int eventType = rand.Next( 65 );
			GameManager.AddLog( "\n=== RANDOM MAINWARE EVENT ===" );

			switch ( eventType )
			{
				case 0:
					GameManager.AddLog( "** A strange green mist rolls in... Both players feel rejuvenated! +15HP! **" );
					player.hp += 15;
					ai.hp += 15;

					if ( player.hp > 100 ) player.hp = 100;
					if ( ai.hp > 100 ) ai.hp = 100;

					GameManager.AddLog( $"{player.name} are now at {player.hp} HP." );
					GameManager.AddLog( $"{ai.name} is now at {ai.hp} HP." );
					break;

				case 1:
					GameManager.AddLog( "** An atmospheric blue electric surge fills the sky, the AI gets zapped! -10HP! **" );
					CombatManager.applyDamage( ref ai, 10 );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;

				case 2:
					GameManager.AddLog( "** A dagger is dropped by a horserider running by, your next attack will be boosted by 10 next round! **" );
					playerBuff += 10;
					break;

				case 3:
					GameManager.AddLog( "** The ground shakes violently! Both fighters are dazed! No attacks this round! **" );
					playerBuff = -999;
					aiBuff = -999;
					break;

				case 4:
					GameManager.AddLog( "** A chicken walks across the battlefield... it lays an egg... nothing happens **" );
					break;

				case 5:
					GameManager.AddLog( "** A uranium surge pulses through the fighters! Everyone gets scorched! -20 HP! **" );
					CombatManager.applyDamage( ref player, 20 );
					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					CombatManager.applyDamage( ref ai, 20 );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;

				case 6:
					GameManager.AddLog( "** A spaceship hovers overhead and fires a confusion ray! Accuracy drops! **" );
					playerBuff = -1;
					aiBuff = -1;
					break;

				case 7:
					GameManager.AddLog( "** A mime walks silently across the battlefield miming a boxing match, taking damage and dealing... both laugh. +5 HP! **" );
					player.hp += 5;
					ai.hp += 5;

					if ( player.hp > 100 ) player.hp = 100;
					if ( ai.hp > 100 ) ai.hp = 100;

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;

				case 8:
					GameManager.AddLog( "** An old man limps into view, shaking his cane: 'You two get a real job!' **" );
					GameManager.AddLog( "*Everyone pauses in shame...*" );
					break;

				case 9:
					{
						GameManager.AddLog( "** A stork glides into view and drops a clothed bag, instead of a baby, it's a package! **" );
						GameManager.AddLog( "[SYSTEM MESSAGE]: Interactive console input disabled. Standard UI framework selection rolled automatically." );

						// Convert blocking Console.ReadLine sequence to an instantaneous server-authoritative engine roll
						int automaticRoll = rand.Next( 1, 4 );

						switch ( automaticRoll )
						{
							case 1:
								GameManager.AddLog( "The package releases a green tree imp, it winks, then emits a green healing mist your way! +20 HP!" );
								player.hp += 20;
								if ( player.hp > 100 ) player.hp = 100;
								break;

							case 2:
								GameManager.AddLog( "The package releases a mini barbarian, it roars, boosting a surge of strength! +10 damage next attack!" );
								playerBuff += 10;
								break;

							case 3:
								{
									int outcome = rand.Next( 2 );
									if ( outcome == 0 )
									{
										GameManager.AddLog( "The potion is white and upon ingesting an angel blesses you and heals your wounds for +15 HP! and +20 damage next attack!" );
										player.hp += 15;
										if ( player.hp > 100 ) player.hp = 100;
										playerBuff += 20;
									}
									else
									{
										GameManager.AddLog( "The potion is black with skulls emanating from the liquid, it explodes in your face! -15 HP!" );
										CombatManager.applyDamage( ref player, 15 );
									}
									break;
								}
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						break;
					}

				case 10:
					GameManager.AddLog( "**A lightning bolt strikes the center of the battlefield! The ground surges blue electric energy! The next attack from both fighters will be +20 damage! **" );
					playerBuff += 20;
					aiBuff += 20;
					break;

				case 11:
					GameManager.AddLog( "** A gnome runs up and tickles your armpit! You lose 5 attack points next round! **" );
					playerBuff -= 5;
					break;

				case 12:
					GameManager.AddLog( "** An enchanted mirror appears in front of you, showing a greater version of yourself. You're inspired! +10 HP! **" );
					player.hp += 10;
					if ( player.hp > 100 ) player.hp = 100;

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					break;

				case 13:
					GameManager.AddLog( "** The AI glitches and enters debug mode. It skips the next turn. **" );
					aiBuff = -999;
					break;

				case 14:
					GameManager.AddLog( "** A passing bard sings a morale-boosting song! Both fighters recover 10 HP and gain +5 damage next round! **" );

					player.hp += 10;
					ai.hp += 10;

					if ( player.hp > 100 ) player.hp = 100;
					if ( ai.hp > 100 ) ai.hp = 100;

					playerBuff += 5;
					aiBuff += 5;

					GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
					GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
					break;

				case 15:
					GameManager.AddLog( "**The AI starts to perform mathematical operations, writes 10 chivalry poems every 5 seconds, and names off weapons you've never heard of! AI gets a combat boost +20 points! **" );
					aiBuff += 20;
					break;

				case 16:
					{
						GameManager.AddLog( "** A veiled lady mushroom sprouts dramatically and whispers in your mind: 'Slap me or hear my tale... your fate awaits.' **" );
						GameManager.AddLog( "[SYSTEM MESSAGE]: Interactive choice rolled automatically to prevent engine blocking loop." );

						int automaticChoice = rand.Next( 1, 3 );
						int outcome = rand.Next( 2 );

						if ( automaticChoice == 1 )
						{
							if ( outcome == 0 )
							{
								GameManager.AddLog( "** The mushroom emits a misty toxic spore cloud and terrifies you! -15 HP! **" );
								CombatManager.applyDamage( ref player, 15 );
							}
							else
							{
								GameManager.AddLog( "** The mushroom bursts into gold dust! You inhale power! +15 attack next round! **" );
								playerBuff += 15;
							}
						}
						else
						{
							if ( outcome == 0 )
							{
								GameManager.AddLog( "** The mushroom speaking to your mind enters your emotions, it tells you a tale of tragic loss.. you feel emotionally drained. -10 HP. **" );
								CombatManager.applyDamage( ref player, 10 );
							}
							else
							{
								GameManager.AddLog( "** The mushroom infiltrates your endorphins and dopamine receptors and starts to whisper battle techniques! +10 damage, +10 HP restored! **" );
								playerBuff += 10;
								player.hp += 10;
								if ( player.hp > 100 ) player.hp = 100;
							}
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						break;
					}

				case 17:
					{
						GameManager.AddLog( "** An enchanted mirror floats before you, refracting with ethereal light... **" );
						int outcome = rand.Next( 2 );

						if ( outcome == 0 )
						{
							GameManager.AddLog( "** The reflection smiles proudly - a future champion! You're inspired! +15 HP and +10 attack next round! **" );
							player.hp += 15;
							if ( player.hp > 100 ) player.hp = 100;
							playerBuff += 10;
						}
						else
						{
							GameManager.AddLog( "** The reflection looks at you as a stranger, then laughs at you mockingly. You lose confidence. -10 HP and -5 attack next round. **" );
							player.hp -= 10;
							playerBuff -= 5;
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						break;
					}

				case 18:
					{
						GameManager.AddLog( "** A wormhole tears open in front of you! A future version of you steps out, battle-scarred and glowing with knowledge... **" );
						int outcome = rand.Next( 2 );

						if ( outcome == 0 )
						{
							GameManager.AddLog( "** They nod solemnly and hand you a device: 'Use this.. to help you with this battle.' It's a healing nanobot swarm! +25 HP! **" );
							player.hp += 25;
							if ( player.hp > 100 ) player.hp = 100;
						}
						else
						{
							GameManager.AddLog( "** They shake their head: 'You weren't supposed to come here...' They vanish in a flash of paradox light. You're dazed. -10 HP, -5 attack next round. **" );
							CombatManager.applyDamage( ref player, 10 );
							playerBuff -= 5;
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						break;
					}

				case 19:
					{
						GameManager.AddLog( "** A beggar walks nearby and coughs at you, giving you a nasty cold! -15 HP! **" );
						CombatManager.applyDamage( ref player, 15 );
						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						break;
					}

				case 20:
					{
						GameManager.AddLog( "** The AI proceeds with lightning fast optimization and patches its combat routines! **" );
						aiBuff = rand.Next( 6 ) + 5;
						GameManager.AddLog( $"** AI's attack caused +{aiBuff} damage points! **" );
						break;
					}

				case 21:
					{
						GameManager.AddLog( "** The AI receives targeting data from the heavens! **" );
						aiBuff = rand.Next( 7 ) + 4;
						GameManager.AddLog( $"** AI's buff increases by {aiBuff} damage points! **" );
						break;
					}

				case 22:
					{
						GameManager.AddLog( "** A purple unknown energy fills the air and causes heavy vibrations teeming with power! The AI's system... **" );
						int fluctuation = (rand.Next( 2 ) == 0) ? -3 : 5;
						aiBuff = fluctuation;

						if ( fluctuation > 0 )
							GameManager.AddLog( $"spikes with a chaotic flux! Attack is at {fluctuation} damage points" );
						else
							GameManager.AddLog( $"loses control of its operating system! It has lost {fluctuation} damage points" );

						break;
					}

				case 23:
					{
						GameManager.AddLog( "** The AI scoops up dirt with its servo arm and pitches it right into your eyes! **" );
						GameManager.AddLog( "** You scream in stinging eye pain as you grasp your face, you aren't facing the opponent and stumble around! You lose attack next round! **" );
						playerBuff = -999;
						break;
					}

				case 24:
					{
						GameManager.AddLog( "** You throw in a quick prayer and ask for assistance! **" );
						int outcome = rand.Next( 2 );

						if ( outcome == 0 )
						{
							GameManager.AddLog( "** Your answered by a divine energy, you have been blessed with +10 HP and +15 attack! **" );
							player.hp += 10;
							playerBuff += 15;
							if ( player.hp > 100 ) player.hp = 100;
						}
						else
						{
							GameManager.AddLog( "** You're ignored and forsaken with your prayer denied and you feel an evil energy overconsume you. You have been cursed with -10 HP and -15 attack! **" );
							CombatManager.applyDamage( ref player, 10 );
							playerBuff -= 15;
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						break;
					}

				case 25:
					{
						GameManager.AddLog( "** You throw two dice to determine your attack fate! **" );
						int die1 = rand.Next( 6 ) + 1;
						int die2 = rand.Next( 6 ) + 1;
						int diceSum = die1 + die2;

						GameManager.AddLog( $"** You rolled a {die1} and a {die2} for a total of {diceSum}! **" );
						GameManager.AddLog( $"** Your attack buff increases by {diceSum} points! **" );

						playerBuff = diceSum;
						break;
					}

				case 26:
					{
						GameManager.AddLog( "** The AI displays a hologram projection of two dice... **" );
						int die1 = rand.Next( 6 ) + 1;
						int die2 = rand.Next( 6 ) + 1;
						int total = die1 + die2;

						GameManager.AddLog( $"** The AI rolls a {die1} and a {die2}! Total: {total} **" );
						aiBuff += total;
						GameManager.AddLog( $"** The hologram dice charge the AI's attack with +{total} damage next round! **" );

						break;
					}

				case 27:
					{
						GameManager.AddLog( "** The AI pulls out a taser gun and shouts, 'Taser! Taser!' **" );
						int damage = rand.Next( 11 ) + 10;

						CombatManager.applyDamage( ref player, damage );
						playerBuff = -999;

						GameManager.AddLog( $"** You're shocked and twitching! -{damage} HP and you're stunned for a round! **" );
						playSoundEffect( "*BZZZZTTT!*" );

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						break;
					}

				case 28:
					{
						GameManager.AddLog( "** You find a mysterious scratch-off lottery ticket on the battlefield... **" );
						GameManager.AddLog( " It reads: '1 in 1000 chance to win BIG!' You nervously scratch it.." );

						int luck = rand.Next( 1000 );

						if ( luck == 0 )
						{
							GameManager.AddLog( "** JACKPOT!!! You've won the mythical grand prize! +100HP and +100 attack next round! **" );
							player.hp += 100;
							playerBuff += 100;

							if ( player.hp > 100 ) player.hp = 100;

							HitJackpot = true;
						}
						else
						{
							GameManager.AddLog( "** YOU LOSE!!! The ticket crumbles to dust. You droop your head in gambling shame. **" );
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						break;
					}

				case 29:
					{
						GameManager.AddLog( "** You roll a mythical d100... time and physics decides your power this turn! **" );
						int roll = rand.Next( 100 ) + 1;

						GameManager.AddLog( $"** You rolled: {roll}! **" );

						if ( roll == 100 )
						{
							playerBuff += 50;
							GameManager.AddLog( "** LEGENDARY ROLL! +50 attack this round!! **" );
						}
						else if ( roll >= 90 )
						{
							playerBuff += 30;
							GameManager.AddLog( "** Incredible! +30 attack! **" );
						}
						else if ( roll >= 70 )
						{
							playerBuff += 15;
							GameManager.AddLog( "** Not bad! +15 attack! **" );
						}
						else if ( roll >= 40 )
						{
							playerBuff += 5;
							GameManager.AddLog( "** A small edge. +5 attack! **" );
						}
						else if ( roll >= 10 )
						{
							playerBuff -= 10;
							GameManager.AddLog( "** Oof... -10 attack this round. **" );
						}
						else
						{
							playerBuff -= 20;
							GameManager.AddLog( "** CURSED! -20 attack! The dice, physics, God, time, and gravity hate you!! (at this moment) **" );
						}

						break;
					}

				case 30:
					{
						GameManager.AddLog( "** The AI projects its hologram of a d100 and rolls it! **" );
						int roll = rand.Next( 100 ) + 1;

						GameManager.AddLog( $"** AI rolled: {roll}! **" );

						if ( roll == 100 )
						{
							aiBuff += 50;
							GameManager.AddLog( "** CRITICAL ALGORITHM SUCCESS! AI gains +50 attack! **" );
						}
						else if ( roll >= 90 )
						{
							aiBuff += 30;
							GameManager.AddLog( "** AI adds up the good result into +30 attack damage! **" );
						}
						else if ( roll >= 70 )
						{
							aiBuff += 15;
							GameManager.AddLog( "** AI compiles with +15 attack! **" );
						}
						else if ( roll >= 40 )
						{
							aiBuff += 5;
							GameManager.AddLog( "** AI musters a small +5 attack! **" );
						}
						else if ( roll >= 10 )
						{
							aiBuff -= 10;
							GameManager.AddLog( "** AI finds some bugs messing up the d100 roll! -10 attack! **" );
						}
						else
						{
							aiBuff -= 20;
							GameManager.AddLog( "** BLUE SCREEN! AI loses 20 attack power! **" );
						}

						break;
					}
				case 31:
					{
						GameManager.AddLog( "** The AI operates its DJ set and plays an electrifying electronic beat! **" );
						GameManager.AddLog( "** The bass drops so hard the battlefield trembles... **" );

						int beatIntensity = rand.Next( 6 ) + 5;
						aiBuff += beatIntensity;

						GameManager.AddLog( $"** AI's attack is boosted by +{beatIntensity} damage next round! **" );
						GameManager.AddLog( "AI: \"Prepare for my Bass Cannon! - WUUUB WUB WUBB.\"" );

						break;
					}

				case 32:
					{
						GameManager.AddLog( "** The sun suddenly powers off and goes dark **" );
						int whoRecovers = rand.Next( 2 );

						if ( whoRecovers == 0 )
						{
							GameManager.AddLog( "** You adapt to the night. Next attack is guaranteed! **" );
							playerBuff += 10;
						}
						else
						{
							GameManager.AddLog( "** The AI's night vision kicks in. It gains +15 attack next round! **" );
							aiBuff += 15;
						}

						break;
					}

				case 33:
					{
						GameManager.AddLog( "** A strange anomaly appears on the battlefield! **" );

						int roll = rand.Next( 100 ) + 1;
						GameManager.AddLog( $"** Rolling for fate... you rolled: {roll}! **" );

						if ( roll <= 40 )
						{
							int dmg = rand.Next( 10 ) + 5;
							CombatManager.applyDamage( ref player, dmg );

							if ( player.hp < 0 )
								player.hp = 0;

							GameManager.AddLog( $"** A sudden shockwave hits YOU! -{dmg} HP! **" );
						}
						else if ( roll <= 70 )
						{
							int dmg = rand.Next( 10 ) + 5;
							CombatManager.applyDamage( ref ai, dmg );

							if ( ai.hp < 0 )
								ai.hp = 0;

							GameManager.AddLog( $"** The anomaly backfires on the AI! -{dmg} HP! **" );
						}
						else if ( roll <= 90 )
						{
							int dmg = rand.Next( 5 ) + 1;

							CombatManager.applyDamage( ref player, dmg );
							CombatManager.applyDamage( ref ai, dmg );

							if ( player.hp < 0 ) player.hp = 0;
							if ( ai.hp < 0 ) ai.hp = 0;

							GameManager.AddLog( $"** Both fighters are affected! -{dmg} HP each! **" );
						}
						else
						{
							GameManager.AddLog( "** Miraculously, nothing happens! Fate smiles on both combatants! **" );
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}

				case 34:
					{
						GameManager.AddLog( "** The combatants unleash unpredictable signature moves! **" );

						int roll = rand.Next( 100 ) + 1;

						if ( roll <= 35 )
						{
							int dmg = rand.Next( 15 ) + 10;

							CombatManager.applyDamage( ref player, dmg );

							if ( player.hp < 0 )
								player.hp = 0;

							GameManager.AddLog( $"** A spinning whirlwind of energy strikes YOU! -{dmg} HP! **" );
						}
						else if ( roll <= 70 )
						{
							int dmg = rand.Next( 15 ) + 10;

							CombatManager.applyDamage( ref ai, dmg );

							if ( ai.hp < 0 )
								ai.hp = 0;

							GameManager.AddLog( $"** The AI performs a devastating laser strike upon itself! -{dmg} HP! **" );
						}
						else if ( roll <= 90 )
						{
							int dmg = rand.Next( 8 ) + 5;

							CombatManager.applyDamage( ref player, dmg );
							CombatManager.applyDamage( ref ai, dmg );

							if ( player.hp < 0 ) player.hp = 0;
							if ( ai.hp < 0 ) ai.hp = 0;

							GameManager.AddLog( $"** A chaotic collision of moves hits both combatants! -{dmg} HP! **" );
						}
						else
						{
							GameManager.AddLog( "** The moves miss spectacularly! No one is hurt. **" );
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}

				case 35:
					{
						GameManager.AddLog( "** A LOGIC CHALLENGE APPEARS! **" );
						GameManager.AddLog( "It questions: 'If all X are Y, and all Y are Z, then all X are...?' " );

						int roll = rand.Next( 100 ) + 1;

						GameManager.AddLog( $"** You roll the logic dice... ({roll}) **" );

						if ( roll >= 95 )
						{
							GameManager.AddLog( "** GENIUS! You give the flawless answer: 'All X are Z.' " );
							CombatManager.applyDamage( ref ai, 35 );
							if ( ai.hp < 0 ) ai.hp = 0;
							GameManager.AddLog( "** Your brilliance strikes the AI for 35 damage! **" );
						}
						else if ( roll >= 75 )
						{
							GameManager.AddLog( "** Strong reasoning! You almost nail it but miss a small detail. **" );
							CombatManager.applyDamage( ref ai, 20 );
							if ( ai.hp < 0 ) ai.hp = 0;
							GameManager.AddLog( "** AI loses 20 health from being mentally outmaneuvered. **" );
						}
						else if ( roll >= 50 )
						{
							GameManager.AddLog( "** Your logic becomes shaky. **" );
							CombatManager.applyDamage( ref player, 20 );
							if ( player.hp < 0 ) player.hp = 0;
							GameManager.AddLog( "** The AI mocks your flawed reasoning! You take 20 psychic damage! **" );
						}
						else if ( roll >= 25 )
						{
							GameManager.AddLog( "** You answer: 'All X are treasure.' **" );
							CombatManager.applyDamage( ref player, 35 );
							if ( player.hp < 0 ) player.hp = 0;
							GameManager.AddLog( "** The AI cackles and fries your neurons. -35 health! **" );
						}
						else
						{
							GameManager.AddLog( "** CRITICAL LOGIC FAILURE!! You say: 'If all X are Y... then all Z are X!!' (The opposite!). **" );
							CombatManager.applyDamage( ref player, 40 );
							if ( player.hp < 0 ) player.hp = 0;
							GameManager.AddLog( "** The AI 'obliterates you' with 'active learning techniques' that leave you more confused! Wait Time = -40 health!! **" );
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}

				case 36:
					{
						GameManager.AddLog( "** An officer suddenly appears! Both you and the AI must explain yourselves! **" );

						int playerExcuse = rand.Next( 100 ) + 1;
						int aiExcuse = rand.Next( 100 ) + 1;

						GameManager.AddLog( $"You rolled a {playerExcuse} for your excuse." );
						GameManager.AddLog( $"AI rolled a {aiExcuse} for its excuse." );

						if ( playerExcuse >= 90 )
						{
							GameManager.AddLog( "** Your excuse was flawless. The officer is completely convinced! **" );
							playerBuff += 20;
							player.hp += 20;
						}
						else if ( playerExcuse >= 60 )
						{
							GameManager.AddLog( "** Your excuse is solid. You scrape by the officer. +10 attack! **" );
							playerBuff += 10;
						}
						else if ( playerExcuse >= 30 )
						{
							GameManager.AddLog( "** Your excuse makes you stutter, you lose composure. -10 health! **" );
							CombatManager.applyDamage( ref player, 10 );
							if ( player.hp < 0 ) player.hp = 0;
						}
						else
						{
							GameManager.AddLog( "** BUSTED! The officer saw right through your lies and humiliates you! -20 health and -20 attack! **" );
							playerBuff -= 20;
							CombatManager.applyDamage( ref player, 20 );
							if ( player.hp < 0 ) player.hp = 0;
						}


						if ( aiExcuse >= 90 )
						{
							GameManager.AddLog( "** AI delivers a textbook-perfect excuse in binary, the officer buys it. +20 health and +20 attack! **" );
							aiBuff += 20;
							ai.hp += 20;
						}
						else if ( aiExcuse >= 60 )
						{
							GameManager.AddLog( "** AI's excuse sounds robotic, but tricks the officer. +10 attack. **" );
							aiBuff += 10;
						}
						else if ( aiExcuse >= 30 )
						{
							GameManager.AddLog( "** AI hits a lag spike mid excuse, officer is suspicious. -10 health. **" );
							CombatManager.applyDamage( ref ai, 10 );
							if ( ai.hp < 0 ) ai.hp = 0;
						}
						else
						{
							GameManager.AddLog( "** BUSTED! The AI starts speaking in 404! Officer puts it in firewall cuffs! -20 health and attack! **" );
							aiBuff -= 20;
							CombatManager.applyDamage( ref ai, 20 );
							if ( ai.hp < 0 ) ai.hp = 0;
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}

				case 37:
					{
						GameManager.AddLog( "** A Rock-Paper-Scissors challenge begins! **" );
						GameManager.AddLog( "Choose your move: " );
						GameManager.AddLog( "1 = Rock, 2 = Paper, 3 = Scissors" );
						Log.Info( "> " );

						// 1. Give playerMove a default value (e.g., 1 for Rock) so the compiler is happy
						int playerMove = 1;

						// 2. Use the modern s&box Random system instead of 'rand'
						int aiMove = Random.Shared.Next( 3 ) + 1;

						string[] moveNames = { "", "Rock", "Paper", "Scissors" };

						GameManager.AddLog( $"** AI chooses {moveNames[aiMove]}! **" );

						// 3. Your original game logic comparisons
						if ( playerMove == aiMove )
						{
							GameManager.AddLog( "** It's a draw! No damage dealt! **" );
						}
						else if (
							(playerMove == 1 && aiMove == 3) ||
							(playerMove == 2 && aiMove == 1) ||
							(playerMove == 3 && aiMove == 2) )
						{
							GameManager.AddLog( "** You win the duel! AI loses 25 HP. **" );
							CombatManager.applyDamage( ref ai, 25 );
							if ( ai.hp < 0 ) ai.hp = 0;
						}
						else
						{
							GameManager.AddLog( "** AI wins the duel! You lose 10 HP. **" );
							CombatManager.applyDamage( ref player, 10 );
							if ( player.hp < 0 ) player.hp = 0;
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}

				case 38:
					{
						GameManager.AddLog( "** A game of CRAPS begins! **" );
						GameManager.AddLog( "You roll two dice..." );

						Func<int> rollDice = () =>
						{
							return (rand.Next( 6 ) + 1) + (rand.Next( 6 ) + 1);
						};

						int rollVal = rollDice();

						GameManager.AddLog( $"Come-out roll: {rollVal}" );

						if ( rollVal == 7 || rollVal == 11 )
						{
							GameManager.AddLog( "** NATURAL! You win instantly! AI loses 30HP! **" );
							CombatManager.applyDamage( ref ai, 30 );
							if ( ai.hp < 0 ) ai.hp = 0;
						}
						else if ( rollVal == 2 || rollVal == 3 || rollVal == 12 )
						{
							GameManager.AddLog( "** CRAPS! You lose instantly! You take 30 HP damage! **" );
							CombatManager.applyDamage( ref player, 30 );
							if ( player.hp < 0 ) player.hp = 0;
						}
						else
						{
							int point = rollVal;

							GameManager.AddLog( $"** Your point is {point}! Keep rolling until you hit {point} again (win) or 7 (lose). **" );

							while ( true )
							{
								rollVal = rollDice();

								GameManager.AddLog( $"You rolled: {rollVal}" );

								if ( rollVal == point )
								{
									GameManager.AddLog( "** You hit your point! You WIN! AI loses 25 HP. **" );
									CombatManager.applyDamage( ref ai, 25 );
									if ( ai.hp < 0 ) ai.hp = 0;
									break;
								}
								else if ( rollVal == 7 )
								{
									GameManager.AddLog( "** Seven-out! You lose! -25 HP. **" );
									CombatManager.applyDamage( ref player, 25 );
									if ( player.hp < 0 ) player.hp = 0;
									break;
								}
							}
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}

				case 39:
					{
						GameManager.AddLog( "\n Both you and the AI open up your dating apps" );

						int playerMatches = rand.Next( 21 );
						int aiMatches = rand.Next( 21 );

						GameManager.AddLog( $"You matched with {playerMatches} matches." );
						GameManager.AddLog( $"AI matched with {aiMatches} matches." );

						if ( playerMatches > aiMatches )
						{
							int damage = (playerMatches - aiMatches) * 2;

							CombatManager.applyDamage( ref ai, damage );
							if ( ai.hp < 0 ) ai.hp = 0;

							GameManager.AddLog( $"You're irresistible! AI loses {damage} HP from crushing loneliness!" );
						}
						else if ( aiMatches > playerMatches )
						{
							int damage = (aiMatches - playerMatches) * 2;

							CombatManager.applyDamage( ref player, damage );
							if ( player.hp < 0 ) player.hp = 0;

							GameManager.AddLog( $"AI's profile is on fire! You lose {damage} HP from rejection!" );
						}
						else
						{
							CombatManager.applyDamage( ref player, 5 );
							CombatManager.applyDamage( ref ai, 5 );
							if ( player.hp < 0 ) player.hp = 0;
							if ( ai.hp < 0 ) ai.hp = 0;

							GameManager.AddLog( "You both got the same matches, both are bitter. Both lose 5 HP." );
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}
				case 40:
					{
						GameManager.AddLog( "\n=== High Dice Duel Begins! ===" );

						Func<int> rollDie = () => rand.Next( 6 ) + 1;

						int p1 = rollDie();
						int p2 = rollDie();

						GameManager.AddLog( $"You rolled: [{p1}] [{p2}] (Total: {p1 + p2})" );

						// [SYSTEM NOTE]: Synchronous console input blocked to prevent engine stall. 
						// Automatic selection implemented for continuous UI execution.
						bool simulatedRerollIntent = rand.Next( 100 ) < 50;

						if ( simulatedRerollIntent )
						{
							GameManager.AddLog( "Re-roll options active... System executing re-roll." );

							int rerollChoice = rand.Next( 1, 4 );

							if ( rerollChoice == 1 )
								p1 = rollDie();
							else if ( rerollChoice == 2 )
								p2 = rollDie();
							else if ( rerollChoice == 3 )
							{
								p1 = rollDie();
								p2 = rollDie();
							}

							GameManager.AddLog( $"Your final roll: [{p1}] [{p2}] (Total: {p1 + p2})" );
						}

						int playerTotal = p1 + p2;

						int a1 = rollDie();
						int a2 = rollDie();

						GameManager.AddLog( $"AI rolled: [{a1}] [{a2}] (Total: {a1 + a2})" );

						bool aiReroll = false;

						if ( (a1 + a2) <= 6 )
						{
							aiReroll = rand.Next( 100 ) < 70;
						}
						else if ( (a1 + a2) <= 8 )
						{
							aiReroll = rand.Next( 100 ) < 40;
						}
						else
						{
							aiReroll = rand.Next( 100 ) < 10;
						}

						if ( aiReroll )
						{
							int rerollChoice = rand.Next( 3 ) + 1;

							if ( rerollChoice == 1 )
								a1 = rollDie();
							else if ( rerollChoice == 2 )
								a2 = rollDie();
							else
							{
								a1 = rollDie();
								a2 = rollDie();
							}

							GameManager.AddLog( $"AI re-rolled! Final roll: [{a1}] [{a2}] (Total: {a1 + a2})" );
						}
						else
						{
							GameManager.AddLog( "AI keeps its roll." );
						}

						int aiTotal = a1 + a2;

						if ( playerTotal > aiTotal )
						{
							GameManager.AddLog( "You WIN the duel! AI loses 25 HP." );
							CombatManager.applyDamage( ref ai, 25 );
						}
						else if ( aiTotal > playerTotal )
						{
							GameManager.AddLog( "AI wins the duel! You lose 25 HP." );
							CombatManager.applyDamage( ref player, 25 );
						}
						else
						{
							GameManager.AddLog( "It's a tie! Both lose 15 HP." );

							CombatManager.applyDamage( ref player, 15 );
							CombatManager.applyDamage( ref ai, 15 );
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}
				case 41:
					{
						GameManager.AddLog( "** A game of BLACKJACK begins! **" );

						Func<int> drawCard = () => rand.Next( 11 ) + 1;

						int playerTotal = drawCard() + drawCard();
						int aiTotal = drawCard() + drawCard();

						GameManager.AddLog( $"You are dealt cards totaling: {playerTotal}" );
						GameManager.AddLog( $"AI is showing: {aiTotal / 2} (one card hidden)" );

						while ( playerTotal < 17 && rand.Next( 100 ) < 65 )
						{
							int card = drawCard();
							playerTotal += card;
							GameManager.AddLog( $"You draw a {card}. Total: {playerTotal}" );
						}

						if ( playerTotal > 21 )
						{
							GameManager.AddLog( "** You BUST! AI wins automatically. -25 HP. **" );
							CombatManager.applyDamage( ref player, 25 );
						}
						else if ( playerTotal == 21 )
						{
							GameManager.AddLog( "** BLACKJACK!! AI loses -40 HP! **" );
							CombatManager.applyDamage( ref ai, 40 );
						}
						else
						{
							GameManager.AddLog( $"You stand with {playerTotal}." );
							GameManager.AddLog( $"AI reveals hidden total: {aiTotal}" );

							while ( aiTotal < 17 )
							{
								int card = drawCard();
								aiTotal += card;
								GameManager.AddLog( $"AI draws a {card}. Total: {aiTotal}" );
							}

							if ( aiTotal == 21 )
							{
								GameManager.AddLog( "** AI hits 21! You lose 40 HP! **" );
								CombatManager.applyDamage( ref player, 40 );
							}
							else if ( aiTotal > 21 || playerTotal > aiTotal )
							{
								GameManager.AddLog( $"** You win with {playerTotal} vs {aiTotal}! AI loses 25 HP! **" );
								CombatManager.applyDamage( ref ai, 25 );
							}
							else if ( aiTotal > playerTotal )
							{
								GameManager.AddLog( $"** AI wins with {aiTotal} vs {playerTotal}! You lose 25 HP! **" );
								CombatManager.applyDamage( ref player, 25 );
							}
							else
							{
								GameManager.AddLog( "** Tie! Both lose 10 HP. **" );
								CombatManager.applyDamage( ref player, 10 );
								CombatManager.applyDamage( ref ai, 10 );
							}
						}

						break;
					}

				case 42:
					{
						GameManager.AddLog( "** Russian Roulette begins! **" );

						int bulletPos = rand.Next( 6 );
						int chamber = rand.Next( 6 );

						GameManager.AddLog( $"Bullet is in chamber: {bulletPos + 1}" );
						GameManager.AddLog( $"You pull the trigger - Chamber {chamber + 1} fires!" );

						if ( chamber == bulletPos )
						{
							GameManager.AddLog( "BANG! -100 HP" );
							CombatManager.applyDamage( ref player, 100 );
						}
						else
						{
							GameManager.AddLog( "*CLICK* You survived! AI takes 25 HP from stress!" );
							CombatManager.applyDamage( ref ai, 25 );
						}

						if ( ai.hp > 0 )
						{
							bulletPos = rand.Next( 6 );
							chamber = rand.Next( 6 );

							GameManager.AddLog( $"AI pulls the trigger - Chamber {chamber + 1} fires!" );

							if ( chamber == bulletPos )
							{
								GameManager.AddLog( "BANG! AI takes -100 HP" );
								CombatManager.applyDamage( ref ai, 100 );
							}
							else
							{
								GameManager.AddLog( "*CLICK* AI survived! You take 25 HP from stress!" );
								CombatManager.applyDamage( ref player, 25 );
							}
						}

						break;
					}
				case 43:
					{
						GameManager.AddLog( "** The skies darken -- clouds gather overhead! **" );

						int weatherRoll = Random.Shared.Next( 1, 101 );

						if ( weatherRoll <= 50 )
						{
							int damage = Random.Shared.Next( 10, 31 );

							GameManager.AddLog( "** A sudden downpour strikes the AI! **" );
							GameManager.AddLog( $"AI takes {damage} HP from the storm!" );

							// Assuming your CombatManager component handles damage taking a player reference
							CombatManager.applyDamage( ref ai, damage );
						}
						else
						{
							GameManager.AddLog( "This AI's model must be water proof! The storm passes, no HP taken." );
						}

						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
						break;
					}

				case 44:
					{
						GameManager.AddLog( "** Welcome to the Monty Hall Challenge! **" );
						GameManager.AddLog( "Three doors stand before you. Behind one is VICTORY, behind the other is FAILURE." );

						int prizeDoor = Random.Shared.Next( 1, 4 );

						// Randomized Player Choice (1, 2, or 3) instead of Console.ReadLine
						int playerChoice = Random.Shared.Next( 1, 4 );
						GameManager.AddLog( $"[Auto-Choice] Player picks Door #{playerChoice}." );

						int aiChoice = Random.Shared.Next( 1, 4 );
						GameManager.AddLog( $"AI picks Door #{aiChoice}." );

						// Player Reveal Logic
						int revealDoorPlayer;
						do
						{
							revealDoorPlayer = Random.Shared.Next( 1, 4 );
						}
						while ( revealDoorPlayer == prizeDoor || revealDoorPlayer == playerChoice );

						GameManager.AddLog( $"Host reveals Door #{revealDoorPlayer} for you... it's FAILURE!" );

						// Randomized Player Decision: 50% chance to switch ('y' or 'n')
						bool playerSwitchDecision = Random.Shared.Next( 2 ) == 1;
						int finalChoicePlayer = playerChoice;

						if ( playerSwitchDecision )
						{
							for ( int i = 1; i <= 3; i++ )
							{
								if ( i != playerChoice && i != revealDoorPlayer )
								{
									finalChoicePlayer = i;
									break;
								}
							}
							GameManager.AddLog( $"[Auto-Choice] You decide to SWITCH to Door #{finalChoicePlayer}!" );
						}
						else
						{
							GameManager.AddLog( $"[Auto-Choice] You decide to STAY with Door #{finalChoicePlayer}." );
						}

						// AI Reveal Logic
						int revealDoorAI;
						do
						{
							revealDoorAI = Random.Shared.Next( 1, 4 );
						}
						while ( revealDoorAI == prizeDoor || revealDoorAI == aiChoice );

						GameManager.AddLog( $"Host reveals Door #{revealDoorAI} for AI... it's FAILURE!" );

						bool aiSwitch = Random.Shared.Next( 2 ) == 1;
						int finalChoiceAI = aiChoice;

						if ( aiSwitch )
						{
							for ( int i = 1; i <= 3; i++ )
							{
								if ( i != aiChoice && i != revealDoorAI )
								{
									finalChoiceAI = i;
									break;
								}
							}
							GameManager.AddLog( $"AI decides to SWITCH to Door #{finalChoiceAI}!" );
						}
						else
						{
							GameManager.AddLog( $"AI decides to STAY with Door #{finalChoiceAI}." );
						}

						// Evaluate Results
						if ( finalChoicePlayer == prizeDoor )
						{
							GameManager.AddLog( $"** YOU WIN! The prize was behind Door #{prizeDoor}! AI loses 35 HP! **" );
							CombatManager.applyDamage( ref ai, 35 );
						}
						else
						{
							GameManager.AddLog( $"** YOU LOSE! The prize was behind Door #{prizeDoor}! You lose 35 HP! **" );
							CombatManager.applyDamage( ref player, 35 );
						}

						if ( finalChoiceAI == prizeDoor )
						{
							GameManager.AddLog( $"** AI WINS! The prize was behind Door #{prizeDoor}! You take 35 HP damage! **" );
							CombatManager.applyDamage( ref player, 35 );
						}
						else
						{
							GameManager.AddLog( $"** AI LOSES! The prize was behind Door #{prizeDoor}! AI takes 35 HP damage! **" );
							CombatManager.applyDamage( ref ai, 35 );
						}

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
						break;
					}
				case 45:
					{
						GameManager.AddLog( "\n** A Gunslinger Duel Begins! **" );
						GameManager.AddLog( "Standoff... draw on the count of three." );

						const int BOTH_MISS_PCT = 5;
						const int PLAYER_ONLY_MISS = 12;
						const int AI_ONLY_MISS = 12;
						const int MUTUAL_KILL_PCT = 3;

						int r = Random.Shared.Next( 1, 101 );

						GameManager.AddLog( $"(Chance roll = {r})" );

						if ( r <= BOTH_MISS_PCT )
						{
							GameManager.AddLog( "** Both shooters fire and miss! Dust settles. No damage! **" );
						}
						else if ( r <= BOTH_MISS_PCT + PLAYER_ONLY_MISS )
						{
							GameManager.AddLog( "** You fumble the draw - you miss! The AI's bullet finds you. **" );
							CombatManager.applyDamage( ref player, 100 );
						}
						else if ( r <= BOTH_MISS_PCT + PLAYER_ONLY_MISS + AI_ONLY_MISS )
						{
							GameManager.AddLog( "** The AI calculated the angle of its aim incorrectly - it misses! Your shot lands true! **" );
							GameManager.AddLog( "BANG! AI takes -100HP." );
							CombatManager.applyDamage( ref ai, 100 );
						}
						else if ( r <= BOTH_MISS_PCT + PLAYER_ONLY_MISS + AI_ONLY_MISS + MUTUAL_KILL_PCT )
						{
							GameManager.AddLog( "** A brutal finale! Both guns fire true at the same instant! **" );
							GameManager.AddLog( "BANG! BANG! Both duelists fall!" );

							CombatManager.applyDamage( ref player, 100 );
							CombatManager.applyDamage( ref ai, 100 );
						}
						else
						{
							int playerSkill = 0;
							int aiSkill = 0;

							int playerQuick = Random.Shared.Next( 1, 101 ) + playerSkill;
							int aiQuick = Random.Shared.Next( 1, 101 ) + aiSkill;

							GameManager.AddLog( "** Quickdraw! **" );
							GameManager.AddLog( $"You quickdraw roll: {playerQuick}" );
							GameManager.AddLog( $"AI quickdraw roll: {aiQuick}" );

							if ( playerQuick > aiQuick )
							{
								GameManager.AddLog( "** Your shot is faster and lands accurate! AI takes -100HP! **" );
								CombatManager.applyDamage( ref ai, 100 );
							}
							else if ( aiQuick > playerQuick )
							{
								GameManager.AddLog( "** The AI's shot is faster and lands accurate! You take -100HP! **" );
								CombatManager.applyDamage( ref player, 100 );
							}
							else
							{
								GameManager.AddLog( "** It's a dead heat - both fire at the same instant and miss! **" );
							}
						}

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
						break;
					}

				case 46:
					{
						GameManager.AddLog( "** Treasure Chest Gamble! **" );
						GameManager.AddLog( "Three chests appear before you.." );
						GameManager.AddLog( "1. Golden Chest\n2. Silver Chest\n3. Wooden Chest\nChoose wisely: " );

						// Automatically randomize choice (1 to 3) instead of Console.ReadLine
						int choice = Random.Shared.Next( 1, 4 );
						GameManager.AddLog( $"[Auto-Choice] You choose Chest #{choice}." );

						int treasure = Random.Shared.Next( 1, 4 );

						if ( choice == treasure )
						{
							GameManager.AddLog( "You found a stash of potions! +20 HP!" );
							player.hp += 20;

							if ( player.hp > 100 )
								player.hp = 100;
						}
						else if ( Random.Shared.Next( 2 ) == 0 )
						{
							GameManager.AddLog( "It's a trap! Poison darts hit you! -20HP!" );
							CombatManager.applyDamage( ref player, 20 );
						}
						else
						{
							GameManager.AddLog( "The chest is empty. Nothing happens..." );
						}

						if ( player.hp < 0 ) player.hp = 0;

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						break;
					}
				case 47:
					{
						GameManager.AddLog( "** A glittering seam of ore suddenly erupts from the ground! **" );
						GameManager.AddLog( "You and the AI rush forward to grab what you can..\n" );

						List<Ore> ores = new List<Ore>
		{
			new Ore("Coal", 12, 0, 0, 0, "Just a lump of coal.. better than nothing."),
			new Ore("Copper", 10, 5, 1, 0, "Soft and reddish. A touch of energy."),
			new Ore("Iron", 10, 10, 2, 0, "Solid and dependable."),
			new Ore("Tin", 8, 3, 0, 1, "A softer metal. Grants minor reinforcement."),
			new Ore("Silver", 6, 12, 3, 1, "Shining silver - power surges a little."),
			new Ore("Gold", 5, 20, 4, 0, "The classic treasure. Feels invigorating."),
			new Ore("Obsidian", 4, 0, 6, 0, "Sharp volcanic glass - dangerous in hand."),
			new Ore("Mithril", 3, 15, 3, 3, "Light, strong, and legendary."),
			new Ore("Adamantine", 2, 25, 6, 4, "A mythic ore - your body feels reinforced."),
			new Ore("Dragonstone", 1, 30, 8, 0, "It pulses like fire. Incredible strength!"),
			new Ore("Aetherite", 1, 40, 10, 5, "Other worldly. Reality bends at your touch!")
		};

						// Local function adapted for s&box
						Ore PickOre()
						{
							int totalWeight = 0;
							foreach ( var o in ores ) totalWeight += o.Weight;

							int r = Random.Shared.Next( totalWeight );
							int running = 0;

							foreach ( var o in ores )
							{
								running += o.Weight;
								if ( r < running )
									return o;
							}

							return ores[ores.Count - 1];
						}

						Ore playerOre = PickOre();
						Ore aiOre = PickOre();

						GameManager.AddLog( $">> You found {playerOre.Name}! {playerOre.Flavor}" );
						GameManager.AddLog( $">> AI found {aiOre.Name}! {aiOre.Flavor}\n" );

						if ( playerOre.Heal > 0 )
						{
							player.hp += playerOre.Heal;
							if ( player.hp > 100 ) player.hp = 100;
							GameManager.AddLog( $"You heal +{playerOre.Heal} HP." );
						}

						if ( playerOre.Attack > 0 )
						{
							playerBuff += playerOre.Attack;
							GameManager.AddLog( $"Your attacks grow stronger! (+{playerOre.Attack})" );
						}

						if ( playerOre.Defense > 0 )
						{
							playerBuff += playerOre.Defense;
							GameManager.AddLog( $"Your defenses feel sturdier! (+{playerOre.Defense})" );
						}

						if ( aiOre.Heal > 0 )
						{
							ai.hp += aiOre.Heal;
							if ( ai.hp > 100 ) ai.hp = 100;
							GameManager.AddLog( $"AI heals +{aiOre.Heal} HP." );
						}

						if ( aiOre.Attack > 0 )
						{
							aiBuff += aiOre.Attack;
							GameManager.AddLog( $"AI's attacks grow stronger! (+{aiOre.Attack})" );
						}

						if ( aiOre.Defense > 0 )
						{
							aiBuff += aiOre.Defense;
							GameManager.AddLog( $"AI braces itself with new strength! (+{aiOre.Defense})" );
						}

						GameManager.AddLog( "\nThe seam collapses back into the ground. The fight continues!" );
						break;
					}

				case 48:
					{
						GameManager.AddLog( "\n=== RANDOM EVENT ===" );
						GameManager.AddLog( "** A horde of ZOMBIES shambles into the arena! **" );

						int hordeSize = Random.Shared.Next( 1, 6 ); // 1 to 5 scale.

						GameManager.AddLog( $"The horde size is: {hordeSize} (1 = tiny, 5 = massive)" );

						int baseDeathChance = 5;
						int baseWoundChance = 15;

						int deathChance = baseDeathChance * hordeSize;
						int woundChance = baseWoundChance * hordeSize;

						if ( deathChance > 60 ) deathChance = 60;
						if ( woundChance > 70 ) woundChance = 70;

						int playerRoll = Random.Shared.Next( 100 );
						int aiRoll = Random.Shared.Next( 100 );

						bool playerAlive = true;
						bool aiAlive = true;

						// Player outcome
						if ( playerRoll < deathChance )
						{
							GameManager.AddLog( "The zombies overwhelm YOU! You're torn apart!" );
							player.hp = 0;
							playerAlive = false;
						}
						else if ( playerRoll < deathChance + woundChance )
						{
							GameManager.AddLog( "You got clawed up and bitten! -30 HP!" );
							CombatManager.applyDamage( ref player, 30 );

							if ( player.hp < 0 )
								player.hp = 0;
						}
						else
						{
							GameManager.AddLog( "You fight the zombies off bravely!" );
						}

						// AI outcome
						if ( aiRoll < deathChance )
						{
							GameManager.AddLog( "The zombies swarm the AI! Circuits and machine parts fly everywhere!" );
							ai.hp = 0;
							aiAlive = false;
						}
						else if ( aiRoll < deathChance + woundChance )
						{
							GameManager.AddLog( "The AI takes heavy damage! -30 HP!" );
							CombatManager.applyDamage( ref ai, 30 );

							if ( ai.hp < 0 )
								ai.hp = 0;
						}
						else
						{
							GameManager.AddLog( "The AI crushes zombies with relentless force!" );
						}

						// Reward if both survive
						if ( playerAlive && aiAlive )
						{
							GameManager.AddLog( "\nYou and the AI stand victorious after the horde!" );

							int heal = 20;

							player.hp += heal;
							ai.hp += heal;

							if ( player.hp > 100 ) player.hp = 100;
							if ( ai.hp > 100 ) ai.hp = 100;

							playerBuff += 10;
							aiBuff += 10;

							GameManager.AddLog( $"Both gain +{heal} HP and +10 attack!" );
						}

						GameManager.AddLog( "The battlefield is littered with corpses!" );

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}
				case 49:
					{
						GameManager.AddLog( "\n=== ELEMENTAL ORBS APPEAR ===" );
						GameManager.AddLog( "Four glowing orbs rise from the ground..." );
						GameManager.AddLog( "1. Fire Orb\n2. Ice Orb\n3. Lightning Orb\n4. Earth Orb" );

						// Automatically randomize player choice (1 to 4) instead of Console.ReadLine
						int choice = Random.Shared.Next( 1, 5 );
						GameManager.AddLog( $"[Auto-Choice] You select Orb #{choice}." );

						int aiChoice = Random.Shared.Next( 1, 5 );

						void ApplyOrb( string name, int orb, Player target, ref int buff )
						{
							int luck = Random.Shared.Next( 100 );

							switch ( orb )
							{
								case 1: // Fire
									GameManager.AddLog( $"{name} grabs the **FIRE ORB**" );

									target.attack += 5;

									if ( luck < 70 )
									{
										GameManager.AddLog( $"{name} grabs the burning inferno! +15 attack!" );
										target.attack += 15;
									}
									else
									{
										GameManager.AddLog( $"{name} is burned from the untamed orb! -10 HP!" );
										target.hp -= 10;
									}
									break;

								case 2: // Lightning
									GameManager.AddLog( $"{name} grabs the **LIGHTNING ORB**" );

									if ( luck < 80 )
									{
										GameManager.AddLog( $"{name} becomes charged! +10 attack, +10 defense!" );

										target.attack += 10;
										target.defense += 10;
									}
									else
									{
										GameManager.AddLog( $"A thunderbolt loses control and backfires on {name}! -20 HP!" );
										target.hp -= 20;
									}
									break;

								case 3: // Ice
									GameManager.AddLog( $"{name} holds the **ICE ORB**" );
									GameManager.AddLog( $"{name} stiffens to reduce attack impact! +5 defense!" );

									target.defense += 5;

									if ( luck < 60 )
									{
										GameManager.AddLog( $"{name}'s skin solidifies like ice! +20 defense!" );
										target.defense += 20;
									}
									else
									{
										GameManager.AddLog( $"{name} freezes their fingers, frostbite! -8 HP!" );
										target.hp -= 8;
									}
									break;

								case 4: // Earth
									GameManager.AddLog( $"{name} scoops up the **EARTH ORB**" );

									if ( luck < 90 )
									{
										GameManager.AddLog( $"{name} gains the grounds fortitude! +30 HP!" );
										target.hp += 30;
									}
									else
									{
										GameManager.AddLog( $"{name} is crushed by the weight of dirt and stone! -25 HP!" );
										target.hp -= 25;
									}
									break;
							}

							if ( target.hp > 100 ) target.hp = 100;
							if ( target.hp < 0 ) target.hp = 0;
						}

						ApplyOrb( "Player", choice, player, ref playerBuff );
						ApplyOrb( "AI", aiChoice, ai, ref aiBuff );

						break;
					}

				case 50:
					{
						GameManager.AddLog( "\n=== WEAPON VAULT EVENT ===" );
						GameManager.AddLog( "A floating vault opens, revealing 4 weapons." );
						GameManager.AddLog( "1. Flame Blade (+15 atk)\n2. Frost Hammer (+10 atk, +5 def)\n3. Volt Dagger (+20 atk, 50% recoil chance)\n4. Stone Shield (+25 def)" );

						// Automatically randomize player choice (1 to 4) instead of Console.ReadLine
						int choice = Random.Shared.Next( 1, 5 );
						GameManager.AddLog( $"[Auto-Choice] You equip Weapon #{choice}." );

						int aiChoice = Random.Shared.Next( 1, 5 );

						void GiveWeapon( string name, int pick, Player target )
						{
							switch ( pick )
							{
								case 1:
									GameManager.AddLog( $"{name} equips the **Flame Blade**" );
									target.attack += 15;
									break;

								case 2:
									GameManager.AddLog( $"{name} equips the **Frost Hammer**" );
									target.attack += 10;
									target.defense += 5;
									break;

								case 3:
									GameManager.AddLog( $"{name} equips the **Volt Dagger**" );
									target.attack += 20;

									if ( Random.Shared.Next( 100 ) < 50 )
									{
										GameManager.AddLog( $"The dagger shocks {name}! -10 HP recoil!" );
										target.hp -= 10;
									}
									break;

								case 4:
									GameManager.AddLog( $"{name} equips the **Stone Shield**" );
									target.defense += 25;
									break;
							}

							if ( target.hp < 0 ) target.hp = 0;
						}

						GiveWeapon( "Player", choice, player );
						GiveWeapon( "AI", aiChoice, ai );

						break;
					}

				case 51:
					{
						GameManager.AddLog( "\n=== ALCHEMY TABLE EVENT ===" );
						GameManager.AddLog( "Four mysterious potions bubble on a wooden table..." );
						GameManager.AddLog( "1. Red Potion (Huge Heal)\n2. Blue Potion (Mystic Buff)\n3. Green Potion (Toxic Gamble)\n4. Purple Potion (Chaos Effect)" );

						// Automatically randomize player choice (1 to 4) instead of Console.ReadLine
						int choice = Random.Shared.Next( 1, 5 );
						GameManager.AddLog( $"[Auto-Choice] You drink Potion #{choice}." );

						int aiChoice = Random.Shared.Next( 1, 5 );

						void DrinkPotion( string name, int potion, Player target )
						{
							int luck = Random.Shared.Next( 100 );

							switch ( potion )
							{
								case 1:
									GameManager.AddLog( $"{name} drinks the **Red Potion**" );

									target.hp += 30;

									if ( luck < 20 )
									{
										GameManager.AddLog( "It was super-charged! +50 HP EXTRA!" );
										target.hp += 50;
									}
									break;

								case 2:
									GameManager.AddLog( $"{name} drinks the **Blue Potion**" );

									target.attack += 10;
									target.defense += 10;

									if ( luck < 35 )
									{
										GameManager.AddLog( $"{name}, the mystics granted you an extra +15 on attack and defense!" );

										target.attack += 15;
										target.defense += 15;
									}
									break;

								case 3:
									GameManager.AddLog( $"{name} drinks the **Green Potion**" );

									if ( luck < 50 )
									{
										GameManager.AddLog( $"{name} is poisoned! -30 HP!" );
										target.hp -= 30;
									}
									else
									{
										GameManager.AddLog( $"{name} gains hazmat strength! +30 attack!" );
										target.attack += 30;
									}
									break;

								case 4:
									GameManager.AddLog( $"{name} drinks the **Purple Potion**" );

									if ( luck < 33 )
									{
										GameManager.AddLog( $"{name} ascends briefly! +40 HP & +20 attack!" );

										target.hp += 40;
										target.attack += 20;
									}
									else if ( luck < 66 )
									{
										GameManager.AddLog( "The potion explodes! -50 HP!" );
										target.hp -= 50;
									}
									else
									{
										GameManager.AddLog( $"{name} becomes UNTOUCHABLE! +50 defense!" );
										target.defense += 50;
									}
									break;
							}

							if ( target.hp > 100 ) target.hp = 100;
							if ( target.hp < 0 ) target.hp = 0;
						}

						DrinkPotion( "Player", choice, player );
						DrinkPotion( "AI", aiChoice, ai );

						break;
					}
				case 52:
					{
						GameManager.AddLog( "\n=== DEATH DICE EVENT ===" );
						GameManager.AddLog( "A skeletal hand offers two dice..." );
						GameManager.AddLog( "Choose your die:\n1. Die of Life\n2. Die of Pain\n3. Die of Chaos\n4. Die of Death" );

						// Automatically randomize player choice (1 to 4) instead of Console.ReadLine
						int choice = Random.Shared.Next( 1, 5 );
						GameManager.AddLog( $"[Auto-Choice] You select Die #{choice}." );

						int aiChoice = Random.Shared.Next( 1, 5 );

						void RollDeathDie( string name, int pick, Player target )
						{
							int roll = Random.Shared.Next( 1, 5 );

							GameManager.AddLog( $"{name} rolls: **{roll}**" );

							switch ( pick )
							{
								case 1: // Life
									target.hp += roll * 10;
									GameManager.AddLog( $"{name} gains {roll * 10} HP!" );
									break;

								case 2: // Pain
									target.hp -= roll * 10;
									GameManager.AddLog( $"{name} loses {roll * 10} HP!" );
									break;

								case 3: // Chaos
									if ( roll % 2 == 0 )
									{
										target.attack += roll * 5;
										GameManager.AddLog( $"{name} gains {roll * 5} attack!" );
									}
									else
									{
										target.hp -= roll * 10;
										GameManager.AddLog( $"{name} takes {roll * 10} damage!" );
									}
									break;

								case 4: // Death
									if ( roll == 4 )
									{
										GameManager.AddLog( $"{name} is INSTANTLY DESTROYED!" );
										target.hp = 0;
									}
									else
									{
										GameManager.AddLog( $"{name} survives... but is drained." );
										target.hp -= 15;
									}
									break;
							}

							if ( target.hp > 100 ) target.hp = 100;
							if ( target.hp < 0 ) target.hp = 0;
						}

						RollDeathDie( "Player", choice, player );
						RollDeathDie( "AI", aiChoice, ai );

						break;
					}

				case 53:
					{
						GameManager.AddLog( "\n=== DEMON CONTRACT EVENT ===" );
						GameManager.AddLog( "A blazing red sigil appears beneath you both." );
						GameManager.AddLog( "\"SIGN THE CONTRACT AND GAIN POWER.. OR REFUSE AND BE WEAK!\" the demon roars.\n" );

						GameManager.AddLog( "Choose:\n1. Sign the contract\n2. Refuse it" );

						// Automatically randomize player choice (1 or 2) instead of Console.ReadLine
						int playerChoice = Random.Shared.Next( 1, 3 );
						int aiChoice = Random.Shared.Next( 1, 3 ); // 1 sign, 2 refuse.

						GameManager.AddLog( $"[Auto-Choice] You choose to {(playerChoice == 1 ? "sign" : "refuse")}." );
						GameManager.AddLog( $"AI chooses to {(aiChoice == 1 ? "sign" : "refuse")}!\n" );

						// CASE: BOTH SIGN.
						if ( playerChoice == 1 && aiChoice == 1 )
						{
							GameManager.AddLog( "** BOTH sign the demonic pact! **" );
							GameManager.AddLog( "An infernal rush of power surges through your bodies!" );

							player.attack += 20;
							player.defense += 10;
							player.hp += 30;

							ai.attack += 20;
							ai.defense += 10;
							ai.hp += 30;

							player.cursed = true;
							ai.cursed = true;

							// Rare instant death chance 1%.
							if ( Random.Shared.Next( 100 ) < 1 )
							{
								GameManager.AddLog( "\n** BUT THE DEMON CLAIMS A SOUL! YOU DIE INSTANTLY! **" );
								player.hp = 0;
							}

							if ( Random.Shared.Next( 100 ) < 1 )
							{
								GameManager.AddLog( "\n** THE DEMON CLAIMS THE AI'S SOUL! **" );
								ai.hp = 0;
							}

							if ( player.hp > 100 ) player.hp = 100;
							if ( ai.hp > 100 ) ai.hp = 100;
							break;
						}

						// CASE: PLAYER SIGNS, AI REFUSES.
						if ( playerChoice == 1 && aiChoice == 2 )
						{
							GameManager.AddLog( "** You sign, AI refuses! **" );
							GameManager.AddLog( "The demon favors your BOLDNESS." );

							player.attack += 20;
							player.defense += 10;
							player.hp += 30;
							player.cursed = true;

							// 5% chance the demon punishes the coward.
							if ( Random.Shared.Next( 100 ) < 5 )
							{
								GameManager.AddLog( "** The demon punishes the AI for cowardice! -15 HP **" );
								CombatManager.applyDamage( ref ai, 15 );
							}

							if ( player.hp > 100 ) player.hp = 100;
							if ( ai.hp < 0 ) ai.hp = 0;
							break;
						}

						// CASE: PLAYER REFUSES, AI SIGNS.
						if ( playerChoice == 2 && aiChoice == 1 )
						{
							GameManager.AddLog( "** AI signs, YOU refuse! **" );
							GameManager.AddLog( "The demon rewards the AI instead." );

							ai.attack += 20;
							ai.defense += 10;
							ai.hp += 30;
							ai.cursed = true;

							// 5% chance the demon punishes the coward.
							if ( Random.Shared.Next( 100 ) < 5 )
							{
								GameManager.AddLog( "** The demon punishes YOUR cowardice! -15 HP **" );
								CombatManager.applyDamage( ref player, 15 );
							}

							if ( ai.hp > 100 ) ai.hp = 100;
							if ( player.hp < 0 ) player.hp = 0;
							break;
						}

						// CASE: BOTH REFUSE.
						GameManager.AddLog( "** Both refuse! The demon is ENRAGED! **" );
						GameManager.AddLog( "It EXPLODES in fury - both take 10 HP!" );

						CombatManager.applyDamage( ref player, 10 );
						CombatManager.applyDamage( ref ai, 10 );

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}
				case 54:
					{
						GameManager.AddLog( "\n=== RANDOM EVENT ===" );
						GameManager.AddLog( "** SLOT MACHINE OF DOOM appears with three glowing reels! **" );
						GameManager.AddLog( "Both you and the AI pull the lever and hope for fortune... or DOOM!" );

						List<string> names = new List<string>
		{
			"SKULL", "HEART", "SWORD", "SHIELD", "CHAOS", "COIN", "BOMB"
		};

						// Adapted array assignment using Game.Random
						int[] pSpin = new int[3];
						int[] aSpin = new int[3];

						pSpin[0] = Random.Shared.Next( names.Count );
						pSpin[1] = Random.Shared.Next( names.Count );
						pSpin[2] = Random.Shared.Next( names.Count );

						aSpin[0] = Random.Shared.Next( names.Count );
						aSpin[1] = Random.Shared.Next( names.Count );
						aSpin[2] = Random.Shared.Next( names.Count );

						GameManager.AddLog( $"You reels: [{names[pSpin[0]]}] [{names[pSpin[1]]}] [{names[pSpin[2]]}]" );
						GameManager.AddLog( $"AI reels: [{names[aSpin[0]]}] [{names[aSpin[1]]}] [{names[aSpin[2]]}]" );
						GameManager.AddLog( "" );

						// Local helper method to replace lambda Func for block clarity inside the switch
						int CountSym( int[] spin, int sym )
						{
							int c = 0;
							for ( int i = 0; i < 3; i++ )
							{
								if ( spin[i] == sym ) c++;
							}
							return c;
						}

						// Player Outcome.
						int pSkull = CountSym( pSpin, 0 );
						int pHeart = CountSym( pSpin, 1 );
						int pSword = CountSym( pSpin, 2 );
						int pShield = CountSym( pSpin, 3 );
						int pChaos = CountSym( pSpin, 4 );
						int pCoin = CountSym( pSpin, 5 );
						int pBomb = CountSym( pSpin, 6 );

						GameManager.AddLog( "-- Resolving your spin --" );

						if ( pSkull == 3 )
						{
							GameManager.AddLog( "** HORRIFYING! Three SKULLS! You are instantly destroyed by the machine! **" );
							player.hp = 0;
						}
						else if ( pCoin == 3 )
						{
							GameManager.AddLog( "** JACKPOT OF DOOM! Three COINS! You are showered in gold and power! **" );
							player.hp += 50;
							if ( player.hp > 100 ) player.hp = 100;
							playerBuff += 30;
							GameManager.AddLog( "You gain +50 HP and +30 attack!" );
						}
						else if ( pSword == 3 )
						{
							GameManager.AddLog( "** Three SWORDS! Your weapons beam with energy! **" );
							playerBuff += 20;
							GameManager.AddLog( "You gain +20 attack buff!" );
						}
						else if ( pShield == 3 )
						{
							GameManager.AddLog( "** Three SHIELDS! The machine grants you protection! **" );
							player.hp += 20;
							if ( player.hp > 100 ) player.hp = 100;
							playerBuff += 5;
							GameManager.AddLog( "You heal +20 HP and gain a small defensive buff (+5 attack)." );
						}
						else if ( pBomb == 3 )
						{
							GameManager.AddLog( "** BOOM! Three BOMBS - the machine EXPLODES! Both fighters take critical damage! **" );
							int dmg = 40;
							CombatManager.applyDamage( ref player, dmg );
							CombatManager.applyDamage( ref ai, dmg );
							GameManager.AddLog( $"Both take {dmg} damage!" );
						}
						else if ( pChaos >= 1 )
						{
							GameManager.AddLog( "** CHAOS symbol! A random chaotic effect triggers on you... **" );
							int r = Random.Shared.Next( 6 );

							if ( r == 0 )
							{
								GameManager.AddLog( "Chaos swaps your HP with the AI's HP!" );
								int temp = player.hp;
								player.hp = ai.hp;
								ai.hp = temp;
							}
							else if ( r == 1 )
							{
								GameManager.AddLog( "Chaos swaps your base attack with the AI's base attack!" );
								int temp = player.attack;
								player.attack = ai.attack;
								ai.attack = temp;
							}
							else if ( r == 2 )
							{
								GameManager.AddLog( "Chaos swaps attack buffs!" );
								int temp = playerBuff;
								playerBuff = aiBuff;
								aiBuff = temp;
							}
							else if ( r == 3 )
							{
								GameManager.AddLog( "Chaos fully heals you!" );
								player.hp = 100;
							}
							else if ( r == 4 )
							{
								GameManager.AddLog( "Chaos STUNS the AI!" );
								aiBuff = -999;
							}
							else
							{
								GameManager.AddLog( "The machine sputters and explodes! Both take -15 HP!" );
								CombatManager.applyDamage( ref player, 15 );
								CombatManager.applyDamage( ref ai, 15 );
							}
						}
						else if ( pSkull == 2 )
						{
							GameManager.AddLog( "Two SKULLS - You take heavy damage!" );
							CombatManager.applyDamage( ref player, 25 );
						}
						else if ( pHeart == 3 )
						{
							GameManager.AddLog( "Three HEARTS - the machine blesses you with potent healing!" );
							player.hp += 30;
							if ( player.hp > 100 ) player.hp = 100;
						}
						else if ( pHeart == 2 )
						{
							GameManager.AddLog( "Two HEARTS - small healing granted." );
							player.hp += 15;
							if ( player.hp > 100 ) player.hp = 100;
						}
						else if ( pSword == 2 )
						{
							GameManager.AddLog( "Two SWORDS - modest weapon boost." );
							playerBuff += 10;
						}
						else if ( pShield == 2 )
						{
							GameManager.AddLog( "Two SHIELDS - small defensive aid and heal." );
							player.hp += 10;
							if ( player.hp > 100 ) player.hp = 100;
							playerBuff += 5;
						}
						else if ( pBomb >= 1 )
						{
							if ( Random.Shared.Next( 100 ) < 50 )
							{
								GameManager.AddLog( "A stray bomb fragment hits you! -15 HP" );
								CombatManager.applyDamage( ref player, 15 );
							}
							else
							{
								GameManager.AddLog( "Bomb fizzles but does not explode!" );
							}
						}
						else
						{
							if ( Random.Shared.Next( 100 ) < 50 )
							{
								GameManager.AddLog( "The machine coughs and gives you a tiny coin +5HP" );
								player.hp += 5;
								if ( player.hp > 100 ) player.hp = 100;
							}
							else
							{
								GameManager.AddLog( "Nothing much - the reels reset." );
							}
						}

						// AI outcome.
						int aSkull = CountSym( aSpin, 0 );
						int aHeart = CountSym( aSpin, 1 );
						int aSword = CountSym( aSpin, 2 );
						int aShield = CountSym( aSpin, 3 );
						int aChaos = CountSym( aSpin, 4 );
						int aCoin = CountSym( aSpin, 5 );
						int aBomb = CountSym( aSpin, 6 );

						GameManager.AddLog( "\n-- Resolving AI spin --" );

						if ( aSkull == 3 )
						{
							GameManager.AddLog( "** HORRIFYING! AI rolled three SKULLS and is instantly destroyed by the machine! **" );
							ai.hp = 0;
						}
						else if ( aCoin == 3 )
						{
							GameManager.AddLog( "** AI hits a JACKPOT (three COINS!) AI gained massive rewards! **" );
							ai.hp += 50;
							if ( ai.hp > 100 ) ai.hp = 100;
							aiBuff += 30;
							GameManager.AddLog( "AI +50 HP and +30 attack buff!" );
						}
						else if ( aSword == 3 )
						{
							GameManager.AddLog( "AI reeled three SWORDS - its weapons power up!" );
							aiBuff += 20;
						}
						else if ( aShield == 3 )
						{
							GameManager.AddLog( "AI reeled three SHIELDS - firewalling its defenses!" );
							ai.hp += 20;
							if ( ai.hp > 100 ) ai.hp = 100;
							aiBuff += 5;
						}
						else if ( aBomb == 3 )
						{
							GameManager.AddLog( "** BOOM! AI's machine explodes - both take heavy damage! **" );
							int dmg = 40;
							CombatManager.applyDamage( ref player, dmg );
							CombatManager.applyDamage( ref ai, dmg );
							GameManager.AddLog( $"Both take {dmg} damage!" );
						}
						else if ( aChaos >= 1 )
						{
							GameManager.AddLog( "AI triggered CHAOS! A random chaotic event affects the battlefield!" );
							int r = Random.Shared.Next( 6 );

							if ( r == 0 )
							{
								GameManager.AddLog( "Chaos swaps AI HP with yours!" );
								int temp = player.hp;
								player.hp = ai.hp;
								ai.hp = temp;
							}
							else if ( r == 1 )
							{
								GameManager.AddLog( "Chaos swaps base attacks!" );
								int temp = player.attack;
								player.attack = ai.attack;
								ai.attack = temp;
							}
							else if ( r == 2 )
							{
								GameManager.AddLog( "Chaos swaps attack buffs!" );
								int temp = playerBuff;
								playerBuff = aiBuff;
								aiBuff = temp;
							}
							else if ( r == 3 )
							{
								GameManager.AddLog( "AI's electrons go chaotic and fully heals the AI!" );
								ai.hp = 100;
							}
							else if ( r == 4 )
							{
								GameManager.AddLog( "AI sends an electric flux towards the player from chaos!" );
								playerBuff = -999;
							}
							else
							{
								GameManager.AddLog( "The machine backfires - both take -15 HP!" );
								CombatManager.applyDamage( ref player, 15 );
								CombatManager.applyDamage( ref ai, 15 );
							}
						}
						else if ( aSkull == 2 )
						{
							GameManager.AddLog( "AI reeled two SKULLS - heavy damage for AI!" );
							CombatManager.applyDamage( ref ai, 25 );
						}
						else if ( aHeart == 3 )
						{
							GameManager.AddLog( "AI reeled three HEARTS - it repairs magically!" );
							ai.hp += 30;
							if ( ai.hp > 100 ) ai.hp = 100;
						}
						else if ( aHeart == 2 )
						{
							GameManager.AddLog( "AI reeled two HEARTS - small heal." );
							ai.hp += 15;
							if ( ai.hp > 100 ) ai.hp = 100;
						}
						else if ( aSword == 2 )
						{
							GameManager.AddLog( "AI reeled two SWORDS - a simple weapons update." );
							aiBuff += 10;
						}
						else if ( aShield == 2 )
						{
							GameManager.AddLog( "AI reeled two SHIELDS - a cheap anti-virus package." );
							ai.hp += 10;
							if ( ai.hp > 100 ) ai.hp = 100;
							aiBuff += 5;
						}
						else if ( aBomb >= 1 )
						{
							if ( Random.Shared.Next( 100 ) < 50 )
							{
								GameManager.AddLog( "Bomb fragment penetrates the AI! -15 HP" );
								CombatManager.applyDamage( ref ai, 15 );
							}
							else
							{
								GameManager.AddLog( "AI's bomb loses the ignition, bomb secure!" );
							}
						}
						else
						{
							if ( Random.Shared.Next( 100 ) < 50 )
							{
								GameManager.AddLog( "AI gets a tiny bonus from the machine, +5 HP" );
								ai.hp += 5;
								if ( ai.hp > 100 ) ai.hp = 100;
							}
							else
							{
								GameManager.AddLog( "AI's spin was lackluster." );
							}
						}

						// Extra glitch jackpot.
						if ( (pCoin == 3 && aCoin == 3) && (Random.Shared.Next( 100 ) < 5) )
						{
							GameManager.AddLog( "\n*** 666 HELLFIRE JACKPOT!! The machine tears a hole in the sky! ***" );
							GameManager.AddLog( "Both fighters are burned - but then an artifact appears to empower the victor!" );

							player.hp -= 30;
							ai.hp -= 30;

							if ( player.hp > ai.hp )
							{
								playerBuff += 40;
								GameManager.AddLog( "You find a cursed relic: +40 attack!" );
							}
							else
							{
								aiBuff += 40;
								GameManager.AddLog( "AI finds a cursed relic: +40 attack!" );
							}
						}

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;
						if ( player.hp > 100 ) player.hp = 100;
						if ( ai.hp > 100 ) ai.hp = 100;

						GameManager.AddLog( "\nThe Slot Machine of Doom closes with a mechanical groan.. its lights flicker off." );
						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}
				case 55:
					{
						GameManager.AddLog( "\n=== DRAGON'S GAMBIT ===" );
						GameManager.AddLog( "The sky trembles, an Ancient Dragon descends, its presence warping reality." );
						GameManager.AddLog( "Both fighters must choose how they face the beast.\n" );

						GameManager.AddLog( "1. Attack the dragon head-on (high risk, high PERMANENT reward)" );
						GameManager.AddLog( "2. Defend against the dragon (moderate risk, permanent defense reward)" );
						GameManager.AddLog( "3. Attempt to flee (low chance of escaping, high chance of punishment)" );
						GameManager.AddLog( "4. Try to negotiate (very high risk, very high reward)\n" );

						// Automatically randomize choice (1 to 4) instead of Console.ReadLine
						int pChoice = Random.Shared.Next( 1, 5 );
						int aChoice = Random.Shared.Next( 1, 5 );

						GameManager.AddLog( $"[Auto-Choice] You choose stance #{pChoice}." );

						// Local helper method instead of a lambda Action for block compatibility
						void ResolveDragonGambit( int choice, Player unit, bool isPlayer )
						{
							string who = isPlayer ? "Player" : "AI";
							int atkGain = 0;
							int defGain = 0;

							switch ( choice )
							{
								// 1. Attack Dragon.
								case 1:
									{
										int dmg = Random.Shared.Next( 20, 51 ); // 20-50
										atkGain = Random.Shared.Next( 4, 10 );  // +4 to +9

										unit.hp -= dmg;
										unit.attack += atkGain;

										GameManager.AddLog( $"{who} strikes the dragon! Takes -{dmg} HP, but absorbs Dragon Blood: +{atkGain} permanent attack." );
										break;
									}

								// 2. Defend.
								case 2:
									{
										int dmg = Random.Shared.Next( 10, 31 ); // 10-30
										defGain = Random.Shared.Next( 2, 6 );   // +2 to +5

										unit.hp -= dmg;
										unit.defense += defGain;

										GameManager.AddLog( $"{who} braces against the flames. -{dmg} HP. Gains Dragon Scales: +{defGain} permanent defense." );
										break;
									}

								// 3. Flee.
								case 3:
									{
										int luck = Random.Shared.Next( 100 );

										if ( luck < 35 )
										{
											GameManager.AddLog( $"{who} escapes untouched!" );
										}
										else if ( luck < 75 )
										{
											int dmg = Random.Shared.Next( 10, 36 ); // 10-35
											unit.hp -= dmg;
											GameManager.AddLog( $"{who} fails to escape and is scorched! -{dmg} HP." );
										}
										else
										{
											int doom = Random.Shared.Next( 40, 91 ); // 40-90
											unit.hp -= doom;
											GameManager.AddLog( $"{who} is CRITICALLY struck by the dragon! -{doom} HP." );
										}
										break;
									}

								// 4. Negotiate.
								case 4:
									{
										int luck = Random.Shared.Next( 100 );

										// Dragon's Favor (super rare).
										if ( luck < 10 )
										{
											atkGain = Random.Shared.Next( 10, 20 );
											defGain = Random.Shared.Next( 10, 20 );

											unit.attack += atkGain;
											unit.defense += defGain;

											GameManager.AddLog( $"{who} speaks ancient words. The dragon bows!" );
											GameManager.AddLog( $"{who} receives DRAGON'S FAVOR: +{atkGain} attack, +{defGain} defense permanently!" );
										}
										else if ( luck < 50 )
										{
											int dmg = Random.Shared.Next( 10, 21 );
											unit.hp -= dmg;
											GameManager.AddLog( $"{who}'s words fail. The dragon lashes out! -{dmg} HP." );
										}
										else
										{
											// Dragon's Curse (severe penalty).
											int curseAtk = Random.Shared.Next( 2, 6 );
											int curseDef = Random.Shared.Next( 2, 6 );

											unit.attack -= curseAtk;
											unit.defense -= curseDef;

											if ( unit.attack < 1 ) unit.attack = 1;
											if ( unit.defense < 0 ) unit.defense = 0;

											GameManager.AddLog( $"{who} angers the dragon!" );
											GameManager.AddLog( $"Dragon's Curse: -{curseAtk} attack, -{curseDef} defense permanently!" );
										}
										break;
									}
							}

							if ( unit.hp > 100 ) unit.hp = 100;
							if ( unit.hp < 0 ) unit.hp = 0;
						}

						// Resolve choices.
						ResolveDragonGambit( pChoice, player, true );
						ResolveDragonGambit( aChoice, ai, false );

						GameManager.AddLog( "\nThe dragon ascends into the burning, lightning clouds..." );
						break;
					}

				case 56:
					{
						GameManager.AddLog( "\n=== COIN OF FATE ===" );
						GameManager.AddLog( "A silver gleaming coin falls from the sky, fate demands a flip!" );

						void Flip( string who, ref Player unit )
						{
							int roll = Random.Shared.Next( 0, 2 ); // 0 = bad, 1 = good.

							if ( roll == 1 )
							{
								int gain = Random.Shared.Next( 5, 11 ); // +5 to 10 attack.
								unit.attack += gain;
								GameManager.AddLog( $"{who} wins the flip! +{gain} permanent attack!" );
							}
							else
							{
								int dmg = Random.Shared.Next( 10, 35 ); // 10-34 HP punishment.
								unit.hp -= dmg;
								GameManager.AddLog( $"{who} loses the flip! -{dmg} HP!" );
							}

							if ( unit.hp < 0 ) unit.hp = 0;
						}

						Flip( "Player", ref player );
						Flip( "AI", ref ai );
						break;
					}

				case 57:
					{
						void GuessGame( Player pUnit, Player aUnit )
						{
							int secret = Random.Shared.Next( 1, 6 ); // Number from 1-5.

							GameManager.AddLog( "\n=== GUESS THE NUMBER ===" );
							GameManager.AddLog( "A hidden number from 1 to 5 has been chosen." );

							// Automatically randomize player guess (1 to 5) instead of Console.ReadLine
							int playerGuess = Random.Shared.Next( 1, 6 );
							int aiGuess = Random.Shared.Next( 1, 6 );

							GameManager.AddLog( $"[Auto-Guess] You guess: {playerGuess}" );
							GameManager.AddLog( $"AI guesses: {aiGuess}" );
							GameManager.AddLog( $"The secret number was: {secret}!\n" );

							// PLAYER RESULT.
							if ( playerGuess == secret )
							{
								int gain = Random.Shared.Next( 5, 11 );
								pUnit.attack += gain;
								GameManager.AddLog( $"You guessed correctly! +{gain} attack!" );
							}
							else
							{
								int dmg = Random.Shared.Next( 5, 21 );
								CombatManager.applyDamage( ref pUnit, dmg );
								if ( pUnit.hp < 0 ) pUnit.hp = 0;
								GameManager.AddLog( $"Wrong! You lose {dmg} HP!" );
							}

							// AI RESULT.
							if ( aiGuess == secret )
							{
								int gain = Random.Shared.Next( 5, 11 );
								aUnit.attack += gain;
								GameManager.AddLog( $"AI guessed correctly! AI gains +{gain} attack!" );
							}
							else
							{
								int dmg = Random.Shared.Next( 5, 21 );
								CombatManager.applyDamage( ref aUnit, dmg );
								if ( aUnit.hp < 0 ) aUnit.hp = 0;
								GameManager.AddLog( $"AI guessed wrong! AI loses {dmg} HP!" );
							}

							GameManager.AddLog( "=========================" );
						}

						GuessGame( player, ai );

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );
						break;
					}
				case 58:
					{
						GameManager.AddLog( "\n=== TRIVIA GAUNTLET ===" );
						GameManager.AddLog( "Both challengers must answer correctly to earn rewards!" );

						int triviaCase = Random.Shared.Next( 0, 5 ); // Number of trivia questions.

						switch ( triviaCase )
						{
							case 0:
								{
									GameManager.AddLog( "\n[Trivia] Which planet has the most moons?" );
									GameManager.AddLog( "1. Earth 2. Mars 3. Jupiter 4. Saturn 5. Uranus 6. Neptune" );

									int correct = 4; // Saturn.

									// Automatically randomized player pick instead of Console.ReadLine
									int pGuess = Random.Shared.Next( 1, 7 );
									int aiGuess = Random.Shared.Next( 1, 7 );

									GameManager.AddLog( $"[Auto-Pick] You pick: {pGuess}" );
									GameManager.AddLog( $"AI picks: {aiGuess}" );
									GameManager.AddLog( $"Correct answer: {correct}\n" );

									if ( pGuess == correct )
									{
										GameManager.AddLog( "Player is correct! +10 attack!" );
										player.attack += 10;
									}
									else
									{
										GameManager.AddLog( "Player is wrong! -10 HP!" );
										CombatManager.applyDamage( ref player, 10 );
									}

									if ( aiGuess == correct )
									{
										GameManager.AddLog( "AI is correct! +10 attack!" );
										ai.attack += 10;
									}
									else
									{
										GameManager.AddLog( "AI is wrong! -10 HP!" );
										CombatManager.applyDamage( ref ai, 10 );
									}
									break;
								}

							case 1:
								{
									GameManager.AddLog( "\n[Trivia] Who was the first President of the United States?" );
									GameManager.AddLog( "1. Adams 2. Jefferson 3. Lincoln 4. Roosevelt 5. Washington 6. Franklin" );

									int correct = 5;

									int pGuess = Random.Shared.Next( 1, 7 );
									int aiGuess = Random.Shared.Next( 1, 7 );

									GameManager.AddLog( $"[Auto-Pick] You pick: {pGuess}" );
									GameManager.AddLog( $"AI picks: {aiGuess}" );
									GameManager.AddLog( $"Correct answer: {correct}\n" );

									if ( pGuess == correct )
									{
										GameManager.AddLog( "Player is correct! +10 attack!" );
										player.attack += 10;
									}
									else
									{
										GameManager.AddLog( "Player is wrong! -10 HP!" );
										CombatManager.applyDamage( ref player, 10 );
									}

									if ( aiGuess == correct )
									{
										GameManager.AddLog( "AI is correct! +10 attack!" );
										ai.attack += 10;
									}
									else
									{
										GameManager.AddLog( "AI is wrong! -10 HP!" );
										CombatManager.applyDamage( ref ai, 10 );
									}
									break;
								}

							case 2:
								{
									GameManager.AddLog( "\n[Trivia] What part of the cell contains DNA?" );
									GameManager.AddLog( "1. Cytoplasm 2. Membrane 3. Nucleus 4. Ribosome 5. Lysosome 6. Mitochondria" );

									int correct = 3;

									int pGuess = Random.Shared.Next( 1, 7 );
									int aiGuess = Random.Shared.Next( 1, 7 );

									GameManager.AddLog( $"[Auto-Pick] You pick: {pGuess}" );
									GameManager.AddLog( $"AI picks: {aiGuess}" );
									GameManager.AddLog( $"Correct answer: {correct}\n" );

									if ( pGuess == correct )
									{
										GameManager.AddLog( "Player is correct! +10 attack!" );
										player.attack += 10;
									}
									else
									{
										GameManager.AddLog( "Player is wrong! -10 HP!" );
										CombatManager.applyDamage( ref player, 10 );
									}

									if ( aiGuess == correct )
									{
										GameManager.AddLog( "AI is correct! +10 attack!" );
										ai.attack += 10;
									}
									else
									{
										GameManager.AddLog( "AI is wrong! -10 HP!" );
										CombatManager.applyDamage( ref ai, 10 );
									}
									break;
								}

							case 3:
								{
									GameManager.AddLog( "\n[Trivia] What is the Earth's largest ocean?" );
									GameManager.AddLog( "1. Atlantic 2. Indian 3. Arctic 4. Southern 5. Pacific 6. Dead Sea" );

									int correct = 5;

									int pGuess = Random.Shared.Next( 1, 7 );
									int aiGuess = Random.Shared.Next( 1, 7 );

									GameManager.AddLog( $"[Auto-Pick] You pick: {pGuess}" );
									GameManager.AddLog( $"AI picks: {aiGuess}" );
									GameManager.AddLog( $"Correct answer: {correct}\n" );

									if ( pGuess == correct )
									{
										GameManager.AddLog( "Player is correct! +10 attack!" );
										player.attack += 10;
									}
									else
									{
										GameManager.AddLog( "Player is wrong! -10 HP!" );
										CombatManager.applyDamage( ref player, 10 );
									}

									if ( aiGuess == correct )
									{
										GameManager.AddLog( "AI is correct! +10 attack!" );
										ai.attack += 10;
									}
									else
									{
										GameManager.AddLog( "AI is wrong! -10 HP!" );
										CombatManager.applyDamage( ref ai, 10 );
									}
									break;
								}

							case 4:
								{
									GameManager.AddLog( "\n[Trivia] Which video game franchise features a character named Master Chief?" );
									GameManager.AddLog( "1. Gears of War 2. Halo 3. Doom 4. Half-Life 2 5. Destiny 6. Titanfall" );

									int correct = 2;

									int pGuess = Random.Shared.Next( 1, 7 );
									int aiGuess = Random.Shared.Next( 1, 7 );

									GameManager.AddLog( $"[Auto-Pick] You pick: {pGuess}" );
									GameManager.AddLog( $"AI picks: {aiGuess}" );
									GameManager.AddLog( $"Correct answer: {correct}\n" );

									if ( pGuess == correct )
									{
										GameManager.AddLog( "Player is correct! +10 attack!" );
										player.attack += 10;
									}
									else
									{
										GameManager.AddLog( "Player is wrong! -10 HP!" );
										CombatManager.applyDamage( ref player, 10 );
									}

									if ( aiGuess == correct )
									{
										GameManager.AddLog( "AI is correct! +10 attack!" );
										ai.attack += 10;
									}
									else
									{
										GameManager.AddLog( "AI is wrong! -10 HP!" );
										CombatManager.applyDamage( ref ai, 10 );
									}
									break;
								}
						}

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;
						break;
					}

				case 59:
					{
						GameManager.AddLog( "\n=== BOMB DEFUSE: RED WIRE / BLUE WIRE ===" );

						int correct = Random.Shared.Next( 0, 2 ); // 0 = red, 1 = blue.

						GameManager.AddLog( "Choose a wire to cut:" );
						GameManager.AddLog( "1. Red" );
						GameManager.AddLog( "2. Blue" );

						// Automatically choose a wire (0 or 1) instead of using Console.ReadLine
						int choice = Random.Shared.Next( 0, 2 );
						int aiChoice = Random.Shared.Next( 0, 2 );

						GameManager.AddLog( $"[Auto-Choice] You choose: {(choice == 0 ? "Red" : "Blue")}" );
						GameManager.AddLog( $"AI chooses: {(aiChoice == 0 ? "Red" : "Blue")}" );

						if ( choice == correct )
						{
							GameManager.AddLog( "You cut the CORRECT wire! AI -15 HP!" );
							CombatManager.applyDamage( ref ai, 15 );
						}
						else
						{
							GameManager.AddLog( "WRONG WIRE! It explodes! You take -25 HP!" );
							CombatManager.applyDamage( ref player, 25 );
						}

						if ( aiChoice == correct )
						{
							GameManager.AddLog( "AI ALSO cut the correct wire! You take 15 damage!" );
							CombatManager.applyDamage( ref player, 15 );
						}
						else
						{
							GameManager.AddLog( "AI cut the wrong wire and got bombed! AI -25 HP!" );
							CombatManager.applyDamage( ref ai, 25 );
						}

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}
				case 60:
					{
						GameManager.AddLog( "\n=== MINI SLOT MACHINE ===" );

						int p1 = Random.Shared.Next( 1, 4 );
						int p2 = Random.Shared.Next( 1, 4 );
						int p3 = Random.Shared.Next( 1, 4 );

						GameManager.AddLog( $"You rolled:  [{p1}][{p2}][{p3}]" );

						bool playerWin = (p1 == p2 && p2 == p3);

						int a1 = Random.Shared.Next( 1, 4 );
						int a2 = Random.Shared.Next( 1, 4 );
						int a3 = Random.Shared.Next( 1, 4 );

						GameManager.AddLog( $"AI rolled:   [{a1}][{a2}][{a3}]" );

						bool aiWin = (a1 == a2 && a2 == a3);

						if ( playerWin && !aiWin )
						{
							GameManager.AddLog( "\nYOU HIT THE JACKPOT! +50 HP, AI -50 HP!" );
							player.hp += 50;
							CombatManager.applyDamage( ref ai, 50 );
						}
						else if ( aiWin && !playerWin )
						{
							GameManager.AddLog( "\nAI HIT THE JACKPOT! -50 HP, AI +50 HP!" );
							ai.hp += 50;
							CombatManager.applyDamage( ref player, 50 );
						}
						else if ( playerWin && aiWin )
						{
							GameManager.AddLog( "\nDOUBLE JACKPOT!! Both gain +50 HP!" );
							player.hp += 50;
							ai.hp += 50;
						}
						else
						{
							GameManager.AddLog( "\nNo jackpots.. Insert another coin." );
						}

						if ( player.hp > 100 ) player.hp = 100;
						if ( ai.hp > 100 ) ai.hp = 100;
						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}

				case 61:
					{
						GameManager.AddLog( "\n=== UNO DUEL ===" );

						string[] colors = { "Red", "Blue", "Green", "Yellow" };

						// Local helper methods instead of generic lambda variables
						int DrawCardType()
						{
							int roll = Random.Shared.Next( 100 );
							if ( roll < 65 ) return 0; // Number.
							if ( roll < 77 ) return 1; // Reverse.
							if ( roll < 92 ) return 2; // Draw Two.
							return 3; // Wild.
						}

						string GetCardTypeName( int t )
						{
							if ( t == 0 ) return "Number";
							if ( t == 1 ) return "Reverse";
							if ( t == 2 ) return "Draw Two";
							return "Wild";
						}

						int topColor = Random.Shared.Next( 4 );
						int topNumber = Random.Shared.Next( 10 );
						int topType = DrawCardType();

						int playerColor = Random.Shared.Next( 4 );
						int playerNumber = Random.Shared.Next( 10 );
						int playerType = DrawCardType();

						int aiColor = Random.Shared.Next( 4 );
						int aiNumber = Random.Shared.Next( 10 );
						int aiType = DrawCardType();

						GameManager.AddLog( $"\nTOP CARD: {GetCardTypeName( topType )} | {colors[topColor]} {topNumber}" );
						GameManager.AddLog( $"\nYOUR CARD: {GetCardTypeName( playerType )} | {colors[playerColor]} {playerNumber}" );
						GameManager.AddLog( $"\nAI CARD: {GetCardTypeName( aiType )} | {colors[aiColor]} {aiNumber}" );

						bool playerCanPlay =
							playerType == 3 ||
							playerType == topType ||
							playerColor == topColor ||
							playerNumber == topNumber;

						GameManager.AddLog( "\n1. Play card\n2. Draw card" );

						// Automatically simulate choice: play if possible, otherwise draw
						int pChoice = playerCanPlay ? 1 : 2;

						if ( pChoice == 1 && playerCanPlay )
						{
							GameManager.AddLog( "You play your card!" );

							if ( playerType == 1 )
							{
								GameManager.AddLog( "REVERSE! You steal 10 HP!" );
								CombatManager.applyDamage( ref ai, 10 );
								player.hp += 10;
							}
							else if ( playerType == 2 )
							{
								GameManager.AddLog( "DRAW TWO! AI loses 20 HP!" );
								CombatManager.applyDamage( ref ai, 20 );
							}
							else if ( playerType == 3 )
							{
								// Auto-pick color
								topColor = Random.Shared.Next( 4 );
								GameManager.AddLog( $"[Auto-Choice] WILD CARD! Color changed to {colors[topColor]}!" );
							}

							topColor = playerColor;
							topNumber = playerNumber;
							topType = playerType;
						}
						else if ( pChoice == 1 )
						{
							GameManager.AddLog( "Invalid play! UNO penalty! -15 HP" );
							CombatManager.applyDamage( ref player, 15 );
						}
						else
						{
							GameManager.AddLog( "You draw and skip." );
						}

						bool aiCanPlay =
							aiType == 3 ||
							aiType == topType ||
							aiColor == topColor ||
							aiNumber == topNumber;

						GameManager.AddLog( "\nAI's turn!" );

						if ( aiCanPlay && ai.hp > 15 )
						{
							GameManager.AddLog( "AI plays its card!" );

							if ( aiType == 1 )
							{
								GameManager.AddLog( "AI REVERSE! AI steals 10 HP!" );
								CombatManager.applyDamage( ref player, 10 );
								ai.hp += 10;
							}
							else if ( aiType == 2 )
							{
								GameManager.AddLog( "AI DRAW TWO! You lose 20 HP!" );
								CombatManager.applyDamage( ref player, 20 );
							}
							else if ( aiType == 3 )
							{
								topColor = Random.Shared.Next( 4 );
								GameManager.AddLog( $"AI uses WILD! Its color is now {colors[topColor]}" );
							}

							topColor = aiColor;
							topNumber = aiNumber;
							topType = aiType;
						}
						else
						{
							GameManager.AddLog( "AI draws a card." );
							if ( !aiCanPlay )
							{
								GameManager.AddLog( "AI failed to play! -15 HP" );
								CombatManager.applyDamage( ref ai, 15 );
							}
						}

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;
						if ( player.hp > 100 ) player.hp = 100;
						if ( ai.hp > 100 ) ai.hp = 100;

						GameManager.AddLog( "\nEND OF UNO DUEL" );
						GameManager.AddLog( $"{player.name} | HP: {player.hp} | Armor: {player.defense}" );
						GameManager.AddLog( $"{ai.name} | HP: {ai.hp} | Armor: {ai.defense}" );

						break;
					}
				case 62:
					{
						GameManager.AddLog( "\n=== CHAOS ARENA (TEST) ===" );

						List<EventFighter> fighters = new List<EventFighter>()
								{
									new EventFighter("Player", player.hp, player.attack, false),
									new EventFighter("AI", ai.hp, ai.attack, true),
									new EventFighter("Goblin", 40, 8, true),
									new EventFighter("Orc", 60, 12, true)
								};

						int lowestRoll = 999;
						int loserIndex = 0;

						for ( int i = 0; i < fighters.Count; i++ )
						{
							int roll = Random.Shared.Next( 100 );

							GameManager.AddLog( $"{fighters[i].Name} rolls {roll}" );

							if ( roll < lowestRoll )
							{
								lowestRoll = roll;
								loserIndex = i;
							}
						}

						GameManager.AddLog( $"{fighters[loserIndex].Name} loses the challenge! -20 HP" );

						EventFighter temp = fighters[loserIndex];
						temp.Hp -= 20;
						fighters[loserIndex] = temp;

						foreach ( EventFighter f in fighters )
						{
							if ( f.Name == "Player" )
								player.hp = f.Hp;

							if ( f.Name == "AI" )
								ai.hp = f.Hp;
						}

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( "\nChaos Arena ends!" );
						break;
					}

				case 63:
					{
						GameManager.AddLog( "\n=== MEGA ARENA ===" );

						List<EventFighter> fighters = new List<EventFighter>()
									{
										new EventFighter("Player", player.hp, player.attack, false),
										new EventFighter("AI", ai.hp, ai.attack, true),
										new EventFighter("Goblin", 40, 8, true),
										new EventFighter("Orc", 60, 12, true)
									};

						List<int> rolls = new List<int>();
						int totalRoll = 0;

						for ( int i = 0; i < fighters.Count; i++ )
						{
							int roll = Random.Shared.Next( 1, 5 );
							rolls.Add( roll );
							totalRoll += roll;

							GameManager.AddLog( $"{fighters[i].Name} chooses {totalRoll}" );
						}

						GameManager.AddLog( $"\nTotal Roll Value: {totalRoll}" );

						int damage = 0;

						if ( totalRoll <= 6 )
						{
							damage = fighters.Count;
						}
						else if ( totalRoll <= 9 )
						{
							damage = 3;
						}
						else if ( totalRoll <= 12 )
						{
							damage = 2;
						}
						else if ( totalRoll <= 15 )
						{
							damage = 1;
						}
						else
						{
							damage = 0;
						}

						GameManager.AddLog( $"{damage} fighter(s) will take 15 damage!" );

						for ( int i = 0; i < damage; i++ )
						{
							int target = Random.Shared.Next( fighters.Count );

							EventFighter temp = fighters[target];
							temp.Hp -= 15;
							fighters[target] = temp;

							// Log the message using the damaged fighter's name!
							GameManager.AddLog( $"{temp.Name} takes 15 damage!" );
						}
					

						foreach ( EventFighter f in fighters )
						{
							if ( f.Name == "Player" )
								player.hp = f.Hp;

							if ( f.Name == "AI" )
								ai.hp = f.Hp;
						}

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( "\n=== EVENT CONCLUDED ===" );
						break;
					}

				case 64:
					{
						GameManager.AddLog( "\n=== MEGA ARENA WITH STATS ===" );

						List<EventFighter> fighters = new List<EventFighter>()
								{
									new EventFighter("Player", player.hp, player.attack, false),
									new EventFighter("AI", ai.hp, ai.attack, true),
									new EventFighter("Goblin", 40, 8, true),
									new EventFighter("Orc", 60, 12, true)
								};

						List<int> strength = new List<int>() { 15, 12, 8, 18 };
						List<int> agility = new List<int>() { 12, 10, 15, 6 };
						List<int> luck = new List<int>() { 10, 8, 5, 4 };
						List<int> defense = new List<int>() { 10, 9, 6, 14 };

						for ( int i = 0; i < fighters.Count; i++ )
						{
							int baseRoll = Random.Shared.Next( 1, 101 );

							int statBonus =
								(strength[i] / 2) +
								(agility[i] / 3) +
								(luck[i] / 4);

							int finalRoll = baseRoll + statBonus;

							GameManager.AddLog( $"{fighters[i].Name} rolls {baseRoll} + stat bonus {statBonus} = {finalRoll}" );

							int threshold = 60 - (defense[i] / 2);

							if ( finalRoll < threshold )
							{
								int damage = 20 - (defense[i] / 4);

								if ( damage < 5 )
									damage = 5;

								EventFighter temp = fighters[i];
								temp.Hp -= damage;
								fighters[i] = temp;

								GameManager.AddLog( $"{fighters[i].Name} FAILS and takes {damage} damage!" );
							}
							else
							{
								GameManager.AddLog( $"{fighters[i].Name} succeeds and avoids damage!" );
							}
						}

						foreach ( EventFighter f in fighters )
						{
							if ( f.Name == "Player" )
								player.hp = f.Hp;

							if ( f.Name == "AI" )
								ai.hp = f.Hp;
						}

						if ( player.hp < 0 ) player.hp = 0;
						if ( ai.hp < 0 ) ai.hp = 0;

						GameManager.AddLog( "=== EVENT COMPLETE ===" );
						break;
					}
			}
		
	}
}