Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
i2_bot/lib/datacache/exported.go
Vladimir Hodakov a9f1d25c7b Add pokememes info, convert it to new format and drop unnecessary database tables
This commit introduces pokememes information storage in source code (because they're rarely changed and I always update them manually).

All information about pokememes updated after nerf of 25 April. Also, added buttons to /pokedeks command for changing pages (there are 21 pages already!), and limited one page to 35 pokememes.
2018-05-02 00:47:55 +04:00

91 lines
2.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2018 Vladimir "fat0troll" Hodakov
package datacache
import (
"source.wtfteam.pro/i2_bot/i2_bot/lib/appcontext"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datacache/datacacheinterface"
"source.wtfteam.pro/i2_bot/i2_bot/lib/datamapping"
"source.wtfteam.pro/i2_bot/i2_bot/lib/dbmapping"
"sync"
)
var (
c *appcontext.Context
)
// DataCache is a function-handling struct for package datacache.
// Also, it's a data cache: it handles all data, powered by DataCache functions.
type DataCache struct {
// Players — users of bot
players map[int]*dbmapping.Player
playersMutex sync.Mutex
// Profiles - game profiles, no matter, actual or not
profiles map[int]*dbmapping.Profile
profilesMutex sync.Mutex
// Current profiles - actual profiles for players, mostly used by bot
// Note: int in this array for player ID, not for profile ID
currentProfiles map[int]*dbmapping.Profile
currentProfilesMutex sync.Mutex
// Chats
chats map[int]*dbmapping.Chat
chatsMutex sync.Mutex
// Squads
squads map[int]*dbmapping.Squad
squadsWithChats map[int]*dbmapping.SquadChat
squadPlayersRelations map[int]*dbmapping.SquadPlayer
squadPlayers map[int]map[int]*dbmapping.SquadPlayerFull
squadsMutex sync.Mutex
// Rarely changing data
// Elements
elements map[int]*datamapping.Element
// Leagues
leagues map[int]*datamapping.League
// Levels
levels map[int]*datamapping.Level
// Locations
locations map[int]*datamapping.Location
// Pokememes
pokememes map[int]*datamapping.Pokememe
fullPokememes map[int]*datamapping.PokememeFull
pokememesGradeLocation map[int]map[int]int
// Weapons
weapons map[int]*datamapping.Weapon
}
// New is an initialization function for appcontext
func New(ac *appcontext.Context) {
c = ac
dc := &DataCache{}
c.RegisterDataCacheInterface(datacacheinterface.DataCacheInterface(dc))
}
// Init is a initialization function for package
func (dc *DataCache) Init() {
c.Log.Info("Initializing DataCache...")
dc.initElements()
dc.loadElements()
dc.initLeagues()
dc.loadLeagues()
dc.initLocations()
dc.loadLocations()
dc.initWeapons()
dc.loadWeapons()
dc.initLevels()
dc.loadLevels()
dc.initPokememes()
dc.loadPokememes()
dc.initPlayers()
dc.loadPlayers()
dc.initProfiles()
dc.loadProfiles()
dc.initChats()
dc.loadChats()
dc.initSquads()
dc.loadSquads()
}