forked from andrecronje/rarity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
names.sol
62 lines (47 loc) · 1.85 KB
/
names.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;
interface rarity {
function summoner(uint _summoner) external view returns (uint _xp, uint _log, uint _class, uint _level);
function level(uint) external view returns (uint);
function getApproved(uint) external view returns (address);
function ownerOf(uint) external view returns (address);
}
interface gold {
function transferFrom(uint executor, uint from, uint to, uint amount) external;
}
contract names {
string constant name = "Rarity Names";
string constant symbol = "names";
rarity constant rm = rarity(0xce761D788DF608BD21bdd59d6f4B54b2e27F25Bb);
gold constant g = gold(0x2069B76Afe6b734Fb65D1d099E7ec64ee9CC76B2);
mapping(uint => string) public n;
function title(uint _lvl) public pure returns (string memory) {
if (_lvl <= 3) {
return "Noob";
} else if (_lvl > 3 && _lvl <= 5) {
return "Trainee";
} else if (_lvl > 5 && _lvl <= 10) {
return "Rookie";
} else if (_lvl > 10 && _lvl <= 20) {
return "Master";
} else if (_lvl > 20 && _lvl <= 30) {
return "Grandmaster";
} else if (_lvl > 30 && _lvl <= 40) {
return "Legend";
} else {
return "Hero";
}
}
function summoner_name(uint _summoner) public view returns (string memory) {
return n[_summoner];
}
function full_name(uint _summoner) public view returns (string memory) {
(uint _xp, uint _log, uint _class, uint _level) = rm.summoner(_summoner);
string memory sn = n[_summoner];
return string(abi.encodePacked(title(_level), " ", sn));
}
function set_name(uint _summoner, string calldata _name) external {
require(rm.ownerOf(_summoner) == msg.sender, "Names: not owner");
n[_summoner] = _name;
}
}