Skip to content

Commit

Permalink
Merge pull request #2002 from viv2005ek/main
Browse files Browse the repository at this point in the history
Pokemon Game
  • Loading branch information
iamrahulmahato authored Nov 5, 2024
2 parents 745c6fc + a509644 commit f4f423b
Show file tree
Hide file tree
Showing 12 changed files with 670 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pokemon-Mini-Game/grass-removebg-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pokemon-Mini-Game/ground-removebg-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions Pokemon-Mini-Game/index .html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Poki-World</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" href="pokeball.jpg">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">


</head>
<body >

<div class="forLoadingBody">

<l-quantum class="loader"
size="100"
speed="2"
color="white"
></l-quantum>


<div id=welcome>
<h1 id="wel"><i>Welcome to Poki-verse</i></h1>
</div>


<button id="mode"><i class="fa-regular fa-lightbulb"></i> <span id="modeText"> Light mode</span></button>

<br>
<br>
<h1 id="choose_your_pokemon"> <pre>Choose your
pokemon:-</pre></h1>
<br>
<div class="choices">

<div class="choice" id="ground"><img src="ground-removebg-preview.png" alt="ground"> <br> <i class="fa-solid fa-map-pin"></i>
Ground-type</div>
<div class="choice" id="water"><img src="water-removebg-preview (1).png" alt="water"><br> <i class="fa-solid fa-droplet"></i>
Water-type</div>
<div class="choice" id="fire"><img src="fire-removebg-preview-removebg-preview.png" alt="fire"><br> <i class="fa-solid fa-fire"></i>
Fire-type</div>
<div class="choice" id="grass"><img src="grass-removebg-preview.png" alt="grass"><br><i class="fa-brands fa-pagelines"></i>
Grass-type</div>
<div class="choice" id="flying"><img src="flying-removebg-preview-removebg-preview.png" alt="flying"><br> <i class="fa-solid fa-dove"></i>
Flying-type</div>

</div>
<br>
<br>
<h1 id="choose"><i class="fa-solid fa-user-ninja"></i> <span id="chooseText">Choose a Pokemon</span></h1>

<h2 id="fight"><i class="fa-brands fa-free-code-camp"></i> <span id="fightText" >Fight</span></h2>



<div id="result">

<div id=y_score>
<h4> <i class="fa-regular fa-user"></i> Your Score</h4>
<h4 id="yourScore">0</h4>
</div>

<div id="c_score">
<h4><i class="fa-solid fa-computer"></i> Computer Score</h4>
<h4 id="computerScore">0</h4>
</div>
</div>
<br>



<details id="rules">
<summary><h3 style="display: inline;"> <i class="fa-solid fa-scale-balanced"></i> Rules</h3> </summary>
<p><span style="font-size:16px;font-weight: bold;">Rules:-</span>
1. Fire type pokemon weakness is Water and Ground type pokemon. <br>
2. Water type pokemon weakness is Grass and Flying type pokemon. <br>
3. Grass type pokemon weakness is Fire and Flying type pokemon. <br>
4. Flying type pokemon weakness is Fire and Ground type pokemon. <br>
5. Ground type pokemon weakness is Water and Grass type pokemon. <br>
6. Fire type pokemon is strong against Flying and Grass type pokemon. <br>
7. Water type pokemon is strong against Fire and Ground type pokemon. <br>
8. Grass type pokemon is strong against Water and Ground type pokemon. <br>
9. Flying type pokemon is strong against Water and Grass type pokemon. <br>
10. Ground type pokemon is strong against Flying and Fire type pokemon. <br>

</p>
</details>





<footer id="copyright">
<p>&copy; 2024 GSSOC. All Rights Reserved.</p>

</footer>






</div>

<script src="script.js"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/ldrs/dist/auto/quantum.js"></script>

</body>
</html>
Binary file added Pokemon-Mini-Game/pokeball.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pokemon-Mini-Game/pokemon-icon-vector-free.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pokemon-Mini-Game/pxfuel.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Pokemon-Mini-Game/pxfuelDark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
270 changes: 270 additions & 0 deletions Pokemon-Mini-Game/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
// alert("Welcome to Poki-Verse");
const loader = document.body.querySelector(".loader");
const forLoadingBody=document.body.querySelector(".forLoadingBody");

window.addEventListener("load", (e) => {
setTimeout(()=>{
loader.classList.add("removeLoader");
forLoadingBody.classList.remove("forLoadingBody");
}, 2000);
});


let bodyNode=document.querySelector("body");
let choose=document.querySelector("#choose");
let chooseText=document.querySelector("#chooseText");
let fight=document.querySelector("#fight");
let fightText=document.querySelector("#fightText");



let yourScore=document.querySelector("#yourScore");
let computerScore=document.querySelector("#computerScore");

let userchoice;
let randchoice;



function choice(){
chooseText.innerText=`Your Pokemon ${userchoice}-type fought with ${randchoice}-type`;
}


function win(){
fightText.innerText= "You Won!";
fight.style.color="#25f505";
fightText.style.color="#25f505";
yourScore.innerText=Number(yourScore.innerText)+1;
yourScore.style.color="#1e6133";
computerScore.style.color="whitesmoke";
}
function lost(){
fightText.innerText="You Lost!";
fightText.style.color="red";
fight.style.color="red";
computerScore.innerText=Number(computerScore.innerText)+1;
yourScore.style.color="whitesmoke";
computerScore.style.color="maroon";
}
function draw(){
fightText.innerText="its Draw!";
fightText.style.color="white";
fight.style.color="white";
yourScore.style.color="#394e5c";
computerScore.style.color="#394e5c";
}

bodyNode.style.backgroundImage = "url('pxfuelDark.jpg')";



let mod=document.querySelector("#mode");
let modText=document.querySelector("#modeText");
let anchorColors=document.querySelectorAll("a");
let wel=document.querySelector("#welcome");

let mode="dark";
document.body.style.color="white";

mod.addEventListener("click",(e) =>{
if (mode === "dark") {
mode = "light";
bodyNode.style.backgroundImage = "url('pxfuel.jpg')";
document.body.style.color="black";
modText.innerText="Dark Mode";

anchorColors.forEach((a) => {
a.style.color = "#01438a";
});
} else {
mode = "dark";
bodyNode.style.backgroundImage = "url('pxfuelDark.jpg')";
document.body.style.color="white";
modText.innerText="Light Mode";

anchorColors.forEach((a) => {
a.style.color = "#aef2f5";
});
}}
);

anchorColors.forEach((a) => {
a.addEventListener("mousemove",(e)=>{
a.style.fontSize="20px";
a.style.transition="all 0.3s ease"
});
a.addEventListener("mouseleave",(e)=>{
a.style.fontSize="16px";
});
});







let ground=document.querySelector("#ground");
let fire=document.querySelector("#fire");
let grass=document.querySelector("#grass");
let water=document.querySelector("#water");
let flying=document.querySelector("#flying");

ground.addEventListener("click",(e) =>{
userchoice="ground";
console.log(`Your Choice ${userchoice}`);
computerPlay();
result(userchoice,randchoice);
})
fire.addEventListener("click",(e) =>{
userchoice="fire";
console.log(`Your Choice ${userchoice}`);
computerPlay();
result(userchoice,randchoice);
})
grass.addEventListener("click",(e) =>{
userchoice="grass";
console.log(`Your Choice ${userchoice}`);
computerPlay();
result(userchoice,randchoice);
})
water.addEventListener("click",(e) =>{
userchoice="water";
console.log(`Your Choice ${userchoice}`);
randchoice=computerPlay();
result(userchoice,randchoice);
})

flying.addEventListener("click",(e) =>{
userchoice="flying";

console.log(`Your Choice ${userchoice}`);
randchoice=computerPlay();
result(userchoice,randchoice);
})

let computerchoice = ["ground", "fire", "grass", "water", "flying"];

function computerPlay() {
randchoice= computerchoice[Math.floor(Math.random()*computerchoice.length)];
console.log(`Computer Choice ${randchoice}`);
return randchoice;
}

function result(userchoice,randchoice){
if(userchoice===randchoice){
console.log("It's a tie!");
draw();
choice();
}
else{
if( (userchoice==="ground") &&(randchoice==="flying" ||randchoice==="fire")){
console.log("You win!");
win();
choice();
}
else if( (userchoice==="ground") &&(randchoice==="grass" ||randchoice==="water")){
console.log("You Lost!");
lost();
choice();
}
else if( (userchoice==="flying") &&(randchoice==="water" ||randchoice==="grass")){
console.log("You win!");
win();
choice();
}
else if( (userchoice==="flying") &&(randchoice==="fire" ||randchoice==="ground")){
console.log("You Lost!");
lost();
choice();
}
else if( (userchoice==="water") &&(randchoice==="fire" ||randchoice==="ground")){
console.log("You win!");
win();
choice();
}
else if( (userchoice==="water") &&(randchoice==="grass" ||randchoice==="flying")){
console.log("You Lost!");
lost();
choice();
}
else if( (userchoice==="fire") &&(randchoice==="flying" ||randchoice==="grass")){
console.log("You win!");
win();
choice();
}
else if( (userchoice==="fire") &&(randchoice==="water" ||randchoice==="ground")){
console.log("You Lost!");
lost();
choice();
}
else if( (userchoice==="grass") &&(randchoice==="water" ||randchoice==="ground")){
console.log("You win!");
win();
choice();
}
else if( (userchoice==="grass") &&(randchoice==="fire" ||randchoice==="flying")){
console.log("You Lost!");
lost();
choice();
}
}
}




let aboutmeFrame = document.querySelector("#aboutmeFrame");
let scaledFrameNode = document.querySelector("#scaledFrame");
scaledFrameNode.classList.add("removeFrame");
let frame=0;

aboutmeFrame.addEventListener("click", (e) => {
if (frame === 0){
scaledFrameNode.classList.remove("removeFrame");
frame=1;
}
else{
scaledFrameNode.classList.add("removeFrame");
frame=0;
}
});


let anchorFontAwesome=document.querySelectorAll("a");

anchorFontAwesome.forEach((a) => {
a.addEventListener("mouseenter",(e)=>{
console.log("Mouse over anchor element:", a.textContent);
a.style.display="inline";
let icon = document.createElement("icon");
icon.innerHTML = ' <i class="fas fa-up-right-from-square" style="display:inline"></i>';
a.append(icon);
icon.style.fontSize="16px";
icon.style.transition="all 1s ease";
});
a.addEventListener("mouseleave",(e)=>{
let icon = a.querySelector("icon");
if (icon) {
a.removeChild(icon);
}
});
});

















Loading

0 comments on commit f4f423b

Please sign in to comment.