//Write your own contracts here. Currently compiles using solc v0.4.15+commit.bbb8e64f. pragma solidity ^0.4.18; contract LandAresh { address public owner; uint public defaultCost; uint public mainLandCost; mapping(uint => mapping(uint => address))public properties; mapping(uint => mapping(uint => address))public landContent; mapping(uint => mapping(uint => bool))public status; mapping(uint => mapping(uint => uint))public prices; function LandAresh() public { owner = msg.sender; } //x and y represent the position of the land in a GRID function setLandPrice(uint x,uint y,uint price) public { if(status[x][y]) { if(msg.sender==properties[x][y]) { prices[x][y]=price; } } else { if(msg.sender==owner) { prices[x][y]=price; } } } function setMainLandCost(uint price) public { if(msg.sender==owner) mainLandCost=price; } function setDefaultCost(uint price) public { if(msg.sender==owner) defaultCost=price; } function getLocation(uint x,uint y)public constant returns(uint,address,bool) { return(prices[x][y],properties[x][y],status[x][y]); } function buyMainLand() public payable { //If bigger than zero, means lang is available if(mainLandCost>0) { if(msg.value>=mainLandCost) { owner=msg.sender; mainLandCost=0; } } } function buyLand(uint x,uint y)public payable { if(status[x][y]) { //land has owner if(prices[x][y]>0) //if price is not zero then its for sale { if(msg.value>=prices[x][y]) //sell at higher price { properties[x][y]=msg.sender; //sold, assigned owner } } } else { //land has no owner if(prices[x][y]>0) { if(msg.value>=prices[x][y]) { properties[x][y]=msg.sender; status[x][y]=true; } } if(prices[x][y]==0) { if(msg.value>=defaultCost) { properties[x][y]=msg.sender; } } } } function setLand(uint x,uint y,address entity) public { if(status[x][y]) { //if status is true, land contains property if(properties[x][y]==msg.sender) { landContent[x][y]=entity; } else { revert(); } } } }
0.4.18