Update the smart contract to use hashes to hide the choice of players.
The solution is shown below so only look if you have had a go at solving it yourself and make sure to watch the video first.
.
..
...
....
.....
......
.......
........
.........
..........
1
pragma solidity 0.6.0;
2
3
contract Game {
4
bytes32 ROCK = keccak256(abi.encodePacked("ROCK"));
5
bytes32 PAPER = keccak256(abi.encodePacked("PAPER"));
6
bytes32 SCISSORS = keccak256(abi.encodePacked("SCISSORS"));
7
8
mapping(address => bytes32) public choices;
9
10
function play(bytes32 choice) external {
11
require(choice == ROCK || choice == PAPER || choice == SCISSORS); // checks that move is valid
12
require(choices[msg.sender] == bytes32(0)); // make sure player hasnt played before
13
choices[msg.sender] = choice;
14
}
15
16
function evaluate(address alice, address bob)
17
external
18
view
19
returns (address)
20
{
21
if (choices[alice] == choices[bob]) {
22
return address(0);
23
}
24
25
if (choices[alice] == ROCK && choices[bob] == PAPER) {
26
return bob;
27
} else if (choices[bob] == ROCK && choices[alice] == PAPER) {
28
return alice;
29
} else if (choices[alice] == SCISSORS && choices[bob] == PAPER) {
30
return alice;
31
} else if (choices[bob] == SCISSORS && choices[alice] == PAPER) {
32
return bob;
33
} else if (choices[alice] == ROCK && choices[bob] == SCISSORS) {
34
return alice;
35
} else if (choices[bob] == ROCK && choices[alice] == SCISSORS) {
36
return bob;
37
}
38
}
39
}