function purchase(uint256 _tokenId) public payable onlyGameStarted {
    Token storage token = tokens[_tokenId];

    
    require(msg.value >= token.price);

    
    require(msg.sender != token.owner);

    uint256 purchaseExcess = msg.value.sub(token.price);

    address newOwner = msg.sender;
    address oldOwner = token.owner;

    uint256 devCut = token.price.mul(4).div(100); 
    uint256 towerBossCut = token.price.mul(3).div(100); 
    uint256 managerCut = getManagerCut(_tokenId, token.price); 
    uint256 oldOwnerProfit = token.price.sub(devCut).sub(towerBossCut).sub(managerCut);

    
    uint256 oldPrice = token.price;
    token.owner = newOwner;
    token.price = getNextPrice(token.price);

    
    earnings[owner] = earnings[owner].add(devCut);

    
    earnings[tokens[TOWER_BOSS_TOKEN_ID].owner] = earnings[tokens[TOWER_BOSS_TOKEN_ID].owner].add(towerBossCut);

    
    if (managerCut > 0) {
      address managerAddress = getManagerAddress(_tokenId);
      earnings[managerAddress] = earnings[managerAddress].add(managerCut);
    }

    
    sendFunds(oldOwner, oldOwnerProfit);

    
    if (purchaseExcess > 0) {
      sendFunds(newOwner, purchaseExcess);
    }

    TokenPurchased(_tokenId, oldOwner, newOwner, oldPrice, token.price, now);
  }