Commit 977f1ca2 authored by Akka's avatar Akka Committed by Melledy
Browse files

implement the activity system

parent 5d35cb49
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.activity.ActivityConfigItem;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ActivityScheduleInfoNotifyOuterClass;
import emu.grasscutter.net.proto.ActivityScheduleInfoOuterClass;
import emu.grasscutter.utils.DateHelper;
import java.util.Collection;
public class PacketActivityScheduleInfoNotify extends BasePacket {
public PacketActivityScheduleInfoNotify(Collection<ActivityConfigItem> activityConfigItemList) {
super(PacketOpcodes.ActivityScheduleInfoNotify);
var proto = ActivityScheduleInfoNotifyOuterClass.ActivityScheduleInfoNotify.newBuilder();
activityConfigItemList.forEach(item -> {
proto.addActivityScheduleList(ActivityScheduleInfoOuterClass.ActivityScheduleInfo.newBuilder()
.setActivityId(item.getActivityId())
.setScheduleId(item.getScheduleId())
.setIsOpen(true)
.setBeginTime(DateHelper.getUnixTime(item.getBeginTime()))
.setEndTime(DateHelper.getUnixTime(item.getEndTime()))
.build());
});
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.activity.PlayerActivityData;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ActivityUpdateWatcherNotifyOuterClass;
public class PacketActivityUpdateWatcherNotify extends BasePacket {
public PacketActivityUpdateWatcherNotify(int activityId, PlayerActivityData.WatcherInfo watcherInfo) {
super(PacketOpcodes.ActivityUpdateWatcherNotify);
var proto = ActivityUpdateWatcherNotifyOuterClass.ActivityUpdateWatcherNotify.newBuilder();
proto.setActivityId(activityId)
.setWatcherInfo(watcherInfo.toProto());
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.activity.ActivityManager;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetActivityInfoRspOuterClass.GetActivityInfoRsp; import emu.grasscutter.net.proto.GetActivityInfoRspOuterClass.GetActivityInfoRsp;
import java.util.Set;
public class PacketGetActivityInfoRsp extends BasePacket { public class PacketGetActivityInfoRsp extends BasePacket {
public PacketGetActivityInfoRsp() { public PacketGetActivityInfoRsp(Set<Integer> activityIdList, ActivityManager activityManager) {
super(PacketOpcodes.GetActivityInfoRsp); super(PacketOpcodes.GetActivityInfoRsp);
GetActivityInfoRsp proto = GetActivityInfoRsp.newBuilder().build(); var proto = GetActivityInfoRsp.newBuilder();
activityIdList.stream()
.map(activityManager::getInfoProto)
.forEach(proto::addActivityInfoList);
this.setData(proto); this.setData(proto);
} }
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.MusicGameSettleRspOuterClass;
public class PacketMusicGameSettleRsp extends BasePacket {
public PacketMusicGameSettleRsp(int musicBasicId) {
super(PacketOpcodes.MusicGameSettleRsp);
var proto = MusicGameSettleRspOuterClass.MusicGameSettleRsp.newBuilder();
proto.setMusicBasicId(musicBasicId)
.setIsNewRecord(true);
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.MusicGameStartRspOuterClass;
public class PacketMusicGameStartRsp extends BasePacket {
public PacketMusicGameStartRsp(int musicBasicId) {
super(PacketOpcodes.MusicGameStartRsp);
var proto = MusicGameStartRspOuterClass.MusicGameStartRsp.newBuilder();
proto.setMusicBasicId(musicBasicId);
this.setData(proto);
}
}
[
{
"activityId" : 5072,
"activityType" : 2202,
"meetCondList" : [
5072001,
5072002,
5072003,
5072004,
5072005,
5072006,
5072007
],
"beginTime" : "2022-05-01T00:00:00+08:00",
"endTime" : "2023-05-01T00:00:00+08:00"
}
]
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment