using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Sog
{
public static class TableIndexCalc
{
///
/// 帐号表的数量
///
public const int AccountTableCount = 100;
///
/// name表数量
///
public const int NameTableCount = 10;
///
/// 角色表的数量(由于是分服的,10够了,全区全服的游戏请改成至少100张)
///
public const int RoleTableCount = 100;
///
/// 战斗回放记录表数量
///
public const int BattleReplayTableCount = 100;
///
/// 关卡记录表数量
///
public const int MainlandRecordTableCount = 10;
///
/// 公会表数量
///
public const int UnionTableCount = 10;
///
/// 公会角色表数量
///
public const int UnionRoleTableCount = 10;
// 支付表
public const int PayTableCount = 10;
//兑换码兑换记录表全服的
public const int ExchangeRecordTableCount = 100;
//普通兑换码兑换记录表全服的
public const int CommonExchangeRecordTableCount = 100;
///
/// 全局领地表数量
///
public const int WorldHomeTableCount = 100;
///
/// 全局赛马表
///
public const int RacehorseTableCount = 10;
///
/// 航海贸易用户信息
///
public const int TradeTableCount = 10;
///
/// petpvp用户信息
///
public const int PetPvpPlayerTableCount = 10;
public const int NewPeakArenaTableCount = 50;
public static int CalcAccountTableIndex(int accountType, string accountID)
{
string strHash = AccountUtils.CalcAccountKey(accountType, accountID);
int index = AccountUtils.HashStringForIndex(strHash) % AccountTableCount;
//为了直观,0放到第100张表
if(index == 0)
{
index = AccountTableCount;
}
return index;
}
public static int CalcNameTableIndex(int accountType, string accountID)
{
//暂时先用,应该没问题
string strHash = AccountUtils.CalcAccountKey(accountType, accountID);
int index = AccountUtils.HashStringForIndex(strHash) % NameTableCount;
//为了直观,0放到第10张表
if (index == 0)
{
index = NameTableCount;
}
return index;
}
//
public static int CalcRoleTableIndex(long uid)
{
int index = (int)(uid % RoleTableCount);
//由于表刚好是10张,为了直观,0放到第10张表
if (index == 0)
{
index = RoleTableCount;
}
return index;
}
public static int CalcBattleReplayTableIndex(long battleid)
{
int index = (int)(battleid % BattleReplayTableCount);
if (index == 0)
{
index = BattleReplayTableCount;
}
return index;
}
public static int CalcMainlandRecordTableIndex(int mainlandId)
{
int index = mainlandId % MainlandRecordTableCount;
if (index == 0)
{
index = MainlandRecordTableCount;
}
return index;
}
public static int CalcUnionTableIndex(int realmId)
{
int index = realmId % UnionTableCount;
if (index == 0)
{
index = UnionTableCount;
}
return index;
}
public static int CalcUnionRoleTableIndex(int realmId)
{
int index = realmId % UnionRoleTableCount;
if (index == 0)
{
index = UnionRoleTableCount;
}
return index;
}
public static int CalcPayTableIndex(long uid)
{
int index = (int)(uid % PayTableCount);
if (index == 0)
{
index = PayTableCount;
}
return index;
}
public static int CalcExchangeRecordIndex(int codeIndex)
{
int index = (int)(codeIndex % ExchangeRecordTableCount);
//为了直观,0放到第100张表
if (index == 0)
{
index = ExchangeRecordTableCount;
}
return index;
}
public static int CalcCommonExchangeRecordIndex(int codeIndex)
{
int index = (int)(codeIndex % CommonExchangeRecordTableCount);
//为了直观,0放到第100张表
if (index == 0)
{
index = CommonExchangeRecordTableCount;
}
return index;
}
public static int CalcWorldHomeTableIndex(long uid)
{
int index = (int)(uid % WorldHomeTableCount);
if (index == 0)
{
index = WorldHomeTableCount;
}
return index;
}
public static int CalcRacehorseTableIndex(long uid)
{
int index = (int)(uid % RacehorseTableCount);
if (index == 0)
{
index = RacehorseTableCount;
}
return index;
}
public static int CalcTradeTableIndex(long uid)
{
int index = (int)(uid % TradeTableCount);
if (index == 0)
{
index = TradeTableCount;
}
return index;
}
public static int CalcPetPvpPlayerTableIndex(long uid)
{
int index = (int)(uid % PetPvpPlayerTableCount);
if (index == 0)
{
index = PetPvpPlayerTableCount;
}
return index;
}
public static int CalcNewPeakArenaPlayerTableIndex(long uid)
{
int index = (int)(uid % NewPeakArenaTableCount);
if (index == 0)
{
index = NewPeakArenaTableCount;
}
return index;
}
}
}