From 2b05675da28567465b95cdb4b3c9ad17ebfebc02 Mon Sep 17 00:00:00 2001 From: Cekis Date: Wed, 4 May 2016 22:54:53 +0100 Subject: [PATCH] Optimized all gambling devices and scripts. --- .../tangible/gambling/slot/standard.tpf | 1 + .../tangible/gambling/wheel/roulette.tpf | 1 + .../game/script/gambling/base/card.java | 14 - .../gambling/base/default_interface.java | 37 +- .../game/script/gambling/base/slot.java | 108 +-- .../game/script/gambling/base/table.java | 88 +- .../game/script/gambling/base/wheel.java | 63 +- .../gambling/saarlac/saarlac_wheel.java | 774 +++++++----------- .../game/script/gambling/slot/standard.java | 11 +- .../game/script/gambling/wheel/roulette.java | 174 ++-- 10 files changed, 492 insertions(+), 779 deletions(-) mode change 100644 => 100755 sku.0/sys.server/compiled/game/object/tangible/gambling/slot/standard.tpf mode change 100644 => 100755 sku.0/sys.server/compiled/game/object/tangible/gambling/wheel/roulette.tpf mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/gambling/base/card.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/gambling/base/default_interface.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/gambling/base/slot.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/gambling/base/table.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/gambling/base/wheel.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/gambling/saarlac/saarlac_wheel.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/gambling/slot/standard.java mode change 100644 => 100755 sku.0/sys.server/compiled/game/script/gambling/wheel/roulette.java diff --git a/sku.0/sys.server/compiled/game/object/tangible/gambling/slot/standard.tpf b/sku.0/sys.server/compiled/game/object/tangible/gambling/slot/standard.tpf old mode 100644 new mode 100755 index 21c6841e7..0fdbf2757 --- a/sku.0/sys.server/compiled/game/object/tangible/gambling/slot/standard.tpf +++ b/sku.0/sys.server/compiled/game/object/tangible/gambling/slot/standard.tpf @@ -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 ] diff --git a/sku.0/sys.server/compiled/game/object/tangible/gambling/wheel/roulette.tpf b/sku.0/sys.server/compiled/game/object/tangible/gambling/wheel/roulette.tpf old mode 100644 new mode 100755 index 4b35fc243..c20fd965d --- a/sku.0/sys.server/compiled/game/object/tangible/gambling/wheel/roulette.tpf +++ b/sku.0/sys.server/compiled/game/object/tangible/gambling/wheel/roulette.tpf @@ -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 ] diff --git a/sku.0/sys.server/compiled/game/script/gambling/base/card.java b/sku.0/sys.server/compiled/game/script/gambling/base/card.java old mode 100644 new mode 100755 index aecf7278c..5264c68d2 --- a/sku.0/sys.server/compiled/game/script/gambling/base/card.java +++ b/sku.0/sys.server/compiled/game/script/gambling/base/card.java @@ -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() diff --git a/sku.0/sys.server/compiled/game/script/gambling/base/default_interface.java b/sku.0/sys.server/compiled/game/script/gambling/base/default_interface.java old mode 100644 new mode 100755 index 8a068c5da..9b46ed949 --- a/sku.0/sys.server/compiled/game/script/gambling/base/default_interface.java +++ b/sku.0/sys.server/compiled/game/script/gambling/base/default_interface.java @@ -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; diff --git a/sku.0/sys.server/compiled/game/script/gambling/base/slot.java b/sku.0/sys.server/compiled/game/script/gambling/base/slot.java old mode 100644 new mode 100755 index fc2794dd5..3fecef361 --- a/sku.0/sys.server/compiled/game/script/gambling/base/slot.java +++ b/sku.0/sys.server/compiled/game/script/gambling/base/slot.java @@ -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"); } } diff --git a/sku.0/sys.server/compiled/game/script/gambling/base/table.java b/sku.0/sys.server/compiled/game/script/gambling/base/table.java old mode 100644 new mode 100755 index 70d945efa..737190197 --- a/sku.0/sys.server/compiled/game/script/gambling/base/table.java +++ b/sku.0/sys.server/compiled/game/script/gambling/base/table.java @@ -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); } } diff --git a/sku.0/sys.server/compiled/game/script/gambling/base/wheel.java b/sku.0/sys.server/compiled/game/script/gambling/base/wheel.java old mode 100644 new mode 100755 index 8d8adfb1a..a69adfeb6 --- a/sku.0/sys.server/compiled/game/script/gambling/base/wheel.java +++ b/sku.0/sys.server/compiled/game/script/gambling/base/wheel.java @@ -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 <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 <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); diff --git a/sku.0/sys.server/compiled/game/script/gambling/saarlac/saarlac_wheel.java b/sku.0/sys.server/compiled/game/script/gambling/saarlac/saarlac_wheel.java old mode 100644 new mode 100755 index 9430bf673..456872ff5 --- a/sku.0/sys.server/compiled/game/script/gambling/saarlac/saarlac_wheel.java +++ b/sku.0/sys.server/compiled/game/script/gambling/saarlac/saarlac_wheel.java @@ -1,20 +1,9 @@ package script.gambling.saarlac; 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.money; -import script.library.gambling; -import script.library.prose; -import script.library.utils; -import script.library.sui; -import script.library.player_structure; -import script.sort; +import java.util.Vector; public class saarlac_wheel extends script.gambling.base.wheel { @@ -45,7 +34,7 @@ public class saarlac_wheel extends script.gambling.base.wheel "Arch Mesa(1 Push)", "Grand Arena Flats(1 Push)" }; - public static final int[] WHEEL_PROBABILITIES = + private static final int[] WHEEL_PROBABILITIES = { 500, 1000, @@ -63,7 +52,7 @@ public class saarlac_wheel extends script.gambling.base.wheel 400, 1 }; - public static final float[] PAYOUTS = + private static final float[] PAYOUTS = { 8.0f, 2.67f, @@ -87,56 +76,56 @@ public class saarlac_wheel extends script.gambling.base.wheel 2.67f, 1.16f }; - public static final int TIMER_BETTING = 40; - public static final String VAR_JABBA_POOL = "gambling.table.jabba_pool"; - public static final String VAR_OASIS_POOL = "gambling.table.oasis_pool"; - public static final String VAR_SAARLAC_POOL = "gambling.table.saarlac_pool"; - public static final String VAR_MONEY_IN = "gambling.table.money_in"; - public static final String VAR_MONEY_OUT = "gambling.table.money_out"; - public static final String VAR_JABBA_POOL_MIN = "gambling.table.jabba_pool_min"; - public static final String VAR_OASIS_POOL_MIN = "gambling.table.oasis_pool_min"; - public static final String VAR_SAARLAC_POOL_MIN = "gambling.table.saarlac_pool_min"; - public static final String VAR_TOTAL_BETS = "gambling.table.total_bets"; - public static final String VAR_ADMIN_SUI = "gambling.admin_sui"; - public static final string_id SID_WHEEL_SPIN = new string_id("gambling/saarlac_wheel", "wheel_spin"); - public static final string_id SID_INVALID_BET = new string_id("gambling/saarlac_wheel", "invalid_bet"); - public static final string_id SID_BET_ALREADY_PLACED = new string_id("gambling/saarlac_wheel", "bet_already_placed"); - public static final string_id SID_BET_PLACED_SELF = new string_id("gambling/saarlac_wheel", "bet_placed_self"); - public static final string_id SID_BET_PLACED_OTHER = new string_id("gambling/saarlac_wheel", "bet_placed_other"); - public static final string_id SID_BET_JABBA_POOL_EMPTY = new string_id("gambling/saarlac_wheel", "jabba_pool_empty"); - public static final string_id SID_BET_OASIS_POOL_EMPTY = new string_id("gambling/saarlac_wheel", "oasis_pool_empty"); - public static final string_id SID_BET_SAARLAC_POOL_EMPTY = new string_id("gambling/saarlac_wheel", "saarlac_pool_empty"); - public static final string_id SID_BET_JABBA_POOL_MAX = new string_id("gambling/saarlac_wheel", "jabba_pool_max"); - public static final string_id SID_BET_OASIS_POOL_MAX = new string_id("gambling/saarlac_wheel", "oasis_pool_max"); - public static final string_id SID_BET_SAARLAC_POOL_MAX = new string_id("gambling/saarlac_wheel", "saarlac_pool_max"); - public static final string_id SID_BET_PAYED_SELF = new string_id("gambling/saarlac_wheel", "bet_payed_self"); - public static final string_id SID_BET_LOST_SELF = new string_id("gambling/saarlac_wheel", "bet_lost_self"); - public static final string_id SID_BET_PAYED_OTHER = new string_id("gambling/saarlac_wheel", "bet_payed_other"); - public static final string_id SID_BET_LOST_OTHER = new string_id("gambling/saarlac_wheel", "bet_lost_other"); - public static final string_id SID_JACKPOT_WON_SELF = new string_id("gambling/saarlac_wheel", "jackpot_won_self"); - public static final string_id SID_JACKPOT_WON_OTHER = new string_id("gambling/saarlac_wheel", "jackpot_won_other"); - public static final string_id SID_BET_PUSH_SELF = new string_id("gambling/saarlac_wheel", "bet_push_self"); - public static final string_id SID_BET_PUSH_OTHER = new string_id("gambling/saarlac_wheel", "bet_push_other"); - public static final string_id SID_BET_PUSH_TO_PIT_SELF = new string_id("gambling/saarlac_wheel", "bet_push_to_pit_self"); - public static final string_id SID_BET_PUSH_TO_PIT_OTHER = new string_id("gambling/saarlac_wheel", "bet_push_to_pit_other"); - public static final string_id SID_BET_PUSH_TO_JABBA_SELF = new string_id("gambling/saarlac_wheel", "bet_push_to_jabba_self"); - public static final string_id SID_BET_PUSH_TO_JABBA_OTHER = new string_id("gambling/saarlac_wheel", "bet_push_to_jabba_other"); - public static final string_id SID_BET_PUSH_TO_OASIS_SELF = new string_id("gambling/saarlac_wheel", "bet_push_to_oasis_self"); - public static final string_id SID_BET_PUSH_TO_OASIS_OTHER = new string_id("gambling/saarlac_wheel", "bet_push_to_oasis_other"); - public static final string_id SID_NO_CASINO = new string_id("gambling/saarlac_wheel", "no_casino"); - public static final string_id SID_INSUFFICIENT_FUNDS = new string_id("gambling/saarlac_wheel", "insufficient_funds"); - public static final string_id SID_INSUFFICIENT_FUNDS_START = new string_id("gambling/saarlac_wheel", "insufficient_funds_start"); - public static final string_id SID_NOT_AN_ADMIN = new string_id("gambling/saarlac_wheel", "not_an_admin"); - public static final string_id SID_POOLS_RESET = new string_id("gambling/saarlac_wheel", "pools_reset"); - public static final string_id SID_CANT_DO_MAINTENANCE = new string_id("gambling/saarlac_wheel", "cant_do_maintenance"); - public static final string_id SID_JABBA_POOL_MIN_SET = new string_id("gambling/saarlac_wheel", "jabba_pool_min_set"); - public static final string_id SID_OASIS_POOL_MIN_SET = new string_id("gambling/saarlac_wheel", "oasis_pool_min_set"); - public static final string_id SID_SAARLAC_POOL_MIN_SET = new string_id("gambling/saarlac_wheel", "saarlac_pool_min_set"); - public static final string_id SID_MNU_ADMIN = new string_id("gambling/saarlac_wheel", "menu_admin"); - public static final string_id SID_MNU_POOL_RESET = new string_id("gambling/saarlac_wheel", "menu_pool_reset"); - public static final string_id SID_MNU_POOL_MINIMUM_JABBA = new string_id("gambling/saarlac_wheel", "menu_pool_minimum_jabba"); - public static final string_id SID_MNU_POOL_MINIMUM_OASIS = new string_id("gambling/saarlac_wheel", "menu_pool_minimum_oasis"); - public static final string_id SID_MNU_POOL_MINIMUM_SAARLAC = new string_id("gambling/saarlac_wheel", "menu_pool_minimum_saarlac"); + private static final int TIMER_BETTING = 40; + private static final String VAR_JABBA_POOL = "gambling.table.jabba_pool"; + private static final String VAR_OASIS_POOL = "gambling.table.oasis_pool"; + private static final String VAR_SAARLAC_POOL = "gambling.table.saarlac_pool"; + private static final String VAR_MONEY_IN = "gambling.table.money_in"; + private static final String VAR_MONEY_OUT = "gambling.table.money_out"; + private static final String VAR_JABBA_POOL_MIN = "gambling.table.jabba_pool_min"; + private static final String VAR_OASIS_POOL_MIN = "gambling.table.oasis_pool_min"; + private static final String VAR_SAARLAC_POOL_MIN = "gambling.table.saarlac_pool_min"; + private static final String VAR_TOTAL_BETS = "gambling.table.total_bets"; + private static final String VAR_ADMIN_SUI = "gambling.admin_sui"; + private static final string_id SID_WHEEL_SPIN = new string_id("gambling/saarlac_wheel", "wheel_spin"); + private static final string_id SID_INVALID_BET = new string_id("gambling/saarlac_wheel", "invalid_bet"); + private static final string_id SID_BET_ALREADY_PLACED = new string_id("gambling/saarlac_wheel", "bet_already_placed"); + private static final string_id SID_BET_PLACED_SELF = new string_id("gambling/saarlac_wheel", "bet_placed_self"); + private static final string_id SID_BET_PLACED_OTHER = new string_id("gambling/saarlac_wheel", "bet_placed_other"); + private static final string_id SID_BET_JABBA_POOL_EMPTY = new string_id("gambling/saarlac_wheel", "jabba_pool_empty"); + private static final string_id SID_BET_OASIS_POOL_EMPTY = new string_id("gambling/saarlac_wheel", "oasis_pool_empty"); + private static final string_id SID_BET_SAARLAC_POOL_EMPTY = new string_id("gambling/saarlac_wheel", "saarlac_pool_empty"); + private static final string_id SID_BET_JABBA_POOL_MAX = new string_id("gambling/saarlac_wheel", "jabba_pool_max"); + private static final string_id SID_BET_OASIS_POOL_MAX = new string_id("gambling/saarlac_wheel", "oasis_pool_max"); + private static final string_id SID_BET_SAARLAC_POOL_MAX = new string_id("gambling/saarlac_wheel", "saarlac_pool_max"); + private static final string_id SID_BET_PAYED_SELF = new string_id("gambling/saarlac_wheel", "bet_payed_self"); + private static final string_id SID_BET_LOST_SELF = new string_id("gambling/saarlac_wheel", "bet_lost_self"); + private static final string_id SID_BET_PAYED_OTHER = new string_id("gambling/saarlac_wheel", "bet_payed_other"); + private static final string_id SID_BET_LOST_OTHER = new string_id("gambling/saarlac_wheel", "bet_lost_other"); + private static final string_id SID_JACKPOT_WON_SELF = new string_id("gambling/saarlac_wheel", "jackpot_won_self"); + private static final string_id SID_JACKPOT_WON_OTHER = new string_id("gambling/saarlac_wheel", "jackpot_won_other"); + private static final string_id SID_BET_PUSH_SELF = new string_id("gambling/saarlac_wheel", "bet_push_self"); + private static final string_id SID_BET_PUSH_OTHER = new string_id("gambling/saarlac_wheel", "bet_push_other"); + private static final string_id SID_BET_PUSH_TO_PIT_SELF = new string_id("gambling/saarlac_wheel", "bet_push_to_pit_self"); + private static final string_id SID_BET_PUSH_TO_PIT_OTHER = new string_id("gambling/saarlac_wheel", "bet_push_to_pit_other"); + private static final string_id SID_BET_PUSH_TO_JABBA_SELF = new string_id("gambling/saarlac_wheel", "bet_push_to_jabba_self"); + private static final string_id SID_BET_PUSH_TO_JABBA_OTHER = new string_id("gambling/saarlac_wheel", "bet_push_to_jabba_other"); + private static final string_id SID_BET_PUSH_TO_OASIS_SELF = new string_id("gambling/saarlac_wheel", "bet_push_to_oasis_self"); + private static final string_id SID_BET_PUSH_TO_OASIS_OTHER = new string_id("gambling/saarlac_wheel", "bet_push_to_oasis_other"); + private static final string_id SID_NO_CASINO = new string_id("gambling/saarlac_wheel", "no_casino"); + private static final string_id SID_INSUFFICIENT_FUNDS = new string_id("gambling/saarlac_wheel", "insufficient_funds"); + private static final string_id SID_INSUFFICIENT_FUNDS_START = new string_id("gambling/saarlac_wheel", "insufficient_funds_start"); + private static final string_id SID_NOT_AN_ADMIN = new string_id("gambling/saarlac_wheel", "not_an_admin"); + private static final string_id SID_POOLS_RESET = new string_id("gambling/saarlac_wheel", "pools_reset"); + private static final string_id SID_CANT_DO_MAINTENANCE = new string_id("gambling/saarlac_wheel", "cant_do_maintenance"); + private static final string_id SID_JABBA_POOL_MIN_SET = new string_id("gambling/saarlac_wheel", "jabba_pool_min_set"); + private static final string_id SID_OASIS_POOL_MIN_SET = new string_id("gambling/saarlac_wheel", "oasis_pool_min_set"); + private static final string_id SID_SAARLAC_POOL_MIN_SET = new string_id("gambling/saarlac_wheel", "saarlac_pool_min_set"); + private static final string_id SID_MNU_ADMIN = new string_id("gambling/saarlac_wheel", "menu_admin"); + private static final string_id SID_MNU_POOL_RESET = new string_id("gambling/saarlac_wheel", "menu_pool_reset"); + private static final string_id SID_MNU_POOL_MINIMUM_JABBA = new string_id("gambling/saarlac_wheel", "menu_pool_minimum_jabba"); + private static final string_id SID_MNU_POOL_MINIMUM_OASIS = new string_id("gambling/saarlac_wheel", "menu_pool_minimum_oasis"); + private static final string_id SID_MNU_POOL_MINIMUM_SAARLAC = new string_id("gambling/saarlac_wheel", "menu_pool_minimum_saarlac"); public int OnInitialize(obj_id self) throws InterruptedException { reseed(getGameTime()); @@ -465,7 +454,7 @@ public class saarlac_wheel extends script.gambling.base.wheel } return null; } - public int wheelRollToIndex(int roll) throws InterruptedException + private int wheelRollToIndex(int roll) throws InterruptedException { int low_roll = 0; for (int i = 0; i < WHEEL_PROBABILITIES.length; i++) @@ -479,18 +468,15 @@ public class saarlac_wheel extends script.gambling.base.wheel } return -1; } - public String wheelIndexToName(int idx) throws InterruptedException + private String wheelIndexToName(int idx) throws InterruptedException { if (idx >= WHEEL_OUTCOMES.length) { return null; } - else - { - return WHEEL_OUTCOMES[idx]; - } + return WHEEL_OUTCOMES[idx]; } - public int wheelNameToIndex(String name) throws InterruptedException + private int wheelNameToIndex(String name) throws InterruptedException { if (name == null) { @@ -505,7 +491,7 @@ public class saarlac_wheel extends script.gambling.base.wheel } return -1; } - public boolean sendTableMessage(obj_id table, prose_package pp, obj_id ommit_player) throws InterruptedException + private boolean sendTableMessage(obj_id table, prose_package pp, obj_id ommit_player) throws InterruptedException { if (!isIdValid(table)) { @@ -518,11 +504,9 @@ public class saarlac_wheel extends script.gambling.base.wheel 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); } } } @@ -532,16 +516,15 @@ public class saarlac_wheel extends script.gambling.base.wheel } return true; } - public boolean sendTableMessage(obj_id table, prose_package pp) throws InterruptedException + private 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 + private 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 int getJabbaPool(obj_id table) throws InterruptedException + private int getJabbaPool(obj_id table) throws InterruptedException { if (!isIdValid(table)) { @@ -549,7 +532,7 @@ public class saarlac_wheel extends script.gambling.base.wheel } return getIntObjVar(table, VAR_JABBA_POOL); } - public int getOasisPool(obj_id table) throws InterruptedException + private int getOasisPool(obj_id table) throws InterruptedException { if (!isIdValid(table)) { @@ -557,7 +540,7 @@ public class saarlac_wheel extends script.gambling.base.wheel } return getIntObjVar(table, VAR_OASIS_POOL); } - public int getSaarlacPool(obj_id table) throws InterruptedException + private int getSaarlacPool(obj_id table) throws InterruptedException { if (!isIdValid(table)) { @@ -565,7 +548,7 @@ public class saarlac_wheel extends script.gambling.base.wheel } return getIntObjVar(table, VAR_SAARLAC_POOL); } - public int adjustJabbaPool(obj_id table, int amt) throws InterruptedException + private int adjustJabbaPool(obj_id table, int amt) throws InterruptedException { if (!isIdValid(table)) { @@ -584,7 +567,7 @@ public class saarlac_wheel extends script.gambling.base.wheel setObjVar(table, VAR_JABBA_POOL, current_amt); return current_amt; } - public int adjustOasisPool(obj_id table, int amt) throws InterruptedException + private int adjustOasisPool(obj_id table, int amt) throws InterruptedException { if (!isIdValid(table)) { @@ -603,7 +586,7 @@ public class saarlac_wheel extends script.gambling.base.wheel setObjVar(table, VAR_OASIS_POOL, current_amt); return current_amt; } - public int adjustSaarlacPool(obj_id table, int amt) throws InterruptedException + private int adjustSaarlacPool(obj_id table, int amt) throws InterruptedException { if (!isIdValid(table)) { @@ -622,7 +605,7 @@ public class saarlac_wheel extends script.gambling.base.wheel setObjVar(table, VAR_SAARLAC_POOL, current_amt); return current_amt; } - public boolean resetJabbaPool(obj_id table) throws InterruptedException + private boolean resetJabbaPool(obj_id table) throws InterruptedException { if (!isIdValid(table)) { @@ -636,7 +619,7 @@ public class saarlac_wheel extends script.gambling.base.wheel setObjVar(table, VAR_JABBA_POOL, jabba_pool_min); return true; } - public boolean resetOasisPool(obj_id table) throws InterruptedException + private boolean resetOasisPool(obj_id table) throws InterruptedException { if (!isIdValid(table)) { @@ -650,7 +633,7 @@ public class saarlac_wheel extends script.gambling.base.wheel setObjVar(table, VAR_OASIS_POOL, oasis_pool_min); return true; } - public boolean resetSaarlacPool(obj_id table) throws InterruptedException + private boolean resetSaarlacPool(obj_id table) throws InterruptedException { if (!isIdValid(table)) { @@ -664,7 +647,7 @@ public class saarlac_wheel extends script.gambling.base.wheel setObjVar(table, VAR_SAARLAC_POOL, saarlac_pool_min); return true; } - public int getTotalBetAmount(obj_id table) throws InterruptedException + private int getTotalBetAmount(obj_id table) throws InterruptedException { if (!isIdValid(table)) { @@ -674,12 +657,9 @@ public class saarlac_wheel extends script.gambling.base.wheel { return utils.getIntScriptVar(table, VAR_TOTAL_BETS); } - else - { - return 0; - } + return 0; } - public boolean hasBetBeenPlaced(obj_id table, int wheel_index) throws InterruptedException + private boolean hasBetBeenPlaced(obj_id table, int wheel_index) throws InterruptedException { if (!isIdValid(table)) { @@ -698,10 +678,8 @@ public class saarlac_wheel extends script.gambling.base.wheel String[] bets = getPlayerBets(table, i); if (bets != null) { - for (int j = 0; j < bets.length; j++) - { - if (bets[j].equals(wheel_name)) - { + for (String bet : bets) { + if (bet.equals(wheel_name)) { return true; } } @@ -710,13 +688,9 @@ public class saarlac_wheel extends script.gambling.base.wheel } return false; } - public String[] getPlayerBets(obj_id table, int player_index) throws InterruptedException + private String[] getPlayerBets(obj_id table, int player_index) throws InterruptedException { - if (!isIdValid(table)) - { - return null; - } - if (player_index < 0) + if (!isIdValid(table) || player_index < 0) { return null; } @@ -729,16 +703,14 @@ public class saarlac_wheel extends script.gambling.base.wheel String[] player_bets = new String[bet_list.getNumItems()]; for (int i = 0; i < bet_list.getNumItems(); i++) { - obj_var bet = bet_list.getObjVar(i); - String bet_name = bet.getName(); - player_bets[i] = bet.getName(); + player_bets[i] = bet_list.getObjVar(i).getName(); } return player_bets; } } return null; } - public Vector getPlayerBetIndices(obj_id table, int player_index) throws InterruptedException + private Vector getPlayerBetIndices(obj_id table, int player_index) throws InterruptedException { LOG("LOG_CHANNEL", "getPlayerBetIndicies -- table ->" + table + " player_index ->" + player_index); if (!isIdValid(table)) @@ -756,15 +728,11 @@ public class saarlac_wheel extends script.gambling.base.wheel bet_idx.setSize(0); Vector push_bet_idx = new Vector(); push_bet_idx.setSize(0); - for (int i = 0; i < bets.length; i++) - { - int bet = wheelNameToIndex(bets[i]); - if (bet <= 14) - { + for (String bet1 : bets) { + int bet = wheelNameToIndex(bet1); + if (bet <= 14) { utils.addElement(bet_idx, bet); - } - else - { + } else { utils.addElement(push_bet_idx, bet); } } @@ -776,15 +744,11 @@ public class saarlac_wheel extends script.gambling.base.wheel { sort.sort(push_bet_idx); } - Vector all_bets = utils.concatArrays(push_bet_idx, bet_idx); - return all_bets; - } - else - { - return null; + return utils.concatArrays(push_bet_idx, bet_idx); } + return null; } - public int validateBet(obj_id table, int wheel_index, int amt, obj_id player) throws InterruptedException + private int validateBet(obj_id table, int wheel_index, int amt, obj_id player) throws InterruptedException { String wheel_name = wheelIndexToName(wheel_index); if (wheel_name == null) @@ -807,82 +771,71 @@ public class saarlac_wheel extends script.gambling.base.wheel sendSystemMessage(player, SID_NO_CASINO); return -1; } - if (wheel_index >= 1 && wheel_index <= 6) - { - } - else - { + if (wheel_index < 1 || wheel_index > 6) { if (hasBetBeenPlaced(table, wheel_index)) { - prose_package pp = prose.getPackage(SID_BET_ALREADY_PLACED, wheel_name); - sendSystemMessageProse(player, pp); + sendSystemMessageProse(player, prose.getPackage(SID_BET_ALREADY_PLACED, wheel_name)); return -1; } switch (wheel_index) { case 8: - int jabba_pool = getIntObjVar(table, VAR_JABBA_POOL) / 2; - if (jabba_pool < 1) - { - sendSystemMessage(player, SID_BET_JABBA_POOL_EMPTY); - return -1; - } - if ((float)amt * PAYOUTS[8] > jabba_pool) - { - int max_bet = (int)(jabba_pool / PAYOUTS[8]); - if (max_bet < 1) + int jabba_pool = getIntObjVar(table, VAR_JABBA_POOL) / 2; + if (jabba_pool < 1) { - max_bet = 1; + sendSystemMessage(player, SID_BET_JABBA_POOL_EMPTY); + return -1; } - int refund = amt - max_bet; - transferBankCreditsTo(table, player, amt, "noHandler", "noHandler", new dictionary()); - prose_package pp = prose.getPackage(SID_BET_JABBA_POOL_MAX, max_bet); - sendSystemMessageProse(player, pp); - amt = max_bet; - } - break; + if ((float)amt * PAYOUTS[8] > jabba_pool) + { + int max_bet = (int)(jabba_pool / PAYOUTS[8]); + if (max_bet < 1) + { + max_bet = 1; + } + transferBankCreditsTo(table, player, amt, "noHandler", "noHandler", new dictionary()); + sendSystemMessageProse(player, prose.getPackage(SID_BET_JABBA_POOL_MAX, max_bet)); + amt = max_bet; + } + break; case 11: - int oasis_pool = getIntObjVar(table, VAR_OASIS_POOL) / 2; - if (oasis_pool < 1) - { - sendSystemMessage(player, SID_BET_OASIS_POOL_EMPTY); - return -1; - } - if ((float)amt * PAYOUTS[11] > oasis_pool) - { - int max_bet = (int)(oasis_pool / PAYOUTS[11]); - if (max_bet < 1) + int oasis_pool = getIntObjVar(table, VAR_OASIS_POOL) / 2; + if (oasis_pool < 1) { - max_bet = 1; + sendSystemMessage(player, SID_BET_OASIS_POOL_EMPTY); + return -1; } - int refund = amt - max_bet; - transferBankCreditsTo(table, player, amt, "noHandler", "noHandler", new dictionary()); - prose_package pp = prose.getPackage(SID_BET_OASIS_POOL_MAX, max_bet); - sendSystemMessageProse(player, pp); - amt = max_bet; - } - break; + if ((float)amt * PAYOUTS[11] > oasis_pool) + { + int max_bet = (int)(oasis_pool / PAYOUTS[11]); + if (max_bet < 1) + { + max_bet = 1; + } + transferBankCreditsTo(table, player, amt, "noHandler", "noHandler", new dictionary()); + sendSystemMessageProse(player, prose.getPackage(SID_BET_OASIS_POOL_MAX, max_bet)); + amt = max_bet; + } + break; case 14: - int saarlac_pool = getIntObjVar(table, VAR_SAARLAC_POOL); - if (saarlac_pool < 1) - { - sendSystemMessage(player, SID_BET_SAARLAC_POOL_EMPTY); - return -1; - } - if ((float)amt * PAYOUTS[14] > saarlac_pool) - { - int max_bet = (int)(saarlac_pool / PAYOUTS[14]); - if (max_bet < 1) + int saarlac_pool = getIntObjVar(table, VAR_SAARLAC_POOL); + if (saarlac_pool < 1) { - max_bet = 1; + sendSystemMessage(player, SID_BET_SAARLAC_POOL_EMPTY); + return -1; } - int refund = amt - max_bet; - transferBankCreditsTo(table, player, amt, "noHandler", "noHandler", new dictionary()); - prose_package pp = prose.getPackage(SID_BET_SAARLAC_POOL_MAX, max_bet); - sendSystemMessageProse(player, pp); - amt = max_bet; - } - break; + if ((float)amt * PAYOUTS[14] > saarlac_pool) + { + int max_bet = (int)(saarlac_pool / PAYOUTS[14]); + if (max_bet < 1) + { + max_bet = 1; + } + transferBankCreditsTo(table, player, amt, "noHandler", "noHandler", new dictionary()); + sendSystemMessageProse(player, prose.getPackage(SID_BET_SAARLAC_POOL_MAX, max_bet)); + amt = max_bet; + } + break; } } if (wheel_index == 8 || wheel_index == 11 || wheel_index == 14) @@ -913,7 +866,7 @@ public class saarlac_wheel extends script.gambling.base.wheel } } } - public boolean completeBet(obj_id table, int bet_index, int amt, obj_id player) throws InterruptedException + private boolean completeBet(obj_id table, int bet_index, int amt, obj_id player) throws InterruptedException { LOG("LOG_CHANNEL", "saarlac_wheel::completeBet"); if (!isIdValid(table)) @@ -971,7 +924,7 @@ public class saarlac_wheel extends script.gambling.base.wheel messageTo(table, "handleRequestUpdatedUI", d, 0f, false); return true; } - public boolean resolveSpin(obj_id table, int wheel_index) throws InterruptedException + private boolean resolveSpin(obj_id table, int wheel_index) throws InterruptedException { if (!isIdValid(table)) { @@ -985,266 +938,150 @@ public class saarlac_wheel extends script.gambling.base.wheel obj_id[] player_ids = getObjIdArrayObjVar(table, gambling.VAR_GAME_PLAYERS_IDS); if (player_ids != null) { - for (int i = 0; i < player_ids.length; i++) - { - Vector bets = getPlayerBetIndices(table, gambling.getGamePlayerIndex(table, player_ids[i])); - if (bets != null) - { - for (int j = 0; j < bets.size(); j++) - { - if (((Integer)bets.get(j)).intValue() == -1) - { + Vector bets; + for (obj_id player_id : player_ids) { + bets = getPlayerBetIndices(table, gambling.getGamePlayerIndex(table, player_id)); + if (bets != null) { + for (int j = 0; j < bets.size(); j++) { + Integer betVal = (Integer) bets.get(j); + if (betVal == -1) { continue; } - LOG("LOG_CHANNEL", "bets[" + j + "] ->" + ((Integer)bets.get(j)).intValue() + " wheel_index ->" + wheel_index + " player ->" + player_ids[i]); - switch (wheel_index) - { + LOG("LOG_CHANNEL", "bets[" + j + "] ->" + betVal + " wheel_index ->" + wheel_index + " player ->" + player_id); + switch (wheel_index) { case 0: - if (((Integer)bets.get(j)).intValue() == 0 || ((Integer)bets.get(j)).intValue() == 15 || ((Integer)bets.get(j)).intValue() == 16) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 3 || ((Integer)bets.get(j)).intValue() == 4 || ((Integer)bets.get(j)).intValue() == 5 || ((Integer)bets.get(j)).intValue() == 18 || ((Integer)bets.get(j)).intValue() == 19 || ((Integer)bets.get(j)).intValue() == 20) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 0 || betVal == 15 || betVal == 16) { + payBet(table, betVal, player_id); + } else if (betVal == 3 || betVal == 4 || betVal == 5 || betVal == 18 || betVal == 19 || betVal == 20) { + pushBet(table, betVal, player_id); + } else if (betVal == 8 || betVal == 11 || betVal == 12 || betVal == 13 || betVal == 14) { + loseBet(table, betVal, player_id); + } + break; case 1: - if (((Integer)bets.get(j)).intValue() == 1 || ((Integer)bets.get(j)).intValue() == 17) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 3 || ((Integer)bets.get(j)).intValue() == 4 || ((Integer)bets.get(j)).intValue() == 5 || ((Integer)bets.get(j)).intValue() == 18 || ((Integer)bets.get(j)).intValue() == 19 || ((Integer)bets.get(j)).intValue() == 20) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 1 || betVal == 17) { + payBet(table, betVal, player_id); + } else if (betVal == 3 || betVal == 4 || betVal == 5 || betVal == 18 || betVal == 19 || betVal == 20) { + pushBet(table, betVal, player_id); + } else if (betVal == 8 || betVal == 11 || betVal == 12 || betVal == 13 || betVal == 14) { + loseBet(table, betVal, player_id); + } + break; case 2: - if (((Integer)bets.get(j)).intValue() == 2) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 3 || ((Integer)bets.get(j)).intValue() == 4 || ((Integer)bets.get(j)).intValue() == 5 || ((Integer)bets.get(j)).intValue() == 18 || ((Integer)bets.get(j)).intValue() == 19 || ((Integer)bets.get(j)).intValue() == 20) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 2) { + payBet(table, betVal, player_id); + } else if (betVal == 3 || betVal == 4 || betVal == 5 || betVal == 18 || betVal == 19 || betVal == 20) { + pushBet(table, betVal, player_id); + } else if (betVal == 8 || betVal == 11 || betVal == 12 || betVal == 13 || betVal == 14) { + loseBet(table, betVal, player_id); + } + break; case 3: - if (((Integer)bets.get(j)).intValue() == 3 || ((Integer)bets.get(j)).intValue() == 18 || ((Integer)bets.get(j)).intValue() == 19) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 0 || ((Integer)bets.get(j)).intValue() == 1 || ((Integer)bets.get(j)).intValue() == 2 || ((Integer)bets.get(j)).intValue() == 15 || ((Integer)bets.get(j)).intValue() == 16 || ((Integer)bets.get(j)).intValue() == 17) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 3 || betVal == 18 || betVal == 19) { + payBet(table, betVal, player_id); + } else if (betVal == 0 || betVal == 1 || betVal == 2 || betVal == 15 || betVal == 16 || betVal == 17) { + pushBet(table, betVal, player_id); + } else if (betVal == 8 || betVal == 11 || betVal == 12 || betVal == 13 || betVal == 14) { + loseBet(table, betVal, player_id); + } + break; case 4: - if (((Integer)bets.get(j)).intValue() == 4 || ((Integer)bets.get(j)).intValue() == 20) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 0 || ((Integer)bets.get(j)).intValue() == 1 || ((Integer)bets.get(j)).intValue() == 2 || ((Integer)bets.get(j)).intValue() == 15 || ((Integer)bets.get(j)).intValue() == 16 || ((Integer)bets.get(j)).intValue() == 17) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 4 || betVal == 20) { + payBet(table, betVal, player_id); + } else if (betVal == 0 || betVal == 1 || betVal == 2 || betVal == 15 || betVal == 16 || betVal == 17) { + pushBet(table, betVal, player_id); + } else if (betVal == 8 || betVal == 11 || betVal == 12 || betVal == 13 || betVal == 14) { + loseBet(table, betVal, player_id); + } + break; case 5: - if (((Integer)bets.get(j)).intValue() == 5) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 0 || ((Integer)bets.get(j)).intValue() == 1 || ((Integer)bets.get(j)).intValue() == 2 || ((Integer)bets.get(j)).intValue() == 15 || ((Integer)bets.get(j)).intValue() == 16 || ((Integer)bets.get(j)).intValue() == 17) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 5) { + payBet(table, betVal, player_id); + } else if ((betVal >= 0 && betVal <= 2) || (betVal >= 15 && betVal <= 17)) { + pushBet(table, betVal, player_id); + } else if (betVal == 8 || (betVal >= 11 && betVal <= 14)) { + loseBet(table, betVal, player_id); + } + break; case 6: - if (((Integer)bets.get(j)).intValue() == 6) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 3 || ((Integer)bets.get(j)).intValue() == 4 || ((Integer)bets.get(j)).intValue() == 5 || ((Integer)bets.get(j)).intValue() == 18 || ((Integer)bets.get(j)).intValue() == 19 || ((Integer)bets.get(j)).intValue() == 20) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 9 || ((Integer)bets.get(j)).intValue() == 10) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 6) { + payBet(table, betVal, player_id); + } else if ((betVal >= 3 && betVal <= 5) || (betVal >= 18 && betVal <= 20)) { + pushBet(table, betVal, player_id); + } else if (betVal >= 8 && betVal <= 14) { + loseBet(table, betVal, player_id); + } + break; case 7: - if (((Integer)bets.get(j)).intValue() == 7) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 3 || ((Integer)bets.get(j)).intValue() == 4 || ((Integer)bets.get(j)).intValue() == 5 || ((Integer)bets.get(j)).intValue() == 18 || ((Integer)bets.get(j)).intValue() == 19 || ((Integer)bets.get(j)).intValue() == 20) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 9 || ((Integer)bets.get(j)).intValue() == 10) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 7) { + payBet(table, betVal, player_id); + } else if ((betVal >= 3 && betVal <= 5) || (betVal >= 18 && betVal <= 20)) { + pushBet(table, betVal, player_id); + } else if (betVal >= 8 && betVal <= 14) { + loseBet(table, betVal, player_id); + } + break; case 8: - if (((Integer)bets.get(j)).intValue() == 8) - { - payPoolBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 6 || ((Integer)bets.get(j)).intValue() == 7) - { - payPoolBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 3 || ((Integer)bets.get(j)).intValue() == 4 || ((Integer)bets.get(j)).intValue() == 5 || ((Integer)bets.get(j)).intValue() == 18 || ((Integer)bets.get(j)).intValue() == 19 || ((Integer)bets.get(j)).intValue() == 20) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 9 || ((Integer)bets.get(j)).intValue() == 10) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal >= 6 || betVal <= 8) { + payPoolBet(table, betVal, player_id); + } else if ((betVal >= 3 && betVal <= 5) || (betVal >= 18 && betVal <= 20)) { + pushBet(table, betVal, player_id); + } else if (betVal >= 9 && betVal <= 14) { + loseBet(table, betVal, player_id); + } + break; case 9: - if (((Integer)bets.get(j)).intValue() == 9) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 0 || ((Integer)bets.get(j)).intValue() == 1 || ((Integer)bets.get(j)).intValue() == 2 || ((Integer)bets.get(j)).intValue() == 15 || ((Integer)bets.get(j)).intValue() == 16 || ((Integer)bets.get(j)).intValue() == 17) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 6 || ((Integer)bets.get(j)).intValue() == 7) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 9) { + payBet(table, betVal, player_id); + } else if ((betVal >= 0 && betVal <= 2) || (betVal >= 15 && betVal <= 17)) { + pushBet(table, betVal, player_id); + } else if ((betVal >= 6 && betVal <= 8) || (betVal >= 11 && betVal <= 14)) { + loseBet(table, betVal, player_id); + } + break; case 10: - if (((Integer)bets.get(j)).intValue() == 10) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 0 || ((Integer)bets.get(j)).intValue() == 1 || ((Integer)bets.get(j)).intValue() == 2 || ((Integer)bets.get(j)).intValue() == 15 || ((Integer)bets.get(j)).intValue() == 16 || ((Integer)bets.get(j)).intValue() == 17) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 6 || ((Integer)bets.get(j)).intValue() == 7) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 10) { + payBet(table, betVal, player_id); + } else if ((betVal >= 0 && betVal <= 2) || (betVal >= 15 && betVal <= 17)) { + pushBet(table, betVal, player_id); + } else if ((betVal >= 6 && betVal <= 8) || (betVal >= 11 && betVal <= 14)) { + loseBet(table, betVal, player_id); + } + break; case 11: - if (((Integer)bets.get(j)).intValue() == 11) - { - payPoolBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 9 || ((Integer)bets.get(j)).intValue() == 10) - { - payPoolBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 0 || ((Integer)bets.get(j)).intValue() == 1 || ((Integer)bets.get(j)).intValue() == 2 || ((Integer)bets.get(j)).intValue() == 15 || ((Integer)bets.get(j)).intValue() == 16 || ((Integer)bets.get(j)).intValue() == 17) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 6 || ((Integer)bets.get(j)).intValue() == 7) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal >= 9 && betVal <= 11){ + payPoolBet(table, betVal, player_id); + } else if ((betVal >= 0 && betVal <= 2) || (betVal >= 15 && betVal <= 17)) { + pushBet(table, betVal, player_id); + } else if ((betVal >= 6 && betVal <= 8) || (betVal >= 12 && betVal <= 14)) { + loseBet(table, betVal, player_id); + } + break; case 12: - if (((Integer)bets.get(j)).intValue() == 12) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 0 || ((Integer)bets.get(j)).intValue() == 1 || ((Integer)bets.get(j)).intValue() == 2 || ((Integer)bets.get(j)).intValue() == 6 || ((Integer)bets.get(j)).intValue() == 7 || ((Integer)bets.get(j)).intValue() == 15 || ((Integer)bets.get(j)).intValue() == 16 || ((Integer)bets.get(j)).intValue() == 17) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 3 || ((Integer)bets.get(j)).intValue() == 4 || ((Integer)bets.get(j)).intValue() == 5 || ((Integer)bets.get(j)).intValue() == 18 || ((Integer)bets.get(j)).intValue() == 19 || ((Integer)bets.get(j)).intValue() == 20) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 13 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 12) { + payBet(table, betVal, player_id); + } else if ((betVal >= 0 && betVal <= 2) || (betVal >= 6 || betVal <= 8) || betVal == 11 || (betVal >= 13 && betVal <= 17)) { + loseBet(table, betVal, player_id); + } else if ((betVal >= 3 && betVal <= 5) || (betVal >= 18 && betVal <= 20)) { + pushBet(table, betVal, player_id); + } + break; case 13: - if (((Integer)bets.get(j)).intValue() == 13) - { - payBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 3 || ((Integer)bets.get(j)).intValue() == 4 || ((Integer)bets.get(j)).intValue() == 5 || ((Integer)bets.get(j)).intValue() == 9 || ((Integer)bets.get(j)).intValue() == 10 || ((Integer)bets.get(j)).intValue() == 18 || ((Integer)bets.get(j)).intValue() == 19 || ((Integer)bets.get(j)).intValue() == 20) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 0 || ((Integer)bets.get(j)).intValue() == 1 || ((Integer)bets.get(j)).intValue() == 2 || ((Integer)bets.get(j)).intValue() == 15 || ((Integer)bets.get(j)).intValue() == 16 || ((Integer)bets.get(j)).intValue() == 17) - { - pushBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12 || ((Integer)bets.get(j)).intValue() == 14) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 13) { + payBet(table, betVal, player_id); + } else if ((betVal >= 3 && betVal <= 5) || (betVal >= 8 && betVal <= 12) || betVal == 14 || (betVal >= 18 && betVal <= 20)) { + loseBet(table, betVal, player_id); + } else if ((betVal >= 0 && betVal <= 2) || (betVal >= 15 && betVal <= 17)) { + pushBet(table, betVal, player_id); + } + break; case 14: - if (((Integer)bets.get(j)).intValue() == 14) - { - payPoolBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - else if (((Integer)bets.get(j)).intValue() == 8 || ((Integer)bets.get(j)).intValue() == 11 || ((Integer)bets.get(j)).intValue() == 12) - { - loseBet(table, ((Integer)bets.get(j)).intValue(), player_ids[i]); - } - break; + if (betVal == 14) { + payPoolBet(table, betVal, player_id); + } else if (betVal == 8 || betVal == 11 || betVal == 12) { + loseBet(table, betVal, player_id); + } + break; } } } @@ -1252,7 +1089,7 @@ public class saarlac_wheel extends script.gambling.base.wheel } return true; } - public boolean setBet(obj_id table, int bet_index, int player_index, int amt) throws InterruptedException + private boolean setBet(obj_id table, int bet_index, int player_index, int amt) throws InterruptedException { if (!isIdValid(table)) { @@ -1285,7 +1122,7 @@ public class saarlac_wheel extends script.gambling.base.wheel return true; } } - public boolean removeBet(obj_id table, int bet_index, int player_index) throws InterruptedException + private boolean removeBet(obj_id table, int bet_index, int player_index) throws InterruptedException { if (!isIdValid(table)) { @@ -1317,12 +1154,9 @@ public class saarlac_wheel extends script.gambling.base.wheel } return true; } - else - { - return false; - } + return false; } - public boolean payBet(obj_id table, int bet_index, obj_id player) throws InterruptedException + private boolean payBet(obj_id table, int bet_index, obj_id player) throws InterruptedException { if (!isIdValid(table)) { @@ -1386,7 +1220,7 @@ public class saarlac_wheel extends script.gambling.base.wheel return false; } } - public boolean payPoolBet(obj_id table, int bet_index, obj_id player) throws InterruptedException + private boolean payPoolBet(obj_id table, int bet_index, obj_id player) throws InterruptedException { if (!isIdValid(table)) { @@ -1488,7 +1322,7 @@ public class saarlac_wheel extends script.gambling.base.wheel return false; } } - public boolean loseBet(obj_id table, int bet_index, obj_id player) throws InterruptedException + private boolean loseBet(obj_id table, int bet_index, obj_id player) throws InterruptedException { LOG("LOG_CHANNEL", "loseBet -- table ->" + table + " bet_index ->" + bet_index + " player ->" + player); if (!isIdValid(table)) @@ -1562,7 +1396,7 @@ public class saarlac_wheel extends script.gambling.base.wheel return false; } } - public boolean pushBet(obj_id table, int bet_index, obj_id player) throws InterruptedException + private boolean pushBet(obj_id table, int bet_index, obj_id player) throws InterruptedException { if (!isIdValid(table)) { @@ -1595,29 +1429,29 @@ public class saarlac_wheel extends script.gambling.base.wheel switch (bet_index) { case 1: - pushed_bet = 16; - setBet(table, pushed_bet, player_index, amt); - break; + pushed_bet = 16; + setBet(table, pushed_bet, player_index, amt); + break; case 2: - pushed_bet = 17; - setBet(table, pushed_bet, player_index, amt); - break; + pushed_bet = 17; + setBet(table, pushed_bet, player_index, amt); + break; case 4: - pushed_bet = 19; - setBet(table, pushed_bet, player_index, amt); - break; + pushed_bet = 19; + setBet(table, pushed_bet, player_index, amt); + break; case 5: - pushed_bet = 20; - setBet(table, pushed_bet, player_index, amt); - break; + pushed_bet = 20; + setBet(table, pushed_bet, player_index, amt); + break; case 17: - pushed_bet = 15; - setBet(table, pushed_bet, player_index, amt); - break; + pushed_bet = 15; + setBet(table, pushed_bet, player_index, amt); + break; case 20: - pushed_bet = 18; - setBet(table, pushed_bet, player_index, amt); - break; + pushed_bet = 18; + setBet(table, pushed_bet, player_index, amt); + break; } String pushed_bet_name = wheelIndexToName(pushed_bet); prose_package pp = prose.getPackage(SID_BET_PUSH_SELF, pushed_bet_name, amt); @@ -1729,12 +1563,15 @@ public class saarlac_wheel extends script.gambling.base.wheel 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 += " "; @@ -1786,14 +1623,11 @@ public class saarlac_wheel extends script.gambling.base.wheel 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++) - { - String ovpath = gambling.VAR_GAME_PLAYERS + "." + players[i] + ".pid"; - if (!utils.hasScriptVar(self, ovpath)) - { - showBetUi(self, players[i]); + for (obj_id player : players) { + if (!utils.hasScriptVar(self, gambling.VAR_GAME_PLAYERS + "." + player + ".pid")) { + showBetUi(self, player); } - sendSystemMessage(players[i], gambling.SID_PLACE_BETS); + sendSystemMessage(player, gambling.SID_PLACE_BETS); } dictionary d = new dictionary(); d.put("stamp", stampTime); diff --git a/sku.0/sys.server/compiled/game/script/gambling/slot/standard.java b/sku.0/sys.server/compiled/game/script/gambling/slot/standard.java old mode 100644 new mode 100755 index 9a244f56b..53acd42f4 --- a/sku.0/sys.server/compiled/game/script/gambling/slot/standard.java +++ b/sku.0/sys.server/compiled/game/script/gambling/slot/standard.java @@ -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 { diff --git a/sku.0/sys.server/compiled/game/script/gambling/wheel/roulette.java b/sku.0/sys.server/compiled/game/script/gambling/wheel/roulette.java old mode 100644 new mode 100755 index 7bf602d30..723215a6e --- a/sku.0/sys.server/compiled/game/script/gambling/wheel/roulette.java +++ b/sku.0/sys.server/compiled/game/script/gambling/wheel/roulette.java @@ -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, ""); } } }