Bash Royale Simulation
This code is a simulation based on the game Clash Royale. This simulation simulates a shorter version of the game where the player has the opportunity to decide between two different options in order to win the game. This code wasn't very difficult to make since it's just a simulation, but it was very time consuming since I had to make over 70 functions for it. There are 39 possible outcomes assuming that the user plays the game correctly and overall, it is supposed to be a fun simulation-type game.
(defn skeletons2 []
(js/alert "Your Skeletons did not affect the minions, as they were able to fly past them, deal 1000 damage, and take out your tower. YOU LOSE. To try again, click Run."))
(defn musketeer4 []
(js/alert "Your Musketeer did absolutely nothing to the opposing Giant Skeleton, and the Giant Skeleton absolutely demolished your tower with five big hits. YOU LOSE. To try again, click Run."))
(defn fire4 []
(js/alert "Your Fire Ball struck the opposing tower, dealing 100 damage and destroying the opposing tower. YOU WIN. To play again, click Run."))
(defn goblin3 []
(let [choice (js/parseInt (js/prompt "Your Goblin Barrel landed right next to the opposing tower but was only able to deal 300 damage, leaving the opposing tower with only 100 health. Your opponent played Giant Skeleton. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Fireball.\n2 Musketeer."))]
(if (= 1 choice)
(fire4)
(musketeer4))))
(defn fire3 []
(js/alert "You Fire Ball the opposing tower, but the opposing tower still has 200 health left. While your opponents Fire Spirit quickly died, your opponent played Giant Skeleton, which surged all the way to your tower and with four big hits, your tower was destroyed. YOU LOSE. To try again, click Run."))
(defn musketeer3 []
(js/alert "Your Musketeer eliminated the opposing Fire Spirit with one hit and with two long range shots, the Musketeer destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn minip3 []
(let [choice (js/parseInt (js/prompt "Your Mini PEKKA took out the opposing barbarians but was defeated before it could reach the opposing tower. Your opponent played Fire Spirit. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Musketeer.\n2 Fire Ball."))]
(if (= 1 choice)
(musketeer3)
(fire3))))
(defn baby2 []
(let [choice (js/parseInt (js/prompt "Your Baby Dragon took out the opposing minions and dealt 800 damage to the opposing tower, leaving the opposing tower at 400 health. Your opponent played Barbarians. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Mini PEKKA.\n2 Goblin Barrel."))]
(if (= 1 choice)
(minip3)
(goblin3))))
(defn giant1 []
(let [choice (js/parseInt (js/prompt "Your Giant did not succesfully defend the Knight but was able to deal 800 damage to the opposing tower. The opposing Knight however dealt 1000 damage to your tower. Your oponent placed Minions to take out your Giant. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Skeletons.\n2 Baby Dragon."))]
(if (= 1 choice)
(skeletons2)
(baby2))))
(defn valk2 []
(js/alert "Your Valkyrie was no match for the opposing Giant Skeleton, and the Giant Skeleton dealt six big hits on your tower, taking out your tower and ending the game. YOU LOSE. To try again, click Run."))
(defn gob2 []
(js/alert "Your Goblin Barrel landed perfectly infront of the opposing tower, and with one hit destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn fire2 []
(js/alert "Your Fire Ball eliminated the Fire Spirit, but your opponent played Barbarians and Minions, and with no defensive cards active, the Barbarians and Minions were able to destroy your tower. YOU LOSE. To try again, click Run."))
(defn minip2 []
(let [choice (js/parseInt (js/prompt "Your Mini PEKKA narrowly defeated the opposing Giant Skeleton and was able to get three big hits on the opposing tower, bringing the opposing towers health down to 500. Your opponent played Fire Spirit. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Goblin Barrel.\n2 Fire Ball."))]
(if (= 1 choice)
(gob2)
(fire2))))
(defn musketeer5[]
(let [choice (js/parseInt (js/prompt "Your Musketeer was not able to defeat the opposing Wizard, and the Wizard did 800 damage to your tower. Your opponent then played a Giant Skeleton. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Mini PEKKA.\n2 Valkyrie."))]
(if (= 1 choice)
(minip2)
(valk2))))
(defn minip4 []
(js/alert "Your Mini PEKKA defeated the Battering Ram with one hit, and was able to reach the opposing tower where it dealt to big hits, destroying the opposing tower with ease. YOU WIN. To play again, click Run."))
(defn valk3 []
(js/alert "Your Valkyrie could not compete with the speed of the Battering Ram, and with just a few hits, the Battering Ram was able to take out your whole tower. YOU LOSE. To try again, click Run."))
(defn giant2 []
(let [choice (js/parseInt (js/prompt "Your Giant did not defend the Wizard, causing the Wizard to deal 700 damage before it was shot down. Your Giant, however, did deal 1200 damage to the opposing tower since it was completely undefended. Your opponent played Battering Ram. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Mini PEKKA.\n2 Valkyrie."))]
(if (= 1 choice)
(minip4)
(valk3))))
(defn skeletons1 []
(let [choice (js/parseInt (js/prompt "Your Skeletons succesfully defeated the Knight before it was able to reach the tower but your opponent played Wizard which was able to wipe out all of the Skeletons. What do you play? Type a number corresponding to the character that you want to play.\n1 Giant.\n2 Musketeer."))]
(if (= 1 choice)
(giant2)
(musketeer5))))
(defn skeletons7 []
(js/alert "Your Skeletons were not able to reach the opposing tower before your opponent played Giant Skeleton, which wiped out every sing Skeleton. The opposing Giant Skeletons made it to your tower, dealt six big hits, and destroyed your tower. YOU LOSE. To try again, click Run."))
(defn giant28 []
(js/alert "Your Giant easily reached the opposing tower and with one big hit destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn gob8 []
(let [choice (js/parseInt (js/prompt "Your Goblin Barrel landed infront of the opposing tower, and dealt 400 damage to the tower. Your opponent placed a Wizard which was able to deal 800 damage to your tower before it was eliminated. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Skeletons.\n2 Giant."))]
(if (= 1 choice)
(skeletons7)
(giant28))))
(defn giant29 []
(js/alert "Your Giant marched past the opponents Skeleton easily and with only two hits destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn musketeer7 []
(js/alert "With no defense from your opponent, your Musketeer was easily able to snipe the opposing tower and destroy the tower. YOU WIN. To play again, click Run."))
(defn valk6 []
(js/alert "With no defense from your opponent, your Valkyrie was easily able to make it to the opposing tower and destroy the tower. YOU WIN. To play again, click Run."))
(defn skeletons60 []
(let [choice (js/parseInt (js/prompt "Your Skeletons defeated the lone Skeleton easily byt could not make it to the opposing tower before being eliminated. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Musketeer.\n2 Valkyrie."))]
(if (= 1 choice)
(musketeer7)
(valk6))))
(defn fire8 []
(let [choice (js/parseInt (js/prompt "Your Fire Ball succesfully defeated the opposing Inferno Tower and dealt 200 damage to the opposing tower, leaving the tower at 400 health. Your opponent played skeleton. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Skeletons.\n2 Giant."))]
(if (= 1 choice)
(skeletons60)
(giant29))))
(defn minip1 []
(let [choice (js/parseInt (js/parseFloat "Your Mini PEKKA destroyed the opposing knight and dealt 1400 damage to the opposing tower before it was defeated by Inferno Tower. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Goblin Barrel.\n2 Fire Ball."))]
(if (= 1 choice)
(gob8)
(fire8))))
(defn minipekka6 []
(js/alert "Your Mini PEKKA destroyed the opposing Wizard, made it to the opposing tower and with two big hits, destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn goblinb5 []
(js/alert "Your Goblin Barrel dealt 1000 damage to the opposing tower, but with no defense, thw opposing Wizard took out your tower. YOU LOSE. To try again, click Run."))
(defn giant18 []
(let [choice (js/parseInt (js/prompt "While your Giant was able to get to the opposing tower and deal 800 damage, the opposing Minions were able to get to your tower and also deal 800 damage. The opponent decided to play Wizard. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Mini PEKKA.\n2 Goblin Barrel."))]
(if (= 1 choice)
(minipekka6)
(goblinb5))))
(defn minipek2 []
(js/alert "Your Mini PEKKA succesfully defeated the opposing Wizard and was able to deal 1400 damage to the opposing tower, destroying the opposing tower and winning you the game. YOU WIN. To play again, click Run."))
(defn skely6 []
(js/alert "Your Skeletons destroyed the opposing Giant Skeleton, made it to the opposing tower, and destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn musk9 []
(js/alert "Your Musketeer was easily destroyed by the opposing Giant Skeleton and with no defense against the Giant Skeleton, your tower was destroyed. YOU LOSE. To try again, click Run."))
(defn goblinba6 []
(let [choice (js/parseInt (js/prompt "Your Goblin Barrel landed infront of the opposing tower and dealt 600 damage but the Wizard was able to make it to your tower and deal 1000 damage of its own. With their tower at 800 health, your opponent decides to play Giant Skeleton. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Skeletons.\n2 Musketeer"))]
(if (= 1 choice)
(skely6)
(musk9))))
(defn dragon7 []
(let [choice (js/parseInt (js/prompt "Your Baby Dragon defeated the opposing Minions and was able to deal 600 damage to the opposing tower before being shot down. Your opponent played WIzard. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Mini PEKKA.\n2 Goblin Barrel."))]
(if (= 1 choice)
(minipek2)
(goblinba6))))
(defn valk1 []
(let [choice (js/parseInt (js/prompt "Your Valkyrie took out the opposing knight but was not able to make it to the opposing tower due to Minions being played. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Giant.\n2 Baby Dragon."))]
(if (= 1 choice)
(giant18)
(dragon7))))
(defn musketee87 []
(js/alert "Your Musketeer was no match for the opposing Giant Skeleton as the Giant Skeleton eliminated your Musketeer in just one hit Furthermore, the Giant Skeleton was able to make it all the way to your tower, and with six big hits destroy your tower. YOU LOSE. To try again, click Run."))
(defn sksl9 []
(js/alert "Your Skeletons destroyed the opposing Giant Skeleton and with only a few hits, your army of Skeletons finished off the opposing tower YOU WIN. To play again, click Run."))
(defn giant98 []
(let [choice (js/parseInt (js/prompt "Your Giant dealt 1200 damage to the opposing tower, bringing the towers health down to 400, but your opponent played Giant Skeleton. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Musketeer.\n2 Skeletons."))]
(if (= 1 choice)
(musketee87)
(sksl9))))
(defn min3 []
(js/alert "Your Mini PEKKA easily destroyed the opposing Giant Skeleton, made it to the opposing tower, and with two big hits, destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn dragin8 []
(js/alert "Your Baby Dragon was not able to defeat the opposing Giant Skeleton, and with only a few hits, the Giant Skeleton destroyed your tower. YOU LOSE. To try again, click Run."))
(defn Valkyrie8 []
(let [choice (js/parseInt (js/prompt "Your Valkyrie destroyed the opposing fire Spirit, made it to the opposing tower, and did 500 damge, leaving the opposing tower at 800 health. Your opponent decides to play Giant Skeleton. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Mini PEKKA.\n2 Baby Dragon."))]
(if (= 1 choice)
(min3)
(dragin8))))
(defn musketeere88 []
(js/alert "Your Musketeer destroyed the opposing Fire Spirit, but the opponent swiftly played Giant Skeleton, eliminating your Musketeer and destroying your whole tower. YOU LOSE. To try again, click Run."))
(defn fire98 []
(let [choice (js/parseInt (js/prompt "Your Fire Ball did 300 damage to the opposing tower. Your oppponent decided to play Fire Spirit. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Valkyrie.\n2 Musketeer."))]
(if (= 1 choice)
(Valkyrie8)
(musketeere88))))
(defn gob1 []
(let [choice (js/parseInt (js/prompt "Your Goblin Barrel dealt 400 damage to the opposing tower but the opposing Knight dealt 800 damge to your tower before it was eliminated. What do you play? Type a number corresponding to the character that you want to play.\n1 Giant.\n2 Fire Ball."))]
(if (= 1 choice)
(giant98)
(fire98))))
(defn skeletonss88 []
(js/alert "Your Skeletons succesfully took out the opposing Battering Ram, made it to the opposing tower and destroyed the tower. YOU WIN. To play again, click Run."))
(defn giant987 []
(js/alert "Your Giant wasn't able to reach the opposing tower before the opposing Battering Ram destroyed your whole tower. YOU LOSE. To try again, click Run."))
(defn Valkyriey []
(let [choice (js/parseInt (js/prompt "Your Valkyriey made it to the opposing tower and dealt 800 damge before it was finally eliminated. Your opponent then decided to play Battering Ram. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Skeletons.\n2 Giant."))]
(if (= 1 choice)
(skeletonss88)
(giant987))))
(defn skeletonss87 []
(js/alert "Your Skeletons succesfully took out the opposing Battering Ram, made it to the opposing tower and destroyed the tower. YOU WIN. To play again, click Run."))
(defn giant988 []
(js/alert "Your Giant wasn't able to reach the opposing tower before the opposing Battering Ram destroyed your whole tower. YOU LOSE. To try again, click Run."))
(defn goblinbarrel574 []
(let [choice (js/parseInt (js/prompt "Your Goblin Barrel landed perfectly infront of the opposing tower and dealt 800 damage. Your opponent, however, countered with Battering Ram. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Skeletons.\n2 Giant."))]
(if (= 1 choice)
(skeletonss87)
(giant988))))
(defn baby1 []
(let [choice (js/parseInt (js/prompt "Your Baby Dragon took out the opposing Knight but the Knight was able to deal 200 damage to your tower. Minions were played and your Baby Dragon destroyed them too before it was finally eliminated. What do you play? Type a number corresponding to the character that you want to play.\n1 Valkyrie.\n2 Goblin Barrel."))]
(if (= 1 choice)
(Valkyriey)
(goblinbarrel574))))
(defn minipekkas76 []
(js/alert "Your Mini PEKKA easily defeated the opposing Giant Skeleton and with four big hits on the opposing tower, destroyed the tower. YOU WIN. To play again, click Run."))
(defn muskeee []
(js/alert "Your Musketeer was easily defeated by the opposing Giant Skeleton and with no defense from your side, the Giant Skeleton destroyed your tower. YOU LOSE. To try again, click Run."))
(defn sk2 []
(let [choice (js/parseInt (js/prompt "Your Skeletons were not able to make it to the opposing tower. Your opponent played Giant Skeleton. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Mini PEKKA.\n2 Musketeer."))]
(if (= 1 choice)
(minipekkas76)
(muskeee))))
(defn Valkyrieee []
(js/alert "Your Valkyrie easily defeated the opposing Fire Spirit, made it to the opposing tower, and with five big hits destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn gianan []
(js/alert "Your Giant was able to make it to the opposing tower before the Giant Skeleton made it to your tower and with three big hits destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn babybaby []
(js/alert "Your Baby Dragon was no match for the opposing Giant Skeleton and with several big hits, the Giant Skeleton took down your tower. YOU LOSE. To try again, click Run."))
(defn muskeete33 []
(let [choice (js/parseInt (js/prompt "Your Musketeer easily defeated the opposing Fire Spirit but was only able to deal 400 damage to the opposing tower. Your opponent decided to play Giant Skeleton. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Giant.\n2 Baby Dragon."))]
(if (= 1 choice)
(gianan)
(babybaby))))
(defn go5 []
(let [choice (js/parseInt (js/prompt "Your Goblin Barrel landed infront of the opposing tower and dealt 800 damage to the tower. Your opponent played Fire Spirit. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Valkyrie.\n2 Musketeer"))]
(if (= 1 choice)
(Valkyrieee)
(muskeete33))))
(defn fire1 []
(let [choice (js/parseInt (js/prompt "Your Fire Ball was not able to defeat the opposing knight and the knight dealt 600 damage to your tower. What do you play. Type a number corresponding to the character that you want to play.\n1 Skeletons.\n2 Valkyrie."))]
(if (= 1 choice)
(sk2)
(go5))))
(defn babydra []
(js/alert "Your Baby Dragon took out the opposing Minions, made it to the opposing tower, and dealt 1000 damage, destroying the opposing tower. YOU WIN. To play again, click Run."))
(defn valkar474 []
(js/alert "Your Valkyrie wasn not able to defeat the opposing Minions and with no defense against the Minions, the Minions destroyed your tower. YOU LOSE. To try again, click Run."))
(defn pekkapekka []
(let [choice (js/parseInt (js/prompt "Your Mini PEKKA easily took out the opposing Battering Ram and was able to reach the opposing tower and deal 1000 damage. Your opponent decided to play Minions. What do you decide to play. Type a number corresponding to the character that you want to play.\n1 Baby Dragon.\n2 Valkyrie."))]
(if (= 1 choice)
(babydra)
(valkar474))))
(defn goblinbarrelbarrel []
(js/alert "Your Goblin Barrel landed infront of the opposing tower and did 600 damage to the tower, but a Giant Skeleton was played by your opponent, taking out your tower and losing you the game. YOU LOST. To try again, click Run."))
(defn giantgiantgiant []
(js/alert "Your Giant marched past the opposing Fire Spirit to the opposing tower and with ten big hits, destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn babydr []
(let [choice (js/parseInt (js/prompt "Your Baby Dragon was destroyed by the opposing Inferno Tower instantly. Your opponent decided to play Fire Spirit. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Goblin Barrel.\n2 Giant."))]
(if (= 1 choice)
(goblinbarrelbarrel)
(giantgiantgiant))))
(defn goblinbarrelbarrelb []
(js/alert "Your Goblin Barrel landed infront of the opposing tower and did 600 damage to the tower, but a Giant Skeleton was played by your opponent, taking out your tower and losing you the game. YOU LOST. To try again, click Run."))
(defn giantgiantg []
(js/alert "Your Giant marched past the opposing Fire Spirit to the opposing tower and with ten big hits, destroyed the opposing tower. YOU WIN. To play again, click Run."))
(defn valka []
(let [choice (js/parseInt (js/prompt "Your Valkyrie was destroyed by the opposing Inferno Tower instantly. Your opponent decided to play Fire Spirit. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Goblin Barrel.\n2 Giant."))]
(if (= 1 choice)
(goblinbarrelbarrelb)
(giantgiantg))))
(defn skeletonskeleton []
(let [choice (js/parseInt (js/prompt "Your Skeletons defeated the opposing Battering Ram but not after the Battering Ram dealt 800 damage. Your Skeletons didn't make it to the opposing tower. Your opponent decided to play Inferno Tower. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Baby Dragon.\n2 Valkyrie."))]
(if (= 1 choice)
(babydr)
(valka))))
(defn musk1 []
(let [choice (js/parseInt (js/prompt "Your Musketeer took out the opposing Knight but was not able to deal any damage to the opposing tower. Your opponent played Battering Ram. What do you play. Type a number corresponding to the character that you want to play.\n1 Mini PEKKA.\n2 Skeletons."))]
(if (= 1 choice)
(pekkapekka)
(skeletonskeleton))))
(defn start-game []
(let [choice (js/parseInt (js/prompt "Your opponent has begun the game by placing a Knight next to the bridge leading to your tower. What do you decide to play? Type a number corresponding to the character that you want to play.\n1 Giant.\n2 Skeletons.\n3 Mini PEKKA.\n4 Valkyrie.\n5 Goblin Barrel.\n6 Baby Dragon.\n7 Fire Ball.\n8 Musketeer."))]
(cond
(= 1 choice)(giant1)
(= 2 choice)(skeletons1)
(= 3 choice)(minip1)
(= 4 choice)(valk1)
(= 5 choice)(gob1)
(= 6 choice)(baby1)
(= 7 choice)(fire1)
(= 8 choice)(musk1))))
(defn run []
(js/alert "Welcome to Bash Royale. Your deck is Giant, Skeletons, Mini PEKKA, Valkyrie, Goblin Barrel, Baby Dragon, Fire Ball, and Musketeer. Your opponents deck is Giant Skeleton, Wizard, Barbarians, Inferno Tower, Minions, Knight, Fire Spirit, and Battering Ram. You will have to place cards depending on what your opponent does to capture more of their towers than they do of yours. Each card has different abilities and damage stats and each tower will have 2000 health. Play wisely.")
(start-game))