Commit 644d1b8e authored by mercury233's avatar mercury233 Committed by mercury233

update OnSelectChain

parent 57e404ae
...@@ -360,7 +360,7 @@ namespace WindBot.Game ...@@ -360,7 +360,7 @@ namespace WindBot.Game
/// <param name="forced">You can't return -1 if this param is true.</param> /// <param name="forced">You can't return -1 if this param is true.</param>
/// <param name="timing">Current hint timing</param> /// <param name="timing">Current hint timing</param>
/// <returns>Index of the activated card or -1.</returns> /// <returns>Index of the activated card or -1.</returns>
public int OnSelectChain(IList<ClientCard> cards, IList<int> descs, bool forced, int timing = -1) public int OnSelectChain(IList<ClientCard> cards, IList<int> descs, IList<bool> forces, int timing = -1)
{ {
Executor.OnSelectChain(cards); Executor.OnSelectChain(cards);
foreach (CardExecutor exec in Executor.Executors) foreach (CardExecutor exec in Executor.Executors)
...@@ -375,8 +375,17 @@ namespace WindBot.Game ...@@ -375,8 +375,17 @@ namespace WindBot.Game
} }
} }
} }
// If we're forced to chain, we chain the first card. However don't do anything. for (int i = 0; i < forces.Count; ++i)
return forced ? 0 : -1; {
if (forces[i])
{
// If the card is forced, we have to activate it.
_dialogs.SendChaining(cards[i].Name);
return i;
}
}
// Don't do anything.
return -1;
} }
/// <summary> /// <summary>
......
...@@ -1172,16 +1172,19 @@ namespace WindBot.Game ...@@ -1172,16 +1172,19 @@ namespace WindBot.Game
packet.ReadByte(); // player packet.ReadByte(); // player
int count = packet.ReadByte(); int count = packet.ReadByte();
packet.ReadByte(); // specount packet.ReadByte(); // specount
bool forced = packet.ReadByte() != 0;
int hint1 = packet.ReadInt32(); // hint1 int hint1 = packet.ReadInt32(); // hint1
int hint2 = packet.ReadInt32(); // hint2 int hint2 = packet.ReadInt32(); // hint2
// TODO: use ChainInfo?
IList<ClientCard> cards = new List<ClientCard>(); IList<ClientCard> cards = new List<ClientCard>();
IList<int> descs = new List<int>(); IList<int> descs = new List<int>();
IList<bool> forces = new List<bool>();
for (int i = 0; i < count; ++i) for (int i = 0; i < count; ++i)
{ {
packet.ReadByte(); // flag packet.ReadByte(); // flag
bool forced = packet.ReadByte() != 0;
int id = packet.ReadInt32(); int id = packet.ReadInt32();
int con = GetLocalPlayer(packet.ReadByte()); int con = GetLocalPlayer(packet.ReadByte());
int loc = packet.ReadByte(); int loc = packet.ReadByte();
...@@ -1200,6 +1203,7 @@ namespace WindBot.Game ...@@ -1200,6 +1203,7 @@ namespace WindBot.Game
cards.Add(card); cards.Add(card);
descs.Add(desc); descs.Add(desc);
forces.Add(forced);
} }
if (cards.Count == 0) if (cards.Count == 0)
...@@ -1208,13 +1212,13 @@ namespace WindBot.Game ...@@ -1208,13 +1212,13 @@ namespace WindBot.Game
return; return;
} }
if (cards.Count == 1 && forced) if (cards.Count == 1 && forces[0])
{ {
Connection.Send(CtosMessage.Response, 0); Connection.Send(CtosMessage.Response, 0);
return; return;
} }
Connection.Send(CtosMessage.Response, _ai.OnSelectChain(cards, descs, forced, hint1 | hint2)); Connection.Send(CtosMessage.Response, _ai.OnSelectChain(cards, descs, forces, hint1 | hint2));
} }
private void OnSelectCounter(BinaryReader packet) private void OnSelectCounter(BinaryReader packet)
......
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