//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.16; //Erc20 contract User { /*modifier enoughmoney { require(balanceOf[msg.sender>=1]); _; }*/ function DefineUserA() public { address PlayerA = msg.sender; } function DefineUserB() public { address PlayerB = msg.sender; } //needs a lock, so functions can't be called while game is still going on } contract Fields { //Field on a 3x3 Plan, value describes which player has chosen this field bytes32[3][3] public fields; modifier occupation(uint _i, uint _k) { // fields is already public require(fields[_i][_k] == "N"); _; } //if someone wants to choose a field, we need to make sure that it isn't occupied yet // i describes the row, k the column // function names should follow camelCase https://en.wikipedia.org/wiki/Camel_case function fieldChange (uint _i, uint _k, bytes32 _newValue){ fields[_i][_k] = _newValue; } //this function is called when sb. wants to choose a field function createFields () public { for (uint i=1; i<=3; i++) { for (uint k=1; k<=3; k++) { fields[i][k] = "N"; } } } //the 3x3 fields are created function PlayA(uint _i, uint _k) public occupation(_i, _k) { require(msg.sender == PlayerA); fieldChange (_i, _k, "A"); } //function which is called by PlayerA to choose field i,k function PlayB(uint _i, uint _k) public occupation(_i, _k) { require(msg.sender == PlayerB); fieldChange (_i, _k, "B"); } //function which is called by PlayerA to choose field i,k } /* k=1 k=2 k=3 ___________ Plan i=1 |___|___|___| i=2 |___|___|___| i=3 |___|___|___| */
0.4.24