44 lines
765 B
Go
44 lines
765 B
Go
![]() |
package data
|
||
|
|
||
|
import json "github.com/json-iterator/go"
|
||
|
|
||
|
type Copy struct {
|
||
|
Id int `json:"id"`
|
||
|
Type int `json:"type"`
|
||
|
SceneId int `json:"scene_id"`
|
||
|
Difficulty int `json:"difficulty"`
|
||
|
UnlockType []int `json:"unlock_type"`
|
||
|
UnlockArgs []int `json:"unlock_args"`
|
||
|
}
|
||
|
|
||
|
type CopyTable struct {
|
||
|
l []*Copy
|
||
|
m map[int]*Copy
|
||
|
}
|
||
|
|
||
|
func (this *CopyTable) load(buf []byte) error {
|
||
|
var err = json.Unmarshal(buf, &this.l)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
this.m = make(map[int]*Copy)
|
||
|
for i := range this.l {
|
||
|
this.m[this.l[i].Id] = this.l[i]
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (this *CopyTable) List() []*Copy {
|
||
|
return this.l
|
||
|
}
|
||
|
|
||
|
func (this *CopyTable) Get(i int) *Copy {
|
||
|
return this.l[i]
|
||
|
}
|
||
|
|
||
|
func (this *CopyTable) Find(id int) *Copy {
|
||
|
return this.m[id]
|
||
|
}
|