-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPitchForkTargetFactory.sol
41 lines (28 loc) · 1.24 KB
/
PitchForkTargetFactory.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
pragma solidity ^0.4.25;
import "./goldengoat.sol";
contract PitchForkTargetFactory is GoldenGoat {
//event for adding a new pitchfork target.
//Includes the id of the target, the target's name and a pitchfork count which will count the pitchforks applied to the target.
event NewTarget(uint targetId, string targetName, uint pitchForkCount);
//data type for the pitchfork target
//Includes the target's name and a count of pitchforks
struct PitchForkTarget {
string targetName;
uint pitchForkCount;
}
//array of pitchfork targets
PitchForkTarget[] public targets;
//mappings
mapping (address => uint) firstStrike;
//function for creating a new pitchfork target
//emits an event when a new target is created
function _createTarget(string _targetName, uint _pitchForkCount) private {
uint id = targets.push(PitchForkTarget(_targetName, _pitchForkCount)) - 1;
emit NewTarget(id, _targetName, _pitchForkCount);
}
//function for goldengoat
function goldengoat(address participant, int score) public view {
//add 1 to goldengoat score when PitchForkTarget is created
firstStrike[id] = msg.sender;
}
}