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
8104378b
Commit
8104378b
authored
Jun 27, 2022
by
GanyusLeftHorn
Committed by
Melledy
Jun 26, 2022
Browse files
Add daily and weekly mission reset.
parent
814d4819
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/battlepass/BattlePassManager.java
View file @
8104378b
package
emu.grasscutter.game.battlepass
;
package
emu.grasscutter.game.battlepass
;
import
java.time.DayOfWeek
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.time.temporal.TemporalAdjuster
;
import
java.time.temporal.TemporalAdjusters
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -32,6 +39,7 @@ import emu.grasscutter.net.proto.BattlePassScheduleOuterClass.BattlePassSchedule
...
@@ -32,6 +39,7 @@ import emu.grasscutter.net.proto.BattlePassScheduleOuterClass.BattlePassSchedule
import
emu.grasscutter.server.packet.send.PacketBattlePassCurScheduleUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketBattlePassCurScheduleUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketBattlePassMissionUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketBattlePassMissionUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketTakeBattlePassRewardRsp
;
import
emu.grasscutter.server.packet.send.PacketTakeBattlePassRewardRsp
;
import
emu.grasscutter.utils.Utils
;
import
lombok.Getter
;
import
lombok.Getter
;
@Entity
(
value
=
"battlepass"
,
useDiscriminator
=
false
)
@Entity
(
value
=
"battlepass"
,
useDiscriminator
=
false
)
...
@@ -255,15 +263,42 @@ public class BattlePassManager {
...
@@ -255,15 +263,42 @@ public class BattlePassManager {
}
}
public
void
resetDailyMissions
()
{
public
void
resetDailyMissions
()
{
// TODO
var
resetMissions
=
new
ArrayList
<
BattlePassMission
>();
for
(
var
mission
:
this
.
missions
.
values
())
{
if
(
mission
.
getData
().
getRefreshType
()
==
null
||
mission
.
getData
().
getRefreshType
()
==
BattlePassMissionRefreshType
.
BATTLE_PASS_MISSION_REFRESH_DAILY
)
{
mission
.
setStatus
(
BattlePassMissionStatus
.
MISSION_STATUS_UNFINISHED
);
mission
.
setProgress
(
0
);
resetMissions
.
add
(
mission
);
}
}
this
.
getPlayer
().
sendPacket
(
new
PacketBattlePassMissionUpdateNotify
(
resetMissions
));
this
.
getPlayer
().
sendPacket
(
new
PacketBattlePassCurScheduleUpdateNotify
(
this
.
getPlayer
()));
}
}
public
void
resetWeeklyMissions
()
{
public
void
resetWeeklyMissions
()
{
// TODO
var
resetMissions
=
new
ArrayList
<
BattlePassMission
>();
for
(
var
mission
:
this
.
missions
.
values
())
{
if
(
mission
.
getData
().
getRefreshType
()
==
BattlePassMissionRefreshType
.
BATTLE_PASS_MISSION_REFRESH_CYCLE_CROSS_SCHEDULE
)
{
mission
.
setStatus
(
BattlePassMissionStatus
.
MISSION_STATUS_UNFINISHED
);
mission
.
setProgress
(
0
);
resetMissions
.
add
(
mission
);
}
}
this
.
getPlayer
().
sendPacket
(
new
PacketBattlePassMissionUpdateNotify
(
resetMissions
));
this
.
getPlayer
().
sendPacket
(
new
PacketBattlePassCurScheduleUpdateNotify
(
this
.
getPlayer
()));
}
}
//
//
public
BattlePassSchedule
getScheduleProto
()
{
public
BattlePassSchedule
getScheduleProto
()
{
var
nextSundayDate
=
LocalDate
.
now
().
with
(
TemporalAdjusters
.
next
(
DayOfWeek
.
SUNDAY
));
var
nextSundayTime
=
LocalDateTime
.
of
(
nextSundayDate
.
getYear
(),
nextSundayDate
.
getMonthValue
(),
nextSundayDate
.
getDayOfMonth
(),
23
,
59
,
59
);
BattlePassSchedule
.
Builder
schedule
=
BattlePassSchedule
.
newBuilder
()
BattlePassSchedule
.
Builder
schedule
=
BattlePassSchedule
.
newBuilder
()
.
setScheduleId
(
2700
)
.
setScheduleId
(
2700
)
.
setLevel
(
this
.
getLevel
())
.
setLevel
(
this
.
getLevel
())
...
@@ -274,7 +309,11 @@ public class BattlePassManager {
...
@@ -274,7 +309,11 @@ public class BattlePassManager {
.
setUnlockStatus
(
this
.
isPaid
()
?
BattlePassUnlockStatus
.
BATTLE_PASS_UNLOCK_STATUS_PAID
:
BattlePassUnlockStatus
.
BATTLE_PASS_UNLOCK_STATUS_FREE
)
.
setUnlockStatus
(
this
.
isPaid
()
?
BattlePassUnlockStatus
.
BATTLE_PASS_UNLOCK_STATUS_PAID
:
BattlePassUnlockStatus
.
BATTLE_PASS_UNLOCK_STATUS_FREE
)
.
setJPFMGBEBBBJ
(
2
)
// Not bought on Playstation.
.
setJPFMGBEBBBJ
(
2
)
// Not bought on Playstation.
.
setCurCyclePoints
(
this
.
getCyclePoints
())
.
setCurCyclePoints
(
this
.
getCyclePoints
())
.
setCurCycle
(
BattlePassCycle
.
newBuilder
().
setBeginTime
(
0
).
setEndTime
(
2059483200
).
setCycleIdx
(
3
));
.
setCurCycle
(
BattlePassCycle
.
newBuilder
()
.
setBeginTime
(
0
)
.
setEndTime
((
int
)
nextSundayTime
.
atZone
(
ZoneId
.
systemDefault
()).
toEpochSecond
())
.
setCycleIdx
(
3
)
);
for
(
BattlePassReward
reward
:
getTakenRewards
().
values
())
{
for
(
BattlePassReward
reward
:
getTakenRewards
().
values
())
{
schedule
.
addRewardTakenList
(
reward
.
toProto
());
schedule
.
addRewardTakenList
(
reward
.
toProto
());
...
...
src/main/java/emu/grasscutter/game/battlepass/BattlePassMission.java
View file @
8104378b
...
@@ -37,6 +37,10 @@ public class BattlePassMission {
...
@@ -37,6 +37,10 @@ public class BattlePassMission {
return
progress
;
return
progress
;
}
}
public
void
setProgress
(
int
value
)
{
this
.
progress
=
value
;
}
public
void
addProgress
(
int
addProgress
,
int
maxProgress
)
{
public
void
addProgress
(
int
addProgress
,
int
maxProgress
)
{
this
.
progress
=
Math
.
min
(
addProgress
+
this
.
progress
,
maxProgress
);
this
.
progress
=
Math
.
min
(
addProgress
+
this
.
progress
,
maxProgress
);
}
}
...
...
src/main/java/emu/grasscutter/game/player/Player.java
View file @
8104378b
...
@@ -77,6 +77,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
...
@@ -77,6 +77,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap
;
import
lombok.Getter
;
import
lombok.Getter
;
import
java.time.DayOfWeek
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.time.ZoneId
;
...
@@ -1368,7 +1369,7 @@ public class Player {
...
@@ -1368,7 +1369,7 @@ public class Player {
this
.
getResinManager
().
rechargeResin
();
this
.
getResinManager
().
rechargeResin
();
}
}
private
void
doDailyReset
()
{
private
synchronized
void
doDailyReset
()
{
// Check if we should execute a daily reset on this tick.
// Check if we should execute a daily reset on this tick.
int
currentTime
=
Utils
.
getCurrentSeconds
();
int
currentTime
=
Utils
.
getCurrentSeconds
();
...
@@ -1383,6 +1384,14 @@ public class Player {
...
@@ -1383,6 +1384,14 @@ public class Player {
// Reset forge points.
// Reset forge points.
this
.
setForgePoints
(
300_000
);
this
.
setForgePoints
(
300_000
);
// Reset daily BP missions.
this
.
getBattlePassManager
().
resetDailyMissions
();
// Reset weekly BP missions.
if
(
currentDate
.
getDayOfWeek
()
==
DayOfWeek
.
MONDAY
)
{
this
.
getBattlePassManager
().
resetWeeklyMissions
();
}
// Done. Update last reset time.
// Done. Update last reset time.
this
.
setLastDailyReset
(
currentTime
);
this
.
setLastDailyReset
(
currentTime
);
}
}
...
@@ -1455,6 +1464,9 @@ public class Player {
...
@@ -1455,6 +1464,9 @@ public class Player {
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_MP_SETTING_TYPE
,
this
.
getMpSetting
().
getNumber
(),
false
);
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_MP_SETTING_TYPE
,
this
.
getMpSetting
().
getNumber
(),
false
);
this
.
setProperty
(
PlayerProperty
.
PROP_IS_MP_MODE_AVAILABLE
,
1
,
false
);
this
.
setProperty
(
PlayerProperty
.
PROP_IS_MP_MODE_AVAILABLE
,
1
,
false
);
// Execute daily reset logic if this is a new day.
this
.
doDailyReset
();
// Packets
// Packets
session
.
send
(
new
PacketPlayerDataNotify
(
this
));
// Player data
session
.
send
(
new
PacketPlayerDataNotify
(
this
));
// Player data
session
.
send
(
new
PacketStoreWeightLimitNotify
());
session
.
send
(
new
PacketStoreWeightLimitNotify
());
...
...
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