Commit f077da46 authored by mercury233's avatar mercury233

avoid using tuple (keep on C# 6)

parent 0f214df0
...@@ -205,6 +205,13 @@ namespace WindBot.Game.AI.Decks ...@@ -205,6 +205,13 @@ namespace WindBot.Game.AI.Decks
return Summon == 0; return Summon == 0;
} }
} }
private struct ZoneData
{
public int Zone;
public ClientCard[] CheckZone;
}
public override void OnNewTurn() public override void OnNewTurn()
{ {
Count.AddPhase(); Count.AddPhase();
...@@ -276,29 +283,35 @@ namespace WindBot.Game.AI.Decks ...@@ -276,29 +283,35 @@ namespace WindBot.Game.AI.Decks
} }
if (cardId == CardId.Allied_Code_Talker_Ignister) if (cardId == CardId.Allied_Code_Talker_Ignister)
{ {
var zones = new Dictionary<(int zone, ClientCard[] chk_zone), int>(); ZoneData[] zoneData = new ZoneData[] {
var updates = new Dictionary<(int zone, ClientCard[] chk_zone), int>(); new ZoneData { Zone = Zones.z0, CheckZone = new ClientCard[] { Bot.MonsterZone[1] } },
zones[(Zones.z0, new ClientCard[] { Bot.MonsterZone[1] })] = 0; new ZoneData { Zone = Zones.z1, CheckZone = new ClientCard[] { Bot.MonsterZone[0], Bot.MonsterZone[2] } },
zones[(Zones.z1, new ClientCard[] { Bot.MonsterZone[0], Bot.MonsterZone[2] })] = 0; new ZoneData { Zone = Zones.z2, CheckZone = new ClientCard[] { Bot.MonsterZone[1], Bot.MonsterZone[3] } },
zones[(Zones.z2, new ClientCard[] { Bot.MonsterZone[1], Bot.MonsterZone[3] })] = 0; new ZoneData { Zone = Zones.z3, CheckZone = new ClientCard[] { Bot.MonsterZone[2], Bot.MonsterZone[4] } },
zones[(Zones.z3, new ClientCard[] { Bot.MonsterZone[2], Bot.MonsterZone[4] })] = 0; new ZoneData { Zone = Zones.z4, CheckZone = new ClientCard[] { Bot.MonsterZone[3] } },
zones[(Zones.z4, new ClientCard[] { Bot.MonsterZone[3] })] = 0; new ZoneData { Zone = Zones.z5, CheckZone = new ClientCard[] { Bot.MonsterZone[0], Bot.MonsterZone[1], Bot.MonsterZone[2] } },
zones[(Zones.z5, new ClientCard[] { Bot.MonsterZone[0], Bot.MonsterZone[1], Bot.MonsterZone[2] })] = 0; new ZoneData { Zone = Zones.z6, CheckZone = new ClientCard[] { Bot.MonsterZone[2], Bot.MonsterZone[3], Bot.MonsterZone[4] } }
zones[(Zones.z6, new ClientCard[] { Bot.MonsterZone[2], Bot.MonsterZone[3], Bot.MonsterZone[4] })] = 0; };
foreach (var entry in zones)
int maxNullCount = -1;
int selectedZone = 0;
foreach (ZoneData data in zoneData)
{ {
if ((entry.Key.zone & available) == 0) if ((data.Zone & available) == 0)
continue; continue;
ClientCard[] checkZone = entry.Key.chk_zone; int nullCount = data.CheckZone.Count(card => card == null);
int nullCount = checkZone.Count(card => card == null); if (nullCount > maxNullCount)
updates[entry.Key] = nullCount; {
maxNullCount = nullCount;
selectedZone = data.Zone;
}
} }
var maxEntry = updates.OrderByDescending(entry => entry.Value).FirstOrDefault();
if (maxEntry.Key != default) if (maxNullCount >= 0)
{ {
var (zone, checkZone) = maxEntry.Key; return selectedZone;
return zone;
} }
} }
if ((Zones.z6 & available) > 0) return Zones.z6; if ((Zones.z6 & available) > 0) return Zones.z6;
......
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