Skip to content

Commit

Permalink
playerAnswer + payable
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogeek committed Nov 4, 2023
1 parent 35cf802 commit efd0da1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions contracts/Game.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
pragma solidity ^0.8.13;

contract Game {
address public immutable player1;
address public player2;
address payable public immutable player1;
address payable public player2;
string playerAnswer1;

constructor(address _player1) {
constructor(address payable _player1, string memory _playerAnswer) payable {
require(msg.value >= 0.1 ether, "Minimum 0.1 ETH required to start a game");
player1 = _player1;
playerAnswer1 = _playerAnswer;
}

function startGame(address _player2) external {
function startGame(address payable _player2) external {
require(player2 == address(0), "Game already has two players.");
require(player1 != _player2, "You cannot join your own game.");
player2 = _player2;
Expand All @@ -18,5 +21,11 @@ contract Game {

function answerQuestion(string memory _playerAnswer) external {
// Game logic for answering questions.
// if player1 wins
player1.transfer(0.1 ether);
//else
player2.transfer(0.1 ether)
}


}

0 comments on commit efd0da1

Please sign in to comment.