Jump to content

Recommended Posts

Posted (edited)

idFactory generates sequential IDs, you need something more random, you can use its IDs as seeds btw, but it will consume available IDs from server objects so you still need a workaround.

 

Ids are released when coupon is used, and the IdFactory grows when needed.

 

Any item on inventory uses a id generated from here, and it never posed any issue, being 100 or 1000 players. So for few coupons per players...

 

Ideas :

 

- Instead of the id of the coupon, it should show generic information based on coupon information : "Gold Coupon - B grade". Id is supposed to be internal value and not being seen from player view anyway.

- You should also add a Config for maximum amount of coupons per player, 0 means unlimited amount (can be set as default).

- Add a way for player to delete a coupon (let's say he doesn't want a nograde coupon anymore, he can delete it).

- Add a limit to open per day (can be a global task like pvpflag, resetted at 0:00).

Edited by Tryskell
Posted

Ids are released when coupon is used, and the IdFactory grows when needed.

 

Any item on inventory uses a id generated from here, and it never posed any issue, being 100 or 1000 players. So for few coupons per players...

 

Instead of the id of the coupon, it should show generic information based on coupon information : "Gold Coupon - B grade". Id is supposed to be internal value and not being seen from player anyway.

players cant see the id since the name of the coupon (this random string) is generated from this id

private static String getCouponName(int id) //the idFactory id
{
	StringBuilder sb = new StringBuilder();
	String number = String.valueOf(id);
	
	for (int i = 0; i < number.length(); i++)
	{
		int j = Character.digit(number.charAt(i), 10);
		char Char = (char) (j + (Rnd.get(65, 81))); //65 == A , 90 == Z
		sb.append(Char);
	}
	
	return sb.toString();
}

i find it cool :P

Posted (edited)

...

 

The point was to use directly the objectId to avoid String generation/manipulation and to assure the uniqueness of the id, and use it only internally for server purpose. :P

 

I edited previous post for additional ideas.

Edited by Tryskell
Posted

Tryskell,

The good thing is that your ideas are awesome.

The bad thing is, finally this share will belong to you xD

 

I'm gonna listen your advice :P

Posted (edited)

Tryskell,

The good thing is that your ideas are awesome.

The bad thing is, finally this share will belong to you xD

 

I'm gonna listen your advice :P

 

Well, if that can learn you one thing or two and in same time your custom becomes more performant/shorter/universal, everyone is winning : users who will use it, and you since you get some knowledge from it.

 

I'm not sure it's a "bad thing" than you know how I "see" your custom, notably on the construction side. A good developer is a lazy developer, so everything must be as simple as possible. First because it's annoying to debug, second because if you re-read your code in some years you will be mad of yourself.

 

Let's say I protect your mental health of your future self from your actual self :D.

 

----

+       int gradeLevel = player.getSkillLevel(239);
+      
+       coupon.setGradeType(gradeLevel == -1 ? 0 : gradeLevel);

>

+      coupon.setGradeType(Math.max(0, player.getSkillLevel(239)));

On the next aCis rev 371, getSkillLevel will return 0 by default not -1 anymore so you could drop the Math stuff and use directly player.getSkillLevel(239).

 

----

 

couponName (and the generation of it) can be dropped, if you generate the name directly based on the coupon. I see only one place where the name is visually called or even used, and it's on the floating list listing players coupons. The StringBuilder can directly generate the coupon name based on Coupon informations, as I said "Golden Coupon - X grade" is enough for the player. The id is used by the server to identify each coupon.

 

----

+       if (coupons.contains(coupon))
+       {
+           coupons.remove(coupon);

>

 

remove can be directly called on the if, since removing an Element returns a result under a boolean.

 

https://docs.oracle.com/javase/7/docs/api/java/util/List.html#remove(java.lang.Object)

Edited by Tryskell
Posted (edited)

Well, if that can learn you one thing or two and in same time your custom becomes more performant/shorter/universal, everyone is winning : users who will use it, and you since you get some knowledge from it.

 

I'm not sure it's a "bad thing" than you know how I "see" your custom, notably on the construction side. A good developer is a lazy developer, so everything must be as simple as possible. First because it's annoying to debug, second because if you re-read your code in some years you will be mad of yourself.

 

Let's say I protect your mental health of your future self from your actual self :D.

Sure! i'm learning by my mistakes that's obvious ... and thank you for all your suggestions. about this: A good developer is a lazy developer

I do not agree :D why a good dev should be lazy? That is the best part of this thing so... (just my opinion)

 

P.s i'm thinking to remove as you said the name and use direcly the sb but there is one problem. 

 

commands like /showcoupons or /deletecoupons or even npcs,html / alert messages etc can be used without any issue 

but...

combobox doesn't accept spaces.. so will fucked up (Golden-Coupon-B-Grade) ? :D

also there is another problem there. The bypass for the redeem is sending the name 

Coupon coupon = player.getCouponsByName(couponName);

if the combobox will contains > 1 example Golden . how the manager can delete the coupon(based on id) ? Cant even add something with placeholder to keep these id's

Edited by melron
Posted (edited)

 

Sure! i'm learning by my mistakes that's obvious ... and thank you for all your suggestions. about this: A good developer is a lazy developer

I do not agree :D why a good dev should be lazy? That is the best part of this thing so... (just my opinion)

 

P.s i'm thinking to remove as you said the name and use direcly the sb but there is one problem. 

 

commands like /showcoupons or /deletecoupons or even npcs,html / alert messages etc can be used without any issue 

but...

combobox doesn't accept spaces.. so will fucked up (Golden-Coupon-B-Grade) ? :D

also there is another problem there. The bypass for the redeem is sending the name 

Coupon coupon = player.getCouponsByName(couponName);

 

You can use coupon id instead of name for all inner, server checks.

 

About combobox you can design it like [Gold]Coupon(A) or generate a whole page for coupons like I did with bookmarks (since you can have unlimited amount of coupons oyu're probably screwed with your combobox if you got 20, 30 coupons).

Edited by Tryskell
Posted (edited)

You can use coupon id instead of name for all inner, server checks.

 

About combobox you can design it like [Gold]Coupon(E) or generate a whole page for coupons like I did with bookmarks (since you can have unlimited amount of coupons oyu're probably screwed with your combobox if you got 20, 30 coupons).

no i edited all those things u told me about the max coupons and limits per day (this task) etc.

now im trying to think other ways to do that :P

 

if the bypass contains (GOLD)Coupon[C] for example i can just check the category and delete a random coupon with the same category. :P

Edited by melron
Posted (edited)

no i edited all those things u told me about the max coupons and limits per day (this task) etc.

now im trying to think other ways to do that :P

 

if the bypass contains (GOLD)Coupon[C] for example i can just check the category and delete a random coupon with the same category. :P

 

I don't rem if a combobox can have a different value than the value passed on the bypass, if not the best is to generate a specific HTM for coupons, with clickable links (like //bk system). At least you control what you show, and you can have an unlimited amount of coupons if someone decide to put configs to 0, since you can introduce a paging system aswell (once again, bookmark system :D).

Edited by Tryskell
Posted (edited)

I don't rem if a combobox can have a different value than the value passed on the bypass, if not the best is to generate a specific HTM for coupons, with clickable links (like //bk system). At least you control what you show, and you can have an unlimited amount of coupons if someone decide to put configs to 0, since you can introduce a paging system aswell (once again, bookmark system :D).

So the manager is useless - can be removed  :D Since if the system will work like bookmark's i can add 2 linked texts redeem,delete and ofc the name of the coupon as linked that will show all the possible rewards :P

Edited by melron
Posted (edited)


+ if (coupons.contains(coupon))

+ {

+ coupons.remove(coupon);

on ConcurrentHashMap you don't need to check for contains on ( Map )

but and on Set i think don't have difference ( try it for better performance )

 

Edited by pirama
Posted

 

on ConcurrentHashMap you don't need to check for contains on ( Map )
but and on Set i think don't have difference ( try it for better performance )

 

alread fixed pirama thank you :) im waiting to finish all the new things to release the update

Posted (edited)

alread fixed pirama thank you :) im waiting to finish all the new things to release the update

i don't know if and tryskel said the same

i see only the code with + and i don't read old post

Edited by pirama
Posted (edited)

i don't know if and tryskel said the same ( bad english sorry ) 

Yeah tryskell told me about how remove works some posts above

 

[GR] Ούτε γνωρίζω καλά, τουλάχιστον το παλεύουμε  :P

Edited by melron
Posted (edited)

Main post updated:

 

  • Redeem manager dropped
  • /coupons command now is available
  • the coupons menu contains : remove,redeem and reward list
  • added daily limit 
  • task manager running and the limit will be lifted the time you will set in configs
  • new video uploaded
  • new html files uploaded
  • added 1 column in characters table
Edited by melron

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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.


×
×
  • Create New...