Skip to content

Commit

Permalink
#topTrumpsGame #6
Browse files Browse the repository at this point in the history
  • Loading branch information
mafromist committed Feb 14, 2021
1 parent aac302e commit 0c6f702
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 42 deletions.
59 changes: 46 additions & 13 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,56 @@ The winning player of the hand continues to choose until they lose.

//define players and score
let player1;
let player1Score;
let pScore1;

//DOM selection from HTML for player and choosen card and an attribute
const p1Score = document.querySelector("#p1Score");
const charImg1 = document.querySelector("#charImg1");
charImg1 = p1.img;
console.log(charImg1);
const charName = document.querySelector("#charName");
const p1magicLevel = document.querySelector("#magicLevel");

/* const p1charName = document.querySelector("#p1charName");
const p1charName = document.querySelector("#p1charName");
const charImg1 = document.querySelector("#charImg1");
const p1magicLevel = document.querySelector("#p1magicLevel");
const p1Score = document.querySelector("#p1Score");
*/


const p1cunningLevel = document.querySelector("#p1cunningLevel");
const p1courageLevel = document.querySelector("#p1courageLevel");
const p1wisdomLevel = document.querySelector("#p1wisdomLevel");
const p1temperLevel = document.querySelector("#p1temperLevel");
const player1Score = document.querySelector("#p1Score");

const p2charName = document.querySelector("#p2charName");
const charImg2 = document.querySelector("#charImg2");
const p2magicLevel = document.querySelector("#p2magicLevel");
const p2cunningLevel = document.querySelector("#p2cunningLevel");
const p2courageLevel = document.querySelector("#p2courageLevel");
const p2wisdomLevel = document.querySelector("#p2wisdomLevel");
const p2temperLevel = document.querySelector("#p2temperLevel");
const player2Score = document.querySelector("#p2Score");


let p1Card = () => {
p1charName.textContent = p1.name;
charImg1.src = p1.img;
charImg1.alt = p1.name;
p1magicLevel.textContent = p1.magic;
p1cunningLevel.textContent = p1.cunning;
p1courageLevel.textContent = p1.courage;
p1wisdomLevel.textContent = p1.wisdom;
p1temperLevel.textContent = p1.temper;
}

let p2Card = () => {
p2charName.textContent = p2.name;
charImg2.src = p2.img;
charImg2.alt = p2.name;
p2magicLevel.textContent = p2.magic;
p2cunningLevel.textContent = p2.cunning;
p2courageLevel.textContent = p2.courage;
p2wisdomLevel.textContent = p2.wisdom;
p2temperLevel.textContent = p2.temper;
}

const gameInit = () => {
p1Card();
p2Card();
}

gameInit();


///// JS TIPS /////
Expand Down
62 changes: 33 additions & 29 deletions newData.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const cardData = [
{
"name": "Argus Filch",
"imgs": "topTrumps/img/argusFilch.jpg",
"imgs": "../topTrumps/img/argusFilch.jpg",
"magic": 0,
"cunning": 17,
"courage": 10,
Expand All @@ -10,7 +10,7 @@ const cardData = [
},
{
"name": "Severus Snape",
"imgs": "topTrumps/img/Severus_Snape.jpg",
"imgs": "../topTrumps/img/Severus_Snape.jpg",
"magic": 120,
"cunning": 45,
"courage": 80,
Expand All @@ -19,7 +19,7 @@ const cardData = [
},
{
"name": "Draco Malfoy",
"imgs": "topTrumps/img/Draco_Malfoy.png",
"imgs": "../topTrumps/img/Draco_Malfoy.png",
"magic": 60,
"cunning": 35,
"courage": 30,
Expand All @@ -28,7 +28,7 @@ const cardData = [
},
{
"name": "Rubeus Hagrid",
"imgs": "topTrumps/img/Rubeushagrid.png",
"imgs": "../topTrumps/img/Rubeushagrid.png",
"magic": 12,
"cunning": 13,
"courage": 45,
Expand All @@ -37,7 +37,7 @@ const cardData = [
},
{
"name": "Luna Lovegood",
"imgs": "topTrumps/img/Luna_profile.jpg",
"imgs": "../topTrumps/img/Luna_profile.jpg",
"magic": 50,
"cunning": 18,
"courage": 65,
Expand All @@ -46,7 +46,7 @@ const cardData = [
},
{
"name": "Nigel",
"imgs": "topTrumps/img/Nigel.jpg",
"imgs": "../topTrumps/img/Nigel.jpg",
"magic": 45,
"cunning": 16,
"courage": 30,
Expand All @@ -55,7 +55,7 @@ const cardData = [
},
{
"name": "Lord Voldemort",
"imgs": "topTrumps/img/VoldemortHeadshot_DHP1.png",
"imgs": "../topTrumps/img/VoldemortHeadshot_DHP1.png",
"magic": 120,
"cunning": 42,
"courage": 0,
Expand All @@ -64,7 +64,7 @@ const cardData = [
},
{
"name": "Ginny Weasley",
"imgs": "topTrumps/img/Ginny_Weasley_hbp_promo.jpg",
"imgs": "../topTrumps/img/Ginny_Weasley_hbp_promo.jpg",
"magic": 50,
"cunning": 22,
"courage": 65,
Expand All @@ -73,7 +73,7 @@ const cardData = [
},
{
"name": "Narcissa Malfoy",
"imgs": "topTrumps/img/Narcissa_Malfoy.png",
"imgs": "../topTrumps/img/Narcissa_Malfoy.png",
"magic": 65,
"cunning": 28,
"courage": 10,
Expand All @@ -82,7 +82,7 @@ const cardData = [
},
{
"name": "James Potter",
"imgs": "topTrumps/img/JamesPotter.jpg",
"imgs": "../topTrumps/img/JamesPotter.jpg",
"magic": 75,
"cunning": 14,
"courage": 43,
Expand All @@ -91,7 +91,7 @@ const cardData = [
},
{
"name": "Alecto Carrow",
"imgs": "topTrumps/img/Alecto-DH2.jpg",
"imgs": "../topTrumps/img/Alecto-DH2.jpg",
"magic": 60,
"cunning": 30,
"courage": 20,
Expand All @@ -100,7 +100,7 @@ const cardData = [
},
{
"name": "Hermione Granger",
"imgs": "topTrumps/img/Hermionedhface.jpg",
"imgs": "../topTrumps/img/Hermionedhface.jpg",
"magic": 88,
"cunning": 32,
"courage": 70,
Expand All @@ -109,7 +109,7 @@ const cardData = [
},
{
"name": "Bellatrix Lestrange",
"imgs": "topTrumps/img/BellatrixLestrange.png",
"imgs": "../topTrumps/img/BellatrixLestrange.png",
"magic": 112,
"cunning": 36,
"courage": 4,
Expand All @@ -118,7 +118,7 @@ const cardData = [
},
{
"name": "Griphook",
"imgs": "topTrumps/img/Griphook.png",
"imgs": "../topTrumps/img/Griphook.png",
"magic": 40,
"cunning": 30,
"courage": 30,
Expand All @@ -127,7 +127,7 @@ const cardData = [
},
{
"name": "Aberforth Dumbledore",
"imgs": "topTrumps/img/AberforthInfobox.jpg",
"imgs": "../topTrumps/img/AberforthInfobox.jpg",
"magic": 40,
"cunning": 32,
"courage": 45,
Expand All @@ -136,7 +136,7 @@ const cardData = [
},
{
"name": "Feurir Greyback",
"imgs": "topTrumps/img/Fenrirgreyback.png",
"imgs": "../topTrumps/img/Fenrirgreyback.png",
"magic": 65,
"cunning": 30,
"courage": 9,
Expand All @@ -145,7 +145,7 @@ const cardData = [
},
{
"name": "Minerva McGonagall",
"imgs": "topTrumps/img/ProfessorMcGonagall-HBP.jpg",
"imgs": "../topTrumps/img/ProfessorMcGonagall-HBP.jpg",
"magic": 107,
"cunning": 36,
"courage": 45,
Expand All @@ -154,7 +154,7 @@ const cardData = [
},
{
"name": "Percy Weasley",
"imgs": "topTrumps/img/Percy_WeasleyDH.jpg",
"imgs": "../topTrumps/img/Percy_WeasleyDH.jpg",
"magic": 65,
"cunning": 15,
"courage": 40,
Expand All @@ -163,7 +163,7 @@ const cardData = [
},
{
"name": "Cho Chang",
"imgs": "topTrumps/img/ChoChang.jpg",
"imgs": "../topTrumps/img/ChoChang.jpg",
"magic": 50,
"cunning": 12,
"courage": 55,
Expand All @@ -172,7 +172,7 @@ const cardData = [
},
{
"name": "Neville Longbottom",
"imgs": "topTrumps/img/NevilleLongbottom.jpg",
"imgs": "../topTrumps/img/NevilleLongbottom.jpg",
"magic": 68,
"cunning": 36,
"courage": 75,
Expand All @@ -181,7 +181,7 @@ const cardData = [
},
{
"name": "Mr Ollivander",
"imgs": "topTrumps/img/GarrickOllivander.png",
"imgs": "../topTrumps/img/GarrickOllivander.png",
"magic": 65,
"cunning": 20,
"courage": 40,
Expand All @@ -190,7 +190,7 @@ const cardData = [
},
{
"name": "Ron Weasley",
"imgs": "topTrumps/img/RonWeasley.jpg",
"imgs": "../topTrumps/img/RonWeasley.jpg",
"magic": 80,
"cunning": 25,
"courage": 70,
Expand All @@ -199,7 +199,7 @@ const cardData = [
},
{
"name": "Harry Potter",
"imgs": "topTrumps/img/Harry_Potter.jpg",
"imgs": "../topTrumps/img/Harry_Potter.jpg",
"magic": 95,
"cunning": 40,
"courage": 80,
Expand All @@ -208,7 +208,7 @@ const cardData = [
},
{
"name": "Seamus Finnegan",
"imgs": "topTrumps/img/Seamus_FinniganDH2.jpg",
"imgs": "../topTrumps/img/Seamus_FinniganDH2.jpg",
"magic": 45,
"cunning": 20,
"courage": 50,
Expand All @@ -217,7 +217,7 @@ const cardData = [
},
{
"name": "Sybill Trelawney",
"imgs": "topTrumps/img/SybillTrelawney.jpg",
"imgs": "../topTrumps/img/SybillTrelawney.jpg",
"magic": 50,
"cunning": 11,
"courage": 40,
Expand All @@ -226,7 +226,7 @@ const cardData = [
},
{
"name": "Nagini",
"imgs": "topTrumps/img/Nagini_PM.png",
"imgs": "../topTrumps/img/Nagini_PM.png",
"magic": 0,
"cunning": 40,
"courage": 1,
Expand All @@ -235,7 +235,7 @@ const cardData = [
},
{
"name": "Dean Thomas",
"imgs": "topTrumps/img/DeanThomas.jpg",
"imgs": "../topTrumps/img/DeanThomas.jpg",
"magic": 45,
"cunning": 20,
"courage": 50,
Expand All @@ -244,7 +244,7 @@ const cardData = [
},
{
"name": "Gregory Goyle",
"imgs": "topTrumps/img/Gregory_Goyle.jpg",
"imgs": "../topTrumps/img/Gregory_Goyle.jpg",
"magic": 18,
"cunning": 20,
"courage": 7,
Expand All @@ -253,7 +253,7 @@ const cardData = [
},
{
"name": "Amycus Carrow",
"imgs": "topTrumps/img/Amycus_Carrow.png",
"imgs": "../topTrumps/img/Amycus_Carrow.png",
"magic": 59,
"cunning": 31,
"courage": 20,
Expand All @@ -275,6 +275,10 @@ class Card {
this.name = cardData[cardNum].name;
this.img = cardData[cardNum].imgs;
this.magic = cardData[cardNum].magic;
this.cunning = cardData[cardNum].cunning;
this.courage = cardData[cardNum].courage;
this.wisdom = cardData[cardNum].wisdom;
this.temper = cardData[cardNum].temper;
}

}
Expand Down

0 comments on commit 0c6f702

Please sign in to comment.