getDecks(); 设置

 private void getDecks()
{
Dictionary<string, int> tmpDeck = new Dictionary<string, int>(startDeck);
List<GraveYardItem> graveYard = new List<GraveYardItem>();
Dictionary<CardDB.cardIDEnum, int> og = new Dictionary<CardDB.cardIDEnum, int>();
Dictionary<CardDB.cardIDEnum, int> eg = new Dictionary<CardDB.cardIDEnum, int>();
int owncontroler = TritonHs.OurHero.GetTag(GAME_TAG.CONTROLLER);
int enemycontroler = TritonHs.EnemyHero.GetTag(GAME_TAG.CONTROLLER);
turnDeck.Clear();
noDuplicates = false; List<HSCard> allcards = TritonHs.GetAllCards(); int allcardscount = allcards.Count;
for (int i = ; i < allcardscount; i++)
{
HSCard entity = allcards[i];
if (entity.Id == null || entity.Id == "") continue; if (CardDB.Instance.cardIdstringToEnum(entity.Id) == CardDB.cardIDEnum.UNG_116t) ownMinionsCost0 = true; if (entity.GetZone() == Triton.Game.Mapping.TAG_ZONE.GRAVEYARD)
{
CardDB.cardIDEnum cide = CardDB.Instance.cardIdstringToEnum(entity.Id);
GraveYardItem gyi = new GraveYardItem(cide, entity.EntityId, entity.GetTag(GAME_TAG.CONTROLLER) == owncontroler);
graveYard.Add(gyi); if (entity.GetTag(GAME_TAG.CONTROLLER) == owncontroler)
{
if (og.ContainsKey(cide)) og[cide]++;
else og.Add(cide, );
}
else if (entity.GetTag(GAME_TAG.CONTROLLER) == enemycontroler)
{
if (eg.ContainsKey(cide)) eg[cide]++;
else eg.Add(cide, );
}
if (cide == CardDB.cardIDEnum.UNG_067t1) ownCrystalCore = ;
} string entityId = entity.Id;
Triton.Game.Mapping.TAG_ZONE entZone = entity.GetZone();
if (i < )
{
if (entityId != "")
{
if (entZone == Triton.Game.Mapping.TAG_ZONE.DECK) continue;
if (tmpDeck.ContainsKey(entityId)) tmpDeck[entityId]--;
}
}
else if (i >= && entity.ControllerId == owncontroler)
{
if (extraDeck.ContainsKey(i))
{
if (entityId != "" && entityId != extraDeck[i].id) extraDeck[i].setId(entityId);
if ((entZone == Triton.Game.Mapping.TAG_ZONE.DECK) != extraDeck[i].isindeck) extraDeck[i].setisindeck(entZone == Triton.Game.Mapping.TAG_ZONE.DECK);
}
else if (entZone == Triton.Game.Mapping.TAG_ZONE.DECK)
{
extraDeck.Add(i, new extraCard(entityId, true));
}
}
} Action a = Ai.Instance.bestmove;
foreach (var c in extraDeck)
{
if (c.Value.isindeck == false) continue;
CardDB.cardIDEnum ce;
string entityId = c.Value.id;
if (entityId == "")
{
if (a != null)
{
switch (a.actionType)
{
case actionEnum.playcard:
switch (a.card.card.cardIDenum)
{
case CardDB.cardIDEnum.LOE_104: goto case CardDB.cardIDEnum.BRM_007;
case CardDB.cardIDEnum.BRM_007:
if (a.target != null) entityId = a.target.handcard.card.cardIDenum.ToString();
break;
case CardDB.cardIDEnum.LOE_002: entityId = "LOE_002t"; break;
case CardDB.cardIDEnum.LOE_079: entityId = "LOE_019t"; break;
case CardDB.cardIDEnum.LOE_019t: entityId = "LOE_019t2"; break;
case CardDB.cardIDEnum.LOE_110: entityId = "LOE_110t"; break;
}
break;
}
}
if (entityId == "")
{
var oldCardsOut = Probabilitymaker.Instance.enemyCardsOut;
foreach (var tmp in eg)
{
if (oldCardsOut.ContainsKey(tmp.Key) && tmp.Value == oldCardsOut[tmp.Key]) continue;
switch (tmp.Key)
{
case CardDB.cardIDEnum.AT_035: entityId = "AT_035t"; break;
case CardDB.cardIDEnum.GVG_031: entityId = "aiextra1"; break;
case CardDB.cardIDEnum.LOE_111: entityId = "LOE_111"; break;
}
}
if (entityId == "" && lastpf != null)
{
int num = ;
foreach (Minion m in this.enemyMinions)
{
if (m.handcard.card.cardIDenum == CardDB.cardIDEnum.GVG_056) num++;
}
if (num > )
{
foreach (Minion m in lastpf.enemyMinions)
{
if (m.handcard.card.cardIDenum == CardDB.cardIDEnum.GVG_056) num--;
}
}
if (num > ) entityId = "GVG_056t";
else
{
num = ;
foreach (Minion m in lastpf.ownMinions)
{
if (m.handcard.card.cardIDenum == CardDB.cardIDEnum.GVG_035) num++;
}
if (num > )
{
foreach (Minion m in this.ownMinions)
{
if (m.handcard.card.cardIDenum == CardDB.cardIDEnum.GVG_035) num--;
}
}
if (num > ) entityId = "GVG_035";
}
}
}
if (entityId == "") entityId = "aiextra1";
}
c.Value.setId(entityId);
ce = CardDB.Instance.cardIdstringToEnum(entityId);
if (turnDeck.ContainsKey(ce)) turnDeck[ce]++;
else turnDeck.Add(ce, );
}
foreach (var c in tmpDeck)
{
if (c.Value < ) continue;
CardDB.cardIDEnum ce = CardDB.Instance.cardIdstringToEnum(c.Key);
if (ce == CardDB.cardIDEnum.None) continue;
if (turnDeck.ContainsKey(ce)) turnDeck[ce] += c.Value;
else turnDeck.Add(ce, c.Value);
} Probabilitymaker.Instance.setOwnCardsOut(og);
Probabilitymaker.Instance.setEnemyCardsOut(eg);
bool isTurnStart = false;
if (Ai.Instance.nextMoveGuess.mana == -)
{
isTurnStart = true;
Ai.Instance.updateTwoTurnSim();
}
Probabilitymaker.Instance.setGraveYard(graveYard, isTurnStart); if (startDeck.Count == ) return;
noDuplicates = true;
foreach (int i in turnDeck.Values)
{
if (i > )
{
noDuplicates = false;
break;
}
}
}

最终的实现

https://github.com/ChuckHearthstone/SilverFish/blob/master/DefaultRoutine/Chuck.SilverFish/Helpers/EvenDeckHelper.cs

05-26 04:36