Challenge OOAD: How should we design different functions used by game items in the OO mode?

Source: Internet
Author: User
In RPG games, people carry items and move around in maps. Different items have different functions. If it is so simple, the use of items can become a method of items, use the item to call this method.

It's terrible. When different people use the same item, the effects are different.

At this time, do I need to put this method into the item object?

It may also be okay. Oo analysis will start to talk about non-human nonsense: if the user parameter is added to a method call, the item knows who is using it, therefore, different processing methods can be performed based on different users.

An item that sells pots actually lives. It becomes an Genie and knows who is using it.

Okay, that's all right. But the problem is that, as an item, it must know the user type for different processing purposes, and coupling is generated, even if you abstract a public interface, coupling still exists, but the processing will be slightly more comfortable.

Someone tried to change this coupling and added the method of using items to the character object, but it was just a matter of ignoring the hacker's practice. The coupling here is lost and will come out in another place. However, experienced designers will know this in advance and weigh the advantages and disadvantages of different methods. For systems of different nature, different processing methods are used.

What should I do if I add another one, that is, the scenario, for example, the ground playing is different from the ground playing is different, and the ground playing is different from the palace using it?

Ask the ox in the garden to tell me how to solve this problem OOAD?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.