diff --git a/code/game/machinery/casino_ch.dm b/code/game/machinery/casino_ch.dm index b6aa6a712d..1c39d2221c 100644 --- a/code/game/machinery/casino_ch.dm +++ b/code/game/machinery/casino_ch.dm @@ -229,57 +229,6 @@ busy = FALSE - -/obj/structure/wheel_of_fortune - name = "wheel of fortune" - desc = "May fortune favour the lucky one!" - icon = 'icons/obj/casino_ch.dmi' - icon_state = "wheel_of_fortune" - density = 1 - anchored = 1 - var/interval = 1 - var/busy = 0 - - var/datum/effect/effect/system/confetti_spread - var/confetti_strength = 8 - -/obj/structure/wheel_of_fortune/verb/setinterval() - set name = "Change interval" - set category = "Object" - set src in view(1) - - if(usr.incapacitated()) - return - if(ishuman(usr) || istype(usr, /mob/living/silicon/robot)) - interval = input("Put the desired interval (1-100)", "Set Interval") as num - if(interval>100 || interval<1) - usr << "Invalid interval." - return - usr << "You set the interval to [interval]" - return - - -/obj/structure/wheel_of_fortune/attack_hand(mob/user as mob) - if (busy) - to_chat(user,"The wheel of fortune is already spinning! ") - return - visible_message("\ [user] spins the wheel of fortune!") - busy = 1 - icon_state = "wheel_of_fortune_spinning" - var/result = rand(1,interval) - add_fingerprint(user) - spawn(5 SECONDS) - visible_message("The wheel of fortune stops spinning, the number is [result]!") - - src.confetti_spread = new /datum/effect/effect/system/confetti_spread() - src.confetti_spread.attach(src) //If somehow people start dragging slot machine - spawn(0) - for(var/i = 1 to confetti_strength) - src.confetti_spread.start() - sleep(10) - busy=0 - icon_state = "wheel_of_fortune" - /obj/structure/stripper_pole name = "stripper pole" icon = 'icons/obj/casino_ch.dmi' @@ -1009,3 +958,186 @@ spawn_money(round(I:worth/2.5), src.loc) src.attack_hand(user) qdel(I) + +/obj/machinery/wheel_of_fortune + name = "wheel of fortune" + desc = "The Wheel of Fortune! Insert chips and may fortune favour the lucky one at the next lottery!" + icon = 'icons/obj/64x64_ch.dmi' + icon_state = "wheel_of_fortune" + density = 1 + anchored = 1 + pixel_x = -16 + + req_access = list(300) + var/interval = 1 + var/busy = 0 + var/public_spin = 0 + var/lottery_sale = "disabled" + var/lottery_price = 100 + var/lottery_entries = 0 + var/lottery_tickets = list() + var/lottery_tickets_ckeys = list() + + var/datum/effect/effect/system/confetti_spread + var/confetti_strength = 15 + + +/obj/machinery/wheel_of_fortune/attack_hand(mob/user as mob) + if (busy) + to_chat(user,"The wheel of fortune is already spinning! ") + return + + if(usr.incapacitated()) + return + if(ishuman(usr) || istype(usr, /mob/living/silicon/robot)) + switch(input(user,"Choose what to do","Wheel Of Fortune") in list("Spin the Wheel! (Not Lottery)", "Set the interval", "Cancel")) + if("Cancel") + return + if("Spin the Wheel! (Not Lottery)") + if(public_spin == 0) + to_chat(user,"The Wheel makes a sad beep, public spins are not enabled right now.. ") + return + else + to_chat(user,"You spin the wheel! ") + spin_the_wheel("not_lottery") + if("Set the interval") + setinterval() + + +/obj/machinery/wheel_of_fortune/attackby(obj/item/weapon/W as obj, mob/user as mob) + if (busy) + to_chat(user,"The wheel of fortune is already spinning! ") + return + + if(usr.incapacitated()) + return + + if(istype(W, /obj/item/weapon/card/id)||istype(W, /obj/item/device/pda)) + if(!check_access(W)) + to_chat(user, "Access Denied.") + return + else + to_chat(user, "Proper access, allowed staff controls.") + if(ishuman(usr) || istype(usr, /mob/living/silicon/robot)) + switch(input(user,"Choose what to do (Management)","Wheel Of Fortune (Management)") in list("Spin the Lottery Wheel!", "Toggle Lottery Sales", "Toggle Public Spins", "Reset Lottery", "Cancel")) + if("Cancel") + return + if("Spin the Lottery Wheel!") + to_chat(user,"You spin the wheel for the lottery! ") + spin_the_wheel("lottery") + + if("Toggle Lottery Sales") + if(lottery_sale == "disabled") + lottery_sale = "enabled" + to_chat(user,"Public Lottery sale has been enabled. ") + else + lottery_sale = "disabled" + to_chat(user,"Public Lottery sale has been disabled. ") + + if("Toggle Public Spins") + if(public_spin == 0) + public_spin = 1 + to_chat(user,"Public spins has been enabled. ") + else + public_spin = 0 + to_chat(user,"Public spins has been disabled. ") + + if("Reset Lottery") + var/confirm = tgui_alert(usr, "Are you sure you want to reset Lottery?", "Confirm Lottery Reset", list("Yes", "No")) + if(confirm == "Yes") + to_chat(user, "Lottery has been Reset!") + lottery_entries = 0 + lottery_tickets = list() + lottery_tickets_ckeys = list() + + if(istype(W, /obj/item/weapon/spacecasinocash)) + if(lottery_sale == "disabled") + to_chat(user, "Lottery sales are currently disabled.") + return + else + if(user.client.ckey in lottery_tickets_ckeys) + to_chat(user, "The scanner beeps in an upset manner, you already have a ticket!") + return + + var/obj/item/weapon/spacecasinocash/C = W + insert_chip(C, user) + +/obj/machinery/wheel_of_fortune/proc/insert_chip(var/obj/item/weapon/spacecasinocash/cashmoney, mob/user) + if (busy) + to_chat(user,"The Wheel of Fortune is busy, wait for it to be done to buy a lottery ticket. ") + return + if(cashmoney.worth < lottery_price) + to_chat(user,"You dont have enough chips to buy a lottery ticket! ") + return + + to_chat(user,"You put [lottery_price] credits worth of chips into the Wheel of Fortune and it pings to notify of your lottery ticket registered!") + cashmoney.worth -= lottery_price + cashmoney.update_icon() + + if(cashmoney.worth <= 0) + usr.drop_from_inventory(cashmoney) + qdel(cashmoney) + cashmoney.update_icon() + + lottery_entries++ + lottery_tickets += "Number.[lottery_entries] [user.name]" + lottery_tickets_ckeys += user.client.ckey + +/obj/machinery/wheel_of_fortune/proc/spin_the_wheel(var/mode) + var/result = 0 + + if(mode == "not_lottery") + busy = 1 + icon_state = "wheel_of_fortune_spinning" + result = rand(1,interval) + + spawn(5 SECONDS) + visible_message("The wheel of fortune stops spinning, the number is [result]!") + src.confetti_spread = new /datum/effect/effect/system/confetti_spread() + src.confetti_spread.attach(src) //If somehow people start dragging slot machine + spawn(0) + for(var/i = 1 to confetti_strength) + src.confetti_spread.start() + sleep(10) + + flick("[icon_state]-winning",src) + busy = 0 + icon_state = "wheel_of_fortune" + + if(mode == "lottery") + if(lottery_entries == 0) + visible_message("There are no tickets in the system!") + return + + busy = 1 + icon_state = "wheel_of_fortune_spinning" + result = pick(lottery_tickets) + + spawn(5 SECONDS) + visible_message("The wheel of fortune stops spinning, and the winner is [result]!") + src.confetti_spread = new /datum/effect/effect/system/confetti_spread() + src.confetti_spread.attach(src) //If somehow people start dragging slot machine + spawn(0) + for(var/i = 1 to confetti_strength) + src.confetti_spread.start() + sleep(10) + + flick("[icon_state]-winning",src) + busy = 0 + icon_state = "wheel_of_fortune" + + +/obj/machinery/wheel_of_fortune/verb/setinterval() + set name = "Change interval" + set category = "Object" + set src in view(1) + + if(usr.incapacitated()) + return + if(ishuman(usr) || istype(usr, /mob/living/silicon/robot)) + interval = input("Put the desired interval (1-1000)", "Set Interval") as num + if(interval>1000 || interval<1) + usr << "Invalid interval." + return + usr << "You set the interval to [interval]" + return \ No newline at end of file diff --git a/icons/obj/64x64_ch.dmi b/icons/obj/64x64_ch.dmi index eba8710141..6f2493d610 100644 Binary files a/icons/obj/64x64_ch.dmi and b/icons/obj/64x64_ch.dmi differ