mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-08-04 04:15:52 -04:00
Optimized all gambling devices and scripts.
This commit is contained in:
Regular → Executable
+1
@@ -5,5 +5,6 @@
|
||||
|
||||
sharedTemplate = "object/tangible/gambling/slot/shared_standard.iff"
|
||||
scripts = ["gambling.slot.standard"]
|
||||
objvars = +["gambling.table.bet.ante" = 0, "gambling.table.bet.max" = 3, "gambling.table.bet.min" = 1, "gambling.table.playerLimit.max" = 1, "gambling.table.playerLimit.min" = 1, "gambling.table.type" = "slot_standard"]
|
||||
|
||||
moveFlags = [ MF_player ]
|
||||
|
||||
Regular → Executable
+1
@@ -5,5 +5,6 @@
|
||||
|
||||
sharedTemplate = "object/tangible/gambling/wheel/shared_roulette.iff"
|
||||
scripts = ["gambling.wheel.roulette"]
|
||||
objvars = +["gambling.table.bet.ante" = 0, "gambling.table.bet.max" = 10000, "gambling.table.bet.min" = 1, "gambling.table.playerLimit.max" = 10, "gambling.table.playerLimit.min" = 1, "gambling.table.type" = "roulette"]
|
||||
|
||||
moveFlags = [ MF_player ]
|
||||
|
||||
Regular → Executable
-14
@@ -1,19 +1,5 @@
|
||||
package script.gambling.base;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
import script.library.prose;
|
||||
import script.library.money;
|
||||
import script.library.gambling;
|
||||
|
||||
public class card extends script.gambling.base.default_interface
|
||||
{
|
||||
public card()
|
||||
|
||||
Regular → Executable
+14
-23
@@ -1,41 +1,34 @@
|
||||
package script.gambling.base;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
import script.library.prose;
|
||||
import script.library.money;
|
||||
import script.library.gambling;
|
||||
import script.library.prose;
|
||||
import script.library.utils;
|
||||
|
||||
public class default_interface extends script.terminal.base.base_terminal
|
||||
{
|
||||
public default_interface()
|
||||
{
|
||||
}
|
||||
public static final float BET_RANGE = 15f;
|
||||
public static final string_id MNU_JOIN = new string_id(gambling.STF_INTERFACE, "mnu_join");
|
||||
public static final string_id MNU_LEAVE = new string_id(gambling.STF_INTERFACE, "mnu_leave");
|
||||
public static final string_id STOP_GAMBLING = new string_id(gambling.STF_INTERFACE, "stop_gambling");
|
||||
private static final float BET_RANGE = 15f;
|
||||
private static final string_id MNU_JOIN = new string_id(gambling.STF_INTERFACE, "mnu_join");
|
||||
private static final string_id MNU_LEAVE = new string_id(gambling.STF_INTERFACE, "mnu_leave");
|
||||
private static final string_id STOP_GAMBLING = new string_id(gambling.STF_INTERFACE, "stop_gambling");
|
||||
public int OnObjectMenuRequest(obj_id self, obj_id player, menu_info mi) throws InterruptedException
|
||||
{
|
||||
if (!hasObjVar(self, gambling.VAR_GAMBLE_BASE))
|
||||
{
|
||||
System.out.println("gambling: no obj var found.");
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
System.out.println("gambling: obj var was found.");
|
||||
int max = getIntObjVar(self, gambling.VAR_TABLE_PLAYER_LIMIT_MAX);
|
||||
obj_id[] players = getObjIdArrayObjVar(self, gambling.VAR_TABLE_PLAYERS);
|
||||
if (players == null || players.length == 0)
|
||||
{
|
||||
if (utils.hasScriptVar(player, "isGambling"))
|
||||
if (utils.hasScriptVar(player, gambling.SCRIPTVAR_GAMBLING))
|
||||
{
|
||||
int mnuLeave = mi.addRootMenu(menu_info_types.SERVER_MENU2, MNU_LEAVE);
|
||||
mi.addRootMenu(menu_info_types.SERVER_MENU2, MNU_LEAVE);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
@@ -43,22 +36,21 @@ public class default_interface extends script.terminal.base.base_terminal
|
||||
{
|
||||
if (utils.getElementPositionInArray(players, player) > -1)
|
||||
{
|
||||
int mnuLeave = mi.addRootMenu(menu_info_types.SERVER_MENU2, MNU_LEAVE);
|
||||
mi.addRootMenu(menu_info_types.SERVER_MENU2, MNU_LEAVE);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
if (max > 0)
|
||||
{
|
||||
if (players.length >= max)
|
||||
{
|
||||
prose_package ppFull = prose.getPackage(gambling.PROSE_STATION_FULL, self);
|
||||
sendSystemMessageProse(player, ppFull);
|
||||
sendSystemMessageProse(player, prose.getPackage(gambling.PROSE_STATION_FULL, self));
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!utils.hasScriptVar(player, gambling.SCRIPTVAR_GAMBLING))
|
||||
{
|
||||
int mnuJoin = mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_JOIN);
|
||||
mi.addRootMenu(menu_info_types.SERVER_MENU1, MNU_JOIN);
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -81,8 +73,7 @@ public class default_interface extends script.terminal.base.base_terminal
|
||||
}
|
||||
if (item == menu_info_types.SERVER_MENU1)
|
||||
{
|
||||
int totalMoney = getTotalMoney(player);
|
||||
if (totalMoney < 1)
|
||||
if (getTotalMoney(player) < 1)
|
||||
{
|
||||
sendSystemMessage(player, gambling.SID_PLAYER_BROKE);
|
||||
return SCRIPT_CONTINUE;
|
||||
|
||||
Regular → Executable
+45
-63
@@ -1,19 +1,10 @@
|
||||
package script.gambling.base;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
import script.dictionary;
|
||||
import script.library.*;
|
||||
import script.obj_id;
|
||||
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
import script.library.prose;
|
||||
import script.library.money;
|
||||
import script.library.colors;
|
||||
import script.library.gambling;
|
||||
import java.util.Vector;
|
||||
|
||||
public class slot extends script.gambling.base.default_interface
|
||||
{
|
||||
@@ -192,28 +183,28 @@ public class slot extends script.gambling.base.default_interface
|
||||
switch (bp)
|
||||
{
|
||||
case sui.BP_OK:
|
||||
if (max > 0)
|
||||
{
|
||||
money.requestPayment(player, self, max - balance, "handleBetPlaced", null);
|
||||
}
|
||||
else
|
||||
{
|
||||
money.requestPayment(player, self, getTotalMoney(player), "handleBetPlaced", null);
|
||||
}
|
||||
break;
|
||||
if (max > 0)
|
||||
{
|
||||
money.requestPayment(player, self, max - balance, "handleBetPlaced", null);
|
||||
}
|
||||
else
|
||||
{
|
||||
money.requestPayment(player, self, getTotalMoney(player), "handleBetPlaced", null);
|
||||
}
|
||||
break;
|
||||
case sui.BP_CANCEL:
|
||||
if (balance == 0)
|
||||
{
|
||||
gambling.removeTablePlayer(self, player, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
spinReels(self, player, balance);
|
||||
}
|
||||
break;
|
||||
if (balance == 0)
|
||||
{
|
||||
gambling.removeTablePlayer(self, player, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
spinReels(self, player, balance);
|
||||
}
|
||||
break;
|
||||
case sui.BP_REVERT:
|
||||
money.requestPayment(player, self, 1, "handleBetPlaced", null);
|
||||
break;
|
||||
money.requestPayment(player, self, 1, "handleBetPlaced", null);
|
||||
break;
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -243,18 +234,18 @@ public class slot extends script.gambling.base.default_interface
|
||||
switch (rand(0, 1))
|
||||
{
|
||||
case 0:
|
||||
results[idx] = 0;
|
||||
break;
|
||||
results[idx] = 0;
|
||||
break;
|
||||
case 1:
|
||||
Vector reelOdds = utils.getResizeableIntBatchScriptVar(self, gambling.VAR_REEL_ODDS);
|
||||
if (reelOdds == null || reelOdds.size() == 0)
|
||||
{
|
||||
reelOdds = gambling.calculateReelOdds(self);
|
||||
utils.setBatchScriptVar(self, gambling.VAR_REEL_ODDS, reelOdds);
|
||||
}
|
||||
int tmpIdx = rand(0, reelOdds.size() - 1);
|
||||
results[idx] = (((Integer)(reelOdds.elementAt(tmpIdx)))).intValue();
|
||||
break;
|
||||
Vector reelOdds = utils.getResizeableIntBatchScriptVar(self, gambling.VAR_REEL_ODDS);
|
||||
if (reelOdds == null || reelOdds.size() == 0)
|
||||
{
|
||||
reelOdds = gambling.calculateReelOdds(self);
|
||||
utils.setBatchScriptVar(self, gambling.VAR_REEL_ODDS, reelOdds);
|
||||
}
|
||||
int tmpIdx = rand(0, reelOdds.size() - 1);
|
||||
results[idx] = (Integer) (reelOdds.elementAt(tmpIdx));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -269,7 +260,7 @@ public class slot extends script.gambling.base.default_interface
|
||||
if (idx == 0)
|
||||
{
|
||||
int tmpIdx = rand(0, reelOdds.size() - 1);
|
||||
results[0] = (((Integer)(reelOdds.elementAt(tmpIdx)))).intValue();
|
||||
results[0] = (Integer) (reelOdds.elementAt(tmpIdx));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -284,15 +275,11 @@ public class slot extends script.gambling.base.default_interface
|
||||
msg += "-- ";
|
||||
for (int i = 0; i < idx; i++)
|
||||
{
|
||||
msg += "|";
|
||||
msg += " " + results[i] + " ";
|
||||
msg += "| ";
|
||||
msg += "| " + results[i] + " | ";
|
||||
}
|
||||
for (int i = idx; i < results.length; i++)
|
||||
{
|
||||
msg += "|";
|
||||
msg += getString(gambling.SID_ROLLING);
|
||||
msg += "| ";
|
||||
msg += "| " + getString(gambling.SID_ROLLING) + " | ";
|
||||
}
|
||||
msg += "--";
|
||||
sendSystemMessageTestingOnly(player, msg);
|
||||
@@ -364,8 +351,7 @@ public class slot extends script.gambling.base.default_interface
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
int payout = params.getInt("payout");
|
||||
prose_package ppPayout = prose.getPackage(gambling.PROSE_PAYOUT, payout);
|
||||
sendSystemMessageProse(player, ppPayout);
|
||||
sendSystemMessageProse(player, prose.getPackage(gambling.PROSE_PAYOUT, payout));
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + player + ") " + getName(player) + " receives " + payout + "cr payout from (" + self + ") " + utils.getStringName(self));
|
||||
showFlyText(self, gambling.FLY_WINNER, 2f, colors.RED);
|
||||
messageTo(self, "handleDelayedRestart", params, 3f, false);
|
||||
@@ -389,7 +375,7 @@ public class slot extends script.gambling.base.default_interface
|
||||
}
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public void startSlotGame(obj_id self, obj_id player) throws InterruptedException
|
||||
private void startSlotGame(obj_id self, obj_id player) throws InterruptedException
|
||||
{
|
||||
if (!isIdValid(self) || !isIdValid(player))
|
||||
{
|
||||
@@ -403,7 +389,7 @@ public class slot extends script.gambling.base.default_interface
|
||||
}
|
||||
showSlotUi(self, player);
|
||||
}
|
||||
public void showSlotUi(obj_id self, obj_id player) throws InterruptedException
|
||||
private void showSlotUi(obj_id self, obj_id player) throws InterruptedException
|
||||
{
|
||||
if (!isIdValid(self) || !isIdValid(player))
|
||||
{
|
||||
@@ -459,7 +445,7 @@ public class slot extends script.gambling.base.default_interface
|
||||
d.put("stamp", now);
|
||||
messageTo(self, "handleBetTimer", d, 60f, false);
|
||||
}
|
||||
public void spinReels(obj_id self, obj_id player, int amt) throws InterruptedException
|
||||
private void spinReels(obj_id self, obj_id player, int amt) throws InterruptedException
|
||||
{
|
||||
if (!isIdValid(self) || !isIdValid(player) || amt < 1)
|
||||
{
|
||||
@@ -487,7 +473,7 @@ public class slot extends script.gambling.base.default_interface
|
||||
sendSystemMessageTestingOnly(player, "You activate the machine and the reels start spinning...");
|
||||
messageTo(self, "handleReelsSpinning", d, 5f, false);
|
||||
}
|
||||
public void showPayoutSchedule(obj_id self, obj_id player) throws InterruptedException
|
||||
private void showPayoutSchedule(obj_id self, obj_id player) throws InterruptedException
|
||||
{
|
||||
String gameType = getStringObjVar(self, gambling.VAR_TABLE_TYPE);
|
||||
if (gameType == null || gameType.equals(""))
|
||||
@@ -524,11 +510,7 @@ public class slot extends script.gambling.base.default_interface
|
||||
{
|
||||
return;
|
||||
}
|
||||
String title = "Payout Schedule";
|
||||
String prompt = "The following is the payout schedule for this slot machine.\n\n";
|
||||
prompt += "Legend:\n";
|
||||
prompt += "XXX: denotes any 3 of the same number\n";
|
||||
prompt += "*X|Y|Z: denotes any combination of the 3 numbers\n";
|
||||
sui.listbox(self, player, prompt, sui.OK_ONLY, title, entries, "noHandler");
|
||||
String prompt = "The following is the payout schedule for this slot machine.\n\nLegend:\nXXX: denotes any 3 of the same number\n*X|Y|Z: denotes any combination of the 3 numbers\n";
|
||||
sui.listbox(self, player, prompt, sui.OK_ONLY, "Payout Schedule", entries, "noHandler");
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
+31
-57
@@ -1,26 +1,20 @@
|
||||
package script.gambling.base;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
import script.dictionary;
|
||||
import script.library.*;
|
||||
import script.obj_id;
|
||||
import script.prose_package;
|
||||
import script.string_id;
|
||||
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
import script.library.prose;
|
||||
import script.library.money;
|
||||
import script.library.gambling;
|
||||
import java.util.Vector;
|
||||
|
||||
public class table extends script.gambling.base.default_interface
|
||||
{
|
||||
public table()
|
||||
{
|
||||
}
|
||||
public static final int TIMER_BETTING = 60;
|
||||
public static final String SCRIPT_VAR_GAME_ACTIVE = "gambling.game.active";
|
||||
private static final int TIMER_BETTING = 60;
|
||||
protected static final String SCRIPT_VAR_GAME_ACTIVE = "gambling.game.active";
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, gambling.VAR_TABLE_PLAYERS);
|
||||
@@ -44,11 +38,9 @@ public class table extends script.gambling.base.default_interface
|
||||
if (players != null && players.length > 0)
|
||||
{
|
||||
prose_package ppJoinOther = prose.getPackage(gambling.PROSE_PLAYER_JOIN_OTHER, player);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
if (players[i] != player)
|
||||
{
|
||||
sendSystemMessageProse(players[i], ppJoinOther);
|
||||
for (obj_id player1 : players) {
|
||||
if (player1 != player) {
|
||||
sendSystemMessageProse(player1, ppJoinOther);
|
||||
}
|
||||
}
|
||||
if (!utils.hasScriptVar(self, gambling.VAR_TABLE_BET_ACCEPT))
|
||||
@@ -132,9 +124,8 @@ public class table extends script.gambling.base.default_interface
|
||||
if (players != null && players.length > 0)
|
||||
{
|
||||
prose_package ppLeftOther = prose.getPackage(gambling.PROSE_PLAYER_LEAVE_OTHER, player);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessageProse(players[i], ppLeftOther);
|
||||
for (obj_id player1 : players) {
|
||||
sendSystemMessageProse(player1, ppLeftOther);
|
||||
}
|
||||
}
|
||||
if (players.length < getIntObjVar(self, gambling.VAR_TABLE_PLAYER_LIMIT_MIN))
|
||||
@@ -232,9 +223,8 @@ public class table extends script.gambling.base.default_interface
|
||||
if (diff > 0)
|
||||
{
|
||||
prose_package ppTimeLeft = prose.getPackage(gambling.PROSE_STARTING_IN, diff);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessageProse(players[i], ppTimeLeft);
|
||||
for (obj_id player : players) {
|
||||
sendSystemMessageProse(player, ppTimeLeft);
|
||||
}
|
||||
}
|
||||
if (diff > 30)
|
||||
@@ -254,7 +244,7 @@ public class table extends script.gambling.base.default_interface
|
||||
public void showBetUi(obj_id self, obj_id player) throws InterruptedException
|
||||
{
|
||||
}
|
||||
public void startTableBetting(obj_id self) throws InterruptedException
|
||||
protected void startTableBetting(obj_id self) throws InterruptedException
|
||||
{
|
||||
obj_id[] players = getObjIdArrayObjVar(self, gambling.VAR_TABLE_PLAYERS);
|
||||
if (players == null || players.length == 0)
|
||||
@@ -264,33 +254,25 @@ public class table extends script.gambling.base.default_interface
|
||||
setObjVar(self, gambling.VAR_GAME_PLAYERS_IDS, players);
|
||||
int stampTime = getGameTime() + TIMER_BETTING;
|
||||
utils.setScriptVar(self, gambling.VAR_TABLE_BET_ACCEPT, stampTime);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessage(players[i], gambling.SID_PLACE_BETS);
|
||||
showBetUi(self, players[i]);
|
||||
for (obj_id player : players) {
|
||||
sendSystemMessage(player, gambling.SID_PLACE_BETS);
|
||||
showBetUi(self, player);
|
||||
}
|
||||
dictionary d = new dictionary();
|
||||
d.put("stamp", stampTime);
|
||||
messageTo(self, "handleBetTimer", d, 30f, false);
|
||||
return;
|
||||
}
|
||||
public void startTableGame(obj_id self) throws InterruptedException
|
||||
{
|
||||
return;
|
||||
}
|
||||
public void stopTableGame(obj_id self) throws InterruptedException
|
||||
protected void stopTableGame(obj_id self) throws InterruptedException
|
||||
{
|
||||
utils.removeScriptVar(self, gambling.VAR_TABLE_BET_ACCEPT);
|
||||
removeObjVar(self, gambling.VAR_GAME_BASE);
|
||||
return;
|
||||
}
|
||||
public boolean updateBetSUI(obj_id table, obj_id player) throws InterruptedException
|
||||
protected boolean updateBetSUI(obj_id table, obj_id player) throws InterruptedException
|
||||
{
|
||||
if (!isIdValid(table))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!isIdValid(player))
|
||||
if (!isIdValid(table) || !isIdValid(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -308,11 +290,7 @@ public class table extends script.gambling.base.default_interface
|
||||
}
|
||||
public boolean closeBetSUI(obj_id table, obj_id player) throws InterruptedException
|
||||
{
|
||||
if (!isIdValid(table))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!isIdValid(player))
|
||||
if (!isIdValid(table) || !isIdValid(player))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -325,7 +303,7 @@ public class table extends script.gambling.base.default_interface
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean sendTableMessage(obj_id table, prose_package pp, obj_id ommit_player) throws InterruptedException
|
||||
protected boolean sendTableMessage(obj_id table, prose_package pp, obj_id ommit_player) throws InterruptedException
|
||||
{
|
||||
if (!isIdValid(table))
|
||||
{
|
||||
@@ -338,11 +316,9 @@ public class table extends script.gambling.base.default_interface
|
||||
obj_id[] players = getObjIdArrayObjVar(table, gambling.VAR_TABLE_PLAYERS);
|
||||
if (players != null)
|
||||
{
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
if (players[i] != ommit_player)
|
||||
{
|
||||
sendSystemMessageProse(players[i], pp);
|
||||
for (obj_id player : players) {
|
||||
if (player != ommit_player) {
|
||||
sendSystemMessageProse(player, pp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,18 +328,16 @@ public class table extends script.gambling.base.default_interface
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean sendTableMessage(obj_id table, prose_package pp) throws InterruptedException
|
||||
protected boolean sendTableMessage(obj_id table, prose_package pp) throws InterruptedException
|
||||
{
|
||||
return sendTableMessage(table, pp, null);
|
||||
}
|
||||
public boolean sendTableMessage(obj_id table, string_id message, obj_id ommit_player) throws InterruptedException
|
||||
{
|
||||
prose_package pp = prose.getPackage(message, table);
|
||||
return sendTableMessage(table, pp, ommit_player);
|
||||
return sendTableMessage(table, prose.getPackage(message, table), ommit_player);
|
||||
}
|
||||
public boolean sendTableMessage(obj_id table, string_id message) throws InterruptedException
|
||||
protected boolean sendTableMessage(obj_id table, string_id message) throws InterruptedException
|
||||
{
|
||||
prose_package pp = prose.getPackage(message, table);
|
||||
return sendTableMessage(table, pp, null);
|
||||
return sendTableMessage(table, prose.getPackage(message, table), null);
|
||||
}
|
||||
}
|
||||
|
||||
Regular → Executable
+24
-39
@@ -1,26 +1,16 @@
|
||||
package script.gambling.base;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
import script.library.*;
|
||||
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
import script.library.prose;
|
||||
import script.library.money;
|
||||
import script.library.colors;
|
||||
import script.library.gambling;
|
||||
import java.util.Vector;
|
||||
|
||||
public class wheel extends script.gambling.base.default_interface
|
||||
{
|
||||
public wheel()
|
||||
{
|
||||
}
|
||||
public static final int TIMER_BETTING = 120;
|
||||
private static final int TIMER_BETTING = 120;
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
removeObjVar(self, gambling.VAR_TABLE_PLAYERS);
|
||||
@@ -46,11 +36,9 @@ public class wheel extends script.gambling.base.default_interface
|
||||
if (players != null && players.length > 0)
|
||||
{
|
||||
prose_package ppJoinOther = prose.getPackage(gambling.PROSE_PLAYER_JOIN_OTHER, player);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
if (players[i] != player)
|
||||
{
|
||||
sendSystemMessageProse(players[i], ppJoinOther);
|
||||
for (obj_id player1 : players) {
|
||||
if (player1 != player) {
|
||||
sendSystemMessageProse(player1, ppJoinOther);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,9 +96,8 @@ public class wheel extends script.gambling.base.default_interface
|
||||
if (players != null && players.length > 0)
|
||||
{
|
||||
prose_package ppLeftOther = prose.getPackage(gambling.PROSE_PLAYER_LEAVE_OTHER, player);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessageProse(players[i], ppLeftOther);
|
||||
for (obj_id player1 : players) {
|
||||
sendSystemMessageProse(player1, ppLeftOther);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -192,9 +179,8 @@ public class wheel extends script.gambling.base.default_interface
|
||||
if (diff > 0)
|
||||
{
|
||||
prose_package ppTimeLeft = prose.getPackage(gambling.PROSE_STARTING_IN, diff);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessageProse(players[i], ppTimeLeft);
|
||||
for (obj_id player : players) {
|
||||
sendSystemMessageProse(player, ppTimeLeft);
|
||||
}
|
||||
}
|
||||
if (diff > 30)
|
||||
@@ -224,8 +210,7 @@ public class wheel extends script.gambling.base.default_interface
|
||||
}
|
||||
int payout = params.getInt("payout");
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + player + ") " + getName(player) + " receives wheel payout for " + payout + " from (" + self + ") " + utils.getStringName(self));
|
||||
prose_package ppPayout = prose.getPackage(gambling.PROSE_PAYOUT, payout);
|
||||
sendSystemMessageProse(player, ppPayout);
|
||||
sendSystemMessageProse(player, prose.getPackage(gambling.PROSE_PAYOUT, payout));
|
||||
showFlyText(player, gambling.FLY_WINNER, 1f, colors.RED);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
@@ -246,8 +231,7 @@ public class wheel extends script.gambling.base.default_interface
|
||||
return;
|
||||
}
|
||||
String title = "@gambling/game_n:" + gameType;
|
||||
String prompt = "The following is a summary of your current bets...\n\n";
|
||||
prompt += "Use /bet <amount> <1-36,0,00,red,black,odd,even,high,low> to wager.\n";
|
||||
String prompt = "The following is a summary of your current bets...\n\nUse /bet <amount> <1-36,0,00,red,black,odd,even,high,low> to wager.\n";
|
||||
prompt += "Example: '/bet 5 black' to wager 5 credits on black\n\n";
|
||||
prompt += "Cash : " + getCashBalance(player) + "\n";
|
||||
prompt += "Bank : " + getBankBalance(player) + "\n";
|
||||
@@ -268,12 +252,15 @@ public class wheel extends script.gambling.base.default_interface
|
||||
if (ovl != null)
|
||||
{
|
||||
int numItems = ovl.getNumItems();
|
||||
obj_var ov;
|
||||
String name;
|
||||
String entry;
|
||||
for (int i = 0; i < numItems; i++)
|
||||
{
|
||||
obj_var ov = ovl.getObjVar(i);
|
||||
String name = ov.getName();
|
||||
ov = ovl.getObjVar(i);
|
||||
name = ov.getName();
|
||||
int val = ov.getIntData();
|
||||
String entry = name + ":";
|
||||
entry = name + ":";
|
||||
for (int x = name.length(); x < 8; x++)
|
||||
{
|
||||
entry += " ";
|
||||
@@ -305,10 +292,9 @@ public class wheel extends script.gambling.base.default_interface
|
||||
setObjVar(self, gambling.VAR_GAME_PLAYERS_IDS, players);
|
||||
int stampTime = getGameTime() + TIMER_BETTING;
|
||||
utils.setScriptVar(self, gambling.VAR_TABLE_BET_ACCEPT, stampTime);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessage(players[i], gambling.SID_PLACE_BETS);
|
||||
showBetUi(self, players[i]);
|
||||
for (obj_id player : players) {
|
||||
sendSystemMessage(player, gambling.SID_PLACE_BETS);
|
||||
showBetUi(self, player);
|
||||
}
|
||||
dictionary d = new dictionary();
|
||||
d.put("stamp", stampTime);
|
||||
@@ -319,7 +305,7 @@ public class wheel extends script.gambling.base.default_interface
|
||||
utils.removeScriptVar(self, gambling.VAR_TABLE_BET_ACCEPT);
|
||||
removeObjVar(self, gambling.VAR_GAME_BASE);
|
||||
}
|
||||
public void spinWheel(obj_id self) throws InterruptedException
|
||||
private void spinWheel(obj_id self) throws InterruptedException
|
||||
{
|
||||
if (!isIdValid(self))
|
||||
{
|
||||
@@ -331,9 +317,8 @@ public class wheel extends script.gambling.base.default_interface
|
||||
return;
|
||||
}
|
||||
utils.removeScriptVar(self, gambling.VAR_TABLE_BET_ACCEPT);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessage(players[i], new string_id(gambling.STF_INTERFACE, "wheel_spin"));
|
||||
for (obj_id player : players) {
|
||||
sendSystemMessage(player, new string_id(gambling.STF_INTERFACE, "wheel_spin"));
|
||||
}
|
||||
dictionary d = new dictionary();
|
||||
d.put("cnt", 3);
|
||||
|
||||
Regular → Executable
+304
-470
File diff suppressed because it is too large
Load Diff
Regular → Executable
+2
-9
@@ -1,21 +1,14 @@
|
||||
package script.gambling.slot;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.gambling;
|
||||
import script.obj_id;
|
||||
|
||||
public class standard extends script.gambling.base.slot
|
||||
{
|
||||
public standard()
|
||||
{
|
||||
}
|
||||
public static final String GAME_TYPE = "slot_standard";
|
||||
private static final String GAME_TYPE = "slot_standard";
|
||||
public static final String TBL = "datatables/gambling/slot/" + GAME_TYPE + ".iff";
|
||||
public int OnInitialize(obj_id self) throws InterruptedException
|
||||
{
|
||||
|
||||
Regular → Executable
+70
-104
@@ -1,26 +1,18 @@
|
||||
package script.gambling.wheel;
|
||||
|
||||
import script.*;
|
||||
import script.base_class.*;
|
||||
import script.combat_engine.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Vector;
|
||||
import script.base_script;
|
||||
|
||||
import script.library.sui;
|
||||
import script.library.utils;
|
||||
import script.library.money;
|
||||
import script.library.prose;
|
||||
import script.library.gambling;
|
||||
import script.dictionary;
|
||||
import script.library.*;
|
||||
import script.obj_id;
|
||||
import script.prose_package;
|
||||
import script.string_id;
|
||||
|
||||
public class roulette extends script.gambling.base.wheel
|
||||
{
|
||||
public roulette()
|
||||
{
|
||||
}
|
||||
public static final String GAME_TYPE = "roulette";
|
||||
public static final int[] RED_NUMBERS =
|
||||
private static final String GAME_TYPE = "roulette";
|
||||
private static final int[] RED_NUMBERS =
|
||||
{
|
||||
1,
|
||||
3,
|
||||
@@ -138,43 +130,38 @@ public class roulette extends script.gambling.base.wheel
|
||||
switch (cnt)
|
||||
{
|
||||
case 2:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessage(players[i], new string_id(gambling.STF_INTERFACE, "wheel_begin_slow"));
|
||||
}
|
||||
break;
|
||||
for (obj_id player : players) {
|
||||
sendSystemMessage(player, new string_id(gambling.STF_INTERFACE, "wheel_begin_slow"));
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
int result = getResult();
|
||||
String sResult = getResultString(result);
|
||||
prose_package pp = prose.getPackage(new string_id(gambling.STF_INTERFACE, "prose_wheel_slow"), sResult, getResultColor(result));
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessageProse(players[i], pp);
|
||||
}
|
||||
params.put("result", result);
|
||||
delay = 10f;
|
||||
break;
|
||||
int result = getResult();
|
||||
String sResult = getResultString(result);
|
||||
prose_package pp = prose.getPackage(new string_id(gambling.STF_INTERFACE, "prose_wheel_slow"), sResult, getResultColor(result));
|
||||
for (obj_id player : players) {
|
||||
sendSystemMessageProse(player, pp);
|
||||
}
|
||||
params.put("result", result);
|
||||
delay = 10f;
|
||||
break;
|
||||
default:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessage(players[i], new string_id(gambling.STF_INTERFACE, "wheel_spinning"));
|
||||
}
|
||||
break;
|
||||
for (obj_id player : players) {
|
||||
sendSystemMessage(player, new string_id(gambling.STF_INTERFACE, "wheel_spinning"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
messageTo(self, "handleWheelSpinning", params, delay, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
prose_package pp = null;
|
||||
int result = getResult();
|
||||
String newResult = getResultString(result);
|
||||
params.put("result", result);
|
||||
pp = prose.getPackage(new string_id(gambling.STF_INTERFACE, "prose_result_change"), newResult, getResultColor(result));
|
||||
prose_package pp = prose.getPackage(new string_id(gambling.STF_INTERFACE, "prose_result_change"), newResult, getResultColor(result));
|
||||
if (pp != null)
|
||||
{
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
sendSystemMessageProse(players[i], pp);
|
||||
for (obj_id player : players) {
|
||||
sendSystemMessageProse(player, pp);
|
||||
}
|
||||
}
|
||||
messageTo(self, "handleParseResults", params, 1f, false);
|
||||
@@ -197,87 +184,72 @@ public class roulette extends script.gambling.base.wheel
|
||||
String resultColor = getResultColor(result);
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + self + ") " + utils.getStringName(self) + " processing results...");
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + self + ") " + utils.getStringName(self) + " results: raw=" + result + " sResult=" + sResult + " color=" + resultColor);
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
int gameTime = getGameTime();
|
||||
String ovpath;
|
||||
dictionary d;
|
||||
for (obj_id player : players) {
|
||||
int total = 0;
|
||||
CustomerServiceLog("gambling", getGameTime() + ": player = " + players[i] + " : " + getName(players[i]));
|
||||
int playerIdx = gambling.getGamePlayerIndex(self, players[i]);
|
||||
if (playerIdx > -1)
|
||||
{
|
||||
String ovpath = gambling.VAR_GAME_PLAYERS + "." + playerIdx + ".bet." + sResult;
|
||||
if (hasObjVar(self, ovpath))
|
||||
{
|
||||
CustomerServiceLog("gambling", gameTime + ": player = " + player + " : " + getName(player));
|
||||
int playerIdx = gambling.getGamePlayerIndex(self, player);
|
||||
if (playerIdx > -1) {
|
||||
ovpath = gambling.VAR_GAME_PLAYERS + "." + playerIdx + ".bet." + sResult;
|
||||
if (hasObjVar(self, ovpath)) {
|
||||
int spotBet = getIntObjVar(self, ovpath);
|
||||
int spotPayout = (spotBet * 36) + spotBet;
|
||||
total += spotPayout;
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + players[i] + ") has spot bet -> payout = " + spotPayout);
|
||||
CustomerServiceLog("gambling", gameTime + ": (" + player + ") has spot bet -> payout = " + spotPayout);
|
||||
}
|
||||
if (result > 0)
|
||||
{
|
||||
if (result > 0) {
|
||||
ovpath = gambling.VAR_GAME_PLAYERS + "." + playerIdx + ".bet." + resultColor;
|
||||
if (hasObjVar(self, ovpath))
|
||||
{
|
||||
if (hasObjVar(self, ovpath)) {
|
||||
int colorBet = getIntObjVar(self, ovpath);
|
||||
int colorPayout = 2 * colorBet;
|
||||
total += colorPayout;
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + players[i] + ") has color bet -> payout = " + colorPayout);
|
||||
CustomerServiceLog("gambling", gameTime + ": (" + player + ") has color bet -> payout = " + colorPayout);
|
||||
}
|
||||
}
|
||||
if (result > 0)
|
||||
{
|
||||
if (result % 2 == 0)
|
||||
{
|
||||
if (result > 0) {
|
||||
if (result % 2 == 0) {
|
||||
ovpath = gambling.VAR_GAME_PLAYERS + "." + playerIdx + ".bet.even";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ovpath = gambling.VAR_GAME_PLAYERS + "." + playerIdx + ".bet.odd";
|
||||
}
|
||||
if (hasObjVar(self, ovpath))
|
||||
{
|
||||
if (hasObjVar(self, ovpath)) {
|
||||
int evenOddBet = getIntObjVar(self, ovpath);
|
||||
int evenOddPayout = 2 * evenOddBet;
|
||||
total += evenOddPayout;
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + players[i] + ") has even/odd bet -> payout = " + evenOddPayout);
|
||||
CustomerServiceLog("gambling", gameTime + ": (" + player + ") has even/odd bet -> payout = " + evenOddPayout);
|
||||
}
|
||||
}
|
||||
if (result > 0)
|
||||
{
|
||||
if (result > 18)
|
||||
{
|
||||
if (result > 0) {
|
||||
if (result > 18) {
|
||||
ovpath = gambling.VAR_GAME_PLAYERS + "." + playerIdx + ".bet.high";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
ovpath = gambling.VAR_GAME_PLAYERS + "." + playerIdx + ".bet.low";
|
||||
}
|
||||
if (hasObjVar(self, ovpath))
|
||||
{
|
||||
if (hasObjVar(self, ovpath)) {
|
||||
int hiLoBet = getIntObjVar(self, ovpath);
|
||||
int hiLoPayout = 2 * hiLoBet;
|
||||
total += hiLoPayout;
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + players[i] + ") has hi/low bet -> payout = " + hiLoPayout);
|
||||
CustomerServiceLog("gambling", gameTime + ": (" + player + ") has hi/low bet -> payout = " + hiLoPayout);
|
||||
}
|
||||
}
|
||||
}
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + players[i] + ") total payout = " + total);
|
||||
if (total > 0)
|
||||
{
|
||||
dictionary d = new dictionary();
|
||||
d.put("player", players[i]);
|
||||
CustomerServiceLog("gambling", getGameTime() + ": (" + player + ") total payout = " + total);
|
||||
if (total > 0) {
|
||||
d = new dictionary();
|
||||
d.put("player", player);
|
||||
d.put("payout", total);
|
||||
transferBankCreditsFromNamedAccount(money.ACCT_ROULETTE, players[i], total, "handleGamblingPayout", "noHandler", d);
|
||||
}
|
||||
else
|
||||
{
|
||||
sendSystemMessageTestingOnly(players[i], "Sorry, you did not win this round. Please try again.");
|
||||
transferBankCreditsFromNamedAccount(money.ACCT_ROULETTE, player, total, "handleGamblingPayout", "noHandler", d);
|
||||
} else {
|
||||
sendSystemMessageTestingOnly(player, "Sorry, you did not win this round. Please try again.");
|
||||
}
|
||||
}
|
||||
cleanupWheelGame(self);
|
||||
messageTo(self, "handleDelayedRestart", null, 10f, false);
|
||||
return SCRIPT_CONTINUE;
|
||||
}
|
||||
public boolean isValidBet(obj_id self, String arg) throws InterruptedException
|
||||
private boolean isValidBet(obj_id self, String arg) throws InterruptedException
|
||||
{
|
||||
if (!isIdValid(self) || arg == null || arg.equals(""))
|
||||
{
|
||||
@@ -292,17 +264,13 @@ public class roulette extends script.gambling.base.wheel
|
||||
return true;
|
||||
}
|
||||
int tmp = utils.stringToInt(arg);
|
||||
if (tmp >= 0 && tmp <= 36)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return tmp >= 0 && tmp <= 36;
|
||||
}
|
||||
public int getResult() throws InterruptedException
|
||||
{
|
||||
return rand(-1, 36);
|
||||
}
|
||||
public String getResultString(int roll) throws InterruptedException
|
||||
private String getResultString(int roll) throws InterruptedException
|
||||
{
|
||||
if (roll == -1)
|
||||
{
|
||||
@@ -317,7 +285,7 @@ public class roulette extends script.gambling.base.wheel
|
||||
{
|
||||
return getResultString(getResult());
|
||||
}
|
||||
public String getResultColor(int result) throws InterruptedException
|
||||
private String getResultColor(int result) throws InterruptedException
|
||||
{
|
||||
if (result == 0 || result == -1)
|
||||
{
|
||||
@@ -329,7 +297,7 @@ public class roulette extends script.gambling.base.wheel
|
||||
}
|
||||
return "black";
|
||||
}
|
||||
public void cleanupWheelGame(obj_id self) throws InterruptedException
|
||||
private void cleanupWheelGame(obj_id self) throws InterruptedException
|
||||
{
|
||||
int bank = getBankBalance(self);
|
||||
if (bank > 0)
|
||||
@@ -339,19 +307,17 @@ public class roulette extends script.gambling.base.wheel
|
||||
obj_id[] players = getObjIdArrayObjVar(self, gambling.VAR_GAME_PLAYERS_IDS);
|
||||
if (players != null && players.length > 0)
|
||||
{
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
int idx = gambling.getGamePlayerIndex(self, players[i]);
|
||||
String ovpath = gambling.VAR_GAME_PLAYERS + "." + players[i] + ".pid";
|
||||
if (utils.hasScriptVar(self, ovpath))
|
||||
{
|
||||
String ovpath;
|
||||
for (obj_id player : players) {
|
||||
int idx = gambling.getGamePlayerIndex(self, player);
|
||||
ovpath = gambling.VAR_GAME_PLAYERS + "." + player + ".pid";
|
||||
if (utils.hasScriptVar(self, ovpath)) {
|
||||
int oldpid = utils.getIntScriptVar(self, ovpath);
|
||||
sui.closeSUI(players[i], oldpid);
|
||||
sui.closeSUI(player, oldpid);
|
||||
}
|
||||
ovpath = gambling.VAR_GAME_PLAYERS + "." + idx + ".bet";
|
||||
if (!hasObjVar(self, ovpath))
|
||||
{
|
||||
gambling.removeTablePlayer(self, players[i], "");
|
||||
if (!hasObjVar(self, ovpath)) {
|
||||
gambling.removeTablePlayer(self, player, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user