diff --git a/code/game/machinery/roulette_machine.dm b/code/game/machinery/roulette_machine.dm index 2372fa4b35c..b5d089b44eb 100644 --- a/code/game/machinery/roulette_machine.dm +++ b/code/game/machinery/roulette_machine.dm @@ -1,10 +1,17 @@ -#define ROULETTE_SINGLES_PAYOUT 35 +#define ROULETTE_SINGLES_PAYOUT 36 #define ROULETTE_SIMPLE_PAYOUT 2 +#define ROULETTE_DOZ_COL_PAYOUT 3 #define ROULETTE_BET_ODD "odd" #define ROULETTE_BET_EVEN "even" #define ROULETTE_BET_1TO18 "s1-18" //adds s to prevent text2num from working #define ROULETTE_BET_19TO36 "s19-36" //adds s to prevent text2num from working +#define ROULETTE_BET_1TO12 "s1-12" +#define ROULETTE_BET_13TO24 "s13-24" +#define ROULETTE_BET_25TO36 "s25-36" +#define ROULETTE_BET_2TO1_FIRST "s1st col" +#define ROULETTE_BET_2TO1_SECOND "s2nd col" +#define ROULETTE_BET_2TO1_THIRD "s3rd col" #define ROULETTE_BET_BLACK "black" #define ROULETTE_BET_RED "red" @@ -22,6 +29,8 @@ idle_power_usage = 10 active_power_usage = 100 max_integrity = 500 + ui_x = 603 + ui_y = 475 armor = list("melee" = 45, "bullet" = 30, "laser" = 30, "energy" = 30, "bomb" = 10, "bio" = 30, "rad" = 30, "fire" = 30, "acid" = 30) var/static/list/numbers = list("0" = "green", "1" = "red", "3" = "red", "5" = "red", "7" = "red", "9" = "red", "12" = "red", "14" = "red", "16" = "red",\ "18" = "red", "19" = "red", "21" = "red", "23" = "red", "25" = "red", "27" = "red", "30" = "red", "32" = "red", "34" = "red", "36" = "red",\ @@ -29,7 +38,7 @@ "22" = "black", "24" = "black", "26" = "black", "28" = "black", "29" = "black", "31" = "black", "33" = "black", "35" = "black") var/chosen_bet_amount = 10 - var/chosen_bet_type = 0 + var/chosen_bet_type = "0" var/last_anti_spam = 0 var/anti_spam_cooldown = 20 var/obj/item/card/id/my_card @@ -39,8 +48,8 @@ var/static/list/coin_values = list(/obj/item/coin/diamond = 100, /obj/item/coin/gold = 25, /obj/item/coin/silver = 10, /obj/item/coin/iron = 1) //Make sure this is ordered from left to right. var/list/coins_to_dispense = list() var/datum/looping_sound/jackpot/jackpot_loop - var/datum/asset/spritesheet/simple/assets var/on = TRUE + var/last_spin = 13 /obj/machinery/roulette/Initialize() . = ..() @@ -56,9 +65,7 @@ return ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open) if(!ui) - var/datum/asset/spritesheet/simple/assets = get_asset_datum(/datum/asset/spritesheet/simple/roulette) - assets.send(user) - ui = new(user, src, ui_key, "roulette", name, 455, 520, master_ui, state) + ui = new(user, src, ui_key, "roulette", name, ui_x, ui_y, master_ui, state) ui.open() /obj/machinery/roulette/ui_data(mob/user) @@ -67,6 +74,8 @@ data["BetAmount"] = chosen_bet_amount data["BetType"] = chosen_bet_type data["HouseBalance"] = my_card?.registered_account.account_balance + data["LastSpin"] = last_spin + data["Spinning"] = playing if(ishuman(user)) var/mob/living/carbon/human/H = user var/obj/item/card/id/C = H.get_idcard(TRUE) @@ -76,8 +85,6 @@ data["AccountBalance"] = 0 data["CanUnbolt"] = (H.get_idcard() == my_card) - if(!assets) - assets = get_asset_datum(/datum/asset/spritesheet/simple/roulette) return data /obj/machinery/roulette/ui_act(action, params) @@ -90,19 +97,11 @@ if("ChangeBetAmount") chosen_bet_amount = CLAMP(text2num(params["amount"]), 10, 500) . = TRUE - if("ChangeBetAmountCustom") - var/amount = input(usr, "Bet amount between 10 and 500:") as num|null - if(amount) - chosen_bet_amount = CLAMP(amount, 10, 500) if("ChangeBetType") chosen_bet_type = params["type"] . = TRUE update_icon() // Not applicable to all objects. -/obj/machinery/roulette/ui_base_html(html) - var/datum/asset/spritesheet/simple/assets = get_asset_datum(/datum/asset/spritesheet/simple/roulette) - . = replacetext(html, "", assets.css_tag()) - ///Handles setting ownership and the betting itself. /obj/machinery/roulette/attackby(obj/item/W, mob/user, params) if(stat & MAINT && is_wire_tool(W)) @@ -126,7 +125,26 @@ if(!chosen_bet_amount || isnull(chosen_bet_type)) return FALSE - var/potential_payout = text2num(chosen_bet_type) ? chosen_bet_amount * ROULETTE_SINGLES_PAYOUT : chosen_bet_amount * ROULETTE_SIMPLE_PAYOUT + //double to nothing bets + var/list/doubles = list( + ROULETTE_BET_2TO1_FIRST, + ROULETTE_BET_2TO1_SECOND, + ROULETTE_BET_2TO1_THIRD, + ROULETTE_BET_1TO12, + ROULETTE_BET_13TO24, + ROULETTE_BET_25TO36 + ) + //result of text2num is null if text starts with a character, meaning it's not a singles bet + var/single = !isnull(text2num(chosen_bet_type)) + var/potential_payout_mult + if (single) + potential_payout_mult = ROULETTE_SINGLES_PAYOUT + else + if (chosen_bet_type in doubles) + potential_payout_mult = ROULETTE_DOZ_COL_PAYOUT + else + potential_payout_mult = ROULETTE_SIMPLE_PAYOUT + var/potential_payout = chosen_bet_amount * potential_payout_mult if(!check_bartender_funds(potential_payout)) return FALSE //bartender is too poor @@ -181,6 +199,7 @@ ///Ran after a while to check if the player won or not. /obj/machinery/roulette/proc/finish_play(obj/item/card/id/player_id, bet_type, bet_amount, potential_payout, rolled_number) + last_spin = rolled_number var/is_winner = check_win(bet_type, bet_amount, rolled_number) //Predetermine if we won var/color = numbers["[rolled_number]"] //Weird syntax, but dict uses strings. @@ -275,8 +294,25 @@ return "black" == numbers["[rolled_number]"]//Check if our number is black in the numbers dict if(ROULETTE_BET_RED) return "red" == numbers["[rolled_number]"] //Check if our number is black in the numbers dict - if("0") - return "0" == "rolled_number" //Check if our number is 0 + if(ROULETTE_BET_1TO12) + return (rolled_number >= 1 && rolled_number <= 12) + if(ROULETTE_BET_13TO24) + return (rolled_number >= 13 && rolled_number <= 24) + if(ROULETTE_BET_25TO36) + return (rolled_number >= 25 && rolled_number <= 36) + if(ROULETTE_BET_2TO1_FIRST) + //You could do this mathematically but w/e this is easy to understand + //numbers in the first column + var/list/winners = list(1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34) + return (rolled_number in winners) + if(ROULETTE_BET_2TO1_SECOND) + //numbers in the second column + var/list/winners = list(2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35) + return (rolled_number in winners) + if(ROULETTE_BET_2TO1_THIRD) + //numbers in the third column + var/list/winners = list(3, 5, 8, 12, 15, 18, 21, 24, 27, 30, 33, 36) + return (rolled_number in winners) ///Returns TRUE if the owner has enough funds to payout diff --git a/code/modules/client/asset_cache.dm b/code/modules/client/asset_cache.dm index ea5be43008b..ebfc2b62519 100644 --- a/code/modules/client/asset_cache.dm +++ b/code/modules/client/asset_cache.dm @@ -630,22 +630,6 @@ GLOBAL_LIST_EMPTY(asset_datums) "pill22" = 'icons/UI_Icons/Pills/pill22.png', ) - -/datum/asset/spritesheet/simple/roulette - name = "roulette" - assets = list( - "black" = 'icons/UI_Icons/Roulette/black.png', - "red" = 'icons/UI_Icons/Roulette/red.png', - "odd" = 'icons/UI_Icons/Roulette/odd.png', - "even" = 'icons/UI_Icons/Roulette/even.png', - "low" = 'icons/UI_Icons/Roulette/1-18.png', - "high" = 'icons/UI_Icons/Roulette/19-36.png', - "nano" = 'icons/UI_Icons/Roulette/nano.png', - "zero" = 'icons/UI_Icons/Roulette/0.png' - - ) - - //this exists purely to avoid meta by pre-loading all language icons. /datum/asset/language/register() for(var/path in typesof(/datum/language)) diff --git a/icons/UI_Icons/Roulette/0.png b/icons/UI_Icons/Roulette/0.png deleted file mode 100644 index 8e10b8e2aec..00000000000 Binary files a/icons/UI_Icons/Roulette/0.png and /dev/null differ diff --git a/icons/UI_Icons/Roulette/1-18.png b/icons/UI_Icons/Roulette/1-18.png deleted file mode 100644 index c9a9ac887b0..00000000000 Binary files a/icons/UI_Icons/Roulette/1-18.png and /dev/null differ diff --git a/icons/UI_Icons/Roulette/19-36.png b/icons/UI_Icons/Roulette/19-36.png deleted file mode 100644 index e6c68bc512e..00000000000 Binary files a/icons/UI_Icons/Roulette/19-36.png and /dev/null differ diff --git a/icons/UI_Icons/Roulette/black.png b/icons/UI_Icons/Roulette/black.png deleted file mode 100644 index c2d9c91af74..00000000000 Binary files a/icons/UI_Icons/Roulette/black.png and /dev/null differ diff --git a/icons/UI_Icons/Roulette/even.png b/icons/UI_Icons/Roulette/even.png deleted file mode 100644 index 0ba2b817d38..00000000000 Binary files a/icons/UI_Icons/Roulette/even.png and /dev/null differ diff --git a/icons/UI_Icons/Roulette/nano.png b/icons/UI_Icons/Roulette/nano.png deleted file mode 100644 index 239e49fcdb6..00000000000 Binary files a/icons/UI_Icons/Roulette/nano.png and /dev/null differ diff --git a/icons/UI_Icons/Roulette/odd.png b/icons/UI_Icons/Roulette/odd.png deleted file mode 100644 index 532a23bd9fa..00000000000 Binary files a/icons/UI_Icons/Roulette/odd.png and /dev/null differ diff --git a/icons/UI_Icons/Roulette/red.png b/icons/UI_Icons/Roulette/red.png deleted file mode 100644 index b2c1632809e..00000000000 Binary files a/icons/UI_Icons/Roulette/red.png and /dev/null differ diff --git a/tgui-next/packages/tgui/interfaces/Roulette.js b/tgui-next/packages/tgui/interfaces/Roulette.js new file mode 100644 index 00000000000..d184156995f --- /dev/null +++ b/tgui-next/packages/tgui/interfaces/Roulette.js @@ -0,0 +1,401 @@ +import { classes } from "common/react"; +import { useBackend } from "../backend"; +import { Box, Button, Grid, NumberInput } from "../components"; +import { createLogger } from "../logging"; +import { Fragment, Component } from "inferno"; +import { act } from "../byond"; + +const logger = createLogger('Roulette'); + +const getNumberColor = number => { + if (number === 0) { + return 'green'; + } + + const evenRedRanges = [ + [1, 10], + [19, 28], + ]; + let oddRed = true; + + for (let i = 0; i < evenRedRanges.length; i++) { + let range = evenRedRanges[i]; + if (number >= range[0] && number <= range[1]) { + oddRed = false; + break; + } + } + + const isOdd = (number % 2 === 0); + + return (oddRed ? isOdd : !isOdd) ? 'red' : 'black'; +}; + +export const RouletteNumberButton = props => { + const { number } = props; + const { act } = useBackend(props); + + return ( +