public new DrawableHearthstoneBoard copy() { DrawableHearthstoneBoard board = new DrawableHearthstoneBoard(); copyValuesTo(board); return(board); }
private void button8_Click(object sender, EventArgs e) { board = new DrawableHearthstoneBoard(); board.p1Board.Add(DrawableCard.makeDrawable(CardCreatorFactory.createFromName(CardCreatorFactory.Cards.DragonspawnLieutenant))); board.p1Board.Add(DrawableCard.makeDrawable(CardCreatorFactory.createFromName(CardCreatorFactory.Cards.DragonspawnLieutenant))); // board.p1Board.Add(DrawableCard.makeDrawable(CardCreatorFactory.createFromName(CardCreatorFactory.Cards.DragonspawnLieutenant))); board.p2Board.Add(DrawableCard.makeDrawable(CardCreatorFactory.createFromName(CardCreatorFactory.Cards.MalGanis))); board.illidanPlayer = 1; board.drawBoardState(new Point(50, 50), new Point(50, 300), this); }
void formRun3() { DrawableHearthstoneBoard runBoard = board.copy(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var boardV = new VisualBoard(runBoard); Application.Run(boardV); }
private void button1_Click(object sender, EventArgs e) { DrawableHearthstoneBoard temp = BoardEditor.loadBoard(Application.StartupPath); if (temp == null) { return; } board = temp; board.drawBoardState(new Point(50, 50), new Point(50, 300), this); }
public void setWorstAndBest(DrawableHearthstoneBoard board, List <int> worst, List <int> best) { worstValues = worst; lastBoard = board.copy(); bestValues = best; this.button1.Invoke((MethodInvoker) delegate { button1.Enabled = true; }); this.button2.Invoke((MethodInvoker) delegate { button2.Enabled = true; }); }
public GUIstate(List <StatisticsManager.DmgDistEntry> dmgdist, double[] dmgdist2, DrawableHearthstoneBoard board, List <int> worstValues, List <int> bestValues, int expectedHealth, string opponent, double deathodds, double ranking) { this.ranking = ranking; this.dmgdist = dmgdist; this.dmgdist2 = dmgdist2; this.board = board.copy(); this.worstValues = worstValues; this.bestValues = bestValues; this.opponent = opponent; this.deathodds = deathodds; this.expectedHealth = expectedHealth; }
void formRun2() { DrawableHearthstoneBoard runBoard = board.copy(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); foreach (int i in worstValues) { runBoard.stockedRandomValues.Add(i); } var boardV = new VisualBoard(runBoard); Application.Run(boardV); }
void simulate(List <int> inputList) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); DrawableHearthstoneBoard board = lastBoard.copy(); board.stockedRandomValues = new List <int>(); foreach (int i in inputList) { board.stockedRandomValues.Add(i); } var visualBoard = new VisualBoard(board); Application.Run(visualBoard); }
public void startNewGame() { expectedHealth = 40; actualHealth = 40; maxHealth = 40; board = new DrawableHearthstoneBoard(); combat = false; waitingForStart = false; minions = new Dictionary <string, DrawableCard>(); menacebuffswaiting = 0; taverntier = 1; luckywins = 0; unluckyloss = 0; round = 0; opponentHeroPWR = ""; playerHeroPwr = ""; if (gui != null) { gui.resetState(); } playerIsIllidan = false; playerIsDW = false; }
public static void saveBoard(DrawableHearthstoneBoard board) { DrawableHearthstoneBoard save = board.copy(); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Board State|*.boardstate"; saveFileDialog1.Title = "Save a Board state"; saveFileDialog1.InitialDirectory = Application.StartupPath; saveFileDialog1.RestoreDirectory = true; saveFileDialog1.ShowDialog(); if (saveFileDialog1.FileName != "") { FileStream fs = (FileStream)saveFileDialog1.OpenFile(); IFormatter formatter = new BinaryFormatter(); formatter.Serialize(fs, save); fs.Close(); } }
public static DrawableHearthstoneBoard loadBoard(string path) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = path; openFileDialog1.RestoreDirectory = true; openFileDialog1.Title = "Load a Board state"; openFileDialog1.Filter = "Board State|*.boardstate"; openFileDialog1.CheckFileExists = true; openFileDialog1.ShowDialog(); if (openFileDialog1.FileName != "") { FileStream fs = new FileStream(openFileDialog1.FileName, FileMode.Open, FileAccess.Read); IFormatter formatter = new BinaryFormatter(); DrawableHearthstoneBoard ret = (DrawableHearthstoneBoard)formatter.Deserialize(fs); ret.printState(); return(ret); } return(null); }
public void handleInput(string line) { if (line.Equals("")) { return; } line = line.Substring(0, line.Length - 1) + "|"; if (line.Contains("TRANSITIONING card") && line.Contains("to FRIENDLY PLAY (Hero)")) { string name = getNameAndId(line)[0]; if (name.Equals(HeroNames.Bob)) { return; } string id = getNameAndId(line)[1]; Console.WriteLine("Hero Discovered:" + nameIDString(line) + " initializing new game"); heroId = id; heroName = getNameAndId(line)[0]; startNewGame(); } if (line.Contains("TRANSITIONING") && line.Contains("FRIENDLY PLAY (Hero Power)")) { string name = getNameAndId(line)[0]; switch (name) { case HeroPower.Deathwing: Console.WriteLine("Hero power discovered: deathwing"); playerIsDW = true; break; case HeroPower.Illidan: Console.WriteLine("Hero power discovered: illidan"); playerIsIllidan = true; break; case HeroPower.Patchwerk: Console.WriteLine("Hero power discovered: patchwerk"); expectedHealth = 50; actualHealth = 50; maxHealth = 50; break; } playerHeroPwr = name; } if (line.Contains("cardId=BOT_312e") && line.Contains("from -> ") && line[line.Length - 2].Equals(' ')) { Console.WriteLine("Next minion to recieve buff will get menace"); menacebuffswaiting++; } // if (line.Contains("DEATHRATTLE value=1") && line.Contains("ProcessChanges()")) // { // string[] a = getNameAndId(line); // Card c = minions[a[1]]; //if (c.typeMatches(Card.Type.Murloc)) //{ // c.addEffect(new ArtificialSummon(CardCreatorFactory.Cards.Plant, 2)); // Console.WriteLine("Recieved plant buff on " + nameIDString(line)); //Console.ReadLine(); // } // } if (line.Contains("entityName=")) { string[] a = getNameAndId(line); if (!minions.ContainsKey(a[1])) { minions.Add(a[1], DrawableCard.makeDrawable(CardCreatorFactory.createFromName(a[0]).setId(int.Parse(a[1])))); } else { checkIfNameMatches(a); } } if (line.Contains("tag=BACON_MINION_IS_LEVEL_TWO")) { string[] a = getNameAndId(line); DrawableCard c = minions[a[1]]; if (c.golden) { return; } c.makeGolden(); Console.WriteLine("Found golden: " + nameIDString(line) + "!!!!"); } if (combat && !waitingForStart) { if (line.Contains("TRANSITIONING") && line.Contains("entityName=Refresh") && line.Contains("FRIENDLY PLAY")) { Console.WriteLine("COMBAT OVER!!!"); lookForAttacker(); board = new DrawableHearthstoneBoard(); combat = false; } if (line.Contains("entityName=")) { string[] a = getNameAndId(line); if (!minions.ContainsKey(a[1])) { minions.Add(a[1], DrawableCard.makeDrawable(CardCreatorFactory.createFromName(a[0]).setId(int.Parse(a[1])))); } } if (line.Contains("tag=COPIED_FROM_ENTITY_ID value=") && !line.Contains("tag=COPIED_FROM_ENTITY_ID value=0") && line.Contains("ProcessChanges()")) { string newvalue = getStringBetween(line, "tag=COPIED_FROM_ENTITY_ID value=", " "); Console.WriteLine(nameIDString(line) + "getting copied over from " + newvalue); string[] a = getNameAndId(line); if (minions.ContainsKey(newvalue)) { minions[a[1]] = ((DrawableCard)minions[newvalue].copy().setId(int.Parse(a[1]))); } } return; } if (line.Contains("zone from FRIENDLY PLAY -> ") && line[line.Length - 2].Equals(' ')) { string id = getNameAndId(line)[1]; Console.WriteLine("Friendly minion sold:" + nameIDString(line)); board.p1Board.Remove(minions[id]); //boardgui.redrawBoard(board); } if (line.Contains("pos from") && line.Contains("->") && !combat) { string id = getNameAndId(line)[1]; checkIfNameMatches(getNameAndId(line)); if (board.p1Board.Contains(minions[id])) { Console.WriteLine("Friendly minion change pos:" + nameIDString(line) + " to " + line[line.Length - 2]); minions[id].BoardPosition = int.Parse((line[line.Length - 2]).ToString()); } } if (line.Contains("TRANSITIONING card [entityName=Tavern Tier ") && line.Contains(" to ") && line[line.Length - 2].Equals(' ') && !combat) { string tier = line[line.IndexOf("Tavern Tier") + 12].ToString(); Console.WriteLine("Upgrade to tier " + tier); taverntier = int.Parse(tier); } if (line.Contains("TRANSITIONING card") && line.Contains("to FRIENDLY PLAY") && line[line.Length - 2].Equals('Y')) { string id = getNameAndId(line)[1]; Console.WriteLine("Friendly minion added:" + nameIDString(line)); string cardID = getStringBetween(line, "cardId=", " "); minions[id].pictureID = cardID; if (board.p1Board.Contains(minions[id])) { return; } board.p1Board.Add(minions[id]); minions[id].printState(); // boardgui.redrawBoard(board); } if (line.Contains("TRANSITIONING card") && line.Contains("to OPPOSING PLAY") && line[line.Length - 2].Equals('Y') && combat) { string id = getNameAndId(line)[1]; Console.WriteLine("Enemy minion added:" + getNameAndId(line)[0] + " id:" + id); if (lookForEntity(id)) { minions[id].makeGolden(); } board.p2Board.Add(minions[id]); string cardID = getStringBetween(line, "cardId=", " "); minions[id].pictureID = cardID; minions[id].printState(); } if (line.Contains("tag=PLAYER_TECH_LEVEL value=") && line.Contains("ProcessChanges")) { string newvalue = getStringBetween(line, "tag=PLAYER_TECH_LEVEL value=", " "); startRound(newvalue, getStringBetween(line, "name=", "]"), opponentHeroPWR); } if (line.Contains("Thuzad") && line.Contains("OPPOSING PLAY (Hero)")) { Console.WriteLine("Kel'Thuzad detected"); startRound("0", HeroNames.KelThuzad, ""); } if (line.Contains("TRANSITIONING") && line.Contains("OPPOSING PLAY (Hero Power)")) { string name = getNameAndId(line)[0]; switch (name) { case HeroPower.Deathwing: Console.WriteLine("Hero power discovered: deathwing"); break; case HeroPower.Illidan: Console.WriteLine("Hero power discovered: illidan"); break; } opponentHeroPWR = name; } /* if (line.Contains("tag=COPIED_FROM_ENTITY_ID value=") && !line.Contains("tag=COPIED_FROM_ENTITY_ID value=0") && line.Contains("ProcessChanges()")) * { * string newvalue = getStringBetween(line, "tag=COPIED_FROM_ENTITY_ID value=", " "); * Console.WriteLine(nameIDString(line) + "getting copied over from " + newvalue); * string[] a = getNameAndId(line); * if (minions.ContainsKey(newvalue)) * minions[a[1]] = ((DrawableCard)minions[newvalue].copy()); * Console.ReadLine(); * * }*/ if (line.Contains("TRANSITIONING") && line.Contains("entityName=Refresh") && line[line.Length - 2].Equals(' ')) { Console.WriteLine("COMBAT STARTS!!!"); //boardgui.disableButtons(); waitingForStart = true; combat = true; } if (line.Contains("tag=ATK value=") && line.Contains("ProcessChanges")) { string[] a = getNameAndId(line); checkIfNameMatches(a); Card c = minions[a[1]]; string newvalue = getStringBetween(line, "tag=ATK value=", " "); c.setAtk(int.Parse(newvalue)); if (menacebuffswaiting > 0) { Console.WriteLine("Added menace buff on " + nameIDString(line)); for (int i = 0; i < menacebuffswaiting; i++) { c.addEffect(new ArtificialSummon(CardCreatorFactory.Cards.Microbot, 3)); } menacebuffswaiting = 0; } if (board.containsCard(c)) { Console.WriteLine("Attack changed on " + nameIDString(line) + " to " + newvalue); } } if (line.Contains("tag=HEALTH value=") && line.Contains("ProcessChanges")) { string[] a = getNameAndId(line); Card c = minions[a[1]]; string newvalue = getStringBetween(line, "tag=HEALTH value=", " "); c.setHp(int.Parse(newvalue)); if (board.containsCard(c)) { Console.WriteLine("Health changed on " + nameIDString(line) + " to " + newvalue); } } if (line.Contains("tag=DIVINE_SHIELD value=1") && line.Contains("ProcessChanges")) { string[] a = getNameAndId(line); Card c = minions[a[1]]; c.setDivineShield(true); if (board.containsCard(c)) { Console.WriteLine("Recieved Divine Shield on " + nameIDString(line)); } } if (line.Contains("tag=POISONOUS value=1") && line.Contains("ProcessChanges")) { string[] a = getNameAndId(line); Card c = minions[a[1]]; c.setPoisonous(true); if (board.containsCard(c)) { Console.WriteLine("Recieved poisonous on " + nameIDString(line)); } } if (line.Contains("tag=WINDFURY value=1") && line.Contains("ProcessChanges")) { string[] a = getNameAndId(line); Card c = minions[a[1]]; c.setWindfury(true); if (board.containsCard(c)) { Console.WriteLine("Recieved Windfury on " + nameIDString(line)); } } if (line.Contains("tag=TAUNT value=1") && line.Contains("ProcessChanges")) { string[] a = getNameAndId(line); Card c = minions[a[1]]; c.setTaunt(true); if (board.containsCard(c)) { Console.WriteLine("Recieved taunt on " + nameIDString(line)); } } }
public void redrawBoard(DrawableHearthstoneBoard board) { this.Invoke((MethodInvoker) delegate { board.drawBoardState(new Point(50, 50), new Point(50, 300), this); }); }
public VisualBoard(DrawableHearthstoneBoard parentBoard) { visualizeBoard = parentBoard.copy(); InitializeComponent(); }