每日任务优化
This commit is contained in:
parent
7b086e99d2
commit
2fe1c75c4e
@ -35,5 +35,5 @@
|
||||
"KafkaHost":"kafka-server",
|
||||
"KafkaPort":"9092",
|
||||
"Version":"1.0.0",
|
||||
"IdVerify":true
|
||||
"IdVerify":false
|
||||
}
|
||||
|
||||
@ -152,11 +152,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) {
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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")
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user