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 13 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
19 changes: 13 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 @@ -235,6 +235,13 @@ For vending packs, see vending_packs.dm*/
A.anchored = 1
src.transfer_fingerprints_to(A)
qdel(src)
if(istype(I, /obj/item/toy/lotto_ticket))
west3436 marked this conversation as resolved.
Show resolved Hide resolved
var/obj/item/toy/lotto_ticket/T = I
for(var/mob/V in hearers(src))
west3436 marked this conversation as resolved.
Show resolved Hide resolved
V.show_message("<b>[src]</b>'s monitor flashes, \"Withdrawing [T.winnings] credits from the Lottery account!\"")
dispense_cash(T.winnings, get_turf(src))
Kurfursten marked this conversation as resolved.
Show resolved Hide resolved
playsound(src, "polaroid", 50, 1)
qdel(T)
else
return ..()

Expand Down Expand Up @@ -318,7 +325,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 +460,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 +521,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 +586,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
34 changes: 34 additions & 0 deletions code/game/machinery/vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3706,3 +3706,37 @@ 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
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"

131 changes: 131 additions & 0 deletions code/modules/games/cards/lotto.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/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
if(istype(src,/obj/item/toy/lotto_ticket/supermatter_surprise))
west3436 marked this conversation as resolved.
Show resolved Hide resolved
input_price = 5 //Sets the prize table equal to the tier-1 card but with a guaranteed win
while(profit == 0)
west3436 marked this conversation as resolved.
Show resolved Hide resolved
for(var/prize = 1 to problist.len)
if(prob(problist[prize]))
return(prizelist[prize]*input_price*tuning_value)
west3436 marked this conversation as resolved.
Show resolved Hide resolved
if(!istype(src,/obj/item/toy/lotto_ticket/supermatter_surprise))
west3436 marked this conversation as resolved.
Show resolved Hide resolved
return

//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 as obj, mob/user as mob)
west3436 marked this conversation as resolved.
Show resolved Hide resolved
if(!src.revealed == 1)
west3436 marked this conversation as resolved.
Show resolved Hide resolved
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>")
if(istype(src,/obj/item/toy/lotto_ticket/supermatter_surprise))
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)
winnings = scratch(ticket_price)
if(winnings > 0)
src.iswinner = 1
return
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
return
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>")
return

/obj/item/toy/lotto_ticket/examine(mob/user)
if(user.range_check(src))
if(revealed == 1)
west3436 marked this conversation as resolved.
Show resolved Hide resolved
..()
west3436 marked this conversation as resolved.
Show resolved Hide resolved
if(iswinner == 1)
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()
if(istype(src,/obj/item/toy/lotto_ticket/gold_rush))
west3436 marked this conversation as resolved.
Show resolved Hide resolved
icon_state = "lotto_1_scratched"
else if(istype(src,/obj/item/toy/lotto_ticket/diamond_hands))
icon_state = "lotto_2_scratched"
else if(istype(src,/obj/item/toy/lotto_ticket/phazon_fortune))
icon_state = "lotto_3_scratched"
else if(istype(src,/obj/item/toy/lotto_ticket/supermatter_surprise))
icon_state = "lotto_4_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 //EV 100,000, ER +99,900 ;^)
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