Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head> 
  <title> Warrior, Mage, Archer </title>
</head>

<body>
  <header> 
    <h1 class="title" id="title-w"> Warrior</h1> 
     <h1 class="title" id="title-m"> Mage</h1>
     <h1 class="title" id="title-a"> Archer</h1> 
  </header>
 
  <div class="scores"><!---Scoreboard-->
    <div id="user-label" class="badge">User </div><!---Div's Are block sections-->
    <div id="swords">
     <img src="https://image.ibb.co/nKMvkA/swords25px.png"  alt="fight">
    </div>
      <div id="comp-label" class="badge">A.I </div>
        <span id="user-score">0</span>:<span id="computer-score">0</span><!---Span, inline sections-->
  </div><!---End of scoreboard-->
 
  <div class="result">
    <!---<p>A Warriors Armor deflects the Arrows of the Archer. You Win. </p>-->
    <p>Warrior beats Archer, Mage beats Warrior, Archer beats Mage. </p>
  </div>
  
  <div class="choices">  
    <div class="choice" id="w">
      <img src="https://image.ibb.co/gEm02q/Warrior.png" alt="Warrior">
    </div>
    
    <div class="choice" id="m">
     <img src="https://image.ibb.co/kmGECq/mage.png" alt="Mage">
    </div>
    
      <div class="choice" id="a">
<img src="https://image.ibb.co/ezx7hq/archer.png" alt="Archer">
    </div>
  </div><!---End of choices-->
  
  <p id="action-message">...Make Your Move, Young Jabawaki... </p>
  
  
  
  
</body>

<!---Made with the help of freeCodeCamp.org at https://www.youtube.com/watch?reload=9&v=jaVNP3nIAv0 -->
              
            
!

CSS

              
                /* *is the universal selector, selects all elements */
@import url("https://fonts.googleapis.com/css?family=Spicy+Rice");
@import url("https://fonts.googleapis.com/css?family=Poor+Story");
@import url("https://fonts.googleapis.com/css?family=Anton");

* {
 margin:0;
padding:0;
box-sizing: border-box;
}
body {
  background-color: #10408D ;
  font-family: 'Spicy Rice', cursive;
}

header {
  background:black;
  text-align: center;
  margin: 10px;
}
.title {
  color: white;
  display: inline-block;
}
#title-w {
  margin: 5px 10px;
  padding: 5px;
  font-family: 'Anton', sans-serif;
  -webkit-text-stroke-width: 0.1px;
  -webkit-text-stroke-color: red;
  
}
#title-m {
  margin: 5px 10px;
  padding: 5px;
  font-family: 'Poor Story', cursive;
  -webkit-text-stroke-width: 0.1px;
  -webkit-text-stroke-color: blue;
}
#title-a {
  margin: 5px 10px;
  padding: 5px;
  font-family: 'Spicy Rice', cursive;
  -webkit-text-stroke-width: 0.1px;
  -webkit-text-stroke-color: green;
  
}
.scores {
  margin: 20px auto;
  border: 3px solid white;
  border-radius: 4px;
  width: 200px;
  text-align: center;
  font-size: 46px;
  padding: 15px 20px;
  position: relative;
}
.badge{
  font-size: 14px;
  padding: 2px 10px;
  color: white;
}
#user-label {
  background: blue;
  position: absolute;
  top: 30px;
  left: -25px;
}
#comp-label {
  background: red;
   position: absolute;
  top: 30px;
  right: -20px;
}
#swords {
  position: absolute;
  top: -20px;
  left:85px;
}

.result {
  font-size: 35px;
  text-align: center;
}
.choices{
  margin-top: 50px;
  text-align: center;
}

.choice {
  border: 4px solid white;
  border-radius: 50%;
  padding: 10px;
  margin: 0 20px;
  display: inline-block;
  transition: all 0.3s ease;
}
.choice:hover {
  cursor:pointer
}
#w:hover {
  background: #d14c27;
}
#m:hover {
  background: #41b2f4;
}
#a:hover {
  background: #9bf442;
}
#action-message {
  text-align: center;
  font-size: 26px;
  margin-top: 25px;
}
.green-glow {
  border: 4px solid #4dcc7c;
  box-shadow: 0 0 10px #31b43a;
}
.red-glow {
  border: 4px solid #fc121b;
  box-shadow: 0 0 10px #d01115;
  
}
.grey-glow {
  border: 4px solid #464647;
  box-shadow: 0 0 10px #25292b;
  
}



              
            
!

JS

              
                var userScore = 0;
var computerScore = 0;
const userScore_span = document.getElementById("user-score");
const computerScore_span = document.getElementById("computer-score");
const scores_div = document.querySelector(".scores");
const result_p = document.querySelector(".result > p ");
const warrior_div = document.getElementById("w");
const mage_div = document.getElementById("m");
const archer_div = document.getElementById("a");

function getComputerChoice() {
  const choices=["w", "m", "a"];
  const randomNumber = Math.floor(Math.random() *3);
  return choices [randomNumber];
}

function convertToWord(letter) {
  if (letter=== "w")
    return "Warrior";
   if (letter=== "m")
    return "Mage";
  else
    return "Archer";
  
  
}

function win(userChoice, computerChoice) {
  userScore++;
  userScore_span.innerHTML = userScore;
  computerScore_span.innerHTML = computerScore;
  const smallUserWord ="user".fontsize(3).sup();
  const smallCompWord ="comp".fontsize(3).sup();
  result_p.innerHTML = `${convertToWord(userChoice)} ${smallUserWord} beats ${convertToWord(computerChoice)} ${smallCompWord}  You Win!`
  document.getElementById(userChoice).classList.add("green-glow");
  setTimeout(function(){
  document.getElementById(userChoice).classList.remove("green-glow")}, 1000);
  }
             

 function lose(userChoice, computerChoice) {
   computerScore++;
  userScore_span.innerHTML = userScore;
  computerScore_span.innerHTML = computerScore;
  const smallUserWord ="user".fontsize(3).sup();
  const smallCompWord ="comp".fontsize(3).sup();
  result_p.innerHTML = `${convertToWord(userChoice)} ${smallUserWord} loses to ${convertToWord(computerChoice)} ${smallCompWord}  You Lose!`
   document.getElementById(userChoice).classList.add("red-glow");
  setTimeout(function(){
  document.getElementById(userChoice).classList.remove("red-glow")}, 1000);
}
function draw(userChoice, computerChoice) {
  const smallUserWord ="user".fontsize(3).sup();
  const smallCompWord ="comp".fontsize(3).sup();
  result_p.innerHTML = `${convertToWord(userChoice)} ${smallUserWord} draws with ${convertToWord(computerChoice)} ${smallCompWord}  Draw!`
   document.getElementById(userChoice).classList.add("grey-glow");
  setTimeout(function(){
  document.getElementById(userChoice).classList.remove("grey-glow")}, 1000);
}

function game (userChoice) {
  const computerChoice = getComputerChoice();
  switch (userChoice + computerChoice) {
    case "wa":
    case "mw":
    case "am":
     win(userChoice, computerChoice);
     break;
    case "wm":
    case "ma":
    case "aw":
       lose(userChoice, computerChoice);
      break;
    case "ww":
    case "mm":
    case "aa":
       draw(userChoice, computerChoice);
      break;
  }
}

function main () {
  warrior_div.addEventListener("click", function() {
  game("w");
})

  mage_div.addEventListener("click", function() {
  game("m");
})

  archer_div.addEventListener("click", function() {
  game("a");
})
}
main();
              
            
!
999px

Console