Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
16622785
Commit
16622785
authored
May 19, 2022
by
Няшик Няшный
Committed by
Melledy
May 20, 2022
Browse files
Changing how banners work
parent
eb54dcec
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/gacha/GachaBanner.java
View file @
16622785
...
@@ -143,7 +143,7 @@ public class GachaBanner {
...
@@ -143,7 +143,7 @@ public class GachaBanner {
String
details
=
"http"
+
(
HTTP_ENCRYPTION
.
useInRouting
?
"s"
:
""
)
+
"://"
String
details
=
"http"
+
(
HTTP_ENCRYPTION
.
useInRouting
?
"s"
:
""
)
+
"://"
+
lr
(
HTTP_INFO
.
accessAddress
,
HTTP_INFO
.
bindAddress
)
+
":"
+
lr
(
HTTP_INFO
.
accessAddress
,
HTTP_INFO
.
bindAddress
)
+
":"
+
lr
(
HTTP_INFO
.
accessPort
,
HTTP_INFO
.
bindPort
)
+
lr
(
HTTP_INFO
.
accessPort
,
HTTP_INFO
.
bindPort
)
+
"/gacha/details?s="
+
sessionKey
+
"&
gachaType="
+
gachaType
;
+
"/gacha/details?s="
+
sessionKey
+
"&
scheduleId="
+
scheduleId
;
// Grasscutter.getLogger().info("record = " + record);
// Grasscutter.getLogger().info("record = " + record);
ItemParamData
costItem1
=
this
.
getCost
(
1
);
ItemParamData
costItem1
=
this
.
getCost
(
1
);
...
...
src/main/java/emu/grasscutter/game/gacha/GachaManager.java
View file @
16622785
...
@@ -82,7 +82,7 @@ public class GachaManager {
...
@@ -82,7 +82,7 @@ public class GachaManager {
List
<
GachaBanner
>
banners
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
TypeToken
.
getParameterized
(
Collection
.
class
,
GachaBanner
.
class
).
getType
());
List
<
GachaBanner
>
banners
=
Grasscutter
.
getGsonFactory
().
fromJson
(
fileReader
,
TypeToken
.
getParameterized
(
Collection
.
class
,
GachaBanner
.
class
).
getType
());
if
(
banners
.
size
()
>
0
)
{
if
(
banners
.
size
()
>
0
)
{
for
(
GachaBanner
banner
:
banners
)
{
for
(
GachaBanner
banner
:
banners
)
{
getGachaBanners
().
put
(
banner
.
get
GachaType
(),
banner
);
getGachaBanners
().
put
(
banner
.
get
ScheduleId
(),
banner
);
}
}
Grasscutter
.
getLogger
().
info
(
"Banners successfully loaded."
);
Grasscutter
.
getLogger
().
info
(
"Banners successfully loaded."
);
...
@@ -236,7 +236,7 @@ public class GachaManager {
...
@@ -236,7 +236,7 @@ public class GachaManager {
};
};
}
}
public
synchronized
void
doPulls
(
Player
player
,
int
gachaType
,
int
times
)
{
public
synchronized
void
doPulls
(
Player
player
,
int
scheduleId
,
int
times
)
{
// Sanity check
// Sanity check
if
(
times
!=
10
&&
times
!=
1
)
{
if
(
times
!=
10
&&
times
!=
1
)
{
return
;
return
;
...
@@ -248,7 +248,7 @@ public class GachaManager {
...
@@ -248,7 +248,7 @@ public class GachaManager {
}
}
// Get banner
// Get banner
GachaBanner
banner
=
this
.
getGachaBanners
().
get
(
gachaType
);
GachaBanner
banner
=
this
.
getGachaBanners
().
get
(
scheduleId
);
if
(
banner
==
null
)
{
if
(
banner
==
null
)
{
player
.
sendPacket
(
new
PacketDoGachaRsp
());
player
.
sendPacket
(
new
PacketDoGachaRsp
());
return
;
return
;
...
@@ -285,7 +285,7 @@ public class GachaManager {
...
@@ -285,7 +285,7 @@ public class GachaManager {
}
}
// Write gacha record
// Write gacha record
GachaRecord
gachaRecord
=
new
GachaRecord
(
itemId
,
player
.
getUid
(),
g
achaType
);
GachaRecord
gachaRecord
=
new
GachaRecord
(
itemId
,
player
.
getUid
(),
banner
.
getG
achaType
()
);
DatabaseHelper
.
saveGachaRecord
(
gachaRecord
);
DatabaseHelper
.
saveGachaRecord
(
gachaRecord
);
// Create gacha item
// Create gacha item
...
...
src/main/java/emu/grasscutter/server/http/handlers/GachaHandler.java
View file @
16622785
...
@@ -104,9 +104,9 @@ public final class GachaHandler implements Router {
...
@@ -104,9 +104,9 @@ public final class GachaHandler implements Router {
.
replace
(
"{{LANGUAGE}}"
,
Utils
.
getLanguageCode
(
account
.
getLocale
()));
.
replace
(
"{{LANGUAGE}}"
,
Utils
.
getLanguageCode
(
account
.
getLocale
()));
// Get the banner info for the banner we want.
// Get the banner info for the banner we want.
int
gachaType
=
Integer
.
parseInt
(
request
.
query
(
"
gachaType
"
));
int
scheduleId
=
Integer
.
parseInt
(
request
.
query
(
"
scheduleId
"
));
GachaManager
manager
=
Grasscutter
.
getGameServer
().
getGachaManager
();
GachaManager
manager
=
Grasscutter
.
getGameServer
().
getGachaManager
();
GachaBanner
banner
=
manager
.
getGachaBanners
().
get
(
gachaType
);
GachaBanner
banner
=
manager
.
getGachaBanners
().
get
(
scheduleId
);
// Add 5-star items.
// Add 5-star items.
Set
<
String
>
fiveStarItems
=
new
LinkedHashSet
<>();
Set
<
String
>
fiveStarItems
=
new
LinkedHashSet
<>();
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerDoGachaReq.java
View file @
16622785
...
@@ -12,6 +12,6 @@ public class HandlerDoGachaReq extends PacketHandler {
...
@@ -12,6 +12,6 @@ public class HandlerDoGachaReq extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
DoGachaReq
req
=
DoGachaReq
.
parseFrom
(
payload
);
DoGachaReq
req
=
DoGachaReq
.
parseFrom
(
payload
);
session
.
getServer
().
getGachaManager
().
doPulls
(
session
.
getPlayer
(),
req
.
getGacha
Type
(),
req
.
getGachaTimes
());
session
.
getServer
().
getGachaManager
().
doPulls
(
session
.
getPlayer
(),
req
.
getGacha
ScheduleId
(),
req
.
getGachaTimes
());
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment