1234567891011121314151617181920212223242526272829303132333435 |
- pragma solidity ^0.4.23;
- import "./Ownable.sol";
- contract ShowFactory is Ownable {
- event NewShow(uint id, string name, bytes music);
- struct Show {
- string name;
- bytes dance;
- bytes music;
- }
- Show[] public shows;
- mapping (uint=>address) public showToOwner;
- mapping (address=>uint) public ownerShowCount;
- modifier onlyOwnerOf(uint id) {
- require(msg.sender == showToOwner[id]);
- _;
- }
- function _createShow(string name, bytes dance, bytes music) internal {
- uint id = shows.push(Show(name, dance, music)) - 1;
- showToOwner[id] = msg.sender;
- ownerShowCount[msg.sender]++;
- emit NewShow(id, name, music);
- }
- function createFirstShow(string name, bytes dance, bytes music) public {
- require(ownerShowCount[msg.sender] == 0); // The 1st show is free
- _createShow(name, dance, music);
- }
- }
|