//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 { enum fieldValue { noValue, aValue, bValue } fieldValue Value; fieldValue constant defaultValue= fieldValue.noValue; //Field on a 3x3 Plan, value describes which player has chosen this field fieldValue [3][3] public fields; //I'm not sure if this is the way you use enums //together with twodimensional arrays modifier occupation(uint _i, uint _k) { // fields is already public require(fields[_i][_k] == fieldValue.noValue); _; } //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, fieldValue Value){ //not sure if I used enum correctly here fields[_i][_k] = fieldValue.Value; } //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 I'm not sure is this function is still needed as the default Value for all Fields in the 2dimensional array is already set to "noValue"...*/ function PlayA(uint _i, uint _k) public occupation(_i, _k) { require(msg.sender == PlayerA); Value = fieldValue.aValue; fieldChange (_i, _k, Value); } //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); Value = fieldValue.bValue; fieldChange (_i, _k, Value); } //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.16