-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2150 from Aditijainnn/Name_Fate
Added Name Fate
- Loading branch information
Showing
8 changed files
with
459 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
|
||
<!-- Logo of website --> | ||
<link rel="shortcut icon" | ||
href="https://static.vecteezy.com/system/resources/previews/004/753/002/original/custom-coding-icon-shadowed-detailed-custom-coding-logo-free-vector.jpg" | ||
type="image/x-icon"> | ||
|
||
<title>Code Cracker</title> | ||
|
||
<!-- custom css --> | ||
<link rel="stylesheet" href="./style.css"> | ||
</head> | ||
|
||
<body> | ||
<!-- game container --> | ||
<div class="game"> | ||
<h1>Code Cracker</h1> | ||
<p class="developer"> | ||
Created By <a href="https://github.com/Avdhesh-Varshney">Avdhesh Varshney</a> | ||
</p> | ||
|
||
<div class="input-section"> | ||
<input type="text" name="user_input" id="i_p" placeholder="XXXX"> | ||
<button id="submit">Submit</button><br> | ||
<button id="show" style="margin: 3px 0; display: none;">show answer</button> | ||
</div> | ||
|
||
<div class="output-section"> | ||
<p id="o_p"></p> | ||
<p id="code" style="display: none;"></p> | ||
<p id="check"></p> | ||
<p id="is_game">Keep guessing</p> | ||
</div> | ||
|
||
<div class="result-section"> | ||
<ul id="step"> | ||
<li> | ||
<b>Guess Result</b> | ||
</li> | ||
</ul> | ||
</div> | ||
|
||
<div id="rules"> | ||
<b>Rules :</b> | ||
<ul> | ||
<li> | ||
Each guess must consist of 4 numberic characters. | ||
</li> | ||
<li> | ||
Numbers may be used more than once! | ||
</li> | ||
<li> | ||
You win only if your guess is an exact match. | ||
</li> | ||
<li> | ||
You lose if you fail to guess the code under 10 guesses. | ||
</li> | ||
<li> | ||
'Y' Indicates a number is in the correct position. | ||
</li> | ||
<li> | ||
'E' Indicates a number is part of the code, but not in the right position. | ||
</li> | ||
<li> | ||
'E' Doesn't consider how many times a number exists in the code. | ||
</li> | ||
<li> | ||
'X' Indicates a number is not part of the code. | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
<!-- custom js --> | ||
<script src="./script.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Crack Code", | ||
"description": "Crack the code with the hints given to you and according to the rules and enjoy the game", | ||
"browser_action":{ | ||
"default_popup":"index.html" | ||
}, | ||
"background": { | ||
"service_worker": "script.js", | ||
"styles" : "style.css" | ||
}, | ||
"permissions":["activeTab"] | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
var secret_code = generateCode(); | ||
var step_counter = 0; | ||
var show = document.getElementById('show'); | ||
var ans = document.getElementById('code'); | ||
|
||
document.getElementById("submit").addEventListener("click", getInput); | ||
|
||
document.addEventListener('keypress', (e) => { | ||
if (e.key === 'Enter') { | ||
getInput(); | ||
} | ||
}); | ||
|
||
function getInput() { | ||
var x = document.getElementById('i_p').value; | ||
var o_p = document.getElementById("o_p"); | ||
o_p.innerHTML = x; | ||
processInput(x); | ||
} | ||
|
||
function processInput(input) { | ||
var n = input.length; | ||
if (document.getElementById("submit").innerHTML === "Reset") { | ||
cleanAll(); | ||
} | ||
else if (n > 4) { | ||
o_p.innerHTML = "Input exceeds 4 character!"; | ||
} | ||
else if (n < 4) { | ||
o_p.innerHTML = "Input is less than 4 character!"; | ||
} | ||
else if (step_counter === 10) { | ||
document.getElementById("is_game").innerHTML = "Fool, You Loose! Eat some Horlics!"; | ||
|
||
show.style.display = ''; | ||
show.addEventListener('click', () => { | ||
ans.style.display = ''; | ||
show.style.display = 'none'; | ||
}); | ||
resetGame(); | ||
} | ||
else { | ||
step_counter++; | ||
checkSubmission(input); | ||
} | ||
|
||
return; | ||
} | ||
|
||
function generateCode() { | ||
var code = ""; | ||
for (var i = 0; i < 4; i++) { | ||
var n = getRandomIntInclusive(0, 9); | ||
code += n.toString(); | ||
} | ||
document.getElementById("code").innerHTML = code; | ||
return code; | ||
} | ||
|
||
function getRandomIntInclusive(min, max) { | ||
min = Math.ceil(min); | ||
max = Math.floor(max); | ||
return Math.floor(Math.random() * (max - min + 1)) + min; | ||
} | ||
|
||
function checkSubmission(usr_input) { | ||
if (usr_input === secret_code) { | ||
document.getElementById("is_game").innerHTML = "Good guess! You win!!"; | ||
resetGame(); | ||
} | ||
var result = ""; | ||
|
||
for (var i = 0; i < 4; i++) { | ||
var found = false; | ||
if (usr_input[i] === secret_code[i]) { | ||
result += "Y "; | ||
found = true; | ||
continue; | ||
} | ||
for (var j = 0; j < 4; j++) { | ||
if (usr_input[i] === secret_code[j]) { | ||
result += "E "; | ||
found = true; | ||
break; | ||
} | ||
} | ||
if (!found) { | ||
result += "X "; | ||
} | ||
} | ||
document.getElementById("check").innerHTML = result; | ||
showSubmission(result, usr_input); | ||
return; | ||
} | ||
function showSubmission(result, usr_input) { | ||
var ul = document.getElementById("step"); | ||
var li = document.createElement("li"); | ||
li.appendChild(document.createTextNode(usr_input + " >>> " + result)); | ||
ul.appendChild(li); | ||
} | ||
|
||
function resetGame() { | ||
document.getElementById("submit").innerHTML = "Reset"; | ||
} | ||
|
||
function cleanAll() { | ||
secret_code = generateCode(); | ||
step_counter = 0; | ||
document.getElementById("step").innerHTML = "<li><b>Guess Result</b></li>" | ||
document.getElementById("submit").innerHTML = "Submit"; | ||
show.style.display = 'none'; | ||
ans.style.display = 'none'; | ||
document.getElementById('is_game').innerHTML = ''; | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
text-decoration: none; | ||
user-select: none; | ||
} | ||
|
||
body { | ||
background-color: aquamarine; | ||
} | ||
|
||
#step { | ||
list-style: none; | ||
} | ||
|
||
.game { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: rgba(red, green, blue, 0.3); | ||
box-shadow: 0 0 100px 0 black; | ||
border-radius: 1rem; | ||
width: 90vh; | ||
height: 90vh; | ||
padding: 1rem; | ||
text-align: center; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
transition: all 0.4s; | ||
} | ||
|
||
h1 { | ||
font-size: 2.5rem; | ||
margin-bottom: 5px; | ||
font-weight: 500; | ||
font-family: cursive; | ||
color: chocolate; | ||
} | ||
|
||
.input-section, | ||
.output-section, | ||
.result-section, | ||
#rules { | ||
margin: 5px 0; | ||
} | ||
|
||
.input-section input { | ||
padding: 5px; | ||
outline: none; | ||
border: none; | ||
text-align: center; | ||
border-radius: 10px; | ||
font-size: 1.2rem; | ||
} | ||
|
||
.input-section input:hover { | ||
box-shadow: 0 2px 50px 0 lightseagreen; | ||
} | ||
|
||
.input-section button { | ||
padding: 10px; | ||
font-size: 1rem; | ||
border-radius: 10px; | ||
outline: none; | ||
border: none; | ||
text-transform: uppercase; | ||
background-color: aqua; | ||
box-shadow: 0 2px 10px black; | ||
transition: all 0.2s; | ||
} | ||
|
||
.input-section button:hover { | ||
box-shadow: 0 0 25px 0 black; | ||
background-color: black; | ||
color: white; | ||
} | ||
|
||
.output-section p { | ||
font-size: 1.2rem; | ||
margin: 2px 0; | ||
font-weight: 700; | ||
text-transform: uppercase; | ||
letter-spacing: 2px; | ||
} | ||
|
||
.output-section #code { | ||
color: lightcoral; | ||
} | ||
|
||
.result-section { | ||
margin: 5px 0; | ||
letter-spacing: 2px; | ||
list-style: none; | ||
} | ||
|
||
#rules ul { | ||
list-style: none; | ||
letter-spacing: 1px; | ||
} | ||
|
||
.developer { | ||
font-size: 1.2rem; | ||
color: #313136; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.developer a { | ||
text-decoration: none; | ||
color: #313136; | ||
} | ||
|
||
.developer a:hover { | ||
text-decoration: underline; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Name Fate</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>FLAMES Game</h1> | ||
<div class="input-group"> | ||
<input type="text" id="name1" placeholder="Enter first name"> | ||
<input type="text" id="name2" placeholder="Enter second name"> | ||
</div> | ||
<button onclick="calculateFlames()">Calculate</button> | ||
<div id="result"></div> | ||
</div> | ||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Name Fate", | ||
"version": "1.0", | ||
"description": "NameFate is an intriguing game that explores the mystical connections between names and destinies. ", | ||
"permissions": [ | ||
"storage" | ||
], | ||
"optional-permissions" : ["tabs"], | ||
"action": { | ||
"default_popup": "index.html" | ||
}, | ||
"web_accessible_resources": [ | ||
{ | ||
"resources": [ | ||
"index.html" | ||
], | ||
"matches": [ | ||
"<all_urls>" | ||
] | ||
} | ||
] | ||
} |
Oops, something went wrong.