-
Notifications
You must be signed in to change notification settings - Fork 0
/
nftModule.go
151 lines (109 loc) · 3.11 KB
/
nftModule.go
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package main
import (
"fmt"
"math/rand"
)
type nfTier struct {
tierClass float64
address string
mobxRewards float64
nftWeight float64
nftBonus float64
}
type nftSet []nfTier
var totalMilesWeight float64
type nftMap struct {
tier float64
multiplier float64
amount float64
}
type mapping []nftMap
func getNFTRewards2(us UserSet, nft nftSet) []nfTier {
// Requires a set of NFT tiers and then only picks one account of each tier
// returns a set of accounts with distinct NFT tiers
for _, mobxUser := range us {
if mobxUser.collectedMiles != 0 {
for i, nftUser := range nft {
if nftUser.address == "" && nftUser.nftWeight == mobxUser.nftWeight {
tier := nftSet{{nftUser.tierClass, mobxUser.address, mobxUser.mobxRewards, mobxUser.nftWeight, mobxUser.nftBonus}}
nft[i] = tier[0]
break
}
}
}
}
return nft
}
func (us UserSet) calculateNFTbonus(us2 UserSet, m mapping) {
// (currently) calculates the difference of the rewards compared to a world without NFT bonus
// prints out final results
nftGroup := nftSet{}
class1 := nfTier{
tierClass: 1,
address: "",
mobxRewards: 0,
nftWeight: 1,
nftBonus: 0,
}
nftGroup = append(nftGroup, class1)
for _, m := range m {
newTier := nfTier{
tierClass: m.tier,
address: "",
mobxRewards: 0,
nftWeight: m.multiplier,
nftBonus: 0,
}
nftGroup = append(nftGroup, newTier)
}
nft := getNFTRewards2(us, nftGroup)
fmt.Println("++++++++++++++++++++++++++++++++ Results ++++++++++++++++++++++++++++++++")
for i, nfTier := range nft {
for _, mobxUser := range us2 {
if mobxUser.address == nfTier.address {
nft[i].nftBonus = (((nfTier.mobxRewards / mobxUser.mobxRewards) - 1) * 100)
effectiveBonus := int(nft[i].nftBonus - nft[0].nftBonus)
fmt.Println("The absolute change with NFT Tier", nfTier.nftWeight, " is:", nft[i].nftBonus, "%")
fmt.Println("The relative change with NFT Tier", nfTier.nftWeight, "compared to a non-NFT holder is", effectiveBonus, "%")
}
}
}
}
func setNFTProps(m mapping) mapping {
fmt.Println("How many different tiers do you want? (excluding non-NFT holders)")
var f4 float64
_, _ = fmt.Scanf("%f4", &f4)
numberOfNFTs := int(f4)
for j := 0; j < numberOfNFTs; j++ {
var f float64
var f2 float64
var f3 float64
fmt.Println("For Nft Tier", j, ", please enter the tier identifier as a number. DON'T USE 1")
_, _ = fmt.Scanf("%f", &f)
fmt.Println("For NFT Tier", j, ", please enter the multiplier as a number")
_, _ = fmt.Scanf("%f2", &f2)
fmt.Println("For Nft Tier", j, ", please enter the issued NFT amount")
_, _ = fmt.Scanf("%f3", &f3)
tierF := float64(f)
multiplierF := float64(f2)
amountF := float64(f3)
m2 := nftMap{tierF, multiplierF, amountF}
m = append(m, m2)
}
return m
}
func (us UserSet) manipulateUsers(m mapping) {
for _, nftTier := range m {
ln := len(us)
am := int(nftTier.amount)
for l := 0; l <= am; l++ {
for o := 0; o < 100; o++ {
user := int(rand.Intn(ln))
if us[user].stakedMobx >= 10 {
us[user].nftWeight = nftTier.multiplier
break
}
}
}
}
}