File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,24 +58,20 @@ contract rockPaperScissorGame{
5858 hasStarted = true ;
5959 }
6060 function commitMoves (string memory _move ) external {
61+ require (player1.addr == msg .sender || player2.addr == msg .sender );
6162 require (validMove (_move), "Invalid Move " );
6263
63- if (msg .sender == player1.addr){
6464
65- if ( ! (player1.hasCommitted) ) revert AlreadyCommitted ();
66- player1.committedMove = _move;
67- player1.hasCommitted = true ;
68-
69- }else if (msg .sender == player2.addr){
70-
71- if ( ! (player2.hasCommitted) ) revert AlreadyCommitted ();
72- player2.committedMove = _move;
73- player2.hasCommitted = true ;
74-
75- } else {
76-
77-
78- }
65+ if (msg .sender == player1.addr) {
66+ require (! player1.hasCommitted, "Already committed " );
67+ player1.committedMove = _move;
68+ player1.hasCommitted = true ;
69+ } else {
70+ require (! player2.hasCommitted, "Already committed " );
71+ player2.committedMove = _move;
72+ player2.hasCommitted = true ;
73+ }
74+
7975
8076 emit moveCommitted ();
8177
You can’t perform that action at this time.
0 commit comments