mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-28 22:47:59 +01:00
Merge pull request #2772 from Fox-McCloud/slot-machine-refactor
Slot Machine Refactor
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
var/datum/announcement/minor/slotmachine_announcement = new(do_log = 0)
|
||||
|
||||
/obj/machinery/slot_machine
|
||||
name = "slot machine"
|
||||
desc = "Gambling for the antisocial."
|
||||
@@ -6,77 +7,70 @@ var/datum/announcement/minor/slotmachine_announcement = new(do_log = 0)
|
||||
icon_state = "slots-off"
|
||||
anchored = 1
|
||||
density = 1
|
||||
// mats = 10
|
||||
var/money = 25000
|
||||
var/plays = 0
|
||||
var/working = 0
|
||||
var/balance=0
|
||||
|
||||
attack_hand(var/mob/user as mob)
|
||||
if(user.mind)
|
||||
if(user.mind.initial_account)
|
||||
balance = user.mind.initial_account.money
|
||||
user.machine = src
|
||||
if (src.working)
|
||||
var/dat = {"<B>Slot Machine</B><BR>
|
||||
<HR><BR>
|
||||
<B>Please wait!</B><BR>"}
|
||||
user << browse(dat, "window=slotmachine;size=450x500")
|
||||
onclose(user, "slotmachine")
|
||||
else
|
||||
var/dat = {"<B>Slot Machine</B><BR>
|
||||
<HR><BR>
|
||||
Five credits to play!<BR>
|
||||
<B>Prize Money Available:</B> [src.money]<BR>
|
||||
<B>Credits Remaining:</B> [balance]<BR>
|
||||
[src.plays] players have tried their luck today!<BR>
|
||||
<HR><BR>
|
||||
<A href='?src=\ref[src];ops=1'>Play!<BR>"}
|
||||
user << browse(dat, "window=slotmachine;size=400x500")
|
||||
onclose(user, "slotmachine")
|
||||
/obj/machinery/slot_machine/attack_hand(var/mob/user as mob)
|
||||
if(user.mind)
|
||||
if(user.mind.initial_account)
|
||||
balance = user.mind.initial_account.money
|
||||
user.machine = src
|
||||
if (working)
|
||||
var/dat = {"<B>Slot Machine</B><BR>
|
||||
<HR><BR>
|
||||
<B>Please wait!</B><BR>"}
|
||||
user << browse(dat, "window=slotmachine;size=450x500")
|
||||
onclose(user, "slotmachine")
|
||||
else
|
||||
var/dat = {"<B>Slot Machine</B><BR>
|
||||
<HR><BR>
|
||||
Five credits to play!<BR>
|
||||
<B>Credits Remaining:</B> [balance]<BR>
|
||||
[plays] players have tried their luck today!<BR>
|
||||
<HR><BR>
|
||||
<A href='?src=\ref[src];ops=1'>Play!<BR>"}
|
||||
user << browse(dat, "window=slotmachine;size=400x500")
|
||||
onclose(user, "slotmachine")
|
||||
|
||||
Topic(href, href_list)
|
||||
if(href_list["ops"])
|
||||
var/operation = text2num(href_list["ops"])
|
||||
if(operation == 1) // Play
|
||||
/* if (src.working == 1)
|
||||
usr << "\red You need to wait until the machine stops spinning!"
|
||||
return */
|
||||
if (balance < 5)
|
||||
usr << "\red Insufficient money to play!"
|
||||
return
|
||||
usr.mind.initial_account.money -= 5
|
||||
src.money += 5
|
||||
src.plays += 1
|
||||
src.working = 1
|
||||
src.icon_state = "slots-on"
|
||||
usr << "Let's roll!"
|
||||
var/roll = rand(1,10000)
|
||||
spawn(100)
|
||||
if (roll == 1)
|
||||
for(var/mob/O in hearers(src, null))
|
||||
O.show_message(text("<b>[]</b> says, 'JACKPOT! You win [src.money]!'", src), 1)
|
||||
slotmachine_announcement.Announce("Congratulations [usr.name] on winning the Jackpot!", "Jackpot Winner")
|
||||
usr.mind.initial_account.money += src.money
|
||||
src.money = 0
|
||||
else if (roll > 1 && roll <= 10)
|
||||
for(var/mob/O in hearers(src, null))
|
||||
O.show_message(text("<b>[]</b> says, 'Big Winner! You win five thousand credits!'", src), 1)
|
||||
usr.mind.initial_account.money += 5000
|
||||
src.money -= 5000
|
||||
else if (roll > 10 && roll <= 100)
|
||||
for(var/mob/O in hearers(src, null))
|
||||
O.show_message(text("<b>[]</b> says, 'Winner! You win five hundred credits!'", src), 1)
|
||||
usr.mind.initial_account.money += 500
|
||||
src.money -= 500
|
||||
else if (roll > 100 && roll <= 1000)
|
||||
usr << "\blue You win a free game!"
|
||||
usr.mind.initial_account.money += 5
|
||||
src.money -= 5
|
||||
else
|
||||
usr << "\red No luck!"
|
||||
src.working = 0
|
||||
src.icon_state = "slots-off"
|
||||
src.add_fingerprint(usr)
|
||||
src.updateUsrDialog()
|
||||
return
|
||||
/obj/machinery/slot_machine/Topic(href, href_list)
|
||||
if(href_list["ops"])
|
||||
var/operation = text2num(href_list["ops"])
|
||||
if(operation == 1) // Play
|
||||
if (working == 1)
|
||||
usr << "<span class='warning'>You need to wait until the machine stops spinning!</span>"
|
||||
return
|
||||
if (balance < 5)
|
||||
usr << "<span class='warning'>Insufficient money to play!</span>"
|
||||
return
|
||||
usr.mind.initial_account.money -= 5
|
||||
plays += 1
|
||||
working = 1
|
||||
icon_state = "slots-on"
|
||||
var/roll = rand(1,10000)
|
||||
playsound(src.loc, 'sound/machines/ding.ogg', 50, 1)
|
||||
spawn(30)
|
||||
if (roll == 1)
|
||||
playsound(src.loc, 'sound/effects/engine_alert2.ogg', 50, 0)
|
||||
visible_message("<b>[src]</b> says, 'JACKPOT! [usr.name] has won two hundred and fifty thousand credits!'")
|
||||
slotmachine_announcement.Announce("Congratulations to [usr.name] on winning the jackpot of two hundred and fifty thousand credits!", "Jackpot Winner")
|
||||
usr.mind.initial_account.money += 250000
|
||||
else if (roll > 1 && roll <= 10)
|
||||
playsound(src.loc, 'sound/machines/ping.ogg', 50, 0)
|
||||
visible_message("<b>[src]</b> says, 'Big Winner! [usr.name] has won five thousand credits!'")
|
||||
usr.mind.initial_account.money += 5000
|
||||
else if (roll > 10 && roll <= 100)
|
||||
playsound(src.loc, 'sound/machines/ping.ogg', 50, 0)
|
||||
visible_message("<b>[src]</b> says, 'Winner! [usr.name] has won win five hundred credits!'")
|
||||
usr.mind.initial_account.money += 500
|
||||
else if (roll > 100 && roll <= 1000)
|
||||
playsound(src.loc, 'sound/machines/ping.ogg', 50, 0)
|
||||
usr << "<span class='notice'>You win 5 credits!</span>"
|
||||
usr.mind.initial_account.money += 5
|
||||
else
|
||||
usr << "<span class='warning'>No luck!</span>"
|
||||
working = 0
|
||||
icon_state = "slots-off"
|
||||
add_fingerprint(usr)
|
||||
updateUsrDialog()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user