每日任务优化

This commit is contained in:
hahwu 2025-06-27 15:39:12 +08:00
parent c2218c245b
commit 39df9df173
4 changed files with 4 additions and 40 deletions

View File

@ -35,5 +35,5 @@
"KafkaHost":"kafka-server",
"KafkaPort":"9092",
"Version":"1.0.0",
"IdVerify":true
"IdVerify":false
}

View File

@ -154,11 +154,10 @@ func (p *Player) ProcessTrigger() {
DailyTaskMod := p.PlayMod.getDailyTaskMod()
MailMod := p.PlayMod.getMailMod()
PlayroomMod := p.PlayMod.getPlayroomMod()
GuideMod := p.PlayMod.getGuideMod()
IsPlayroomBack := false
IsMailBack := false
for _, tr := range p.Trigger {
if DailyTaskMod.Trigger(tr, GuideMod.CheckFinishFirstTask()) {
if DailyTaskMod.Trigger(tr) {
IsDailyBack = true
}
if p.MailTrigger(tr) {

View File

@ -107,8 +107,8 @@ func (dt *DailyTaskMod) WeekUpdate() {
dt.WeekReward = weekReward
}
func (dt *DailyTaskMod) Trigger(Tr *quest.Trigger, Unlock bool) bool {
if !Unlock {
func (dt *DailyTaskMod) Trigger(Tr *quest.Trigger) bool {
if !dt.Lock {
return false
}
update := false

View File

@ -10,46 +10,11 @@ import (
)
var KafkaMod *kafka.Writer
var topic string
func init() {
if conf.Server.GameName == "pet_home_local" {
return
}
topic = conf.Server.GameName
// Create a Kafka connection to the broker
conn, err := kafka.Dial("tcp", fmt.Sprintf("%s:%s", conf.Server.KafkaHost, conf.Server.KafkaPort))
if err != nil {
log.Debug("Failed to connect to Kafka broker: %v", err)
return
}
defer conn.Close()
// Check if topic exists, create if not
partitions, err := conn.ReadPartitions()
if err != nil {
log.Debug("Failed to read partitions: %v", err)
return
}
exists := false
for _, p := range partitions {
if p.Topic == topic {
exists = true
break
}
}
if !exists {
err = conn.CreateTopics(kafka.TopicConfig{
Topic: topic,
NumPartitions: 1,
ReplicationFactor: 1,
})
if err != nil {
log.Debug("Failed to create topic: %v", err)
return
}
}
KafkaMod = newKafkaWriter(fmt.Sprintf("%s:%s", conf.Server.KafkaHost, conf.Server.KafkaPort), conf.Server.GameName)
log.Debug("KafkaMod init")
}