conf.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package scratchcard
  2. import (
  3. "active/tools"
  4. "fmt"
  5. )
  6. var ScratchardConf = &ScratchardConfig{}
  7. type ScratchardConfig struct {
  8. CardTotal int64 `json:"card_total" yaml:"card_total"`
  9. CardRate []int64 `json:"card_rate" yaml:"card_rate"`
  10. CardNumber []int64 `json:"card_number" yaml:"card_number"`
  11. GetCardLimit int64 `json:"get_card_limit" yaml:"get_card_limit"`
  12. WatchAdLimit int64 `json:"watch_ad_limit" yaml:"watch_ad_limit"`
  13. ALLSend int64 `json:"all_send" yaml:"all_send"`
  14. BigPrizeList []int `json:"big_prize_list" yaml:"big_prize_list"`
  15. ItemsList []struct {
  16. Rate int64 `json:"rate" yaml:"rate"`
  17. Random [][]int64 `json:"random" yaml:"random"`
  18. Items [][]int64 `json:"items" yaml:"items"`
  19. Level int64 `json:"level" yaml:"level"`
  20. Limit int64 `json:"limit" yaml:"limit"`
  21. ToLink int64 `json:"to_link" yaml:"to_link"`
  22. BigPrize int64 `json:"big_prize" yaml:"big_prize"`
  23. } `json:"items_list" yaml:"items_list"`
  24. ItemTotal int64 `json:"item_total"`
  25. HelpLimit int64 `json:"help_limit" yaml:"help_limit"`
  26. }
  27. func (this *ScratchardConfig) ReloadConf() {
  28. tools.ReloadYaml("scrathcard.yaml", this)
  29. var rate int64
  30. for i := range this.CardRate {
  31. rate += this.CardRate[i]
  32. this.CardRate[i] = rate
  33. }
  34. rate = 0
  35. for i := range this.ItemsList {
  36. rate += this.ItemsList[i].Rate
  37. this.ItemsList[i].Rate = rate
  38. }
  39. this.ItemTotal = rate
  40. fmt.Printf("fff %+v\n", *this)
  41. }