Jump to content

Recommended Posts

Posted (edited)

567136f854304129a821319417203fff.png

package com.l2jfresh.gameserver.model.actor.instance;

import java.util.StringTokenizer;
import java.util.NoSuchElementException;

import com.l2jfresh.gameserver.Announcements;
import com.l2jfresh.gameserver.model.actor.L2Npc;
import com.l2jfresh.gameserver.model.actor.template.NpcTemplate;
import com.l2jfresh.gameserver.network.clientpackets.Say2;
import com.l2jfresh.gameserver.network.serverpackets.Dice;
import com.l2jfresh.gameserver.network.serverpackets.ExShowScreenMessage;
import com.l2jfresh.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfresh.gameserver.network.serverpackets.NpcSay;
import com.l2jfresh.gameserver.util.Broadcast;
import com.l2jfresh.util.Rnd;



public class L2CasinoInstance extends L2Npc
{
	//Item Id
    public static int _itemId;
	private String itemname= "None";
    //Ammount Item
    public static int jackpot;
    public static int jackpot2;
    public L2CasinoInstance(int objectId, NpcTemplate template)
    {
        super(objectId, template);
    }
    
	@Override
	public boolean isAttackable()
	{
		return false;
	}
    @Override
    public void onBypassFeedback(L2PcInstance player, String command)
    {
      int ammount = 0;
      if (command.startsWith("play1"))
      {
        StringTokenizer st = new StringTokenizer(command);
        st.nextToken();
        try
        {
          String type = st.nextToken();

          if(type.startsWith("VoteStone"))
          {
        	  _itemId = 9595;
          }
          else if(type.startsWith("FarmCoin"))
          {
        	  _itemId = 9696;
          }
          ammount = Integer.parseInt(st.nextToken());
        }
        catch (NoSuchElementException nse)
        {
        }
        if (ammount >0)
        {
            Dice(player, this, ammount);
        }
        else return;
      }
    }
    
    @Override
    public void showChatWindow(L2PcInstance player)
    {
        NpcHtmlMessage msg = new NpcHtmlMessage(this.getObjectId());
        msg.setHtml(casinoWindow(player));
        msg.replace("%objectId%", String.valueOf(this.getObjectId()));
        player.sendPacket(msg);
    }

    private static String casinoWindow(L2PcInstance player)
    {
    	StringBuilder tb = new StringBuilder();
        tb.append("<html><title>L2Ultimate Casino</title><body>");
        tb.append("<center><img src=\"L2Ultimate.logo\" width=\"300\" height=\"100\"/><br>");
        tb.append("<font color=\"3b8d8d\">Casino Manager</font><br>");
        tb.append("<img src=\"L2UI.SquareGray\" width=\"200\" height=\"1\"><br>");
        tb.append("<table width=290>");
        tb.append("<tr>");
        tb.append("<td align=\"center\"><font color=\"FFCC33\">Hello Sir, i Am Here for Your bets.<font></td></tr>");        
        tb.append("<tr><td align=\"center\"><font color=\"FFCC33\">You got need to Roll Number: 6-6 or 6-5 or 5-5 or 3-3</font></td></tr>");
        tb.append("<tr><td align=\"center\"><font color=\"LEVEL\">But if you are Lucky and you will win the Jackpot ,</font></td></tr>");
        tb.append("<tr><td align=\"center\"><font color=\"FF0000\">Jackpot of Vote Stone: "+jackpot+"</font></td></tr>");	
        tb.append("<tr><td align=\"center\"><font color=\"FF0000\">Jackpot of Farm Coin: "+jackpot2+"</font></td></tr>"); 
        tb.append("<tr></tr>");
        tb.append("</table>");
        tb.append("<center><img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"><br>");
        tb.append("<table width=290>");
        tb.append("<tr>");
        tb.append("<td align=\"center\"><font color=\"0F92FF\">Select a Currency To Bet:</font></td>");
        tb.append("<td><combobox width=120 height=21 var=\"cb\"list=VoteStone;FarmCoin></td>");
        tb.append("</tr>");
        tb.append("<tr></tr>");
        tb.append("<tr></tr>");
        tb.append("<tr>");
        tb.append("<td align=center><font color=\"0F92FF\">Type an Amount:</font></td>");
        tb.append("<td><edit var=\"qbox\" width=120 height=15></td>");
        tb.append("</table><br>");
        tb.append("<center><img src=\"L2UI.SquareGray\" width=\"280\" height=\"1\"></center><br><br>");
        tb.append("<center><button value=\"Try Your Luck!\" action=\"bypass -h npc_%objectId%_play1 $cb $qbox\" width=134 height=21 back=\"L2UI_ch3.BigButton3_over\" fore=\"L2UI_ch3.BigButton3\"></center>");
        tb.append("</body></html>");
        return tb.toString();
    }
    
    public void Dice(L2PcInstance activeChar,L2Npc npc,int _ammount)
    {
		if(activeChar.getInventory().getInventoryItemCount(_itemId, 0) >= _ammount)
		{
				int number = rollDice();
				int number2 = rollDice2();
				if(number == 6 && number2 == 6 || number == 6 && number2 == 5 || number == 5 && number2 == 5 || number == 3 && number2 == 3)
				{
			        ExShowScreenMessage screen = new ExShowScreenMessage("Congratulations "+activeChar.getName()+" won You got "+number+"-"+number2+" Good!", 6000);
			        String name = activeChar.getName();
			        activeChar.sendPacket(new NpcSay(npc.getObjectId(), Say2.TELL, npc.getNpcId(), "Congratulations "+name+" won You got "+number+"-"+number2+" Good!"));
			        activeChar.sendPacket(screen);
					activeChar.addItem("Consume", _itemId, _ammount, activeChar,true);
					/*if(_itemId == 9595)
					{
				   	  jackpot += _ammount;
					}
					else if(_itemId == 9696)
					{
					  jackpot2 += _ammount;
					}*/
					showChatWindow(activeChar);
					switch(_itemId)
					{
					    case 9595:
						itemname = "Vote Stone";
						break;
					    case 9696:
						itemname = "Look Coin";
						break;
					}
					
					switch(Rnd.get(1,20))
					{
					    case 1:
						break;
					    case 2:
						break;
					    case 3:
						break;
					    case 4:
						break;
					    case 5:
						    if(_itemId == 9595)
						    {
						     activeChar.addItem("Consume", _itemId, jackpot, activeChar,true);
						     activeChar.broadcastUserInfo();
						     Announcements.gameAnnounceToAll("Congratulations "+ activeChar.getName() +" he won "+ jackpot +" Jackpot of "+ itemname +"!");
						     jackpot = 0;
						    }
						    else if(_itemId == 9696)
						    {
						    activeChar.addItem("Consume", _itemId, jackpot2, activeChar,true);
						    activeChar.broadcastUserInfo();
						    Announcements.gameAnnounceToAll("Congratulations "+ activeChar.getName() +" he won "+ jackpot2 +" Jackpot of "+ itemname +"!");
						    jackpot2 = 0;
						    }
						break;
					    case 6:
						break;
					    case 7:
						break;
					    case 8:
						break;
					    case 9:
						break;
					    case 10:
						break;
					    case 11:
					    if(_itemId == 9595)
					    {
					     activeChar.addItem("Consume", _itemId, jackpot, activeChar,true);
					     activeChar.broadcastUserInfo();
					     Announcements.gameAnnounceToAll("Congratulations "+ activeChar.getName() +" he won "+ jackpot +" Jackpot of "+ itemname +"!");
					     jackpot = 0;
					    }
					    else if(_itemId == 9696)
					    {
					    activeChar.addItem("Consume", _itemId, jackpot2, activeChar,true);
					    activeChar.broadcastUserInfo();
					    Announcements.gameAnnounceToAll("Congratulations "+ activeChar.getName() +" he won "+ jackpot2 +" Jackpot of "+ itemname +"!");
					    jackpot2 = 0;
					    }
						break;
					    case 12:
						break;
					    case 13:
						break;
					    case 14:
						break;
					    case 16:
						break;
					    case 17:
						break;
					    case 18:
						break;
					    case 19:
						break;
					    case 20:
						break;
					}
					activeChar.broadcastUserInfo();
				}
				else
				{
			        ExShowScreenMessage screen = new ExShowScreenMessage(""+activeChar.getName()+" Ïops lost again play can be lucky!", 6000);
			        String name = activeChar.getName();
			        activeChar.sendPacket(new NpcSay(npc.getObjectId(),Say2.TELL, npc.getNpcId(), name+" Ïops lost again Play can be Lucky!"));
			        activeChar.sendPacket(screen);
					activeChar.destroyItemByItemId("Consume", _itemId, _ammount, activeChar, true);
					if(_itemId == 9595)
					{
				   	  jackpot += _ammount;
					}
					else if(_itemId == 9696)
					{
					   jackpot2 += _ammount;
					}
					activeChar.broadcastUserInfo();
					showChatWindow(activeChar);
				}
				Broadcast.toSelfAndKnownPlayers(npc, new Dice(npc.getObjectId(), 4625, number, npc.getX() - 30, npc.getY() - 30, npc.getZ()));
				Broadcast.toSelfAndKnownPlayers(npc, new Dice(npc.getObjectId(), 4626, number2, npc.getX() - 22, npc.getY() - 22, npc.getZ()));
			}
			else
			{
				switch(_itemId)
				{
				    case 9595:
					itemname = "Vote Stone";
					break;
				    case 9696:
					itemname = "Look Coin";
					break;
				}
				activeChar.sendMessage("You do not have enough "+itemname+".");
			}
	}
    
	public static int rollDice2()
	{
		return Rnd.get(1, 7);
	}
	
	public static int rollDice()
	{
		return Rnd.get(1, 7);
	}
	
}

code by fofas :)

Edited by Crazyboy*
Posted

lmao, what a bad code.. What's the point of this "dice"? As I see it's normal bet "double or nothing", so I don't relly get it. You only need one Rnd.get(.

Posted

You don't have to add all Cases that are not used in switch lel just the 2 that are used and the default:  that will happen in case none of them is.. 

Devorakoc the dev guy aka MrPRO* BFF

Posted

lmao, what a bad code.. What's the point of this "dice"? As I see it's normal bet "double or nothing", so I don't relly get it. You only need one Rnd.get(.

Shut the fuck up kid, we all know you're jealous of his skills and u can't remake this code.. stop being kid

Posted

Shut the fuck up kid, we all know you're jealous of his skills and u can't remake this code.. stop being kid

:( :( :(

 

You hurt my feelings. But still, its "one code line".

Posted (edited)

You probably can cut the code from 60 to 80% :

  • a chance of 50% (according your HTM) doesn't need 5 different dice rolls, it's a simple Rnd.nextBoolean()
  • HTM content = static HTM to avoid hardcoded HTMs.
  • The bypass can be directly the itemId to avoid string checks.
  • The whole switch is pointless. I don't want to imagine if you were using a Rnd.get(1000)... You would wrote 998 empty cases ? If you don't want a 50% win case, simply write Rnd.get(1000) or 10000 and test 0 and 1 as results. No need your whole fat ugly switch.
  • You lose all jackpot data on server restart. Use GobalVariables (or ServerMemo) to store it.
  • jackpot and jackpot2 is a stupid concept, imagine you want to add or remove currencies. You're fucked up. And static the itemId is also wrong, if 2 players are using 2 different currencies in same time, one of the player can end with the other currency when the other player flipped it.

I don't recommend to use it, being aCis or not.

Edited by Tryskell
Posted

Wow you really have to try very hard to suck at coding such a basic concept.

 

I remember a time where you were coding almost as bad as the OP (your old balancer stats, just to give an exemple of extremely redundant code style). I say that, I say nothing.

 

;D

Posted

I remember a time where you were coding almost as bad as the OP (your old balancer stats, just to give an exemple of extremely redundant code style). I say that, I say nothing.

 

;D

We all begin from something don't we ? :D

Posted (edited)

We all begin from something don't we ? :D

 

So you should be the best to know it's not nice to bash people, while you can explain where are the flaws and how to improve the code. In both case you say the code got issues, but one way is negative while the second is more positive.

 

That was the morale lesson of the day, cya tomorrow for new lessons ! :D

Edited by Tryskell

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.



  • Posts

    • sql procedure missed and wrong...fixed it...ZOUMHS 
    • Hello Dexters! https://lineage2dex.com    This is pre-announcing of NEW season server, so we want to share some key points of it. Full details with road map, patch notes we will announce a bit latter Opening September 27 at 19:00 (UTC +3) Open Beta Test from September 23 What’s New This Season?, This is just a short preview of the most exciting changes and updates. A patch note with balance change will be posted later in this thread – one topic with all patchnotes history from 2022 year EXP/SP x25 - Over the past few seasons, our servers were drifting closer to a mid-rate style. And hard to call it now pure PVP server. That’s why we’ve reduced EXP/SP rates from x50 to x25 – making progression smoother, more balanced, and more in line with the mid-rate identity., Improved Olympiad matchmaking – opponents will be matched by strength, making feeding much harder., K/D stats for CC – track your real impact!, New In-Game Shop Interface - no more running to NPCs for supplies – buy everything directly from the interface. NPC Astarte will now only handle services like WH, sales, LS insertion, etc., Balance Adjustments - small but important tweaks for a smoother PvP experience (details in patch notes)., Replica Instance System Reworked - upgrading replicas now requires not only fragments but also real jewellery from B to S grades. You can choose from 3 instance types: PvP Instance – biggest rewards (everyone spawns together for mass PvP)., CC Instance – private instance for your CC., Party Instance – private instance for your party., , Dino Island Returns - back by popular demand: Dark Zone (PvP) and Light Zone (PvE)., Newbie Pass Questline - available at character creation – helps you get familiar with the server and make start progression faster., Clan members taxation system, Full announce - read on forum, https://forum.lineage2dex.com/threads/16723/ (edited)   We’re excited to show you how the Newbie Path will look on the Seasonal Server and share a few details about it. The Newbie Path is designed to help new players on Dex adapt more easily on project. While it won’t reveal the full content of the game, it will greatly assist during the early stages of your journey. But it’s not just for newcomers! Even veteran players will find it useful — completing Newbie Path steps will grant you small progression boosts and extra rewards(exp boosts, some gear, potions etc). Definitely worth using! You’ll be able to test the full Newbie Path system yourself during the Open Beta, launching on September 23rd!
    • 📢 [OFFICIAL ANNOUNCEMENT] 🔥 Lineage 2 Interlude x10 Craft-PvP 🔥 🎮 Grand Opening — September 19 @ 19:00 [UTC +2] 🧪 Open Beta — September 15 @ 19:00 [UTC +2]    🌐 Full server description - https://lineage2.ms/en/wiki 💥 Why Interlude x10 Craft-PvP? ✅ GM Shop up to B-Grade + Full Buffs — get straight to action, no pointless grinding. ✅ Unique Geodata & Geopathfinding Engine — smooth, tactical, and truly next-gen. ✅ Two Client Options — play in Classic or Interlude style. ✅ No Pay-to-Win — donations don’t break the balance. ✅ 1+1 Mode Enabled — max 2 windows, only 1 active = no box armies. ✅ Bot-Free Zone — advanced protection + non-intrusive popup captchas. ✅ No GM Interference — fair, competitive PvP environment. ✅ No Wipes — your progress is safe. ✅ Truly International — global reach, not just CIS players. 🛡 2nd Season. Stronger, Smarter, Updated. 🎯 Pure Craft-PvP. 🌍 Real Competition. 📅 Mark your calendars. Tell your clan. Invite your friends. Let’s make this season legendary. 💪 https://discord.gg/lineage2ms
    • As far as I know, L2Gold stated (unofficially) that closed for legal reasons. Although, my estimation is that it had reached such low popularity (believe me I know, I played till the last day), so they closed it because of that. As for "other" copies or w/e. I believe that everyone has the right to do what they think is best.  I have to say, I find your claims a bit exaggerating. Many servers have done a good job at recreating such a server. There are actually leaked files of C4 L2Gold (L2OFF) so many owners started working from there (L2Gold.cc (old Avellan), L2Gold.in, L2Gold.co etc.) There are other owners that took the idea 1 step further, adapting L2Gold in higher Chronicles and started working on a brand-new style with old features along. @Trance @Brado @To4kA (those are some of the owners that I can think of right now). I think you should re-think your opinions and don't judge them all together. Many of the servers you've mentioned has actually done a decent job and tried to take the brand, one step further. The argument here is that everyone should do what they want. Community will judge if it's good or bad.
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock