//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 { struct Field { uint i; //row uint k; //column bytes32 value; //bytes32 takes too much space } //Field on a 3x3 Plan, value describes which player has chosen this field Field[] public fields; modifier occupation(Field _fields) { require(fields.value[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 Fieldchange (uint _i, uint _k, bytes32 _newValue){ fields.value[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.push(Field(i, k, "N")); } } } //the 3x3 fields are created function PlayA(uint _i, uint _k) public occupation{ 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{ 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.16