Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing a Dynamic Award System

Tags:

java

poker

I have been developing a Online Poker Game. But I keep hitting a wall. I want to implement Awards into the system, but I want them to be dynamic. Meaning I don't want to recompile for every award I would like to add.

I have thought about using Python code for each award. Then when the server checks to see if the user qualifies for the award it runs the python script with Jython (server is in Java and Netty NIO) and if the function returns a certain value I award the award to the user. Which could work but is there maybe a more efficient technique out there that will not force me to run hundreds of python scripts each time I need to check if a user got a award.

And when are the best times to do these checks? I have tought about a hook system where I will specify the hooks like ( [onconnect][ondisconnect][chatmessage.received] ). Which also could work but feels a bit crude and I will still have to run all the scripts from the database.

like image 750
Johann du Toit Avatar asked Aug 04 '11 09:08

Johann du Toit


People also ask

What is dynamic award?

The Dynamic Awards 2022 The Dynamic Awards are designed to change that as they are exclusively for women, although the audience will be mixed. The inaugural event is made up of fourteen categories and recognises achievements made across all aspects of life, from personal successes to outstanding contributions.

What is an award chart?

Award charts will show you how many miles you will need to spend to take your trip. Award prices can vary greatly on certain routes, so it is helpful to do some price comparisons before you book. For example, a coach flight from the US to the Caribbean costs 17,500 United Airlines miles each way.


2 Answers

If I were you, I'd have a totally separate process that grants awards. It runs perhaps once a day on the underlying database that contains all your player/game data.

Your core customer-facing app knows about awards, but all it knows about them is data it loads from the DB -- something like a title, image, description, maybe how many people have the award, etc., and (based on DB tables) who has won the award.

Your "award granter" process simply runs in batch mode, once per day / hour etc, and grants new awards to eligible players. Then the core customer-facing app notifies them but doesn't actually have to know the smarts of how to grant them. This gives you the freedom to recompile and re-run your award granter any time you want with no core app impact.

Another approach, depending on how constrained your awards are, would be to write a simple rules interface that allows you to define rules in data. That would be ideal to achieve what you describe, but it's quite a bit of work for not much reward, in my opinion.

PS -- in running something like an online poker server, you're going to run into versions of this problem all the time. You are absolutely going to need to develop a way to deploy new code without killing your service or having a downtime window. Working around a java-centric code solution for awards is not going to solve that problem for you in the long run. You should look into the literature on running true 24/7 services, there are quite a few ways to address the issue and it's actually not that difficult these days.

like image 159
jkraybill Avatar answered Oct 04 '22 14:10

jkraybill


There are a number of options I can think of:

  • OSGi as described above - it comes at a cost, but is probably the most generic and dynamic solution out there
  • If you're open to restart (just not recompile), a collection of jars in a well known folder and spring give you a cheaper but equally generic solution. Just have your award beans implement a standard interface, be beans, and let spring figure @Autowire all the available awards into your checker.
  • If you award execution is fairly standard, and the only variation between awards are the rules themselves, you can have some kind of scripted configuration. Many options there, from the python you described (except I'd go for a few big script managing all awards), to basic regular expressions, with LUA and Drools in the middle. In all cases you're looking at some kind of rules engine architecture, which is flexible in term of what the award can trigger on but doesn't offer much flexibility in term of what an award can lead to (i.e. perfect for achievements).
like image 29
ptyx Avatar answered Oct 04 '22 14:10

ptyx