<filename>core/server/project/commonBase/src/main/java/com/home/commonBase/config/game/BigFloatRankConfig.java
package com.home.commonBase.config.game;
import com.home.commonBase.config.base.BaseConfig;
import com.home.shine.bytes.BytesReadStream;
import com.home.shine.bytes.BytesWriteStream;
import com.home.shine.ctrl.Ctrl;
import com.home.shine.support.collection.IntObjectMap;
import com.home.shine.support.collection.StringIntMap;

/** 大浮点数阶位(generated by shine) */
public class BigFloatRankConfig extends BaseConfig
{
	/** 存储集合 */
	private static IntObjectMap<BigFloatRankConfig> _dic;
	
	/** id */
	public int id;
	
	/** 文本 */
	public String str="";
	
	/** 反向查找 */
	private static StringIntMap _dicT;
	
	/** 获取 */
	public static BigFloatRankConfig get(int id)
	{
		return _dic.get(id);
	}
	
	/** 设置字典 */
	public static void setDic(IntObjectMap<BigFloatRankConfig> dic)
	{
		_dic=dic;
	}
	
	/** 获取全部 */
	public static IntObjectMap<BigFloatRankConfig> getDic()
	{
		return _dic;
	}
	
	/** 读取字节流(简版) */
	@Override
	protected void toReadBytesSimple(BytesReadStream stream)
	{
		super.toReadBytesSimple(stream);
		
		this.id=stream.readInt();
		
		this.str=stream.readUTF();
		
	}
	
	/** 读完所有表后处理 */
	public static void afterReadConfigAll()
	{
		_dicT=new StringIntMap();
		
		BigFloatRankConfig[] values;
		BigFloatRankConfig v;
		
		for(int i=(values=_dic.getValues()).length-1;i>=0;--i)
		{
			if((v=values[i])!=null)
			{
				_dicT.put(v.str,v.id);
			}
		}
	}
	
	/** 获取每阶文字 */
	public static String getRankStr(int rank)
	{
		BigFloatRankConfig config=get(rank);
		
		if(config!=null)
			return config.str;
		
		return "rank("+rank+")";
	}
	
	/** 通过文字获取阶数 */
	public static int getRankByStr(String str)
	{
		int rank=_dicT.get(str);
		
		if(rank==0)
		{
			Ctrl.warnLog("未找到BigFloatRank配置:"+str);
			return 0;
		}
		
		return rank;
	}
	
	/** 写入字节流(简版) */
	@Override
	protected void toWriteBytesSimple(BytesWriteStream stream)
	{
		super.toWriteBytesSimple(stream);
		
		stream.writeInt(this.id);
		
		stream.writeUTF(this.str);
		
	}
	
}
