Addition of Monster Race with reward system.
Adapted from aCis free version.
This commit is contained in:
15
L2J_Mobius_Classic_Interlude/dist/db_installer/sql/game/mdt_bets.sql
vendored
Normal file
15
L2J_Mobius_Classic_Interlude/dist/db_installer/sql/game/mdt_bets.sql
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS `mdt_bets` (
|
||||
`lane_id` INT(1) DEFAULT 0,
|
||||
`bet` INT DEFAULT 0,
|
||||
PRIMARY KEY (`lane_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
|
||||
|
||||
INSERT INTO `mdt_bets` VALUES
|
||||
('1','0'),
|
||||
('2','0'),
|
||||
('3','0'),
|
||||
('4','0'),
|
||||
('5','0'),
|
||||
('6','0'),
|
||||
('7','0'),
|
||||
('8','0');
|
7
L2J_Mobius_Classic_Interlude/dist/db_installer/sql/game/mdt_history.sql
vendored
Normal file
7
L2J_Mobius_Classic_Interlude/dist/db_installer/sql/game/mdt_history.sql
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS `mdt_history` (
|
||||
`race_id` MEDIUMINT DEFAULT 0,
|
||||
`first` INT(1) DEFAULT 0,
|
||||
`second` INT(1) DEFAULT 0,
|
||||
`odd_rate` DOUBLE(10,2) DEFAULT 0,
|
||||
PRIMARY KEY (`race_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
|
@@ -370,6 +370,9 @@ DefaultFinishTime = 5
|
||||
# Misc Settings
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# Default: True
|
||||
AllowRace = True
|
||||
|
||||
# Default: True
|
||||
AllowWater = True
|
||||
|
||||
|
22
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-1.htm
vendored
Normal file
22
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-1.htm
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<html><body>
|
||||
<br>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_Chat 0">Go Back</Button>
|
||||
<br>
|
||||
In a monster race eight monsters race at the same time. If you guess which monster is expected to finish first and buy that monster's race ticket, based upon the odds to win you will receive an appropriate amount of adena.<br>
|
||||
<font color="LEVEL">Racing Schedule</font><br>
|
||||
Monster races every 20 minutes in real time.<br>
|
||||
<font color="LEVEL">Method of Race Participation</font><br>
|
||||
You can purchase a monster race ticket through a race manager NPC. Only between 18 minutes before the start of a race until 3 minutes before the race begins you can buy a ticket for the applicable race. When you purchase a ticket through a conversation with a race manager, you can find out the names of participating monsters in the race and their current statistics. Five minutes before a race starts, the race manager will stop ticket sales and announce monsters' individual odds rate for the current race.<br>
|
||||
<font color="LEVEL">Types of Race</font><br>
|
||||
There are two types of race betting. The Win type betting means that you back a monster that will win the first prize. Place type of betting means that you will have to guess the 1st and 2nd winning monsters, regardless of who finishes first or second.<br>
|
||||
<font color="00FFFF">Win</font><br1>
|
||||
* Among the entire betting amount for Win betting, after subtracting the race track's own share of profit, the amount left will be your total winnings. Three minutes before the race each monster's expected odds are announced. Each Win ticket's dividend amount is calculated by multiplying the odds by the price of a ticket. The odds rate is never less than 1.<br1>
|
||||
* The prize money does not get transferred to the next race.<br>
|
||||
<font color="00FFFF">Place</font><br1>
|
||||
* Place betting is a way of betting when you correctly guess the two monsters who will finish first and second regardless of their order. The method of calculating dividend amount is the same as Win betting.<br>
|
||||
* Currently place betting is not offered.<br>
|
||||
<font color="LEVEL">End of Race</font><br>
|
||||
When a race is over, the race manager will shout out the results of the race. Through a conversation with a race manager NPC, you can trade your ticket for adena. By looking up on the Winning Information Data, you can find out the types of tickets and quantity of the winnings in the race you betted on and your win status and prize amount you won. If you won, you can receive your prize money thorough a race manager NPC. If you did not win, a race manager will buy back your ticket by paying you a very small amount of money.<br>
|
||||
If a server goes down while tickets are being sold, or while a race is in progress, the race will be cancelled. You can receive a full refund for your ticket for a cancelled race through a race manager.<br>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_Chat 0">Go Back</Button>
|
||||
</body></html>
|
94
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-2.htm
vendored
Normal file
94
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-2.htm
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
<html><body>
|
||||
<center>Monster Race Betting <font color="00ffff">To Win</font> (Race #<font color="LEVEL"> 1race</font>)<br1>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=1 height=3>
|
||||
</center>
|
||||
|
||||
<table width=270 border=0 bgcolor="111111">
|
||||
<tr>
|
||||
<td fixwidth=60>Lane Selection</td>
|
||||
<td fixwidth=130 align=center>Name of Racer</td>
|
||||
<td fixwidth=40 align=center>Rating</td>
|
||||
<td fixwidth=40 align=right>Odds</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width=270 border=0>
|
||||
<tr>
|
||||
<td fixwidth=13><button action="bypass -h npc_%objectId%_BuyTicket 1" back="L2UI.rightBtn2" fore="L2UI.rightBtn1" width=14 height=13></button></td>
|
||||
<td fixwidth=30>1</td>
|
||||
<td fixwidth=152><font color="LEVEL">Mob1</font></td>
|
||||
<td fixwidth=50 align=center>&$745;</td>
|
||||
<td fixwidth=30 align=right><font color="00ffff">13%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><button action="bypass -h npc_%objectId%_BuyTicket 2" back="L2UI.rightBtn2" fore="L2UI.rightBtn1" width=14 height=13></button></td>
|
||||
<td>2</td>
|
||||
<td><font color="LEVEL">Mob2</font></td>
|
||||
<td align=center>&$745;</td>
|
||||
<td align=right><font color="00ffff">6%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><button action="bypass -h npc_%objectId%_BuyTicket 3" back="L2UI.rightBtn2" fore="L2UI.rightBtn1" width=14 height=13></button></td>
|
||||
<td>3</td>
|
||||
<td><font color="LEVEL">Mob3</font></td>
|
||||
<td align=center>&$747;</td>
|
||||
<td align=right><font color="00ffff">4%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><button action="bypass -h npc_%objectId%_BuyTicket 4" back="L2UI.rightBtn2" fore="L2UI.rightBtn1" width=14 height=13></button></td>
|
||||
<td>4</td>
|
||||
<td><font color="LEVEL">Mob4</font></td>
|
||||
<td align=center>&$745;</td>
|
||||
<td align=right><font color="00ffff">12%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><button action="bypass -h npc_%objectId%_BuyTicket 5" back="L2UI.rightBtn2" fore="L2UI.rightBtn1" width=14 height=13></button></td>
|
||||
<td>5</td>
|
||||
<td><font color="LEVEL">Mob5</font></td>
|
||||
<td align=center>&$745;</td>
|
||||
<td align=right><font color="00ffff">14%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><button action="bypass -h npc_%objectId%_BuyTicket 6" back="L2UI.rightBtn2" fore="L2UI.rightBtn1" width=14 height=13></button></td>
|
||||
<td>6</td>
|
||||
<td><font color="LEVEL">Mob6</font></td>
|
||||
<td align=center>&$745;</td>
|
||||
<td align=right><font color="00ffff">13%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><button action="bypass -h npc_%objectId%_BuyTicket 7" back="L2UI.rightBtn2" fore="L2UI.rightBtn1" width=14 height=13></button></td>
|
||||
<td>7</td>
|
||||
<td><font color="LEVEL">Mob7</font></td>
|
||||
<td align=center>&$745;</td>
|
||||
<td align=right><font color="00ffff">13%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><button action="bypass -h npc_%objectId%_BuyTicket 8" back="L2UI.rightBtn2" fore="L2UI.rightBtn1" width=14 height=13></button></td>
|
||||
<td>8</td>
|
||||
<td><font color="LEVEL">Mob8</font></td>
|
||||
<td align=center>&$746;</td>
|
||||
<td align=right><font color="00ffff">14%</font></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
<img src="L2UI.SquareBlank" width=270 height=10>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=270 height=5>
|
||||
|
||||
<table width=270 border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td width=70 height=20><button value="Back" action="bypass -h npc_%objectId%_Chat 0" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
<td width=130 align=center>Select Lane :<font color="LEVEL"> No1</font></td>
|
||||
<td width=70 align=right><button value="Quantity" action="bypass -h npc_%objectId%_BuyTicket 10" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body></html>
|
48
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-3.htm
vendored
Normal file
48
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-3.htm
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<html><body>
|
||||
<center>Monster Race Betting <font color="00ffff">To Win</font> (Race #<font color="LEVEL"> 1race</font>)<br1>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=1 height=3>
|
||||
</center>
|
||||
|
||||
<table width=270 border=0 bgcolor="111111">
|
||||
<tr>
|
||||
<td fixwidth=60>Lane Selection</td>
|
||||
<td fixwidth=140 align=center>Racer's Name </td>
|
||||
<td fixwidth=40 align=center>Rating</td>
|
||||
<td fixwidth=30 align=right>Odds</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width=270 border=0>
|
||||
<tr>
|
||||
<td fixwidth=13><img src="L2UI.rightBtn2" width=14 height=13></td>
|
||||
<td fixwidth=30>0place</td>
|
||||
<td fixwidth=152><font color="LEVEL">Mob1</font></td>
|
||||
<td fixwidth=50 align=center>&$745;</td>
|
||||
<td fixwidth=30 align=right><font color="00ffff">13%</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width=270 border=0>
|
||||
<tr><td width=100>Select Bet Amount</td>
|
||||
<td width=170>
|
||||
<a action="bypass -h npc_%objectId%_BuyTicket 11" >100 Adena</a> , <a action="bypass -h npc_%objectId%_BuyTicket 12" >500 Adena</a> <br1>
|
||||
<a action="bypass -h npc_%objectId%_BuyTicket 13" >1,000 Adena</a> , <a action="bypass -h npc_%objectId%_BuyTicket 14" >5,000 Adena</a> <br1>
|
||||
<a action="bypass -h npc_%objectId%_BuyTicket 15" >10,000 Adena</a> , <a action="bypass -h npc_%objectId%_BuyTicket 16" >20,000 Adena</a> <br1>
|
||||
<a action="bypass -h npc_%objectId%_BuyTicket 17" >50,000 Adena</a> , <a action="bypass -h npc_%objectId%_BuyTicket 18" >100,000 Adena</a> <br1>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<img src="L2UI.SquareBlank" width=270 height=10>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=270 height=5>
|
||||
|
||||
<table width=270 border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td width=70 height=20><button value="Select Lane" action="bypass -h npc_%objectId%_BuyTicket 0" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
<td width=130 align=center>Purchase Price :<font color="LEVEL"> 0adena</font></td>
|
||||
<td width=70 align=right><button value="Confirm" action="bypass -h npc_%objectId%_BuyTicket 20" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body></html>
|
56
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-4.htm
vendored
Normal file
56
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-4.htm
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<html><body>
|
||||
<center>Monster Race <font color="00ffff">Single</font> Ticket Purchase (Race #<font color="LEVEL"> 1race</font>)<br1>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=1 height=3>
|
||||
</center>
|
||||
<table width=270 border=0 bgcolor="111111">
|
||||
<tr>
|
||||
<td fixwidth=60>Lane Selection</td>
|
||||
<td fixwidth=140 align=center>Racer's Name</td>
|
||||
<td fixwidth=40 align=center>Rating</td>
|
||||
<td fixwidth=30 align=right>Odds</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width=270 border=0>
|
||||
<tr>
|
||||
<td fixwidth=13><img src="L2UI.rightBtn2" width=14 height=13></td>
|
||||
<td fixwidth=30>0place</td>
|
||||
<td fixwidth=152><font color="LEVEL">Mob1</font></td>
|
||||
<td fixwidth=50 align=center>&$745;</td>
|
||||
<td fixwidth=30 align=right><font color="00ffff">13%</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width=270 border=0 bgcolor=111111>
|
||||
<tr>
|
||||
<td fixwidth=60>Bet Amount </td>
|
||||
<td fixwidth=200></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bet Amount </td>
|
||||
<td><font color="LEVEL">0adena</font> Adena</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tax </td>
|
||||
<td><font color="LEVEL">0tax</font> Adena</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Total </td>
|
||||
<td><font color="LEVEL">0total</font> Adena</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<center>If the information is correct, please click Confirm.</center><br>
|
||||
<img src="L2UI.SquareBlank" width=270 height=10>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=270 height=5>
|
||||
|
||||
<table width=270 border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td width=70 height=20><button value=&$141; action="bypass -h npc_%objectId%_Chat 0" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
<td width=130 align=center><button value="Select Lane" action="bypass -h npc_%objectId%_BuyTicket 0" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
<td width=70 align=right><button value=&$140; action="bypass -h npc_%objectId%_BuyTicket 21" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body></html>
|
74
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-5.htm
vendored
Normal file
74
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-5.htm
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<html><body>
|
||||
<center>Monster Race Betting <font color="00ffff">To Win</font> View Odds (Race #<font color="LEVEL"> 1race</font> )<br1>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=1 height=3>
|
||||
</center>
|
||||
<table width=270 border=0 bgcolor=111111>
|
||||
<tr>
|
||||
<td fixwidth=40 align=left>Lane</td>
|
||||
<td fixwidth=130 align=center>Racer's Name</td>
|
||||
<td fixwidth=100 align=right>Odds</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width=270 border=0>
|
||||
<tr>
|
||||
<td fixwidth=40>No.1</td>
|
||||
<td fixwidth=130 align=left><font color="LEVEL">Mob1</font></td>
|
||||
<td fixwidth=100 align=right><font color="00ffff">Odd1</font> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>No.2</td>
|
||||
<td fixwidth=130 align=left><font color="LEVEL">Mob2</font></td>
|
||||
<td fixwidth=100 align=right><font color="00ffff">Odd2</font> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>No.3</td>
|
||||
<td fixwidth=130 align=left><font color="LEVEL">Mob3</font></td>
|
||||
<td fixwidth=100 align=right><font color="00ffff">Odd3</font> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>No.4</td>
|
||||
<td fixwidth=130 align=left><font color="LEVEL">Mob4</font></td>
|
||||
<td fixwidth=100 align=right><font color="00ffff">Odd4</font> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>No.5</td>
|
||||
<td fixwidth=130 align=left><font color="LEVEL">Mob5</font></td>
|
||||
<td fixwidth=100 align=right><font color="00ffff">Odd5</font> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>No.6</td>
|
||||
<td fixwidth=130 align=left><font color="LEVEL">Mob6</font></td>
|
||||
<td fixwidth=100 align=right><font color="00ffff">Odd6</font> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>No.7</td>
|
||||
<td fixwidth=130 align=left><font color="LEVEL">Mob7</font></td>
|
||||
<td fixwidth=100 align=right><font color="00ffff">Odd7</font> </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>No.8</td>
|
||||
<td fixwidth=130 align=left><font color="LEVEL">Mob8</font></td>
|
||||
<td fixwidth=100 align=right><font color="00ffff">Odd8</font> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<img src="L2UI.SquareBlank" width=270 height=10>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=270 height=5>
|
||||
|
||||
<table width=270 border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td width=90 height=20><button value="Back" action="bypass -h npc_%objectId%_Chat 0" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
<td width=90></td>
|
||||
<td width=90 align=right><button value="Racer Info" action="bypass -h npc_%objectId%_ShowInfo" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body></html>
|
80
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-6.htm
vendored
Normal file
80
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-6.htm
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<html><body>
|
||||
<center>Participating Monsters<br1>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=1 height=3>
|
||||
</center>
|
||||
<table width=270 border=0 bgcolor=111111>
|
||||
<tr>
|
||||
<td fixwidth=40 align=left>Lane</td>
|
||||
<td fixwidth=140 align=center>Racer's Name</td>
|
||||
<td fixwidth=50 align=center>Rating</td>
|
||||
<td fixwidth=40 align=right>Odds</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width=270 border=0>
|
||||
<tr>
|
||||
<td fixwidth=40>1</td>
|
||||
<td fixwidth=140 align=left><font color="LEVEL">Mob1</font></td>
|
||||
<td fixwidth=50 align=center>&$747;</td>
|
||||
<td fixwidth=40 align=right><font color="00ffff">12%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>2</td>
|
||||
<td fixwidth=140 align=left><font color="LEVEL">Mob2</font></td>
|
||||
<td fixwidth=50 align=center>&$745;</td>
|
||||
<td fixwidth=40 align=right><font color="00ffff">6%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>3</td>
|
||||
<td fixwidth=140 align=left><font color="LEVEL">Mob3</font></td>
|
||||
<td fixwidth=50 align=center>&$746;</td>
|
||||
<td fixwidth=40 align=right><font color="00ffff">3%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>4</td>
|
||||
<td fixwidth=140 align=left><font color="LEVEL">Mob4</font></td>
|
||||
<td fixwidth=50 align=center>&$747;</td>
|
||||
<td fixwidth=40 align=right><font color="00ffff">7%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>5</td>
|
||||
<td fixwidth=140 align=left><font color="LEVEL">Mob5</font></td>
|
||||
<td fixwidth=50 align=center>&$747;</td>
|
||||
<td fixwidth=40 align=right><font color="00ffff">4%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>6</td>
|
||||
<td fixwidth=140 align=left><font color="LEVEL">Mob6</font></td>
|
||||
<td fixwidth=50 align=center>&$747;</td>
|
||||
<td fixwidth=40 align=right><font color="00ffff">14%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>7</td>
|
||||
<td fixwidth=140 align=left><font color="LEVEL">Mob7</font></td>
|
||||
<td fixwidth=50 align=center>&$747;</td>
|
||||
<td fixwidth=40 align=right><font color="00ffff">26%</font></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td fixwidth=40>8</td>
|
||||
<td fixwidth=140 align=left><font color="LEVEL">Mob8</font></td>
|
||||
<td fixwidth=50 align=center>&$745;</td>
|
||||
<td fixwidth=40 align=right><font color="00ffff">5%</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<img src="L2UI.SquareBlank" width=270 height=10>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=270 height=5>
|
||||
<table width=270 border=0 cellpadding=0 cellspacing=0><tr>
|
||||
<td width=90 height=20><button value="Back" action="bypass -h npc_%objectId%_Chat 0" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
<td width=90></td>
|
||||
<td width=90></td>
|
||||
</tr></table></body></html>
|
19
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-7.htm
vendored
Normal file
19
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-7.htm
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<html><body>
|
||||
<center>Confirm Monster Race Bet / Calculate Winnings</center>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=1 height=3>
|
||||
<table width=270 border=0 bgcolor=111111>
|
||||
<tr><td fixwidth=70>Winnings for a Race.</td><td fixwidth=70 align=right>Lane</td><td fixwidth=130 align=right>Bet Amount</td></tr>
|
||||
<tr><td fixwidth=70 fixheight=1></td><td fixwidth=70></td><td fixwidth=130></td></tr>
|
||||
</table>
|
||||
<table width=270 border=0>
|
||||
%tickets%
|
||||
</table>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=270 height=5>
|
||||
<table width=270 border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td width=90 height=20><button value="Back" action="bypass -h npc_%objectId%_Chat 0" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
<td width=90></td>
|
||||
<td width=90></td>
|
||||
</tr></table></body></html>
|
25
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-8.htm
vendored
Normal file
25
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-8.htm
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
<html><body>
|
||||
<center>Confirm Monster Race Bet / Calculate Winnings</center>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=1 height=3>
|
||||
<table width=270 border=0>
|
||||
<tr>
|
||||
<td width=230>Race #%raceId%<br>
|
||||
Lane: %lane%<br>
|
||||
Bet: %bet% Adena<br>
|
||||
1st place: Lane [%firstLane%]<br>
|
||||
Odds: [%odd%]
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<img src="L2UI.SquareBlank" width=270 height=10>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=270 height=5>
|
||||
|
||||
<table width=270 border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td width=90 height=20><button value="Previous" action="bypass -h npc_%objectId%_ShowTickets" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
<td width=90></td>
|
||||
<td width=90 align=right><button value="Calculate" action="bypass -h npc_%objectId%_CalculateWin %ticketObjectId%" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
</tr></table>
|
||||
</body></html>
|
22
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-9.htm
vendored
Normal file
22
L2J_Mobius_Classic_Interlude/dist/game/data/html/default/30995-9.htm
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<html><body>
|
||||
<center>View Monster Race Results</center>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=1 height=3>
|
||||
<table width=270 border=0 bgcolor=111111>
|
||||
<tr><td fixwidth=60>Race Number</td><td fixwidth=70 align=center>1st Finish</td><td fixwidth=70 align=center>2nd Finish</td><td fixwidth=70 align=right>Odds Rate for Win Bet</td></tr>
|
||||
</table>
|
||||
<table width=270 border=0>
|
||||
<tr><td fixwidth=60 fixheight=1></td><td fixwidth=70></td><td fixwidth=70></td><td fixwidth=70></td></tr>
|
||||
%infos%
|
||||
</table>
|
||||
<img src="L2UI.SquareBlank" width=270 height=10>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=270 height=5>
|
||||
<table width=270 border=0 cellpadding=0 cellspacing=0>
|
||||
<tr>
|
||||
<td width=90 height=20><button value="Back" action="bypass -h npc_%objectId%_Chat 0" back="L2UI.DefaultButton_click" fore="L2UI.DefaultButton" width=67 height=19></td>
|
||||
<td width=90></td>
|
||||
<td width=90></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body></html>
|
@@ -1,3 +1,15 @@
|
||||
<html><body>Monster Race Manager:<br>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_Quest TeleportToRaceTrack" msg="1298;Monster Race Track">Exit the Monster Race Track</Button>
|
||||
<center>Monster Race Manager</center>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=1 height=3>
|
||||
<br>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_Chat 1">Monster Race Help</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_ShowOdds">View Odds</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_ShowInfo">View Monster Information</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_BuyTicket 0">Purchase Ticket</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_ShowTickets">Calculate Winnings</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_ViewHistory">View Past Results</Button>
|
||||
<Button ALIGN=LEFT ICON="NORMAL" action="bypass -h npc_%objectId%_Quest TeleportToRaceTrack" msg="1298;Monster Race Track">Exit the monster race track.</Button>
|
||||
<img src="L2UI.SquareBlank" width=270 height=10>
|
||||
<img src="L2UI.SquareWhite" width=270 height=1>
|
||||
<img src="L2UI.SquareBlank" width=270 height=5>
|
||||
</body></html>
|
@@ -3856,7 +3856,7 @@
|
||||
<height normal="23.5" />
|
||||
</collision>
|
||||
</npc>
|
||||
<npc id="30995" level="70" type="Npc" name="Race Manager" title="Monster Race Track">
|
||||
<npc id="30995" level="70" type="RaceManager" name="Race Manager" title="Monster Race Track">
|
||||
<!-- Confirmed CT2.5 -->
|
||||
<race>DWARF</race>
|
||||
<sex>FEMALE</sex>
|
||||
|
@@ -500,6 +500,7 @@ public class Config
|
||||
public static int INSTANCE_FINISH_TIME;
|
||||
public static boolean RESTORE_PLAYER_INSTANCE;
|
||||
public static int EJECT_DEAD_PLAYER_TIME;
|
||||
public static boolean ALLOW_RACE;
|
||||
public static boolean ALLOW_WATER;
|
||||
public static boolean ALLOW_FISHING;
|
||||
public static boolean ALLOW_BOAT;
|
||||
@@ -1960,6 +1961,7 @@ public class Config
|
||||
INSTANCE_FINISH_TIME = General.getInt("DefaultFinishTime", 5);
|
||||
RESTORE_PLAYER_INSTANCE = General.getBoolean("RestorePlayerInstance", false);
|
||||
EJECT_DEAD_PLAYER_TIME = General.getInt("EjectDeadPlayerTime", 1);
|
||||
ALLOW_RACE = General.getBoolean("AllowRace", true);
|
||||
ALLOW_WATER = General.getBoolean("AllowWater", true);
|
||||
ALLOW_FISHING = General.getBoolean("AllowFishing", true);
|
||||
ALLOW_MANOR = General.getBoolean("AllowManor", true);
|
||||
|
@@ -141,6 +141,7 @@ import org.l2jmobius.gameserver.instancemanager.SiegeGuardManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.SiegeManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.WalkingManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import org.l2jmobius.gameserver.instancemanager.games.MonsterRace;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.entity.Hero;
|
||||
import org.l2jmobius.gameserver.model.events.EventDispatcher;
|
||||
@@ -401,6 +402,8 @@ public class GameServer
|
||||
ItemsAutoDestroy.getInstance();
|
||||
}
|
||||
|
||||
MonsterRace.getInstance();
|
||||
|
||||
TaskManager.getInstance();
|
||||
|
||||
AntiFeedManager.getInstance().registerEvent(AntiFeedManager.GAME_ID);
|
||||
|
@@ -0,0 +1,623 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.instancemanager.games;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.NpcData;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
import org.l2jmobius.gameserver.model.zone.type.DerbyTrackZone;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.DeleteObject;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.MonRaceInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import org.l2jmobius.gameserver.util.Broadcast;
|
||||
|
||||
public class MonsterRace
|
||||
{
|
||||
protected static final Logger LOGGER = Logger.getLogger(MonsterRace.class.getName());
|
||||
|
||||
public static enum RaceState
|
||||
{
|
||||
ACCEPTING_BETS,
|
||||
WAITING,
|
||||
STARTING_RACE,
|
||||
RACE_END
|
||||
}
|
||||
|
||||
protected static final PlaySound SOUND_1 = new PlaySound(1, "S_Race", 0, 0, 0, 0, 0);
|
||||
protected static final PlaySound SOUND_2 = new PlaySound("ItemSound2.race_start");
|
||||
|
||||
protected static final int[][] CODES =
|
||||
{
|
||||
{
|
||||
-1,
|
||||
0
|
||||
},
|
||||
{
|
||||
0,
|
||||
15322
|
||||
},
|
||||
{
|
||||
13765,
|
||||
-1
|
||||
}
|
||||
};
|
||||
|
||||
protected final List<Integer> _npcTemplates = new ArrayList<>(); // List holding npc templates, shuffled on a new race.
|
||||
protected final List<HistoryInfo> _history = new ArrayList<>(); // List holding old race records.
|
||||
protected final Map<Integer, Long> _betsPerLane = new ConcurrentHashMap<>(); // Map holding all bets for each lane ; values setted to 0 after every race.
|
||||
protected final List<Double> _odds = new ArrayList<>(); // List holding sorted odds per lane ; cleared at new odds calculation.
|
||||
|
||||
protected int _raceNumber = 1;
|
||||
protected int _finalCountdown = 0;
|
||||
protected RaceState _state = RaceState.RACE_END;
|
||||
|
||||
protected MonRaceInfo _packet;
|
||||
|
||||
private final Npc[] _monsters = new Npc[8];
|
||||
private int[][] _speeds = new int[8][20];
|
||||
private final int[] _first = new int[2];
|
||||
private final int[] _second = new int[2];
|
||||
|
||||
protected MonsterRace()
|
||||
{
|
||||
if (!Config.ALLOW_RACE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Feed _history with previous race results.
|
||||
loadHistory();
|
||||
|
||||
// Feed _betsPerLane with stored informations on bets.
|
||||
loadBets();
|
||||
|
||||
// Feed _npcTemplates, we will only have to shuffle it when needed.
|
||||
for (int i = 31003; i < 31027; i++)
|
||||
{
|
||||
_npcTemplates.add(i);
|
||||
}
|
||||
|
||||
ThreadPool.scheduleAtFixedRate(new Announcement(), 0, 1000);
|
||||
}
|
||||
|
||||
public static class HistoryInfo
|
||||
{
|
||||
private final int _raceId;
|
||||
private int _first;
|
||||
private int _second;
|
||||
private double _oddRate;
|
||||
|
||||
public HistoryInfo(int raceId, int first, int second, double oddRate)
|
||||
{
|
||||
_raceId = raceId;
|
||||
_first = first;
|
||||
_second = second;
|
||||
_oddRate = oddRate;
|
||||
}
|
||||
|
||||
public int getRaceId()
|
||||
{
|
||||
return _raceId;
|
||||
}
|
||||
|
||||
public int getFirst()
|
||||
{
|
||||
return _first;
|
||||
}
|
||||
|
||||
public int getSecond()
|
||||
{
|
||||
return _second;
|
||||
}
|
||||
|
||||
public double getOddRate()
|
||||
{
|
||||
return _oddRate;
|
||||
}
|
||||
|
||||
public void setFirst(int first)
|
||||
{
|
||||
_first = first;
|
||||
}
|
||||
|
||||
public void setSecond(int second)
|
||||
{
|
||||
_second = second;
|
||||
}
|
||||
|
||||
public void setOddRate(double oddRate)
|
||||
{
|
||||
_oddRate = oddRate;
|
||||
}
|
||||
}
|
||||
|
||||
private class Announcement implements Runnable
|
||||
{
|
||||
public Announcement()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_finalCountdown > 1200)
|
||||
{
|
||||
_finalCountdown = 0;
|
||||
}
|
||||
|
||||
switch (_finalCountdown)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
newRace();
|
||||
newSpeeds();
|
||||
|
||||
_state = RaceState.ACCEPTING_BETS;
|
||||
_packet = new MonRaceInfo(CODES[0][0], CODES[0][1], getMonsters(), getSpeeds());
|
||||
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.TICKETS_ARE_NOW_AVAILABLE_FOR_MONSTER_RACE_S1);
|
||||
msg.addInt(_raceNumber);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, _packet, msg);
|
||||
break;
|
||||
}
|
||||
case 30: // 30 sec
|
||||
case 60: // 1 min
|
||||
case 90: // 1 min 30 sec
|
||||
case 120: // 2 min
|
||||
case 150: // 2 min 30
|
||||
case 180: // 3 min
|
||||
case 210: // 3 min 30
|
||||
case 240: // 4 min
|
||||
case 270: // 4 min 30 sec
|
||||
case 330: // 5 min 30 sec
|
||||
case 360: // 6 min
|
||||
case 390: // 6 min 30 sec
|
||||
case 420: // 7 min
|
||||
case 450: // 7 min 30
|
||||
case 480: // 8 min
|
||||
case 510: // 8 min 30
|
||||
case 540: // 9 min
|
||||
case 570: // 9 min 30 sec
|
||||
case 630: // 10 min 30 sec
|
||||
case 660: // 11 min
|
||||
case 690: // 11 min 30 sec
|
||||
case 720: // 12 min
|
||||
case 750: // 12 min 30
|
||||
case 780: // 13 min
|
||||
case 810: // 13 min 30
|
||||
case 870: // 14 min 30 sec
|
||||
{
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.TICKETS_ARE_NOW_AVAILABLE_FOR_MONSTER_RACE_S1);
|
||||
msg.addInt(_raceNumber);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg);
|
||||
break;
|
||||
}
|
||||
case 300: // 5 min
|
||||
{
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.NOW_SELLING_TICKETS_FOR_MONSTER_RACE_S1);
|
||||
msg.addInt(_raceNumber);
|
||||
final SystemMessage msg2 = new SystemMessage(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S);
|
||||
msg2.addInt(10);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg, msg2);
|
||||
break;
|
||||
}
|
||||
case 600: // 10 min
|
||||
{
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.NOW_SELLING_TICKETS_FOR_MONSTER_RACE_S1);
|
||||
msg.addInt(_raceNumber);
|
||||
final SystemMessage msg2 = new SystemMessage(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S);
|
||||
msg2.addInt(5);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg, msg2);
|
||||
break;
|
||||
}
|
||||
case 840: // 14 min
|
||||
{
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.NOW_SELLING_TICKETS_FOR_MONSTER_RACE_S1);
|
||||
msg.addInt(_raceNumber);
|
||||
final SystemMessage msg2 = new SystemMessage(SystemMessageId.TICKET_SALES_FOR_THE_MONSTER_RACE_WILL_END_IN_S1_MINUTE_S);
|
||||
msg2.addInt(1);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg, msg2);
|
||||
break;
|
||||
}
|
||||
case 900: // 15 min
|
||||
{
|
||||
_state = RaceState.WAITING;
|
||||
|
||||
calculateOdds();
|
||||
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.TICKETS_ARE_NOW_AVAILABLE_FOR_MONSTER_RACE_S1);
|
||||
msg.addInt(_raceNumber);
|
||||
final SystemMessage msg2 = new SystemMessage(SystemMessageId.TICKETS_SALES_ARE_CLOSED_FOR_MONSTER_RACE_S1_ODDS_ARE_POSTED);
|
||||
msg2.addInt(_raceNumber);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg, msg2);
|
||||
break;
|
||||
}
|
||||
case 960: // 16 min
|
||||
case 1020: // 17 min
|
||||
{
|
||||
final int minutes = (_finalCountdown == 960) ? 2 : 1;
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.MONSTER_RACE_S2_WILL_BEGIN_IN_S1_MINUTE_S);
|
||||
msg.addInt(minutes);
|
||||
msg.addInt(_raceNumber);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg);
|
||||
break;
|
||||
}
|
||||
case 1050: // 17 min 30 sec
|
||||
{
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.MONSTER_RACE_S1_WILL_BEGIN_IN_30_SECONDS);
|
||||
msg.addInt(_raceNumber);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg);
|
||||
break;
|
||||
}
|
||||
case 1070: // 17 min 50 sec
|
||||
{
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.MONSTER_RACE_S1_IS_ABOUT_TO_BEGIN_COUNTDOWN_IN_FIVE_SECONDS);
|
||||
msg.addInt(_raceNumber);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg);
|
||||
break;
|
||||
}
|
||||
case 1075: // 17 min 55 sec
|
||||
case 1076: // 17 min 56 sec
|
||||
case 1077: // 17 min 57 sec
|
||||
case 1078: // 17 min 58 sec
|
||||
case 1079: // 17 min 59 sec
|
||||
{
|
||||
final int seconds = 1080 - _finalCountdown;
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.THE_RACE_WILL_BEGIN_IN_S1_SECOND_S);
|
||||
msg.addInt(seconds);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg);
|
||||
break;
|
||||
}
|
||||
case 1080: // 18 min
|
||||
{
|
||||
_state = RaceState.STARTING_RACE;
|
||||
_packet = new MonRaceInfo(CODES[1][0], CODES[1][1], getMonsters(), getSpeeds());
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, new SystemMessage(SystemMessageId.THEY_RE_OFF), SOUND_1, SOUND_2, _packet);
|
||||
break;
|
||||
}
|
||||
case 1085: // 18 min 5 sec
|
||||
{
|
||||
_packet = new MonRaceInfo(CODES[2][0], CODES[2][1], getMonsters(), getSpeeds());
|
||||
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, _packet);
|
||||
break;
|
||||
}
|
||||
case 1115: // 18 min 35 sec
|
||||
{
|
||||
_state = RaceState.RACE_END;
|
||||
|
||||
// Populate history info with data, stores it in database.
|
||||
final HistoryInfo info = _history.get(_history.size() - 1);
|
||||
info.setFirst(getFirstPlace());
|
||||
info.setSecond(getSecondPlace());
|
||||
info.setOddRate(_odds.get(getFirstPlace() - 1));
|
||||
|
||||
saveHistory(info);
|
||||
clearBets();
|
||||
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.FIRST_PRIZE_GOES_TO_THE_PLAYER_IN_LANE_S1_SECOND_PRIZE_GOES_TO_THE_PLAYER_IN_LANE_S2);
|
||||
msg.addInt(getFirstPlace());
|
||||
msg.addInt(getSecondPlace());
|
||||
final SystemMessage msg2 = new SystemMessage(SystemMessageId.MONSTER_RACE_S1_IS_FINISHED);
|
||||
msg2.addInt(_raceNumber);
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, msg, msg2);
|
||||
_raceNumber++;
|
||||
break;
|
||||
}
|
||||
case 1140: // 19 min
|
||||
{
|
||||
Broadcast.toAllPlayersInZoneType(DerbyTrackZone.class, new DeleteObject(getMonsters()[0]), new DeleteObject(getMonsters()[1]), new DeleteObject(getMonsters()[2]), new DeleteObject(getMonsters()[3]), new DeleteObject(getMonsters()[4]), new DeleteObject(getMonsters()[5]), new DeleteObject(getMonsters()[6]), new DeleteObject(getMonsters()[7]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
_finalCountdown += 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void newRace()
|
||||
{
|
||||
// Edit _history.
|
||||
_history.add(new HistoryInfo(_raceNumber, 0, 0, 0));
|
||||
|
||||
// Randomize _npcTemplates.
|
||||
Collections.shuffle(_npcTemplates);
|
||||
|
||||
// Setup 8 new creatures ; pickup the first 8 from _npcTemplates.
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
final NpcTemplate template = NpcData.getInstance().getTemplate(_npcTemplates.get(i));
|
||||
_monsters[i] = (Npc) Class.forName("org.l2jmobius.gameserver.model.actor.instance." + template.getType() + "Instance").getConstructors()[0].newInstance(template);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void newSpeeds()
|
||||
{
|
||||
_speeds = new int[8][20];
|
||||
int total = 0;
|
||||
_first[1] = 0;
|
||||
_second[1] = 0;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
total = 0;
|
||||
for (int j = 0; j < 20; j++)
|
||||
{
|
||||
if (j == 19)
|
||||
{
|
||||
_speeds[i][j] = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
_speeds[i][j] = Rnd.get(60) + 65;
|
||||
}
|
||||
total += _speeds[i][j];
|
||||
}
|
||||
|
||||
if (total >= _first[1])
|
||||
{
|
||||
_second[0] = _first[0];
|
||||
_second[1] = _first[1];
|
||||
_first[0] = 8 - i;
|
||||
_first[1] = total;
|
||||
}
|
||||
else if (total >= _second[1])
|
||||
{
|
||||
_second[0] = 8 - i;
|
||||
_second[1] = total;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load past races informations, feeding _history arrayList.<br>
|
||||
* Also sets _raceNumber, based on latest HistoryInfo loaded.
|
||||
*/
|
||||
protected void loadHistory()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("SELECT * FROM mdt_history");
|
||||
ResultSet rset = statement.executeQuery();
|
||||
|
||||
while (rset.next())
|
||||
{
|
||||
_history.add(new HistoryInfo(rset.getInt("race_id"), rset.getInt("first"), rset.getInt("second"), rset.getDouble("odd_rate")));
|
||||
_raceNumber++;
|
||||
}
|
||||
rset.close();
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "MonsterRace: Can't load history: " + e.getMessage(), e);
|
||||
}
|
||||
LOGGER.info("MonsterRace: loaded " + _history.size() + " records, currently on race #" + _raceNumber);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save an history record into database.
|
||||
* @param history The infos to store.
|
||||
*/
|
||||
protected void saveHistory(HistoryInfo history)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("INSERT INTO mdt_history (race_id, first, second, odd_rate) VALUES (?,?,?,?)");
|
||||
statement.setInt(1, history.getRaceId());
|
||||
statement.setInt(2, history.getFirst());
|
||||
statement.setInt(3, history.getSecond());
|
||||
statement.setDouble(4, history.getOddRate());
|
||||
statement.execute();
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "MonsterRace: Can't save history: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load current bets per lane ; initialize the map keys.
|
||||
*/
|
||||
protected void loadBets()
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("SELECT * FROM mdt_bets");
|
||||
ResultSet rset = statement.executeQuery();
|
||||
|
||||
while (rset.next())
|
||||
{
|
||||
setBetOnLane(rset.getInt("lane_id"), rset.getLong("bet"), false);
|
||||
}
|
||||
|
||||
rset.close();
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "MonsterRace: Can't load bets: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the current lane bet into database.
|
||||
* @param lane : The lane to affect.
|
||||
* @param sum : The sum to set.
|
||||
*/
|
||||
protected void saveBet(int lane, long sum)
|
||||
{
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("REPLACE INTO mdt_bets (lane_id, bet) VALUES (?,?)");
|
||||
statement.setInt(1, lane);
|
||||
statement.setLong(2, sum);
|
||||
statement.execute();
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "MonsterRace: Can't save bet: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all lanes bets, either on database or Map.
|
||||
*/
|
||||
protected void clearBets()
|
||||
{
|
||||
for (int key : _betsPerLane.keySet())
|
||||
{
|
||||
_betsPerLane.put(key, 0L);
|
||||
}
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement("UPDATE mdt_bets SET bet = 0");
|
||||
statement.execute();
|
||||
statement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, "MonsterRace: Can't clear bets: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup lane bet, based on previous value (if any).
|
||||
* @param lane : The lane to edit.
|
||||
* @param amount : The amount to add.
|
||||
* @param saveOnDb : Should it be saved on db or not.
|
||||
*/
|
||||
public void setBetOnLane(int lane, long amount, boolean saveOnDb)
|
||||
{
|
||||
final long sum = (_betsPerLane.containsKey(lane)) ? _betsPerLane.get(lane) + amount : amount;
|
||||
|
||||
_betsPerLane.put(lane, sum);
|
||||
|
||||
if (saveOnDb)
|
||||
{
|
||||
saveBet(lane, sum);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate odds for every lane, based on others lanes.
|
||||
*/
|
||||
protected void calculateOdds()
|
||||
{
|
||||
// Clear previous List holding old odds.
|
||||
_odds.clear();
|
||||
|
||||
// Sort bets lanes per lane.
|
||||
final Map<Integer, Long> sortedLanes = new TreeMap<>(_betsPerLane);
|
||||
|
||||
// Pass a first loop in order to calculate total sum of all lanes.
|
||||
long sumOfAllLanes = 0;
|
||||
for (long amount : sortedLanes.values())
|
||||
{
|
||||
sumOfAllLanes += amount;
|
||||
}
|
||||
|
||||
// As we get the sum, we can now calculate the odd rate of each lane.
|
||||
for (long amount : sortedLanes.values())
|
||||
{
|
||||
_odds.add((amount == 0) ? 0D : Math.max(1.25, (sumOfAllLanes * 0.7) / amount));
|
||||
}
|
||||
}
|
||||
|
||||
public Npc[] getMonsters()
|
||||
{
|
||||
return _monsters;
|
||||
}
|
||||
|
||||
public int[][] getSpeeds()
|
||||
{
|
||||
return _speeds;
|
||||
}
|
||||
|
||||
public int getFirstPlace()
|
||||
{
|
||||
return _first[0];
|
||||
}
|
||||
|
||||
public int getSecondPlace()
|
||||
{
|
||||
return _second[0];
|
||||
}
|
||||
|
||||
public MonRaceInfo getRacePacket()
|
||||
{
|
||||
return _packet;
|
||||
}
|
||||
|
||||
public RaceState getCurrentRaceState()
|
||||
{
|
||||
return _state;
|
||||
}
|
||||
|
||||
public int getRaceNumber()
|
||||
{
|
||||
return _raceNumber;
|
||||
}
|
||||
|
||||
public List<HistoryInfo> getHistory()
|
||||
{
|
||||
return _history;
|
||||
}
|
||||
|
||||
public List<Double> getOdds()
|
||||
{
|
||||
return _odds;
|
||||
}
|
||||
|
||||
public static MonsterRace getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final MonsterRace INSTANCE = new MonsterRace();
|
||||
}
|
||||
}
|
@@ -0,0 +1,377 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.actor.instance;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.util.StringUtil;
|
||||
import org.l2jmobius.gameserver.idfactory.IdFactory;
|
||||
import org.l2jmobius.gameserver.instancemanager.games.MonsterRace;
|
||||
import org.l2jmobius.gameserver.instancemanager.games.MonsterRace.HistoryInfo;
|
||||
import org.l2jmobius.gameserver.instancemanager.games.MonsterRace.RaceState;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
|
||||
import org.l2jmobius.gameserver.model.items.instance.ItemInstance;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
|
||||
public class RaceManagerInstance extends Npc
|
||||
{
|
||||
protected static final int TICKET_PRICES[] =
|
||||
{
|
||||
100,
|
||||
500,
|
||||
1000,
|
||||
5000,
|
||||
10000,
|
||||
20000,
|
||||
50000,
|
||||
100000
|
||||
};
|
||||
|
||||
public RaceManagerInstance(NpcTemplate template)
|
||||
{
|
||||
super(template);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBypassFeedback(PlayerInstance player, String command)
|
||||
{
|
||||
if (command.startsWith("BuyTicket"))
|
||||
{
|
||||
if (!Config.ALLOW_RACE || (MonsterRace.getInstance().getCurrentRaceState() != RaceState.ACCEPTING_BETS))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.MONSTER_RACE_TICKETS_ARE_NO_LONGER_AVAILABLE);
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
int val = Integer.parseInt(command.substring(10));
|
||||
if (val == 0)
|
||||
{
|
||||
player.setRace(0, 0);
|
||||
player.setRace(1, 0);
|
||||
}
|
||||
|
||||
if (((val == 10) && (player.getRace(0) == 0)) || ((val == 20) && (player.getRace(0) == 0) && (player.getRace(1) == 0)))
|
||||
{
|
||||
val = 0;
|
||||
}
|
||||
|
||||
String search, replace;
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
|
||||
|
||||
if (val < 10)
|
||||
{
|
||||
html.setFile(player, getHtmlPath(getId(), 2, player));
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int n = i + 1;
|
||||
search = "Mob" + n;
|
||||
html.replace(search, MonsterRace.getInstance().getMonsters()[i].getTemplate().getName());
|
||||
}
|
||||
search = "No1";
|
||||
if (val == 0)
|
||||
{
|
||||
html.replace(search, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace(search, val);
|
||||
player.setRace(0, val);
|
||||
}
|
||||
}
|
||||
else if (val < 20)
|
||||
{
|
||||
if (player.getRace(0) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
html.setFile(player, getHtmlPath(getId(), 3, player));
|
||||
html.replace("0place", player.getRace(0));
|
||||
search = "Mob1";
|
||||
replace = MonsterRace.getInstance().getMonsters()[player.getRace(0) - 1].getTemplate().getName();
|
||||
html.replace(search, replace);
|
||||
search = "0adena";
|
||||
|
||||
if (val == 10)
|
||||
{
|
||||
html.replace(search, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
html.replace(search, TICKET_PRICES[val - 11]);
|
||||
player.setRace(1, val - 10);
|
||||
}
|
||||
}
|
||||
else if (val == 20)
|
||||
{
|
||||
if ((player.getRace(0) == 0) || (player.getRace(1) == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
html.setFile(player, getHtmlPath(getId(), 4, player));
|
||||
html.replace("0place", player.getRace(0));
|
||||
search = "Mob1";
|
||||
replace = MonsterRace.getInstance().getMonsters()[player.getRace(0) - 1].getTemplate().getName();
|
||||
html.replace(search, replace);
|
||||
search = "0adena";
|
||||
int price = TICKET_PRICES[player.getRace(1) - 1];
|
||||
html.replace(search, price);
|
||||
search = "0tax";
|
||||
int tax = 0;
|
||||
html.replace(search, tax);
|
||||
search = "0total";
|
||||
int total = price + tax;
|
||||
html.replace(search, total);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((player.getRace(0) == 0) || (player.getRace(1) == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int ticket = player.getRace(0);
|
||||
int priceId = player.getRace(1);
|
||||
|
||||
if (!player.reduceAdena("Race", TICKET_PRICES[priceId - 1], this, true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
player.setRace(0, 0);
|
||||
player.setRace(1, 0);
|
||||
|
||||
ItemInstance item = new ItemInstance(IdFactory.getInstance().getNextId(), 4443);
|
||||
item.setCount(1);
|
||||
item.setEnchantLevel(MonsterRace.getInstance().getRaceNumber());
|
||||
item.setCustomType1(ticket);
|
||||
item.setCustomType2(TICKET_PRICES[priceId - 1] / 100);
|
||||
|
||||
player.addItem("Race", item, player, false);
|
||||
final SystemMessage msg = new SystemMessage(SystemMessageId.ACQUIRED_S1_S2);
|
||||
msg.addInt(MonsterRace.getInstance().getRaceNumber());
|
||||
msg.addItemName(4443);
|
||||
player.sendPacket(msg);
|
||||
|
||||
// Refresh lane bet.
|
||||
MonsterRace.getInstance().setBetOnLane(ticket, TICKET_PRICES[priceId - 1], true);
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
html.replace("1race", MonsterRace.getInstance().getRaceNumber());
|
||||
html.replace("%objectId%", getObjectId());
|
||||
player.sendPacket(html);
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else if (command.equals("ShowOdds"))
|
||||
{
|
||||
if (!Config.ALLOW_RACE || (MonsterRace.getInstance().getCurrentRaceState() == RaceState.ACCEPTING_BETS))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.MONSTER_RACE_PAYOUT_INFORMATION_IS_NOT_AVAILABLE_WHILE_TICKETS_ARE_BEING_SOLD);
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
|
||||
html.setFile(player, getHtmlPath(getId(), 5, player));
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
final int n = i + 1;
|
||||
|
||||
html.replace("Mob" + n, MonsterRace.getInstance().getMonsters()[i].getTemplate().getName());
|
||||
|
||||
// Odd
|
||||
final double odd = MonsterRace.getInstance().getOdds().get(i);
|
||||
html.replace("Odd" + n, (odd > 0D) ? String.format(Locale.ENGLISH, "%.1f", odd) : "&$804;");
|
||||
}
|
||||
html.replace("1race", MonsterRace.getInstance().getRaceNumber());
|
||||
html.replace("%objectId%", getObjectId());
|
||||
player.sendPacket(html);
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else if (command.equals("ShowInfo"))
|
||||
{
|
||||
if (!Config.ALLOW_RACE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
|
||||
html.setFile(player, getHtmlPath(getId(), 6, player));
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int n = i + 1;
|
||||
String search = "Mob" + n;
|
||||
html.replace(search, MonsterRace.getInstance().getMonsters()[i].getTemplate().getName());
|
||||
}
|
||||
html.replace("%objectId%", getObjectId());
|
||||
player.sendPacket(html);
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else if (command.equals("ShowTickets"))
|
||||
{
|
||||
if (!Config.ALLOW_RACE)
|
||||
{
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate data.
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
// Retrieve player's tickets.
|
||||
for (ItemInstance ticket : player.getInventory().getAllItemsByItemId(4443))
|
||||
{
|
||||
// Don't list current race tickets.
|
||||
if (ticket.getEnchantLevel() == MonsterRace.getInstance().getRaceNumber())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
StringUtil.append(sb, "<tr><td><a action=\"bypass -h npc_%objectId%_ShowTicket ", "" + ticket.getObjectId(), "\">", "" + ticket.getEnchantLevel(), " Race Number</a></td><td align=right><font color=\"LEVEL\">", "" + ticket.getCustomType1(), "</font> Number</td><td align=right><font color=\"LEVEL\">", "" + (ticket.getCustomType2() * 100), "</font> Adena</td></tr>");
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
|
||||
html.setFile(player, getHtmlPath(getId(), 7, player));
|
||||
html.replace("%tickets%", sb.toString());
|
||||
html.replace("%objectId%", getObjectId());
|
||||
player.sendPacket(html);
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else if (command.startsWith("ShowTicket"))
|
||||
{
|
||||
// Retrieve ticket objectId.
|
||||
final int val = Integer.parseInt(command.substring(11));
|
||||
if (!Config.ALLOW_RACE || (val == 0))
|
||||
{
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
// Retrieve ticket on player's inventory.
|
||||
final ItemInstance ticket = player.getInventory().getItemByObjectId(val);
|
||||
if (ticket == null)
|
||||
{
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
final int raceId = ticket.getEnchantLevel();
|
||||
final int lane = ticket.getCustomType1();
|
||||
final int bet = ticket.getCustomType2() * 100;
|
||||
|
||||
// Retrieve HistoryInfo for that race.
|
||||
final HistoryInfo info = MonsterRace.getInstance().getHistory().get(raceId - 1);
|
||||
if (info == null)
|
||||
{
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
|
||||
html.setFile(player, getHtmlPath(getId(), 8, player));
|
||||
html.replace("%raceId%", raceId);
|
||||
html.replace("%lane%", lane);
|
||||
html.replace("%bet%", bet);
|
||||
html.replace("%firstLane%", info.getFirst());
|
||||
html.replace("%odd%", (lane == info.getFirst()) ? String.format(Locale.ENGLISH, "%.2f", info.getOddRate()) : "0.01");
|
||||
html.replace("%objectId%", getObjectId());
|
||||
html.replace("%ticketObjectId%", val);
|
||||
player.sendPacket(html);
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else if (command.startsWith("CalculateWin"))
|
||||
{
|
||||
// Retrieve ticket objectId.
|
||||
final int val = Integer.parseInt(command.substring(13));
|
||||
if (!Config.ALLOW_RACE || (val == 0))
|
||||
{
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete ticket on player's inventory.
|
||||
final ItemInstance ticket = player.getInventory().getItemByObjectId(val);
|
||||
if (ticket == null)
|
||||
{
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
final int raceId = ticket.getEnchantLevel();
|
||||
final int lane = ticket.getCustomType1();
|
||||
final int bet = ticket.getCustomType2() * 100;
|
||||
|
||||
// Retrieve HistoryInfo for that race.
|
||||
final HistoryInfo info = MonsterRace.getInstance().getHistory().get(raceId - 1);
|
||||
if (info == null)
|
||||
{
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
// Destroy the ticket.
|
||||
if (player.destroyItem("MonsterTrack", ticket, this, true))
|
||||
{
|
||||
player.addAdena("MonsterTrack", (int) (bet * ((lane == info.getFirst()) ? info.getOddRate() : 0.01)), this, true);
|
||||
}
|
||||
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
else if (command.equals("ViewHistory"))
|
||||
{
|
||||
if (!Config.ALLOW_RACE)
|
||||
{
|
||||
super.onBypassFeedback(player, "Chat 0");
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate data.
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
// Use whole history, pickup from 'last element' and stop at 'latest element - 7'.
|
||||
final List<HistoryInfo> history = MonsterRace.getInstance().getHistory();
|
||||
for (int i = history.size() - 1; i >= Math.max(0, history.size() - 7); i--)
|
||||
{
|
||||
final HistoryInfo info = history.get(i);
|
||||
StringUtil.append(sb, "<tr><td><font color=\"LEVEL\">", "" + info.getRaceId(), "</font> th</td><td><font color=\"LEVEL\">", "" + info.getFirst(), "</font> Lane </td><td><font color=\"LEVEL\">", "" + info.getSecond(), "</font> Lane</td><td align=right><font color=00ffff>", String.format(Locale.ENGLISH, "%.2f", info.getOddRate()), "</font> Times</td></tr>");
|
||||
}
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
|
||||
html.setFile(player, getHtmlPath(getId(), 9, player));
|
||||
html.replace("%infos%", sb.toString());
|
||||
html.replace("%objectId%", getObjectId());
|
||||
player.sendPacket(html);
|
||||
player.sendPacket(ActionFailed.STATIC_PACKET);
|
||||
}
|
||||
else
|
||||
{
|
||||
super.onBypassFeedback(player, command);
|
||||
}
|
||||
}
|
||||
}
|
@@ -20,10 +20,12 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Summon;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneType;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CharInfo;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
|
||||
@@ -191,4 +193,29 @@ public class Broadcast
|
||||
{
|
||||
toAllOnlinePlayers(new ExShowScreenMessage(text, 10000));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a packet to all players in a specific zone type.
|
||||
* @param <T> ZoneType.
|
||||
* @param zoneType : The zone type to send packets.
|
||||
* @param packets : The packets to send.
|
||||
*/
|
||||
public static <T extends ZoneType> void toAllPlayersInZoneType(Class<T> zoneType, IClientOutgoingPacket... packets)
|
||||
{
|
||||
for (ZoneType zone : ZoneManager.getInstance().getAllZones(zoneType))
|
||||
{
|
||||
for (Creature creature : zone.getCharactersInside())
|
||||
{
|
||||
if (creature == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (IClientOutgoingPacket packet : packets)
|
||||
{
|
||||
creature.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user