Jump to content

Acis Coupons + Redeem


Recommended Posts

Hello members,

 

Since my mobile service provider has an app and allows me play a game in order to win certain prizes like (extra mbs, msgs, talk time ) when i put a code 

i decided to create something similar to l2.

 

Explaination:

  1. Every player can get a coupon.
  2. Coupons have categories : Silver,Gold,Platinum
  3. Each category has its own reward list (configurable)
  4. Coupons can be deleted , redeemed  and show their rewards by writting /coupons
  5. You will win a random reward based on coupon's category and grade type
  6. Create your own condition and add a new coupon to this player.
  7. Grade Type added (No grade,D,C,B,A,S) based on the current level of the player, the grade will not change once the coupon activated
  8. Players have daily limit.
  9. Coupons Task Manager running and every day the time you will set all limits will be lifted.

If you guys find any mistakes please let me know i would really appreciate it, cause i want to learn alternative and easier ways  ;)

The code is working properly.

 

Coded on aCis 370 rev.

 

Video

 

Code

 

Htmls

 

Database

 

 

DROP TABLE IF EXISTS `coupons`;
CREATE TABLE `coupons` (
  `owner_objid` int(10) DEFAULT NULL,
  `coupon_id` int(11) NOT NULL DEFAULT '0',
  `coupon_category` varchar(45) DEFAULT NULL,
  `grade` tinyint(3) NOT NULL DEFAULT '0',
  PRIMARY KEY (`coupon_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 
ALTER TABLE `characters` ADD COLUMN `couponsused` tinyint(3) NOT NULL DEFAULT 0 AFTER `death_penalty_level`;
 

 

 

 

Player configs:

 

 

# Maximum coupons per day (0 = disalbe)
# This limit will be lifted at the time you will set in ResetCouponsLimitAt config
CouponsLimit = 5
 
# Time for the daily lift (default 00:00)
ResetCouponsLimitAt = 00:00

 

 

 

Special thanks to Tryskell.

 

P.s I do not have voiced command handlers so i used usercommandhandelrs.

if you want too, you have to add 1 line in commandname-e.dat

115	114	a,coupons\0
Edited by melron
  • Upvote 5
Link to comment
Share on other sites

Not bad idea, sort of lucky wheel :P

 

To make it more complete create an item which could be droppable from a Rb, let's say, and this item will generate the coupon code, else some exchange option, x item for the coupon code. :)

Edited by SweeTs
Link to comment
Share on other sites

- Rewards should be handled by a static map <String, List<CouponReward>> (basically a map with 3 entries), where string is the type of coupon. Your coupon will only stores coupon type (gold, silver,...) and not rewards.

- CouponManager coupons List can't be an ArrayList, you will get ConcurrentException. Either use ConcurrentHashMap, or CopyOnWriteArrayList (which is really horrible on .set()).

- final String DELETE_COUPON = "DELETE FROM coupons where coupon_id = ?"; and all other queries must be private static final and set out of the method (or at least passed directly the parameter in prepareStatement).

- getCouponId : use Rnd from commons package, and not Random. The method probably can be cleanup by a lot (using StringUtil.LETTERS_AND_DIGITS) and a scramble method.

 

The whole reward acquisition should be reworked. The basic concept is, your coupon is linked to a RewardType (SILVER, etc), your reward map .get( retrieve all possible rewards. Then you only need to Rnd.get(rewards) to retrieve the associated reward.

 

Atm you pass all possible rewards on each coupon, which is totally uneeded and generate a lot of pointless data. The whole bypass "redeem" needs to be reviewed too.

 

PS : if you want to enforce the coupon type, you can create RewardType enum, and store rewards under an EnumMap rather than a HashMap <String, List<CouponReward>>.

PS2 : at least you thought about coupon id already existing, good job :).

Edited by Tryskell
Link to comment
Share on other sites

Well as i can see there are serious problems , should a mod move it to the proper section until it get fixed? It is not worth for someone to get it if its not completed.

 

 

Nick,Tryskell i love you guys. I will try to fix it as soon as possible :)

 

Thank you pirama,Sweets!

Link to comment
Share on other sites

Well as i can see there are serious problems , should a mod move it to the proper section until it get fixed? It is not worth for someone to get it if its not completed.

 

 

Nick,Tryskell i love you guys. I will try to fix it as soon as possible :)

 

Thank you pirama,Sweets!

 

Simply share it under a v1, v2 model with a little changeset for each version.

 

The only real serious problem impacting the stability of your custom is the ConcurrentException if numerous players got/remove coupons in same time. Use ConcurrentHashMap.newKeySet() to handle it properly. Other changes are readability, performance and optimization.

Edited by Tryskell
Link to comment
Share on other sites

Some comments.

  • Why are you returning null instead of empty list when a list is empty? It is easier and safer to handle empty lists than null statements that throw NPEs

 

Nice try overall. Thanks for the share.

 

I don't agree with this, empty lists, empty string etc have terrible performance, I always go with null checks, NPE means bad code that should be fixed not handled, imho NPE should be an Error and not an exception

Link to comment
Share on other sites

Your opinion versus the whole internet.

 

Can't get it, so you're saying that few unnecessary calls that give you a dummy empty list are cleaner than nullptr ? Its obvious that this emptylist should be used on other cases but here? Explain me why this is worst and I will go to fck off right away

 

final ArrayList<Coupon> coupons = getCoupons(player);

if (coupons == null)

{

     //msg and exit

}

{

else

{

   for (Coupon c : coupons)

        c.something();

}

 

if getCoupons returns empty list instead of null, the flow of the rest code is dumb and nonsense. null checks are as fast as 1 == 1

Edited by xxdem
Link to comment
Share on other sites

Why you even share it for free? I mean, you probably spent time on this, maybe even much time.

By the video i see its a unique idea, never seen something on other servers.

 

You probably should fix all the code the guys mentioned above and try to sell it.

because community is in need of new things i guess. It's a good idea to make new shares like old times.

Link to comment
Share on other sites

Why you even share it for free? I mean, you probably spent time on this, maybe even much time.

By the video i see its a unique idea, never seen something on other servers.

 

You probably should fix all the code the guys mentioned above and try to sell it.

Designatix answered you but it's not only this thing.

Imagine this topic in marketplace section with these bugs inside ;)

Also there are many shares that deserves your question and not mine for sure :P.

I'm gonna update it to be completed and reshare it

Thank you for your good words my friend!

Edited by melron
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • Keto Move ||  https://rebrand.ly/keto-move-official   Keto Move, as the name the provider has given it, is a pragmatic and regular arrangement that will help you in consuming the additional fat that is all put away in different substantial segments of your body. It can help you through your weight reduction venture in each conceivable way and assist you with consuming off every one of the additional calories put away in your headstrong body districts. On a keto diet, you should comply to specific tight rules, for example, consuming only 5% of carbs, considerably less than whatever we ordinarily take.   Facebook:- https://www.facebook.com/Keto.Move.Official/   Keto Move targets obstinate fat stores all through your body and attempts to kill them, permitting you to get thinner. This keto supplement contains BHB salts, green tea remove, espresso separate, and other home grown parts. Each part of this recipe ensures that Ketosis works appropriately in the body. What's more, this adds to fruitful weight reduction. These sticky bears offer your body all it expects for appropriate cell action. These desserts taste better, yet they additionally work better.   More Relative Blogs https://keto-move.webflow.io/ https://keto-move.company.site/ https://keto-move.jimdosite.com/ https://keto-move.mystrikingly.com/ https://ketomove.journoportfolio.com/ https://solo.to/ketomove https://bio.link/ketomoveofficial https://in.pinterest.com/pin/1145532855383041696 https://soundcloud.com/ketomove/keto-move-weight-loss-review-price-benefits https://medium.com/@ketomove/keto-move-expert-tips-for-staying-on-track-with-keto-71933c4ceaa5 https://sketchfab.com/3d-models/keto-move-better-sale-price-2024-54158d06ed6b48a485ec4ae5568792d9 https://www.eventbrite.com/e/keto-move-keto-move-updated-customer-warning-alert-exposed-tickets-891768873707
    • Attention, attention, the heroes of Elmoraden are wanted! Get ready for new adventures, because our gates are open for you! We switch to the Interlude chronicles on Lionna x5 server, where exciting battles, exciting quests and incredible adventures await you! But that's not all! For beginners, we have a special offer – shadow equipment that will help you develop faster and more efficiently in the world of Elmoraden. With these powerful items, you can easily reach new heights! Join us on May 17th and become a part of the great saga! An unforgettable adventure awaits you on the Lionna X5 server with the Interlude chronicles. Don't miss your chance to become a real hero!     More info: - Characters created from 17.05 09:00 server time, when created will receive gifts in the form of chests with coupons for temporary weapons \ armor No Grade - A grade; - Characters created from 15.05 00:00 server time to 17.05 09:00 will receive gifts in the form of chests with coupons for temporary weapons \ armor No Grade - A grade; - Gifts are divided by grades (No Grade - A Grade) and gifts can be opened at levels corresponding to the grade of the gift. (A gift of D Grade can be opened at the 20th level, B Grade at 52, etc.), but the character's level when opening the gift should not exceed the 75th; - The duration of the equipment \ weapon is 10 hours; - Chaotic characters (characters whose PK counter is higher than 0) cannot use shadow equipment; - On 17.05 at 09:00 server time (10:00 Moscow time), you can meet Looney the Cat in the cities, who will exchange coupons for temporary weapons and equipment; Coupon amount in the gift chests: No Grade: 1 D Grade: 2 C Grade: 2 B Grade: 1 A Grade: 1   On 17.06 at 00:00 server time, the cats will disappear, and with them the chests and coupons. Items received for coupons are not deleted.
  • Topics

×
×
  • Create New...