You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.9 KiB
67 lines
1.9 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Sog;
|
|
using ProtoCSStruct;
|
|
using Sog.Data;
|
|
|
|
namespace PlayerOp
|
|
{
|
|
public class ExchangeCodeGroupCache
|
|
{
|
|
public int m_groupId;
|
|
public int m_codeId;
|
|
public string m_exchangeCodePre;
|
|
public int m_count;
|
|
public bool m_needSave = false;
|
|
public Dictionary<int, string> m_exchangeCodes; // <index, code> index从1开始 是连续的
|
|
|
|
public ExchangeCodeGroupCache(int groupId, string exchangeCodePre, Dictionary<int, string> exchangeCodes, int codeId)
|
|
{
|
|
m_groupId = groupId;
|
|
m_exchangeCodePre = exchangeCodePre;
|
|
m_exchangeCodes = exchangeCodes;
|
|
m_count = m_exchangeCodes.Count;
|
|
m_codeId = codeId;
|
|
|
|
if (exchangeCodes.Count > 0)
|
|
{
|
|
m_needSave = true;
|
|
}
|
|
}
|
|
|
|
public bool IsNeedSave()
|
|
{
|
|
return m_needSave;
|
|
}
|
|
|
|
public SSExchangeCodeRecordSaveDbReq SaveData(int count)
|
|
{
|
|
SSExchangeCodeRecordSaveDbReq req = new SSExchangeCodeRecordSaveDbReq();
|
|
req.ReqId = m_codeId;
|
|
foreach (var codeItem in m_exchangeCodes)
|
|
{
|
|
ExchangeRecordConfigure tempRecord = new ExchangeRecordConfigure();
|
|
tempRecord.Code.SetString(codeItem.Value);
|
|
tempRecord.Index = codeItem.Key;
|
|
tempRecord.GroupId = m_groupId;
|
|
tempRecord.CodeId = m_codeId;
|
|
req.Data.Add(tempRecord);
|
|
if(req.Data.Count >= count)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
for(int i = 0; i < req.Data.Count; i++)
|
|
{
|
|
m_exchangeCodes.Remove(req.Data[i].Index);
|
|
}
|
|
|
|
return req;
|
|
}
|
|
}
|
|
}
|
|
|