Skip to content

Vanssh-k/Odd-Eve-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Odd-Eve-Game-Task

I have created the smart contract named oddEvenGame. First I have declared three state variables named score, isEnded and randNonce.

  1. Score --> uint256 --> This will store computer's scores.
  2. isEnded --> bool --> This is a flag for the match is ended or not.
  3. randNonce --> uint256 --> This will store a random nonce which will help to generate random values.

Then I declared and defined some fuctions like -->

  1. randomNo --> This is a function which is used to generate random number.
  2. reset --> This is a function which will reset the value of score to zero and turn the flag isEnded to false to restarts the match. Basically this function restarts the match.
  3. play --> This function will take a user value ranging from 1 to 6 and checks if the user value is equal to the random generated value or not and and then does the logic part respectively.

First I tested my contract on remix virtual machine then I have deployed the contract to goerli testnet. Goerli testnet address --> 0xCD4288fD856BDbd2ea7dA112936a2f8419435631

Tests -->

  1. Played the match by putting user input 2.

Screenshot 2022-09-12 at 9 47 08 PM

In this the decode input is number 2 and output is "5 RUNS" because the randomly generated number was not equal to 2 and hence it shows the generated number and "RUNS"..
  1. Again played the match by putting user input 2.

Screenshot 2022-09-12 at 9 47 18 PM

In this the decode input is number 2 and output is "1 RUNS" because the randomly generated number was not equal to 2 and hence it shows the generated number and "RUNS".
  1. Played the match once again by putting the user input 2.

Screenshot 2022-09-12 at 9 46 58 PM

In this the decode input is number 2 and output is "18 OUT" because the randomly generated number was equal to 2 and hence it shows the total score and "OUT".
  1. After the computer got out then I played without hitting the reset button so I got this error that match has ended.. press reset to restart

Screenshot 2022-09-12 at 9 48 30 PM

  1. Screenshot of deploying the smart contract to goeri nestnet at the address = 0xCD4288fD856BDbd2ea7dA112936a2f8419435631

Screenshot 2022-09-12 at 9 49 08 PM

Screenshot 2022-09-12 at 9 21 50 PM

  1. Played the game by giving the wrong user input 7. It responded with an error

Screenshot 2022-09-12 at 11 38 37 PM

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published