public Deck(Playfield p, CardIdEnum cardId, int number, bool own) { Deck newDeck = new Deck(); newDeck.deckChanged = true; if (this.deckChanged) { newDeck.deckSize += this.deckSize; foreach (KeyValuePair <CardIdEnum, int> diff in this.deckDiff) { newDeck.deckDiff.Add(diff.Key, diff.Value); } } if (number > 0) { newDeck.deckSize += number; if (newDeck.deckDiff.ContainsKey(cardId)) { newDeck.deckDiff[cardId] += number; } else { newDeck.deckDiff.Add(cardId, number); } } //if (own) p.ownDeck = newDeck; //else p.enemyDeck = newDeck; }
public void Reset() { this.Id = CardIdEnum.None; this.questProgress = 0; this.maxProgress = 1000; this.mobsTurn.Clear(); }
private string getMullRuleKey(CardIdEnum cardIDM = CardIdEnum.None, HeroEnum ownMHero = HeroEnum.None, HeroEnum enemyMHero = HeroEnum.None, int isExtraRule = 0) { StringBuilder MullRuleKey = new StringBuilder("", 500); MullRuleKey.Append(cardIDM).Append(";").Append(ownMHero).Append(";").Append(enemyMHero).Append(";").Append(isExtraRule); return(MullRuleKey.ToString()); }
public miniEnch(CardIdEnum id, int crtr, int controler, int copydr) { this.CARDID = id; this.creator = crtr; this.controllerOfCreator = controler; this.copyDeathrattle = copydr; }
public static SimTemplate GetCardSimulation(CardIdEnum tempCardIdEnum) { SimTemplate result = new SimTemplate(); var className = $"Sim_{tempCardIdEnum}"; var list = GetTypeByName(className); if (list.Count != 1) { if (list.Count >= 2) { var content = string.Join(",", list.Select(x => x.FullName)); throw new Exception($"Find multiple card simulation class for {tempCardIdEnum} : {content}"); } } else { var type = list[0]; var simTemplateInstance = Activator.CreateInstance(type); if (simTemplateInstance is SimTemplate temp) { result = temp; } else { throw new Exception($"class {className} should inherit from {typeof(SimTemplate)}"); } } return(result); }
public QuestItem(string s) { String[] q = s.Split(' '); this.Id = CardDB.Instance.cardIdstringToEnum(q[0]); this.questProgress = Convert.ToInt32(q[1]); this.maxProgress = Convert.ToInt32(q[2]); }
public int getProbOfEnemyHavingCardInHand(CardIdEnum cardid, int handsize, int decksize) { //calculates probability \in [0,...,100] int cardsremaining = this.anzCardsInDeck(cardid); if (cardsremaining == 0) { return(0); } double retval = 0.0; //http://de.wikipedia.org/wiki/Hypergeometrische_Verteilung (we calculte 1-p(x=0)) if (cardsremaining == 1) { retval = 1.0 - ((double)(decksize)) / ((double)(decksize + handsize)); } else { retval = 1.0 - ((double)(decksize * (decksize - 1))) / ((double)((decksize + handsize) * (decksize + handsize - 1))); } retval = Math.Min(retval, 1.0); return((int)(100.0 * retval)); }
public bool isAllowedSecret(CardIdEnum cardID) { if (ownCardsOut.ContainsKey(cardID) && ownCardsOut[cardID] >= 2) { return(false); } return(true); }
// Your Hero Power becomes 'Deal 2 damage'. If already in Shadowform: 3 damage. public override void onCardPlay(Playfield p, bool ownplay, Minion target, int choice) { CardIdEnum newHeroPower = CardIdEnum.EX1_625t; // Mind Spike if ((ownplay ? p.ownHeroAblility.card.cardIDenum : p.enemyHeroAblility.card.cardIDenum) == CardIdEnum.EX1_625t) { newHeroPower = CardIdEnum.EX1_625t2; // Mind Shatter } p.setNewHeroPower(newHeroPower, ownplay); }
public CardName GetSpecialCardNameEnumFromCardIdEnum(CardIdEnum tempCardIdEnum) { if (SpecialNames.ContainsKey(tempCardIdEnum)) { return(SpecialNames[tempCardIdEnum]); } else { return(CardName.unknown); } }
public bool hasCardinGraveyard(CardIdEnum cardid) { foreach (GraveYardItem gyi in this.graveyard) { if (gyi.cardid == cardid) { return(true); } } return(false); }
public bool hasEnemyThisCardInDeck(CardIdEnum cardid) { if (this.enemyCardsOut.ContainsKey(cardid)) { if (this.enemyCardsOut[cardid] == 1) { return(true); } return(false); } return(true); }
public int getPlayValue(CardIdEnum ce) { if (this.playByValue.Count == 0) { return(0); } if (this.playByValue.ContainsKey(ce)) { return(-this.playByValue[ce]); } return(0); }
//Battlecry: Replace your starting Hero Power with a better one. public override void getBattlecryEffect(Playfield p, Minion m, Minion target, int choice) { TAG_CLASS HeroStartClass = (m.own) ? p.ownHeroStartClass : p.enemyHeroStartClass; CardIdEnum tmp = CardIdEnum.None; switch (HeroStartClass) { case TAG_CLASS.WARRIOR: tmp = CardIdEnum.AT_132_WARRIOR; //Tank Up! break; case TAG_CLASS.WARLOCK: tmp = CardIdEnum.AT_132_WARLOCK; //Soul Tap break; case TAG_CLASS.ROGUE: tmp = CardIdEnum.AT_132_ROGUE; //Poisoned Daggers break; case TAG_CLASS.SHAMAN: tmp = CardIdEnum.AT_132_SHAMAN; //Totemic Slam break; case TAG_CLASS.PRIEST: tmp = CardIdEnum.AT_132_PRIEST; //Heal break; case TAG_CLASS.PALADIN: tmp = CardIdEnum.AT_132_PALADIN; //The Silver Hand break; case TAG_CLASS.MAGE: tmp = CardIdEnum.AT_132_MAGE; //Fireblast Rank 2 break; case TAG_CLASS.HUNTER: tmp = CardIdEnum.AT_132_HUNTER; //Ballista Shot break; case TAG_CLASS.DRUID: tmp = CardIdEnum.AT_132_DRUID; //Dire Shapeshift break; //default: } if (tmp != CardIdEnum.None) { p.setNewHeroPower(tmp, m.own); } }
public void Copy(QuestItem q) { this.Id = q.Id; this.questProgress = q.questProgress; this.maxProgress = q.maxProgress; if (Id == CardIdEnum.UNG_067) { this.mobsTurn.Clear(); foreach (var n in q.mobsTurn) { this.mobsTurn.Add(n.Key, n.Value); } } }
public CardName cardNameStringToEnum(string s, CardIdEnum tempCardIdEnum) { if (Enum.TryParse(s, false, out CardName nameEnum)) { return(nameEnum); } else { nameEnum = GetSpecialCardNameEnumFromCardIdEnum(tempCardIdEnum); if (nameEnum == CardName.unknown) { Logger.GetLoggerInstanceForType() .ErrorFormat("[Unidentified card name :" + s + "]"); } } return(nameEnum); }
// Deathrattle: Summon a minion from your deck with less Attack than this minion. public override void onDeathrattle(Playfield p, Minion m) { CardIdEnum cId = CardIdEnum.None; for (int i = m.Attack - 1; i >= 0; i--) { cId = p.prozis.GetDeckCardsForCost(i); if (cId != CardIdEnum.None) { break; } } if (cId != CardIdEnum.None) { CardDB.Card kid = CardDB.Instance.getCardDataFromID(cId); p.CallKid(kid, m.zonepos - 1, m.own); } }
public int anzCardsInDeck(CardIdEnum cardid) { int ret = 2; CardDB.Card c = CardDB.Instance.getCardDataFromID(cardid); if (c.rarity == 5) { ret = 1; //you can have only one rare; } if (this.enemyCardsOut.ContainsKey(cardid)) { if (this.enemyCardsOut[cardid] == 1) { return(1); } return(0); } return(ret); }
public GraveYardItem(CardIdEnum id, int entity, bool own) { this.own = own; this.cardid = id; this.entity = entity; }
public Card getCardDataFromID(CardIdEnum id) { return(cardidToCardList.ContainsKey(id) ? cardidToCardList[id] : unknownCard); }
public CardIDEntity(string id_string, int entt) { this.id = CardDB.Instance.cardIdstringToEnum(id_string); this.entitiy = entt; }
private void validateRule(string behavName) { List <string> rejectedRule = new List <string>(); int repairedRules = 0; Dictionary <string, string> MulliganRulesTmp = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> oneRule in MulliganRules) { string[] ruleKey = oneRule.Key.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string[] ruleValue = oneRule.Value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string ruleValueOne = oneRule.Value; if (ruleKey.Length != 4 || ruleValue.Length != 3) { rejectedRule.Add(getClearRule(oneRule.Key)); continue; } if (ruleKey[0] != CardDB.Instance.cardIdstringToEnum(ruleKey[0]).ToString()) { rejectedRule.Add(getClearRule(oneRule.Key)); continue; } if (ruleKey[1] != Hrtprozis.Instance.heroNametoEnum(ruleKey[1]).ToString()) { rejectedRule.Add(getClearRule(oneRule.Key)); continue; } if (ruleKey[2] != Hrtprozis.Instance.heroNametoEnum(ruleKey[2]).ToString()) { rejectedRule.Add(getClearRule(oneRule.Key)); continue; } if (ruleValue[0] != "Hold" && ruleValue[0] != "Discard") { rejectedRule.Add(getClearRule(oneRule.Key)); continue; } try { Convert.ToInt32(ruleValue[1]); } catch (Exception ex) { Helpfunctions.Instance.ErrorLog(ex); rejectedRule.Add(getClearRule(oneRule.Key)); continue; } if (ruleValue[2] != "/") { if (ruleValue[2].Length < 4) // if lenght < 4 then it a manarule { int manaRule = 4; try { manaRule = Convert.ToInt32(ruleValue[2]); } catch (Exception ex) { Helpfunctions.Instance.ErrorLog(ex); } if (manaRule < 0) { manaRule = 0; } else if (manaRule > 100) { manaRule = 100; } StringBuilder tmpSB = new StringBuilder(ruleValue[0], 500); tmpSB.Append(";").Append(ruleValue[1]).Append(";").Append(manaRule); ruleValueOne = tmpSB.ToString(); } else { bool wasBreak = false; string[] addedCards = ruleValue[2].Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries); Dictionary <CardIdEnum, string> MulliganRulesManualTmp = new Dictionary <CardIdEnum, string>(); foreach (string s in addedCards) { CardIdEnum tempID = CardDB.Instance.cardIdstringToEnum(s); if (s != tempID.ToString()) { rejectedRule.Add(getClearRule(oneRule.Key)); wasBreak = true; break; } else { if (MulliganRulesManualTmp.ContainsKey(tempID)) { repairedRules++; continue; } else { MulliganRulesManualTmp.Add(tempID, ""); } } } if (wasBreak) { continue; } StringBuilder tmpSB = new StringBuilder(ruleValue[0], 500); tmpSB.Append(";").Append(ruleValue[1]).Append(";"); for (int i = 0; i < MulliganRulesManualTmp.Count; i++) { if (i + 1 == MulliganRulesManualTmp.Count) { break; } tmpSB.Append(MulliganRulesManualTmp.ElementAt(i).Key.ToString()).Append("/"); } tmpSB.Append(MulliganRulesManualTmp.ElementAt(MulliganRulesManualTmp.Count - 1).Key.ToString()); ruleValueOne = tmpSB.ToString(); } } MulliganRulesTmp.Add(oneRule.Key, ruleValueOne); } if (rejectedRule.Count > 0) { Helpfunctions.Instance.InfoLog("[Mulligan] List of rejected Rules:"); foreach (string tmp in rejectedRule) { Helpfunctions.Instance.InfoLog(tmp); } Helpfunctions.Instance.InfoLog("[Mulligan] End list of rejected Rules."); } if (repairedRules > 0) { Helpfunctions.Instance.InfoLog(repairedRules.ToString() + " repaired rules"); } MulliganRules.Clear(); foreach (KeyValuePair <string, string> oneRule in MulliganRulesTmp) { MulliganRules.Add(oneRule.Key, oneRule.Value); } Helpfunctions.Instance.InfoLog("[Mulligan] " + (MulliganRules.Count > 0 ? (MulliganRules.Count + " rules loaded successfully") : "No special rules.")); mulliganRulesLoaded = true; if (behavName == "") //oldCompatibility { MulliganRulesDB.Add("Control", new Dictionary <string, string>(MulliganRules)); MulliganRulesDB.Add("Rush", new Dictionary <string, string>(MulliganRules)); } else { MulliganRulesDB.Add(behavName, new Dictionary <string, string>(MulliganRules)); } }
public void ReadCombos(string behavName, bool nameIsPath = false) { string pathToCombo = behavName; if (!nameIsPath) { if (!SilverFishBot.Instance.BehaviorPath.ContainsKey(behavName)) { help.ErrorLog(behavName + ": no special combos."); return; } pathToCombo = Path.Combine(SilverFishBot.Instance.BehaviorPath[behavName], "_combo.txt"); } if (!File.Exists(pathToCombo)) { help.InfoLog(behavName + ": no special combos."); return; } help.InfoLog($"[Combo] Load combos for {behavName}"); string[] lines = new string[0] { }; combos.Clear(); playByValue.Clear(); try { lines = File.ReadAllLines(pathToCombo); } catch (Exception ex) { LogHelper.WriteCombatLog("cant find _combo.txt"); help.ErrorLog(ex); help.ErrorLog("cant find _combo.txt (if you don't created your own combos, ignore this message)"); return; } help.InfoLog("read _combo.txt..."); foreach (string line in lines) { if (string.IsNullOrEmpty(line)) { continue; } if (line.StartsWith("//")) { continue; } if (line.Contains("weapon:")) { try { this.attackFaceHP = Convert.ToInt32(line.Replace("weapon:", "")); } catch (Exception ex) { LogHelper.WriteCombatLog("combomaker cant read: " + line); help.ErrorLog(ex); help.ErrorLog("combomaker cant read: " + line); } } else { if (line.Contains("cardvalue:")) { try { string cardvalue = line.Replace("cardvalue:", ""); CardIdEnum ce = cdb.cardIdstringToEnum(cardvalue.Split(',')[0]); int val = Convert.ToInt32(cardvalue.Split(',')[1]); if (this.playByValue.ContainsKey(ce)) { continue; } this.playByValue.Add(ce, val); //help.ErrorLog("adding: " + line); } catch (Exception ex) { LogHelper.WriteCombatLog("combomaker cant read: " + line); help.ErrorLog(ex); help.ErrorLog("combomaker cant read: " + line); } } else { try { combo c = new combo(line); this.combos.Add(c); } catch (Exception ex) { LogHelper.WriteCombatLog("combomaker cant read: " + line); help.ErrorLog(ex); help.ErrorLog("combomaker cant read: " + line); } } } } help.InfoLog("[Combo] " + combos.Count + " combos loaded successfully, " + playByValue.Count + " values loaded successfully"); }