每日任务优化
This commit is contained in:
parent
c2218c245b
commit
39df9df173
@ -35,5 +35,5 @@
|
|||||||
"KafkaHost":"kafka-server",
|
"KafkaHost":"kafka-server",
|
||||||
"KafkaPort":"9092",
|
"KafkaPort":"9092",
|
||||||
"Version":"1.0.0",
|
"Version":"1.0.0",
|
||||||
"IdVerify":true
|
"IdVerify":false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,11 +154,10 @@ func (p *Player) ProcessTrigger() {
|
|||||||
DailyTaskMod := p.PlayMod.getDailyTaskMod()
|
DailyTaskMod := p.PlayMod.getDailyTaskMod()
|
||||||
MailMod := p.PlayMod.getMailMod()
|
MailMod := p.PlayMod.getMailMod()
|
||||||
PlayroomMod := p.PlayMod.getPlayroomMod()
|
PlayroomMod := p.PlayMod.getPlayroomMod()
|
||||||
GuideMod := p.PlayMod.getGuideMod()
|
|
||||||
IsPlayroomBack := false
|
IsPlayroomBack := false
|
||||||
IsMailBack := false
|
IsMailBack := false
|
||||||
for _, tr := range p.Trigger {
|
for _, tr := range p.Trigger {
|
||||||
if DailyTaskMod.Trigger(tr, GuideMod.CheckFinishFirstTask()) {
|
if DailyTaskMod.Trigger(tr) {
|
||||||
IsDailyBack = true
|
IsDailyBack = true
|
||||||
}
|
}
|
||||||
if p.MailTrigger(tr) {
|
if p.MailTrigger(tr) {
|
||||||
|
|||||||
@ -107,8 +107,8 @@ func (dt *DailyTaskMod) WeekUpdate() {
|
|||||||
dt.WeekReward = weekReward
|
dt.WeekReward = weekReward
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dt *DailyTaskMod) Trigger(Tr *quest.Trigger, Unlock bool) bool {
|
func (dt *DailyTaskMod) Trigger(Tr *quest.Trigger) bool {
|
||||||
if !Unlock {
|
if !dt.Lock {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
update := false
|
update := false
|
||||||
|
|||||||
@ -10,46 +10,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var KafkaMod *kafka.Writer
|
var KafkaMod *kafka.Writer
|
||||||
var topic string
|
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if conf.Server.GameName == "pet_home_local" {
|
if conf.Server.GameName == "pet_home_local" {
|
||||||
return
|
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)
|
KafkaMod = newKafkaWriter(fmt.Sprintf("%s:%s", conf.Server.KafkaHost, conf.Server.KafkaPort), conf.Server.GameName)
|
||||||
log.Debug("KafkaMod init")
|
log.Debug("KafkaMod init")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user