Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1f0cf77

Browse files
committed
add tier helper
1 parent 4e1e78b commit 1f0cf77

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

‎utils/tier.go‎

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package utils
2+
3+
const (
4+
BronzeBR = 0
5+
BronzeColorCode = 0xb57156
6+
7+
SilverBR = 2000
8+
SilverColorCode = 0xdbdbdb
9+
10+
PlatinumBR = 4000
11+
PlatinumColorCode = 0xe5e4e2
12+
13+
GoldBR = 6000
14+
GoldColorCode = 0xd7af00
15+
16+
DiamondBR = 9000
17+
DiamondColorCode = 0x16f7ef
18+
)
19+
20+
type Tier struct {
21+
Name string `json:"name"`
22+
ColorCode int `json:"colorCode"`
23+
EmblemFile string `json:"emblemFile"`
24+
}
25+
26+
type Promotion struct {
27+
Drop bool `json:"drop"`
28+
NewTier Tier `json:"newTier"`
29+
}
30+
31+
func GetTier(br int) Tier {
32+
if br >= BronzeBR && br < SilverBR {
33+
return Tier {
34+
Name: "bronze",
35+
ColorCode: BronzeColorCode,
36+
EmblemFile: "emblem_bronze.png",
37+
}
38+
} else if br >= SilverBR && br < PlatinumBR {
39+
return Tier {
40+
Name: "silver",
41+
ColorCode: SilverColorCode,
42+
EmblemFile: "emblem_silver.png",
43+
}
44+
} else if br >= PlatinumBR && br < GoldBR {
45+
return Tier {
46+
Name: "platinum",
47+
ColorCode: PlatinumColorCode,
48+
EmblemFile: "emblem_platinum.png",
49+
}
50+
} else if br >= GoldBR && br < DiamondBR {
51+
return Tier {
52+
Name: "gold",
53+
ColorCode: GoldColorCode,
54+
EmblemFile: "emblem_gold.png",
55+
}
56+
} else if br >= DiamondBR {
57+
return Tier {
58+
Name: "diamond",
59+
ColorCode: DiamondColorCode,
60+
EmblemFile: "emblem_diamond.png",
61+
}
62+
} else {
63+
return Tier {}
64+
}
65+
}
66+
67+
func PromotedTo(oldBR int, newBR int) Promotion {
68+
if oldBR >= SilverBR && newBR < SilverBR {
69+
// silver -> bronze
70+
return Promotion { true, GetTier(BronzeBR) }
71+
} else if oldBR < SilverBR && newBR >= SilverBR {
72+
// bronze -> silver
73+
return Promotion { false, GetTier(SilverBR) }
74+
} else if oldBR >= PlatinumBR && newBR < PlatinumBR {
75+
// platinum -> silver
76+
return Promotion { true, GetTier(SilverBR) }
77+
} else if oldBR < PlatinumBR && newBR >= PlatinumBR {
78+
// silver -> platinum
79+
return Promotion { false, GetTier(PlatinumBR) }
80+
} else if oldBR >= GoldBR && newBR < GoldBR {
81+
// gold -> platinum
82+
return Promotion { true, GetTier(PlatinumBR) }
83+
} else if oldBR < GoldBR && newBR >= GoldBR {
84+
// platinum -> gold
85+
return Promotion { false, GetTier(GoldBR) }
86+
} else if oldBR >= DiamondBR && newBR < DiamondBR {
87+
// diamond -> gold
88+
return Promotion { true, GetTier(GoldBR) }
89+
} else if oldBR < DiamondBR && newBR >= DiamondBR {
90+
// gold -> diamond
91+
return Promotion { false, GetTier(DiamondBR) }
92+
}
93+
94+
return Promotion{}
95+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /