52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package data
|
|
|
|
import json "github.com/json-iterator/go"
|
|
|
|
type CopyMain struct {
|
|
Id int `json:"id"`
|
|
CopyId int `json:"copy_id"`
|
|
CopyType int `json:"copy_type"`
|
|
SceneId int `json:"scene_id"`
|
|
Difficulty int `json:"difficulty"`
|
|
UnlockType []int `json:"unlock_type"`
|
|
UnlockArgs []int `json:"unlock_args"`
|
|
}
|
|
|
|
type CopyMainTable struct {
|
|
l []*CopyMain
|
|
m1 map[int]*CopyMain
|
|
m2 map[int][]*CopyMain
|
|
}
|
|
|
|
func (this *CopyMainTable) load(buf []byte) error {
|
|
var err = json.Unmarshal(buf, &this.l)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
this.m1 = make(map[int]*CopyMain)
|
|
this.m2 = make(map[int][]*CopyMain)
|
|
for i := range this.l {
|
|
this.m1[this.l[i].Id] = this.l[i]
|
|
this.m2[this.l[i].CopyId] = append(this.m2[this.l[i].CopyId], this.l[i])
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (this *CopyMainTable) List() []*CopyMain {
|
|
return this.l
|
|
}
|
|
|
|
//func (this *CopyMainTable) Get(i int) *CopyMain {
|
|
// return this.l[i]
|
|
//}
|
|
|
|
func (this *CopyMainTable) Find1(id int) *CopyMain {
|
|
return this.m1[id]
|
|
}
|
|
|
|
func (this *CopyMainTable) Find2(copyId int) []*CopyMain {
|
|
return this.m2[copyId]
|
|
}
|