Implementation of a dynamic premium system

I am developing an online poker game. But I keep breaking the wall. I want to incorporate rewards into the system, but I want them to be dynamic. Meaning I do not want to recompile for every award I would like to add.

I was thinking about using Python code for every reward. Then, when the server checks to see if the user is suitable for the award, it runs a python script with Jython (the server is in Java and Netty NIO), and if the function returns a specific value, I award the award to the user. Which might work, but is there perhaps a more efficient method that won't force me to run hundreds of python scripts every time I need to check if the user has received an award.

And when is the best time for these checks? I have a problem with the hook system where I will specify hooks like ([onconnect] [ondisconnect] [chatmessage.received]). It might work as well, but it seems a little rude, and I still have to run all the scripts from the database.

+8
java poker
source share
4 answers

If I were you, I would have a completely separate process that would give rewards. It works, perhaps once a day, in a base database containing all the data of your player / game.

Your main client-oriented application knows about the rewards, but all he knows about them is the data that he downloads from the database - something like a name, image, description, maybe how many people have a reward, etc. ., and (based on DB tables) that won the award.

Your grantor process simply starts in batch mode once a day / hour, etc. and provides new rewards to suitable players. Then the main client-oriented application notifies you of this, but doesn’t really know how to provide them. This gives you the freedom to recompile and restart your grantor at any time without any impact on the application.

Another approach, depending on how limited your rewards are, is to write a simple rules interface that allows you to define rules in the data. This would be ideal for achieving what you described, but in my opinion, this is quite a bit of work for a not-so-high award.

PS - running something like an online poker server, you will constantly encounter versions of this problem. You absolutely need to develop a way to deploy new code without killing your service or having no downtime. Working on a java-oriented reward software solution will not solve this problem for you in the long run. You should study the literature on launching real 24/7 services, there are quite a few ways to solve the problem, and in fact it is not so difficult these days.

+6
source share

There are several options that I can think of:

  • OSGi, as described above, is expensive, but is probably the most common and dynamic solution.
  • If you are open to reboot (just don’t recompile), a collection of banners in the well-known folder and spring will give you a cheaper, but no less general solution. Just get the standard interface beans award, beans, and let spring draw @Autowire with all the available awards in your validation.
  • If you award a performance, it is pretty standard, and the only change between the awards is the rules themselves, you may have some kind of scripted configuration. A lot of options there, from the python you describe (except that I would select a few large scripts that manage all the rewards), to the main regular expressions, with LUA and Drools in the middle. In all cases, you are looking at some kind of rule engine architecture, which is flexible in terms of what the award can claim, but does not offer much flexibility as to what the award can bring (i.e. ideal for achievements) .
+3
source share

Some comments on answers with batch ideas: Implementing a dynamic reward system

These batch processes can be on a separate server / machine, so you can recompile the application or restart the server at any time. Obtaining new rewards can be used, for example, using the mentioned approach with adding banners and restarting the server, as well as new serial tasks can be introduced at any time and so on. Thus, your main application works in 99% of cases, a periodic server can be restarted often. Therefore, you can use separate batch machines.

When you need to deploy a new version of the main application, I think you can just stop, deploy and start it with a service notification to users. This approach is used even in the best poker rooms with excellent software (for example, FullTiltPoker did it, now it doesn’t work due to a loss of license, but their site says "System Update" :)).

Thus, one of the options for updating versions is to redeploy / restart after hours.

Another approach is real-time updates. As a rule, this is done by transferring a group of users using the bundle to the new version. Therefore, at the same time, some users use the old version, and some use the new ones. Not very cool for poker software, as users with different versions can interact. But if you are confident in the compatibility of versions, you can go with this approach by checking the version of the client client, for example, at login.

In my answer, I tried to say that you do not need to enter 24/7 support logic for your code. Leave the problems of system availability for hardware (fault tolerance, load balancing, etc.). You can follow any good methods that you used to write code, only you need to remember that your key core logic is not deployed often (for example, once a week), and part of the batch can be updated / restarted at any time, if necessary.

+3
source share

As I understand it, you probably shouldn't start external processes from your application or use OSGI. Just create a simple Java interface and implement each plugin ("reward") as a class that implements the interface. Then you can simply compile any new plugin and load it as a class file from your application at runtime using Class.forName(String className) . Any logic that you need from such a plugin will be contained in the interface methods.

http://download.oracle.com/javase/1,5.0/docs/api/java/lang/Class.html#forName (java. lang.String)

+2
source share

All Articles