Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Super Wars</title>
<link rel="stylesheet" href="./src/style.css">
</head>
<link rel="stylesheet" href="./src/style.css" />
</head>

<body>
<body>
<div class="arena">
<div id="heroes" class="team">
</div>
<div id="score">
</div>
<div id="villains" class="team">
</div>
<div id="heroes" class="team"></div>
<div id="score"></div>
<div id="villains" class="team"></div>
</div>
<footer class="footer">Made with <img src="/images/Vector.svg"> by ProGrad</footer>
</body>
<script src="./src/app.js"></script>

</html>
<footer class="footer">
Made with <img src="images/Vector.svg" /> by VITFED21
</footer>
</body>
<script src="./src/app.js"></script>
</html>
54 changes: 29 additions & 25 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,54 @@
const PLAYERS = [
"Spiderman",
"Captain America",
"Wonderwoman",
"Popcorn",
"Gemwoman",
"Bolt",
"Antwoman",
"Mask",
"Tiger",
"Captain",
"Catwoman",
"Fish",
"Hulk",
"Ninja",
"Black Cat",
"Volverine",
"Thor",
"Slayer",
"Vader",
"Slingo"
const PLAYERS = ["Spiderman","Captain America", "Wonderwoman","Popcorn", "Gemwoman", "Bolt","Antwoman","Mask","Tiger", "Captain","Catwoman","Fish", "Hulk","Ninja","Black Cat","Volverine","Thor","Slayer","Vader", "Slingo"
];

// initialize players with image and strength
const initPlayers = (players) => {
let detailedPlayers = [];
// Create players using for loop
// Type your code here

for (var i = 0; i < players.length; i++) {
detailedPlayers[i] = {
name: players[i],
strength: getRandomStrength(),
image: "images/super-" + (i + 1) + ".png",
};
if (i % 2 == 0) {
detailedPlayers[i].type = "hero";
} else {
detailedPlayers[i].type = "villain";
}
}
return detailedPlayers;
}

function herovillian(n) {
if (n % 2 == 0) {
return "hero";
} else {
return "villain";
}
}
// getting random strength
const getRandomStrength = () => {
// Return a random integer (0,100]
// Note: You can use Math.random() and Math.ceil()
}
let s = Math.ceil(Math.random() * (100 - 1) + 1);
return s;
};

const buildPlayers = (players, type) => {
let fragment = '';

// Loop through players and accumulate HTML template
// depending of type of player(hero|villain)
// Type your code here
for (var i = 0; i < players.length; i++) {
if (players[i].type == type) {
fragment += `<div class="player"> <img src="${players[i].image}" alt=""> <div class="name">${players[i].name}</div> <div class="strength">${players[i].strength}</div> </div>`;
}
}

return fragment;
}
};
// Display players in HTML
const viewPlayers = (players) => {

Expand Down