I have been busy with projects in the past six months, and I have no time to study the technology. I am constantly discovering that most of the problems encountered in projects are at the business layer. Many of them are not bottlenecks, So I seldom study the technology.
This is an interface for testing the bombing Effect of 25 Aberdeen in the legend of hearth stone. I designed the scene to show 2 blood in the opposite face, and I also had 2 blood, And a 3/2 x-dragon on the opposite side, A 0/1 bloody little devil. At this time, 25 children were randomly assigned 3 points of damage to test the character...
Core Idea: At the UI (winform) End, The boomrequest class is passed into the helper class, which contains a dictionary. The key represents each element (your own face, your opponent's face, field creature, etc.), value is int type, representing the current blood volume of each element. Helper randomly generates an index based on the number of currently living organisms, reduces the biological blood volume of the corresponding index, returns the calculated response, and displays the UI end;
The general situation here is that each bombing is actually calculated separately. That is to say, each random bombing is performed. The skill of 25 litters in the hearth stone is three random points, therefore, the UI side calls the related methods in helper three times;
Public static boomresponse boom (boomrequest request) {random = new random (system. datetime. now. millisecond); stringbuilder sb = new stringbuilder (); int boomindex = 0; string boomobject = string. empty; boomresponse response = new boomresponse (); dictionary <int, string> DIC = new dictionary <int, string> (); int I = 1; foreach (keyvaluepair <string, int> key in request. requsetdata) {If (key. value> 0) {dic. add (I, key. key); I ++ ;}} boomindex = random. next (1, DIC. count + 1); boomobject = DIC [boomindex]; request. requsetdata [boomobject] = request. requsetdata [boomobject]-1; sb. append (string. format ("{0}'s bomb hit {1}, causing some damage", "25 Zai", boomobject); response. battlelog = Sb; response. responsedata = request. requsetdata; return response ;}
At last, I cyclically tested a large amount of data on the front end, and the results were similar to what I expected:
Case 1: there are very few cases where the opposite creature is killed, and less than 60 of the attempts;
Case 2: Beat the opponent to death, about 2000 times
Case 3: Self-killed, about 2000 times
Case 4: it is unlikely that the opponent has been hit and not killed. It only appears less than 300 times, but it is more than Case 1.
Case 5: the remaining cases are the most likely to occur, more than 5000 times. Both myself and my opponent are not dead, and the creature is not dead (one of them may survive)
I don't know how blizzard calculates it?