Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

111 Neutral

About NicholasAnthonyMalacarne

  • Rank
  1. NicholasAnthonyMalacarne

    Creating A 'Combat Log' System

    Hello!   I am currently making a turn based game written in Java. I would like to implement a 'Combat Log' feature that displays what is currently happening in the game (e.g. "Orc hits you for X damage!") . The game will not utilize the console, so I can not just print these messages to the console as they occur. I was studying the Observer Pattern and I think that I can use it to my advantage; however, I am not sure how I should implement the Observer into my system. I have the UML for three different approaches, and I would like to know which one (if any) you all would recommend.  The classes that I have provided in the following UML are simplified so that I can get my point across without wasting too much of your time:   1. Static Observer   The first thought I had was making the Observer class static. The Observer class would have a private static member variable in the form of a collection; the collection would be used to store each message. The Observer class would also have a public static method used to add a new message to the collection and a public static method used to retrieve the collection. I am really not fond of this design because it reminds me of a global variable !   Static Observer UML here !   2. Singleton Observer   The second design I thought of was implementing the Observer class as a Singleton. A Singleton version of the Observer class would have a collection in the form of an instance variable instead of a static variable. I like this design more than the Static Observer design that I previously explained, but it still makes me feel like I am cheating. I have also read that most people are not very fond of the Singleton pattern for various reasons.   Singleton Observer UML here !   3. 'Has-A' Observer   The third design that I have contemplated is having the Observer be a part of the class composition of each class that it needs to observe. This design seems like it follows the Observer Pattern to a better degree. My only concern with this design is the number of objects that the Observer will be observing. There will be 8 x Hero objects to observe, and there will be 64 x Skill objects to observe; there will eventually be many conditional effects on each of the Heros that I think the Observer will need to keep an eye on as well. Should I worry about the number of objects that the Observer is watching?   'Has-A' Observer UML here !   So, these are the three designs that I have drawn up to help me solve this problem. I would appreciate any insight on which one of these may be the best option to use (or an alternative if anyone has an ideas). Thank you for your help, and I hope that I made my thoughts clear to you.
  2. "My friends, you don’t need to do nation building in Israel. We’re already built. You don’t need to export democracy to Israel. We’ve already got it. You don’t need to send American troops to defend Israel. We defend ourselves. You’ve been very generous in giving us tools to do the job of defending Israel on our own. Thank you all, and thank you President Obama, for your steadfast commitment to Israel’s security. I know economic times are tough. I deeply appreciate this." - Israeli Prime Mini...
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!