import { FishInfo } from './FishInfo'
import config from './Config'
export class FishConfig {
  public static config: Array<FishInfo> = [
    // new FishInfo(1, '蝴蝶鱼', 2, 2),
    // new FishInfo(2, '鲶鱼', 2, 1),
    // new FishInfo(3, '狮子鱼', 2, 2),
    // new FishInfo(4, '条纹鱼', 2, 2),
    // new FishInfo(5, '沙丁鱼', 2, 2),
    // new FishInfo(6, '石斑鱼', 2, 2),
    // new FishInfo(7, '河豚', 3, 1.2),
    // new FishInfo(8, '海螺', 3, 2),
    // new FishInfo(9, '接吻鱼', 3, 1.2),
    // new FishInfo(10, '海姆', 4, 1),
    // new FishInfo(11, '绿鳍鱼', 4, 1.2),
    // new FishInfo(12, '鲎', 4, 1.2),
    // new FishInfo(13, '魔鬼鱼', 5, 0.6),
    // new FishInfo(14, '小海龟', 5, 2),
    // new FishInfo(15, '锤头鲨', 6, 0.5),
    // new FishInfo(16, '金枪鱼', 6, 0.5),
    // new FishInfo(17, '大三元', 6, 0.5),
    // new FishInfo(18, '黄金鲎', 6, 1.2),
    // new FishInfo(19, '大四喜', 7, 0.5),
    // new FishInfo(20, '黄金锤头鲨', 7, 0.5),
    // new FishInfo(21, '金海姆', 7, 0.6),
    // new FishInfo(22, '五福临门', 8, 0.4),
    // new FishInfo(23, '金海龟', 8, 0.7),
    // new FishInfo(24, '金鲨', 8, 0.5),
    // new FishInfo(25, '蓝鲨', 8, 0.5),
    // new FishInfo(26, '美人鱼', 14, 0.4),
    // new FishInfo(27, '金龙', 14, 0.3),
    // new FishInfo(28, '章鱼', 10, 0.5),
    // new FishInfo(29, '电鳗鱼', 3, 0.8),
    // new FishInfo(1, '蝴蝶鱼'),
    // new FishInfo(2, '鲶鱼'),
    // new FishInfo(3, '狮子鱼'),
    // new FishInfo(4, '条纹鱼'),
    // new FishInfo(5, '沙丁鱼'),
    // new FishInfo(6, '石斑鱼'),
    // new FishInfo(7, '河豚'),
    // new FishInfo(8, '海螺'),
    // new FishInfo(9, '接吻鱼'),
    // new FishInfo(10, '海姆'),
    // new FishInfo(11, '绿鳍鱼'),
    // new FishInfo(12, '鲎'),
    // new FishInfo(13, '魔鬼鱼'),
    // new FishInfo(14, '小海龟'),
    // new FishInfo(15, '锤头鲨'),
    // new FishInfo(16, '金枪鱼'),
    // new FishInfo(17, '大三元'),
    // new FishInfo(18, '黄金鲎'),
    // new FishInfo(19, '大四喜'),
    // new FishInfo(20, '黄金锤头鲨'),
    // new FishInfo(21, '金海姆'),
    // new FishInfo(22, '五福临门'),
    // new FishInfo(23, '金海龟'),
    // new FishInfo(24, '金鲨'),
    // new FishInfo(25, '蓝鲨'),
    // new FishInfo(26, '美人鱼'),
    // new FishInfo(27, '金龙'),
    // new FishInfo(28, '章鱼'),
    // new FishInfo(29, '电鳗鱼'),
  ]

  public static async init() {
    this.config = []
    return new Promise<boolean>((resolve) => {
      fetch(`${config.url()}/fish/list`)
        .then((response) => response.text())
        .then((response) => {
          const { data: res } = JSON.parse(response)
          res.data.forEach((item) => {
            this.config.push(new FishInfo(item.ID, item.name, item.health))
          })
          resolve(true)
        })
    })
  }

  public static getFishInfoByType(fishType: number) {
    for (let i = 0; i < this.config.length; i++) {
      const fishInfo: FishInfo = this.config[i]
      if (fishInfo.fishType === fishType) return fishInfo
    }
  }
}
