Commit 7eb0f1e9 authored by mercury233's avatar mercury233

fix sync not working under some situation

parent 7b46ed23
......@@ -180,7 +180,7 @@ namespace MycardBot.Game.AI.Decks
public override IList<ClientCard> OnSelectSum(IList<ClientCard> cards, int sum, int min, int max)
{
Logger.DebugWriteLine(cards.Count + " sync " + sum);
//Logger.DebugWriteLine(cards.Count + " sync " + sum);
IList<ClientCard> selected = new List<ClientCard>();
int trysum = 0;
if (使用过的青眼亚白龙.Count > 0 && cards.IndexOf(使用过的青眼亚白龙[0])>0)
......@@ -193,7 +193,7 @@ namespace MycardBot.Game.AI.Decks
trysum = card.Level;
if (trysum == sum)
{
Logger.DebugWriteLine(trysum + " dselected " + sum);
Logger.DebugWriteLine("直接选择了" + card.Name);
return selected;
}
}
......@@ -203,15 +203,18 @@ namespace MycardBot.Game.AI.Decks
Logger.DebugWriteLine("同调素材可以选择: " + card.Name);
if (card.Level == sum)
{
Logger.DebugWriteLine("直接选择了" + card.Name);
return new[] { card };
}
// try level add
if (trysum + card.Level > sum)
{
Logger.DebugWriteLine("跳过了" + card.Name);
continue;
}
selected.Add(card);
trysum += card.Level;
Logger.DebugWriteLine("添加" + card.Name);
Logger.DebugWriteLine(trysum + " selected " + sum);
if (trysum == sum)
{
......@@ -229,7 +232,7 @@ namespace MycardBot.Game.AI.Decks
// try level sub
selected2.Remove(card);
trysum -= card.Level;
Logger.DebugWriteLine(card.Id + "");
Logger.DebugWriteLine("排除" + card.Name);
Logger.DebugWriteLine(trysum + " selected2 " + sum);
if (trysum == sum)
{
......
......@@ -29,6 +29,7 @@ namespace WindBot.Game
public int Owner { get; private set; }
public int Controller { get; private set; }
public int Disabled { get; private set; }
public int SelectSeq { get; set; }
public int[] ActionIndex { get; set; }
public IDictionary<int, int> ActionActivateIndex { get; private set; }
......
......@@ -895,6 +895,7 @@ namespace WindBot.Game
{
if (cardId != 0 && card.Id != cardId)
card.SetId(cardId);
card.SelectSeq = i;
}
if (j == 0)
mandatoryCards.Add(card);
......@@ -915,23 +916,13 @@ namespace WindBot.Game
int index = 0;
result[index++] = (byte)(mandatoryCards.Count + selected.Count);
while (index < mandatoryCards.Count)
while (index <= mandatoryCards.Count)
{
result[index++] = 0;
}
for (int i = 0; i < selected.Count; ++i)
{
int id = 0;
for (int j = 0; j < cards.Count; ++j)
{
if (cards[j] == null) continue;
if (cards[j].Equals(selected[i]))
{
id = j;
break;
}
}
result[index++] = (byte)id;
result[index++] = (byte)selected[i].SelectSeq;
}
BinaryWriter reply = GamePacketFactory.Create(CtosMessage.Response);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment