Rock paper scissors

I tried this but it didnt work;

//The Variables for the players
const player = "Ian";
const miAi = "Computer";

//The Variables for the moves
//const choice1 = "lapis";
//const choice2 = "papyrus";
//const choice3 = "scalpellus"

// eventual refactor of moves variables \\1 - 2 - 3\\
let result = "";

const movesList = [
  (choice1 = "lapis"),
  (choice2 = "papyrus"),
  (choice3 = "scalpellus")
];
const results = [
  `${miAi} wins! ${miAi}  chose ${choice2} and ${player} chose ${choice1}.`,
  `${miAi}  wins! ${miAi} chose ${choice3} and ${player} chose ${choice2}.`,
  `${miAi}  wins! ${miAi}  chose ${choice1} and ${player} chose ${choice3}.`,
  `${player} wins! The player chose ${choice2} and ${miAi}  chose ${choice1}.`,
  `${player} wins! The player chose ${choice3} and ${miAi}  chose ${choice2}.`,
  `${player} wins! The player chose ${choice1} and ${miAi}  chose ${choice3}.`
];

let playerMove = function () {
  let index1 = Math.floor(Math.random() * 3);
  let selection1 = movesList.at(index1);
  return selection1;
};

let miAiMove = function () {
  let index2 = Math.floor(Math.random() * 3);
  let selection2 = movesList.at(index2);
  return selection2;
};

const decisionMaker = function () {
  playerMove();
  miAiMove();
};

const move = () => {
  decisionMaker();
  if (playerMove() === choice1 && miAiMove() === choice2) {
    result = results[0];
  }

  if (playerMove() === choice2 && miAiMove() === choice3) {
    result = results[1];
  }

  if (playerMove() === choice3 && miAiMove() === choice1) {
    result = results[2];
  }
  ///////////////////////////////////////////

  if (miAiMove() === choice1 && playerMove() === choice2) {
    result = results[3];
  }

  if (miAiMove() === choice2 && playerMove() === choice3) {
    result = results[4];
  }

  if (miAiMove() === choice3 && playerMove() === choice1) {
    result = results[5];
  }
  if (miAiMove() === playerMove()) {
    result = "Its a Tie";
    decisionMaker();
    move();
  }
  return result;
};
console.log(move());
console.log(move());
console.log(move());


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.