using System.Collections.Generic;
using System.RandomPool;
using FJson.Core;
using UnityEngine;
using Views;
namespace Game.Data
{
///
/// 基于此配置表扩展该通用随机池
///
///
public class CommonPoolConfig where T : class
{
internal Dictionary>> poolContents;
internal Dictionary poolLevelWeight;
public CommonPoolConfig ()
{
this.poolContents = new Dictionary>> ();
this.poolLevelWeight = new Dictionary ();
}
public CommonPoolConfig (Dictionary>> poolContents, Dictionary poolLevelWeight)
{
this.poolContents = poolContents;
this.poolLevelWeight = poolLevelWeight;
}
public void PutPools (int level, RandomNode node)
{
if (this.poolContents.ContainsKey (level))
{
this.poolContents[level].Add (node);
}
else
{
this.poolContents[level] = new List> () { node };
}
}
internal virtual CommonRandomGroup CreateGroup (int poolId)
{
return new CommonRandomGroup (poolId);
}
// ///
// /// 用于创建怪物池对应配置表
// ///
// ///
// ///
// public static CommonPoolConfig CreateEnemyPoolConfig(RofEnemyPoolRow poolRow)
// {
// var poolConfig = new CommonPoolConfig();
// var poolValue = KeywordUtils.DecodeRangeNum(poolRow.EnemyIDs);
// if (!string.IsNullOrWhiteSpace(poolValue))
// {
// poolValue = poolValue.Replace(" ", "");
// var enemyIds = poolValue.Split(',');
//
// foreach (var enemyId in enemyIds)
// {
// if (int.TryParse(enemyId, out var id))
// {
// var rofEnemyRow = EnemyManager.Instance.GetEnemy(id);
// var level = (ItemQuality) rofEnemyRow.quality;
// RandomNode node = new RandomNode(rofEnemyRow.ID, rofEnemyRow,
// -1, rofEnemyRow.weight, rofEnemyRow.exploreCondition);
// poolConfig.PutPools(level, node);
// }
// }
// }
//
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Normal))
// poolConfig.poolLevelWeight[ItemQuality.Normal] = poolRow.NormalWeight;
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Rare))
// poolConfig.poolLevelWeight[ItemQuality.Rare] = poolRow.RareWeight;
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Epic))
// poolConfig.poolLevelWeight[ItemQuality.Epic] = poolRow.EpicWeight;
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Legend))
// poolConfig.poolLevelWeight[ItemQuality.Legend] = poolRow.LegendWeight;
// if (poolConfig.poolContents.ContainsKey(ItemQuality.Hide))
// poolConfig.poolLevelWeight[ItemQuality.Hide] = poolRow.HideWeight;
// return poolConfig;
// }
}
}