Talk about my understanding of objects, classes and attributes in python

I will talk about my understanding of classes, objects and attributes in python based on my experience of playing the game of Genting.

I selected a few suitable camps from Genting Game:

1.三国猛将
2.永恒之森
3.龙魂

Take the Three Kingdoms as an example to analyze

Three Kingdoms Warriors Faction Characters

盖伦,奈德丽,皇子,卡特琳娜,蛮王,黄鸡,蔚

Fetters of the Three Kingdoms camp:

Three population: 250 health and 25 spell power

Six population: 6500 health and 50 spell power

Nine population: 850 health and 85 spell power
Insert picture description here

We can think of the Three Kingdoms Faction as a class. The heroes contained in this class can be regarded as objects. All heroes (all objects) have attribute bonuses provided by this faction. If you haven't played this game, you may find that there are only seven people, how can they make up a population of nine? At this time, we can use the golden shovel to be full-time, that is, turn a hero who is not in this camp into a hero in this camp. Is this operation similar to constructing an object?

In this game, all heroes have several roles. For example, Nidalee is both a character in the Three Kingdoms camp and a sharpshooter (the sharpshooter can make basic attacks have a catapult effect); Galen (don’t be afraid , I’m here) is also a heavy armored warrior (can provide high armor); the prince (thousands of troops and horses will be there, how difficult is it to get things from the bag?) at the same time an Aegis (can provide heroes with sometimes restricted Shield) and so on. Depending on the object you want to cultivate, you can make enough bonds for him. In the current version, Nidalee can hit a high amount of damage. At this time, you can choose to join her in the marksman's bond, so as to add an attribute that can hit her projectile damage. At this point we can say that this is an attribute of an object (Nidalee).

Take Nidalee as an example. You can equip her. Today's more abnormal equipment is two blue dragon knives, one law violent, and one spear that hurts you. The attribute provided by Qinglong Knife is that normal attacks return to blue; the attribute provided by Magic Blast is skill damage plus %40 crit damage. Does this look like adding an attribute to an object?

Above we proposed that a faction is a class. The hero in each faction is an object. The operation of converting the hero faction through the golden shovel is regarded as constructing an object. The fetters and achievements of each hero are the attributes of each object. Equipping a hero is like adding attributes to an object.

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_47249161/article/details/114026657