提交 2f1534e0 编写于 作者: W weixin_67016521

Auto Commit

上级 dd4417a5
......@@ -8,6 +8,7 @@
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id = "score" class="score"></div>
<div id="result">
<div id="players">
<div id="player-icon" class="player"></div>
......
// 定义变量,记录双方出拳
let playerChoice = "";
let computerChoice = "";
var wins = 0;
var losts = 0;
var draws=0;
var rate = 0;
// 定义函数,用于电脑出拳
function computerPlay() {
......@@ -44,15 +48,25 @@ function emojiOf(choice) {
function determineOutcome(playerChoice, computerChoice) {
if (playerChoice === computerChoice) {
draws++;
rate = (wins/(wins+losts)).toFixed(3);
document.getElementById("score").innerHTML = "😊 wins: "+(wins).toString()+" 🤖️ wins: "+ losts.toString()+" odds: "+rate.toString();
return " draw ";
} else if (
(playerChoice === "scissors" && computerChoice === "paper") ||
(playerChoice === "rock" && computerChoice === "scissors") ||
(playerChoice === "paper" && computerChoice === "rock")
) {
wins++;
rate = (wins/(wins+losts)).toFixed(3);
document.getElementById("score").innerHTML = "😊 wins: "+(wins).toString()+" 🤖️ wins: "+ losts.toString()+" odds: "+rate.toString();
return "😊 wins !";
} else {
losts++;
rate = (wins/(wins+losts)).toFixed(3);
document.getElementById("score").innerHTML = "😊 wins: "+(wins).toString()+" 🤖️ wins: "+ losts.toString()+" odds: "+rate.toString();
return "🤖️ wins !";
}
}
......@@ -8,6 +8,12 @@ body {
justify-content: center;
}
score{
position: absolute;
top:10px;
left: 10px;
}
button {
font-size: 3rem;
margin: 10px;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册