Peking University cxsjsx 2022 Warcraft Project by MOLYHECI
If you have any question, just contact me:
QQ: 1322916662
WeChat: Molyqueatius
E-mail: molyheci@outlook.com
or create an issue
To be honest, Warcraft 1 is easy to code and I needn't to use C++ OOP to manage it,just use C is OK(In fact, using C to manage the all project is OK, too).
But I have a dream that I can use the origin frame in Warcraft 1 to do the all project, so I do Warcraft using C++ OOP.
Back to Warcraft 1, obviously, it needs a class named Head, and a build function in class Head. To fit the struct of inputs(the HP of warriors), I build a dictionary connecting the name and HP.
Now, we need to build the Warrior class and its derived class: Dragon, Ninja, Iceman, Lion and Wolf. I just put printf in the constructor.
The most hard work in this project comes. In this work, We need to build the Warrior class, the Weapon class and the City class and let the class Head to be the derived class of the City class. You might ask why I build this City class and let the class Head to be the derived class of the City class. In my opinion, "fight" is independent of the rest class and it should be the member function of the City class. As for the Head class, I think there should be a line with heads both ends and citys middle in my code.
This work is easier but has many details. If the frame before is awful, the work must be very hard and complicated. And the City class has more properties —— the "useless" action before works here.
For bomb, a Warrior should think what will happen next. The action "think" is hard for me ('cause I do so many search recently and I don't want to do it anymore). So I just copy the state and start a "virtual fight".
The project Warcraft is a good exercise for C++ OOP, and all in all, it seems fairly smooth to me. Benefiting from the code frame, I needn't refactor my code as others do. Most of my work is debugging and modifying according to the game rule.
Good Luck!