Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
var scissors = "scissors";
var paper = "paper";
var stone = "stone";

var noTimesPlayerWin = 0;
var noTimesPlayerLose = 0;
var noTimesDraw = 0;

var userName = "";

var diceRoll = function () {
randomDice = Math.floor(Math.random) * 3;
if (randomDice == 0) {
return scissors;
}
if (randomDice == 1) {
return paper;
}
if (randomDice == 2) {
return stone;
}
};

var main = function (input) {
var myOutputValue = 'hello world';
return myOutputValue;
if (!userName) {
if (!input) {
return "please input username";
}
userName = input;
return "thank you," + userName + ".you can start playing sps.";
}
if (input != scissors && input != paper && input != stone) {
return "please input scissors,paper or stone.";
}

var playerObject = input;
var computerObject = diceRoll();

if (playerObject == computerObject) {
return "draw";
}
if (
(playerObject == scissors && computerObject == paper) ||
(playerObject == paper && computerObject == stone) ||
(playerObject == stone && computerObject == scissors)
) {
return "win";
}
return "lose";
};