logic_data.go 827 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package mapLogic
  2. import (
  3. "f1-game/internal/pb"
  4. "f1-game/internal/types"
  5. "time"
  6. "github.com/goburrow/cache"
  7. )
  8. var (
  9. aoiUpdateBattleMap = cache.New(
  10. cache.WithMaximumSize(-1),
  11. cache.WithExpireAfterWrite(time.Minute),
  12. )
  13. pbMapLeagues = types.NewMap[int64, *pb.MapLeague]()
  14. )
  15. func getAOIUpdateBattle(updateID uint32) (*pb.MapBattlePush, bool) {
  16. value, ok := aoiUpdateBattleMap.GetIfPresent(updateID)
  17. if !ok {
  18. return nil, false
  19. }
  20. push, ok := value.(*pb.MapBattlePush)
  21. return push, ok
  22. }
  23. func (p *actor) getPlayerName(playerID int64) string {
  24. if watcherTable, ok := p.WatcherTables.Get(playerID); ok {
  25. return watcherTable.PlayerName
  26. }
  27. return ""
  28. }
  29. func (p *actor) getLeagueName(leagueID int64) string {
  30. if leauge, found := pbMapLeagues.Get(leagueID); found {
  31. return leauge.LeagueName
  32. }
  33. return ""
  34. }