Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scratch-Off Lotto Tickets #31992

Merged
merged 23 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions code/game/machinery/computer/cargo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ For vending packs, see vending_packs.dm*/
var/permissions_screen = FALSE
var/last_viewed_group = "Supplies" // not sure how to get around hard coding this
var/list/current_acct
var/list/current_acct_override
var/list/current_acct_override
var/screen = SCR_MAIN
light_color = LIGHT_COLOR_BROWN

Expand Down Expand Up @@ -185,7 +185,7 @@ For vending packs, see vending_packs.dm*/

if(current_acct_override)
current_acct = current_acct_override
else
else
current_acct = get_account_info(user, linked_db)

user.set_machine(src)
Expand Down Expand Up @@ -318,7 +318,7 @@ For vending packs, see vending_packs.dm*/
add_fingerprint(usr)
if(current_acct_override)
current_acct = current_acct_override
else
else
current_acct = get_account_info(usr, linked_db)
var/idname
var/datum/money_account/account
Expand Down Expand Up @@ -453,7 +453,7 @@ For vending packs, see vending_packs.dm*/
SSsupply_shuttle.requisition = text2num(href_list["requisition_status"])
if(current_acct_override)
current_acct = current_acct_override
else
else
current_acct = get_account_info(usr, linked_db)
return 1
else if (href_list["screen"])
Expand Down Expand Up @@ -514,7 +514,7 @@ For vending packs, see vending_packs.dm*/
return
if(current_acct_override)
current_acct = current_acct_override
else
else
current_acct = get_account_info(user, linked_db)
user.set_machine(src)
ui_interact(user)
Expand Down Expand Up @@ -579,7 +579,7 @@ For vending packs, see vending_packs.dm*/
add_fingerprint(usr)
if(current_acct_override)
current_acct = current_acct_override
else
else
current_acct = get_account_info(usr, linked_db)
var/idname
var/datum/money_account/account
Expand Down
59 changes: 59 additions & 0 deletions code/game/machinery/vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3706,3 +3706,62 @@ var/global/num_vending_terminals = 1
return pick(grey_slogans)
else
return pick(product_slogans)

/obj/machinery/vending/lotto
name = "\improper Lotto Tickets"
desc = "Wall-mounted vending machine which dispenses scratch-off lottery tickets. Winners can be cashed at Cargo."
west3436 marked this conversation as resolved.
Show resolved Hide resolved
product_slogans = list(
"Feeling lucky?",
"Money won is twice as sweet as money earned.",
"The greatest risk is not taking one."
)
product_ads = list(
"Quit while you’re ahead. All the best gamblers do.",
"If there weren’t luck involved, I would win every time.",
"Better an ounce of luck than a pound of gold.",
"Behind bad luck comes good luck."
)
vend_reply = "Good luck!"
icon_state = "Lotto"
icon_vend = "Lotto-vend"
products = list(
/obj/item/toy/lotto_ticket/gold_rush = 20,
/obj/item/toy/lotto_ticket/diamond_hands = 20,
/obj/item/toy/lotto_ticket/phazon_fortune = 20
)
contraband = list(
/obj/item/toy/lotto_ticket/supermatter_surprise = 1
)
prices = list(
/obj/item/toy/lotto_ticket/gold_rush = 5,
/obj/item/toy/lotto_ticket/diamond_hands = 20,
/obj/item/toy/lotto_ticket/phazon_fortune = 50,
/obj/item/toy/lotto_ticket/supermatter_surprise = 100
)

pack = /obj/structure/vendomatpack/lotto

/obj/machinery/vending/lotto/attackby(obj/item/I as obj, user as mob)
west3436 marked this conversation as resolved.
Show resolved Hide resolved
add_fingerprint(user)
if(istype(I, /obj/item/toy/lotto_ticket))
var/obj/item/toy/lotto_ticket/T = I
if(!T.iswinner)
playsound(src, "buzz-sigh", 50, 1)
for(var/mob/V in hearers(src))
V.visible_message("<b>[src]</b>'s monitor flashes, \"This ticket is not a winning ticket.\"")
west3436 marked this conversation as resolved.
Show resolved Hide resolved
return
else
if(T.winnings <= 10000)
for(var/mob/V in hearers(src))
V.visible_message("<b>[src]</b>'s monitor flashes, \"Withdrawing [T.winnings] credits from the Central Command Lottery Fund!\"")
dispense_cash(T.winnings, get_turf(src))
playsound(src, "polaroid", 50, 1)
else
var/mob/living/carbon/human/H = user
var/account_num = H?.mind?.initial_account?.account_number
var/datum/money_account/account = get_money_account_global(account_num)
account.money += T.winnings
west3436 marked this conversation as resolved.
Show resolved Hide resolved
playsound(src, "ping", 50, 1)
for(var/mob/V in hearers(src))
V.visible_message("<b>[src]</b>'s monitor flashes, \"Withdrawing [T.winnings] credits from the Central Command Lottery Fund into your account!\"")
qdel(T)
6 changes: 6 additions & 0 deletions code/game/machinery/vending_packs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,9 @@
name = "Zam Snax recharge pack"
targetvendomat = /obj/machinery/vending/zamsnax
icon_state = "ZAMsnax"

/obj/structure/vendomatpack/lotto
name = "Lotto Ticket recharge pack"
targetvendomat = /obj/machinery/vending/lotto
icon_state = "sale"

130 changes: 130 additions & 0 deletions code/modules/games/cards/lotto.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/obj/item/toy/lotto_ticket
name = "scratch-off lotto ticket"
desc = "A scratch-off lotto ticket."
icon = 'icons/obj/toy.dmi'
w_class = W_CLASS_TINY
var/obj/item/toy/lotto_ticket/revealed = 0
var/obj/item/toy/lotto_ticket/iswinner = 0
var/obj/item/toy/lotto_ticket/ticket_price
var/obj/item/toy/lotto_ticket/winnings = 0
west3436 marked this conversation as resolved.
Show resolved Hide resolved

/obj/item/toy/lotto_ticket/New()
..()
pixel_y = rand(-8, 8) * PIXEL_MULTIPLIER
pixel_x = rand(-9, 9) * PIXEL_MULTIPLIER

/obj/item/toy/lotto_ticket/proc/scratch(var/input_price)
var/list/prizelist = list(100000,50000,10000,5000,1000,500,250,100,50,20,10,5,4,3,2,1)
var/list/problist = list(0.0001, 0.0002, 0.001, 0.002, 0.01, 0.02, 0.04, 0.2, 1, 2.5, 5, 10, 12.5, 17, 20, 25)
west3436 marked this conversation as resolved.
Show resolved Hide resolved
var/tuning_value = 1/5 //Used to adjust expected values.
var/profit = 0
for(var/prize = 1 to problist.len)
if(prob(problist[prize]))
profit = prizelist[prize]*input_price*tuning_value
return profit

//Flash code taken from Blinder
/obj/item/toy/lotto_ticket/proc/flash(var/turf/T , var/mob/living/M)
playsound(src, 'sound/effects/EMPulse.ogg', 100, 1)

if(M.blinded)
return

M.flash_eyes(visual = 1, affect_silicon = 1)

if(issilicon(M))
M.Knockdown(rand(5, 10))
M.visible_message("<span class='warning'>[M]'s sensors are overloaded by the flash of light!</span>","<span class='warning'>Your sensors are overloaded by the flash of light!</span>")

if(ishuman(M))
var/mob/living/carbon/human/H = M
var/datum/organ/internal/eyes/E = H.internal_organs_by_name["eyes"]
if (E && E.damage >= E.min_bruised_damage)
to_chat(M, "<span class='warning'>Your eyes start to burn badly!</span>")
M.update_icons()


/obj/item/toy/lotto_ticket/attackby(obj/item/weapon/S, mob/user)
if(!revealed)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel as if an early return would be good here, so go straight to the

to_chat(user, "The film covering the prizes has already been scratched off.")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? If !revealed is false (meaning it was already scratched off) then the associated else produces

to_chat(user, "The film covering the prizes has already been scratched off.")

if(S.is_sharp() || istype(S, /obj/item/weapon/coin))
if(do_after(user, src, 1 SECONDS))
src.revealed = 1
src.update_icon()
to_chat(user, "<span class='notice'>You scratch off the film covering the prizes.</span>")
winnings = scratch(ticket_price)
if(winnings)
src.iswinner = 1
else
to_chat(user, "<span class='notice'>You need to use something sharp to scratch the ticket.</span>")
west3436 marked this conversation as resolved.
Show resolved Hide resolved
else
to_chat(user, "<span class='notice'>The film covering the prizes has already been scratched off.</span>")

/obj/item/toy/lotto_ticket/examine(mob/user)
if(user.range_check(src))
if(revealed)
..()
west3436 marked this conversation as resolved.
Show resolved Hide resolved
if(iswinner)
to_chat(user, "<span class='notice'>This one is a winner! You've won [winnings] credits.</span>")
else
to_chat(user, "<span class='notice'>No wins on this one.</span>")
else
..()
to_chat(user, "<span class='notice'>It hasn't been scratched off yet.</span>")
else
..() //Only show a regular description if it is too far away to read.
to_chat(user, "<span class='notice'>It is too far away to read.</span>")

/obj/item/toy/lotto_ticket/update_icon()
icon_state = initial(icon_state) + (revealed ? "_scratched" : "")

//Tier 1 card
/obj/item/toy/lotto_ticket/gold_rush
name = "Gold Rush lottery ticket"
desc = "A cheap scratch-off lottery ticket. Win up to 100,000 credits!"
icon_state = "lotto_1"
ticket_price = 5 //EV 4.55, ER -0.45

//Tier 2 card
/obj/item/toy/lotto_ticket/diamond_hands
name = "Diamond Hands lottery ticket"
desc = "A mid-price scratch-off lottery ticket. Win up to 400,000 credits!"
icon_state = "lotto_2"
ticket_price = 20 //EV 18.20, ER -1.80

//Tier 3 card
/obj/item/toy/lotto_ticket/phazon_fortune
name = "Phazon Fortune lottery ticket"
desc = "An expensive scratch-off lottery ticket. Win up to 1,000,000 credits!"
icon_state = "lotto_3"
ticket_price = 50 //EV 45.50, ER -4.50


//Emag card
/obj/item/toy/lotto_ticket/supermatter_surprise
name = "Supermatter Surprise lottery ticket"
desc = "An extremely expensive scratch-off lottery ticket. Guaranteed win up to 100,000 credits!"
icon_state = "lotto_4"
ticket_price = 100

/obj/item/toy/lotto_ticket/supermatter_surprise/scratch()
var/list/prizelist = list(100000,50000,10000,5000,1000,500,250,100,50,20,10,5,4,3,2,1)
var/list/problist = list(0.0001, 0.0002, 0.001, 0.002, 0.01, 0.02, 0.04, 0.2, 1, 2.5, 5, 10, 12.5, 17, 20, 25)
west3436 marked this conversation as resolved.
Show resolved Hide resolved
var/input_price = 5
var/profit = 0
while(!profit)
for(var/prize = 1 to problist.len)
if(prob(problist[prize]))
profit = prizelist[prize]*input_price
return profit

/obj/item/toy/lotto_ticket/supermatter_surprise/attackby(obj/item/weapon/S, mob/user)
west3436 marked this conversation as resolved.
Show resolved Hide resolved
..()
to_chat(user, "<span class='notice'>Removing the film emits a brilliant flash of light!</span>")
//Radiation emission code taken from Jukebox
emitted_harvestable_radiation(get_turf(src), 20, range = 5) //Standing by a juke applies a dose of 17 rads to humans so we'll round based on that. 1/5th the power of a freshly born stage 1 singularity.
for(var/mob/living/carbon/M in view(src,3))
var/rads = 50 * sqrt( 1 / (get_dist(M, src) + 1) ) //It's like a transmitter, but 1/3 as powerful.
M.apply_radiation(round(rads/2),RAD_EXTERNAL) //Distance/rads: 1 = 18, 2 = 14, 3 = 12
var/flash_turf = get_turf(src)
for(var/mob/living/M in get_hearers_in_view(3, flash_turf))
flash(get_turf(M), M)
Binary file modified icons/obj/toy.dmi
Binary file not shown.
Binary file modified icons/obj/vending.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions vgstation13.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1636,6 +1636,7 @@
#include "code\modules\food\customizables.dm"
#include "code\modules\food\icecreamvat.dm"
#include "code\modules\food\recipes_microwave.dm"
#include "code\modules\games\cards\lotto.dm"
#include "code\modules\games\cards\playing_cards.dm"
#include "code\modules\games\cards\wizard_cards.dm"
#include "code\modules\games\cards\une\une_cards.dm"
Expand Down