//Rūdolfs Čābūts 110 //Minigames v0.5 program //Šī ir programma, kurā ir dažas minigames. Esmu izveidojis arī vienkāršu valūtas sistēmu, kur spēlētājs var izvēlēties dažādas summas, un pēc tam vinnēt vai zaudēt atkarībā no minigame rezultāta. //Es biju aizmirsis ielikt progresu pec katras stundas beigas, bet es katras stundas beigas un kad mājas uz viņu strādāju atsutiju vinu sev tāpec visas versijas man ir saglabatas un ari ieliktas IS projekts. Un komentēšanas pēc šī ir diena pirms pedejas stundas (06.03.2026.) un man iepriekš bija stradigas dienas prieks ši darba, bet šodien ir pedeja diena un es šo rakstu kad jau esmu tuvu pabeigšanai, bet es esmu nosedejis ĻOTI ILGI ar šo čakarējoties. Es tiešām ceru ka šis darbs atbilst pēc iespējas vairāk kritēriju un lai veicas vērtēt un labot ;) Lai jums jauka diena!!! :D using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Net.Configuration; using System.Runtime.InteropServices; using System.Security.Policy; using System.Text; using System.Threading.Tasks; namespace Minigames_v0._6 { public class Cards { public string[,] cards = { { "Ace", "Deuce", "Trey", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" }, //hearts { "Ace", "Deuce", "Trey", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" }, //diamonds { "Ace", "Deuce", "Trey", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" }, //clubs { "Ace", "Deuce", "Trey", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" } //spade }; } class gameChoice { public static SpeletajaStatistika iestatijumi = new SpeletajaStatistika("Spēlētājs"); public static void Main() { Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Choose an option:"); Console.WriteLine("(1) - Coin Flip"); Console.WriteLine("(2) - BlackJack"); Console.WriteLine("(3) - Settings"); Console.WriteLine("(4) - Exit"); Console.WriteLine(); int choice = Convert.ToInt32(Console.ReadLine()); switch (choice) { case 1: coinFlip coinFlip = new coinFlip(); coinFlip.Flip(); break; case 2: blackJack blackJack = new blackJack(); blackJack.Play(); break; case 3: Console.Clear(); Console.WriteLine("=== SETTINGS ==="); Console.WriteLine("Pašreizējais lietotājs: " + iestatijumi.ProfilaVards); Console.WriteLine("(1) - Ieslēgt kāršu vērtību palīdzību (PRO mode OFF)"); Console.WriteLine("(2) - Izslēgt kāršu vērtību palīdzību (PRO mode ON)"); Console.WriteLine("(3) - HARD MODE"); Console.WriteLine("(4) - Atpakaļ"); Console.WriteLine(); int setChoice = Convert.ToInt32(Console.ReadLine()); if (setChoice == 1) { iestatijumi.VaiJaunsSpeletajs = true; iestatijumi.SniegtBonusu(); } else if (setChoice == 2) { iestatijumi.VaiJaunsSpeletajs = false; Console.WriteLine("Palīdzība izslēgta!"); } else if (setChoice == 3) { iestatijumi.VaiJaunsSpeletajs = false; Console.WriteLine("TU JUTIES BAIGI LABS!?!"); } System.Threading.Thread.Sleep(500); Console.Clear(); Main(); break; case 4: break; default: Console.Clear(); Main(); break; } } } public class Betting { public static int money = 100; public static int bet; public static void placeBet() { bet = 0; Console.WriteLine("Balance: " + money + "$"); Console.WriteLine("(1) - Bet 5$"); Console.WriteLine("(2) - Bet 10$"); Console.WriteLine("(3) - Bet 20$"); Console.WriteLine("(4) - ALL IN $$$"); Console.WriteLine("(5) - Bet chosen amount $"); Console.WriteLine("(6) - Back"); Console.WriteLine(); int choice = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); switch (choice) { case 1: money = money - 5; bet = bet + 5; Console.Clear(); Console.WriteLine("Balance: " + money + "$"); Console.WriteLine(); Console.WriteLine("Bet: " + bet + "$"); Console.WriteLine(); break; case 2: money = money - 10; bet = bet + 10; Console.Clear(); Console.WriteLine("Balance: " + money + "$"); Console.WriteLine(); Console.WriteLine("Bet: " + bet + "$"); Console.WriteLine(); break; case 3: money = money - 20; bet = bet + 20; Console.Clear(); Console.WriteLine("Balance: " + money + "$"); Console.WriteLine(); Console.WriteLine("Bet: " + bet + "$"); Console.WriteLine(); break; case 4: bet = money; money = money - bet; Console.Clear(); Console.WriteLine("Balance: " + money + "$"); Console.WriteLine(); Console.WriteLine("Bet: " + bet + "$"); Console.WriteLine(); break; case 5: Console.WriteLine(); Console.WriteLine("Enter the amount:"); int customBet = Convert.ToInt32(Console.ReadLine()); money = money - customBet; bet = bet + customBet; Console.Clear(); Console.WriteLine("Balance: " + money + "$"); Console.WriteLine(); Console.WriteLine("Bet: " + bet + "$"); Console.WriteLine(); break; case 6: Console.Clear(); gameChoice.Main(); break; } } } public class coinFlip { public static void Flip() { Console.Clear(); Console.WriteLine("Minigame: Coin Flip"); Console.WriteLine(); Betting.placeBet(); Random rand = new Random(); int flipResult = rand.Next(1, 101); // 50/50 chance Console.WriteLine("Flipping the coin..."); Console.WriteLine(); System.Threading.Thread.Sleep(2000); // Flipping time if (flipResult > 50) // makes it 49/51 chance, beacuse the house always wins >:D { Console.WriteLine("It's Heads! You win!"); Betting.money = Betting.money + (Betting.bet * 2); Console.WriteLine(); Console.WriteLine("Balance: " + Betting.money + "$"); } else { Console.WriteLine("It's Tails! You lose!"); Console.WriteLine(); Console.WriteLine("Balance: " + Betting.money + "$"); } Console.WriteLine(); gameChoice.Main(); } } public class blackJack { public static void Play() { Console.Clear(); Console.WriteLine("Minigame: BlackJack"); Console.WriteLine(); Betting.placeBet(); string[] cardHandNPC; cardHandNPC = new string[4]; string rndType = null; //Dealer NPC string[] cardTypeArrayNPC; cardTypeArrayNPC = new string[4]; string[] cardHand; cardHand = new string[4]; //Player string[] cardTypeArray; cardTypeArray = new string[4]; Random rand = new Random(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Dealing NPC`s cards..."); Console.WriteLine(); System.Threading.Thread.Sleep(2000); // Card giving time int npcHandValue = 0; for (int i = 0; i < 3; i++) //NPC card random { int rndTypeRow = rand.Next(0, 4); int rndValue = rand.Next(0, 13); Cards Cards = new Cards(); string rndCard = Cards.cards[rndTypeRow, rndValue]; if (rndTypeRow == 0) { rndType = "Hearts"; } else if (rndTypeRow == 1) { rndType = "Diamonds"; } else if (rndTypeRow == 2) { rndType = "Clubs"; } else if (rndTypeRow == 3) { rndType = "Spades"; } cardHandNPC[i] = rndCard; cardTypeArrayNPC[i] = rndType; npcHandValue += GetCardValue(rndCard); } if (gameChoice.iestatijumi.VaiJaunsSpeletajs) { Console.WriteLine("NPC kartis: " + cardHandNPC[0] + cardTypeArrayNPC[0] + " (" + GetCardValue(cardHandNPC[0]) + ") " + cardHandNPC[1] + cardTypeArrayNPC[1] + " (" + GetCardValue(cardHandNPC[1]) + ")"); } else { Console.WriteLine("NPC kartis: " + cardHandNPC[0] + cardTypeArrayNPC[0] + " " + cardHandNPC[1] + cardTypeArrayNPC[1]); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Dealing cards..."); Console.WriteLine(); System.Threading.Thread.Sleep(1500); // Card giving time int playerHandValue = 0; for (int i = 0; i < 3; i++) //Player card random { int rndTypeRow = rand.Next(0, 4); int rndValue = rand.Next(0, 13); Cards Cards = new Cards(); string rndCard = Cards.cards[rndTypeRow, rndValue]; if (rndTypeRow == 0) { rndType = "Hearts"; } else if (rndTypeRow == 1) { rndType = "Diamonds"; } else if (rndTypeRow == 2) { rndType = "Clubs"; } else if (rndTypeRow == 3) { rndType = "Spades"; } cardHand[i] = rndCard; cardTypeArray[i] = rndType; playerHandValue += GetCardValue(rndCard); } playerHandValue = GetCardValue(cardHand[0]) + GetCardValue(cardHand[1]); npcHandValue = GetCardValue(cardHandNPC[0]) + GetCardValue(cardHandNPC[1]); System.Threading.Thread.Sleep(1500); // Card giving time if (gameChoice.iestatijumi.VaiJaunsSpeletajs) { Console.Write("Tavas kartis: " + cardHand[0] + cardTypeArray[0] + " (" + GetCardValue(cardHand[0]) + ") " + cardHand[1] + cardTypeArray[1] + " (" + GetCardValue(cardHand[1]) + ")"); Console.WriteLine(); Console.WriteLine("Hand Value: " + playerHandValue); } else { Console.Write("Tavas kartis: " + cardHand[0] + cardTypeArray[0] + " " + cardHand[1] + cardTypeArray[1]); Console.WriteLine(); } System.Threading.Thread.Sleep(1000); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("(1) - Hit"); Console.WriteLine("(2) - Stand"); Console.WriteLine("(3) - Double"); int choice = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); switch (choice) { case 1: //Hit Console.Clear(); Console.WriteLine("=== REZULTATI ==="); if (gameChoice.iestatijumi.VaiJaunsSpeletajs) { Console.WriteLine("NPC kartis: " + cardHandNPC[0] + cardTypeArrayNPC[0] + " (" + GetCardValue(cardHandNPC[0]) + ") " + cardHandNPC[1] + cardTypeArrayNPC[1] + " (" + GetCardValue(cardHandNPC[1]) + ")"); Console.WriteLine("NPC Value: " + npcHandValue); } else { Console.WriteLine("NPC kartis: " + cardHandNPC[0] + cardTypeArrayNPC[0] + " " + cardHandNPC[1] + cardTypeArrayNPC[1]); } Console.WriteLine("--------------------------------------"); cardHand[2] = cardHand[2]; playerHandValue = GetCardValue(cardHand[0]) + GetCardValue(cardHand[1]) + GetCardValue(cardHand[2]); if (gameChoice.iestatijumi.VaiJaunsSpeletajs) { Console.WriteLine("Tavas kartis: " + cardHand[0] + cardTypeArray[0] + " (" + GetCardValue(cardHand[0]) + ") " + cardHand[1] + cardTypeArray[1] + " (" + GetCardValue(cardHand[1]) + ") " + cardHand[2] + cardTypeArray[2] + " (" + GetCardValue(cardHand[2]) + ")"); Console.WriteLine("Hand Value: " + playerHandValue); } else { Console.WriteLine("Tavas kartis: " + cardHand[0] + cardTypeArray[0] + " " + cardHand[1] + cardTypeArray[1] + " " + cardHand[2] + cardTypeArray[2]); } Console.WriteLine(); if (playerHandValue > 21) { Console.WriteLine("Bust! You lose."); } else if (npcHandValue > 21) { Console.WriteLine("Dealer bust! You win."); Betting.money = Betting.money + (Betting.bet * 2); } else if (playerHandValue > npcHandValue) { Console.WriteLine("You win!"); Betting.money = Betting.money + (Betting.bet * 2); } else if (playerHandValue < npcHandValue) { Console.WriteLine("You lose!"); } else { Console.WriteLine("Draw!"); Betting.money = Betting.money + Betting.bet; } break; case 2: //Stand Console.Clear(); Console.WriteLine("=== NPC gājiens ==="); // Īstā Blackjack NPC loģika: dīleris ņem klāt kartis, kamēr summa ir mazāka par 17 int npcCardIndex = 2; while (npcHandValue < 17 && npcCardIndex < 4) { Console.WriteLine("NPC ņem kārti..."); System.Threading.Thread.Sleep(1500); int rndTypeRow = rand.Next(0, 4); int rndValue = rand.Next(0, 13); Cards Cards = new Cards(); string rndCard = Cards.cards[rndTypeRow, rndValue]; if (rndTypeRow == 0) rndType = "Hearts"; else if (rndTypeRow == 1) rndType = "Diamonds"; else if (rndTypeRow == 2) rndType = "Clubs"; else if (rndTypeRow == 3) rndType = "Spades"; cardHandNPC[npcCardIndex] = rndCard; cardTypeArrayNPC[npcCardIndex] = rndType; npcHandValue += GetCardValue(rndCard); npcCardIndex++; } Console.Clear(); Console.WriteLine("=== REZULTATI ==="); // Izvadām visas NPC kartis, kas viņam tagad ir sakrājušās Console.Write("NPC kartis: "); for (int i = 0; i < npcCardIndex; i++) { if (gameChoice.iestatijumi.VaiJaunsSpeletajs) { Console.Write(cardHandNPC[i] + cardTypeArrayNPC[i] + " (" + GetCardValue(cardHandNPC[i]) + ") "); } else { Console.Write(cardHandNPC[i] + cardTypeArrayNPC[i] + " "); } } Console.WriteLine(); if (gameChoice.iestatijumi.VaiJaunsSpeletajs) { Console.WriteLine("NPC Value: " + npcHandValue); } Console.WriteLine("--------------------------------------"); // Izvadām spēlētāja kartis un vērtību if (gameChoice.iestatijumi.VaiJaunsSpeletajs) { Console.WriteLine("Your Value: " + playerHandValue); } else { Console.WriteLine("Tavas kartis: " + cardHand[0] + cardTypeArray[0] + " " + cardHand[1] + cardTypeArray[1]); } Console.WriteLine(); // Uzvaras pārbaudes loģika if (playerHandValue > 21) { Console.WriteLine("Bust! You lose."); } else if (npcHandValue > 21) { Console.WriteLine("Dealer bust! You win."); Betting.money = Betting.money + (Betting.bet * 2); } else if (playerHandValue > npcHandValue) { Console.WriteLine("You win!"); Betting.money = Betting.money + (Betting.bet * 2); } else if (playerHandValue < npcHandValue) { Console.WriteLine("You lose!"); } else { Console.WriteLine("Draw!"); Betting.money = Betting.money + Betting.bet; } break; case 3: //Double break; } Console.WriteLine(); gameChoice.Main(); } public static int GetCardValue(string card) //Methode kas dabu kartim vertibu, lai varētu salīdzināt spēlētāja un dīlera rokas { if (string.IsNullOrEmpty(card)) return 0; //Parbauda vai strings ir null vai tukšs un ja tā tad atgriež 0 vērtību switch (card) { case "Ace": return 11; case "Deuce": return 2; case "Trey": return 3; case "Four": return 4; case "Five": return 5; case "Six": return 6; case "Seven": return 7; case "Eight": return 8; case "Nine": return 9; case "Ten": case "Jack": case "Queen": case "King": return 10; default: return 0; } } } public abstract class BonusSistema { public abstract void SniegtBonusu(); } public class SpeletajaStatistika : BonusSistema { public string ProfilaVards { get; set; } public bool VaiJaunsSpeletajs { get; set; } public SpeletajaStatistika(string vards) { ProfilaVards = vards; VaiJaunsSpeletajs = false; } public override void SniegtBonusu() { AprekinatPapildusPunktus(1, 0); } public void AprekinatPapildusPunktus(int a, int b) { int maxSkaitlis = Math.Max(a, b); if (maxSkaitlis == 1) { Console.WriteLine("Palīdzības režīms ieslēgts! (Nekas būt noob ir okay ;) )"); } } } }