Last active
December 13, 2015 19:18
-
-
Save adrientetar/4961486 to your computer and use it in GitHub Desktop.
Pierre Feuille Ciseau, en HTML/CSS/Javascript. (W3C HTML5 compliant)
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
<IfModule mod_setenvif.c> | |
<IfModule mod_headers.c> | |
BrowserMatch MSIE ie | |
Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie | |
</IfModule> | |
</IfModule> |
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
<!DOCTYPE html> | |
<html lang="fr-fr"> | |
<head> | |
<meta charset="utf-8" /> | |
<link rel="stylesheet" type="text/css" href="style.css" /> | |
<title>Pierre Feuille Ciseau</title> | |
<meta name="description" content="Jeu du Pierre Feuille Ciseau" /> | |
<meta name="author" content="Adrien Tétar" /> | |
<meta name="viewport" content="width=device-width; initial-scale=1.0" /> | |
<!-- Replace favicon.ico & apple-touch-icon.png in the root of your domain and delete these references --> | |
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="favicon.ico" /> | |
<link rel="apple-touch-icon" href="apple-touch-icon.png" /> | |
</head> | |
<body> | |
<div> | |
<p style="text-align: right"> <a href="index.html">Actualiser</a> </p> | |
<header> | |
<div style="text-align: center"><h1>Pierre Feuille Ciseau</h1></div> | |
</header> | |
<script type="text/javascript" src="script.js"> </script> | |
<noscript>Désolé, le jeu a besoin de JavaScript pour fonctionner!</noscript> | |
<form> | |
<div> <br> | |
<table> | |
<tbody> | |
<tr> | |
<td colspan="3"> <input name="texte" size="15" style="text-align:center" type="text" readonly> </td> | |
</tr> | |
<tr> | |
<td> <input value=" Pierre " onclick="res(this.form,'Pierre')" type="button"> </td> | |
<td> <input value=" Feuille " onclick="res(this.form,'Feuille')" type="button"> </td> | |
<td> <input value=" Ciseau " onclick="res(this.form,'Ciseau')" type="button"> </td> | |
</tr> | |
<tr> | |
<td colspan="3"> <input value=" Résultat... " onclick='compute(); testing(this.form); raz(this.form)' type="button"> </td> | |
</tr> | |
</tbody> | |
</table> | |
<br> | |
<div id="score" style="font-weight: bold; text-align: center"> | |
Gagné: 0 fois. Perdu: 0 fois. | |
</div> | |
</div> | |
</form> | |
<br> | |
<footer> | |
<div style="text-align: center"><p> | |
Copyright © 2013, Adrien Tétar. | |
</p></div> | |
</footer> | |
</div> | |
</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
/** | |
* Pierre Feuille Ciseau | |
* | |
* @author: Adrien Tétar | |
* | |
* Copyright © 2013, Adrien Tétar. All rights reserved. | |
*/ | |
//================================== Var definitions. ====================================== | |
var user = ""; | |
var computer = ""; | |
var nb; | |
var won = 0, lost = 0; | |
function compute() | |
{ | |
nb = Math.floor(Math.random()*3) + 1; | |
if (nb == 1) | |
computer = "Pierre"; | |
else if (nb == 2) | |
computer = "Feuille"; | |
else if (nb == 3) | |
computer = "Ciseau"; | |
} | |
//=================================== Get user input. ====================================== | |
function res(form,val) | |
{ | |
if (user != "") | |
return; | |
form.texte.value = val; | |
user = val; | |
} | |
//================================= Test for validity. ===================================== | |
function testing(form) | |
{ | |
if (user == "" || computer == "") | |
return; | |
if (user == computer) | |
{ | |
alert("Gagné !"); | |
won += 1; | |
calcScore(form); | |
} | |
else | |
{ | |
alert("Perdu !\nL'ordinateur avait choisi " + computer + "."); | |
lost += 1; | |
calcScore(form); | |
} | |
} | |
//=================================== Sum up score. ======================================== | |
function calcScore(form) | |
{ | |
document.getElementById("score").innerHTML = "Gagné: " + won + " fois. Perdu: " + lost + " fois." | |
} | |
//====================================== Reset. ============================================ | |
function raz(form) | |
{ | |
form.texte.value = ""; | |
user = ""; | |
computer = ""; | |
} |
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
html { | |
color: black; | |
background-color: #E3CEF6; | |
background-image: none; | |
background-repeat: repeat; | |
background-attachment: scroll; | |
background-position: 0% 0%; | |
font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; | |
font-size: small; | |
} | |
table { | |
background-color: #ffffff; | |
border-color: #000000; | |
border-style: solid; | |
border-width: 2px; | |
margin-left: auto; | |
margin-right: auto; | |
text-align: center; | |
} | |
table td { | |
border-style: double; | |
border-width: 1px; | |
text-align: center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment