mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 02:16:05 +00:00
Adds bank account security prefs (#19547)
* Adds bank account security prefs * right, that's not live yet * fucking SPACES * okay i guess we're removing 012 again * Use INTEGER instead of TEXT for storing preferences. Plus other changes. * String represent of bank security level numbers is now shown. * Fixed typos and added suggestions * fix explanation * clarify which account is secure
This commit is contained in:
@@ -19,6 +19,7 @@ CREATE TABLE players (
|
||||
be_special TEXT,
|
||||
disabilities INTEGER,
|
||||
nanotrasen_relation TEXT,
|
||||
bank_security INTEGER,
|
||||
UNIQUE ( player_ckey, player_slot )
|
||||
);
|
||||
|
||||
|
||||
@@ -404,3 +404,30 @@ var/station_does_not_tip = FALSE
|
||||
#define CARD_CAPTURE_FAILURE_USER_CANCELED 7 // The user canceled the transaction
|
||||
#define CARD_CAPTURE_FAILURE_NO_DESTINATION 8 // There was no linked account to send funds to.
|
||||
#define CARD_CAPTURE_FAILURE_NO_CONNECTION 9 // Account database not available.
|
||||
|
||||
#define BANK_SECURITY_EXPLANATION {"Choose your bank account security level.
|
||||
Vendors will try to subtract from your virtual wallet if possible.
|
||||
If you're too broke, they'll try to access your bank account directly.
|
||||
This setting decides how much info you have to enter to allow for that.
|
||||
Zero; Only your account number is required to deduct funds.
|
||||
One; Your account number and PIN are required.
|
||||
Two; Your ID card, account number and PIN are required.
|
||||
You can change this mid-game at an ATM."}
|
||||
|
||||
proc/bank_security_num2text(var/num)
|
||||
switch(num)
|
||||
if(0)
|
||||
return "Zero"
|
||||
if(1)
|
||||
return "One"
|
||||
if(2)
|
||||
return "Two"
|
||||
else
|
||||
return "OUT OF RANGE"
|
||||
|
||||
var/list/bank_security_text2num_associative = list(
|
||||
"Zero" = 0,
|
||||
"One" = 1,
|
||||
"Two" = 2
|
||||
) // Can't use a zero. Throws a fit about out of bounds indices if you do.
|
||||
// Also if you add more security levels, please also update the above BANK_SECURITY_EXPLANATION
|
||||
|
||||
@@ -396,8 +396,10 @@ var/global/datum/controller/occupations/job_master
|
||||
// Total between $200 and $500
|
||||
var/balance_bank = rand(100,250)
|
||||
balance_wallet = rand(100,250)
|
||||
var/bank_pref_number = H.client.prefs.bank_security
|
||||
var/bank_pref = bank_security_num2text(bank_pref_number)
|
||||
if(centcomm_account_db)
|
||||
var/datum/money_account/M = create_account(H.real_name, balance_bank, null, wage_payout = PLAYER_START_WAGE)
|
||||
var/datum/money_account/M = create_account(H.real_name, balance_bank, null, wage_payout = PLAYER_START_WAGE, security_pref = bank_pref_number)
|
||||
if(H.mind)
|
||||
var/remembered_info = ""
|
||||
remembered_info += "<b>Your account number is:</b> #[M.account_number]<br>"
|
||||
@@ -427,6 +429,7 @@ var/global/datum/controller/occupations/job_master
|
||||
spawn()
|
||||
to_chat(H, "<span class='danger'>Your bank account number is: <span style='color: black;'>[M.account_number]</span>, your bank account pin is: <span style='color: black;'>[M.remote_access_pin]</span></span>")
|
||||
to_chat(H, "<span class='danger'>Your virtual wallet funds are: <span style='color: black;'>$[balance_wallet]</span>, your bank account funds are: <span style='color: black;'>$[balance_bank]</span></span>")
|
||||
to_chat(H, "<span class='danger'>Your bank account security level is set to: <span style='color: black;'>[bank_pref]</span></span>")
|
||||
|
||||
var/alt_title = null
|
||||
if(H.mind)
|
||||
|
||||
@@ -64,8 +64,7 @@ var/global/datum/money_account/trader_account
|
||||
//the current ingame time (hh:mm) can be obtained by calling:
|
||||
//worldtime2text()
|
||||
|
||||
/proc/create_account(var/new_owner_name = "Default user", var/starting_funds = 0, var/obj/machinery/account_database/source_db, var/wage_payout = 0)
|
||||
|
||||
/proc/create_account(var/new_owner_name = "Default user", var/starting_funds = 0, var/obj/machinery/account_database/source_db, var/wage_payout = 0, var/security_pref = 1)
|
||||
|
||||
//create a new account
|
||||
var/datum/money_account/M = new()
|
||||
@@ -73,6 +72,7 @@ var/global/datum/money_account/trader_account
|
||||
M.remote_access_pin = rand(1111, 9999)
|
||||
M.money = starting_funds
|
||||
M.wage_gain = wage_payout
|
||||
M.security_level = security_pref
|
||||
|
||||
//create an entry in the account transaction log for when it was created
|
||||
var/datum/transaction/T = new()
|
||||
|
||||
@@ -167,6 +167,8 @@ var/const/MAX_SAVE_SLOTS = 8
|
||||
var/disabilities = 0 // NOW A BITFIELD, SEE ABOVE
|
||||
|
||||
var/nanotrasen_relation = "Neutral"
|
||||
var/bank_security = 1 //for bank accounts, 0-2, no-pin,pin,pin&card
|
||||
|
||||
|
||||
// 0 = character settings, 1 = game preferences
|
||||
var/current_tab = 0
|
||||
@@ -262,6 +264,7 @@ var/const/MAX_SAVE_SLOTS = 8
|
||||
<b>Flavor Text:</b><a href='byond://?src=\ref[user];preference=flavor_text;task=input'>Set</a><br>
|
||||
<b>Character records:</b>
|
||||
[jobban_isbanned(user, "Records") ? "Banned" : "<a href=\"byond://?src=\ref[user];preference=records;record=1\">Set</a>"]<br>
|
||||
<b>Bank account security preference:</b><a href ='?_src_=prefs;preference=bank_security;task=input'>[bank_security_num2text(bank_security)]</a> <br>
|
||||
</td><td valign='top' width='21%'>
|
||||
<h3>Hair Style</h3>
|
||||
<a href='?_src_=prefs;preference=h_style;task=input'>[h_style]</a><BR>
|
||||
@@ -1252,6 +1255,11 @@ NOTE: The change will take effect AFTER any current recruiting periods."}
|
||||
if(new_relation)
|
||||
nanotrasen_relation = new_relation
|
||||
|
||||
if("bank_security")
|
||||
var/new_bank_security = input(user, BANK_SECURITY_EXPLANATION, "Character Preference") as null|anything in bank_security_text2num_associative
|
||||
if(!isnull(new_bank_security))
|
||||
bank_security = bank_security_text2num_associative[new_bank_security]
|
||||
|
||||
if("flavor_text")
|
||||
flavor_text = input(user,"Set the flavor text in your 'examine' verb. This can also be used for OOC notes and preferences!","Flavor Text",html_decode(flavor_text)) as message
|
||||
|
||||
|
||||
@@ -310,6 +310,7 @@ SELECT
|
||||
players.player_alt_titles,
|
||||
players.disabilities,
|
||||
players.nanotrasen_relation,
|
||||
players.bank_security,
|
||||
jobs.player_ckey,
|
||||
jobs.player_slot,
|
||||
jobs.alternate_option,
|
||||
@@ -400,6 +401,7 @@ AND players.player_slot = ? ;"}, ckey, slot)
|
||||
player_alt_titles = player_alt_list2
|
||||
disabilities = text2num(preference_list["disabilities"])
|
||||
nanotrasen_relation = preference_list["nanotrasen_relation"]
|
||||
bank_security = preference_list["bank_security"]
|
||||
|
||||
r_hair = text2num(preference_list["hair_red"])
|
||||
g_hair = text2num(preference_list["hair_green"])
|
||||
@@ -455,6 +457,8 @@ AND players.player_slot = ? ;"}, ckey, slot)
|
||||
language = "None"
|
||||
if(isnull(nanotrasen_relation))
|
||||
nanotrasen_relation = initial(nanotrasen_relation)
|
||||
if(isnull(bank_security))
|
||||
bank_security = initial(bank_security)
|
||||
if(!real_name)
|
||||
real_name = random_name(gender,species)
|
||||
be_random_name = sanitize_integer(be_random_name, 0, 1, initial(be_random_name))
|
||||
@@ -581,6 +585,7 @@ AND players.player_slot = ? ;"}, ckey, slot)
|
||||
S["organ_data"] >> organ_data
|
||||
|
||||
S["nanotrasen_relation"] >> nanotrasen_relation
|
||||
S["bank_security"] >> bank_security
|
||||
//S["skin_style"] >> skin_style
|
||||
|
||||
//Sanitize
|
||||
@@ -592,6 +597,8 @@ AND players.player_slot = ? ;"}, ckey, slot)
|
||||
language = "None"
|
||||
if(isnull(nanotrasen_relation))
|
||||
nanotrasen_relation = initial(nanotrasen_relation)
|
||||
if(isnull(bank_security))
|
||||
bank_security = initial(bank_security)
|
||||
if(!real_name)
|
||||
real_name = random_name(gender,species)
|
||||
be_random_name = sanitize_integer(be_random_name, 0, 1, initial(be_random_name))
|
||||
@@ -715,17 +722,17 @@ AND players.player_slot = ? ;"}, ckey, slot)
|
||||
check.Add("SELECT player_ckey FROM players WHERE player_ckey = ? AND player_slot = ?", ckey, slot)
|
||||
if(check.Execute(db))
|
||||
if(!check.NextRow())
|
||||
q.Add("INSERT INTO players (player_ckey,player_slot,ooc_notes,real_name, random_name, gender, age, species, language, flavor_text, med_record, sec_record, gen_record, player_alt_titles, disabilities, nanotrasen_relation, random_body)\
|
||||
q.Add("INSERT INTO players (player_ckey,player_slot,ooc_notes,real_name, random_name, gender, age, species, language, flavor_text, med_record, sec_record, gen_record, player_alt_titles, disabilities, nanotrasen_relation, bank_security, random_body)\
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
ckey, slot, metadata, real_name, be_random_name, gender, age, species, language, flavor_text, med_record, sec_record, gen_record, altTitles, disabilities, nanotrasen_relation, be_random_body)
|
||||
ckey, slot, metadata, real_name, be_random_name, gender, age, species, language, flavor_text, med_record, sec_record, gen_record, altTitles, disabilities, nanotrasen_relation, bank_security, be_random_body)
|
||||
if(!q.Execute(db))
|
||||
message_admins("InsertPlayer: Error #:[q.Error()] - [q.ErrorMsg()]")
|
||||
WARNING("InsertPlayer: Error #:[q.Error()] - [q.ErrorMsg()]")
|
||||
return 0
|
||||
to_chat(user, "Created Character")
|
||||
else
|
||||
q.Add("UPDATE players SET ooc_notes=?,real_name=?,random_name=?, gender=?,age=?,species=?,language=?,flavor_text=?,med_record=?,sec_record=?,gen_record=?,player_alt_titles=?,disabilities=?,nanotrasen_relation=?,random_body=? WHERE player_ckey = ? AND player_slot = ?",\
|
||||
metadata, real_name, be_random_name, gender, age, species, language, flavor_text, med_record, sec_record, gen_record, altTitles, disabilities, nanotrasen_relation, be_random_body, ckey, slot)
|
||||
q.Add("UPDATE players SET ooc_notes=?,real_name=?,random_name=?, gender=?,age=?,species=?,language=?,flavor_text=?,med_record=?,sec_record=?,gen_record=?,player_alt_titles=?,disabilities=?,nanotrasen_relation=?,bank_security=?,random_body=? WHERE player_ckey = ? AND player_slot = ?",\
|
||||
metadata, real_name, be_random_name, gender, age, species, language, flavor_text, med_record, sec_record, gen_record, altTitles, disabilities, nanotrasen_relation, bank_security, be_random_body, ckey, slot)
|
||||
if(!q.Execute(db))
|
||||
message_admins("UpdatePlayer: Error #:[q.Error()] - [q.ErrorMsg()]")
|
||||
WARNING("UpdatePlayer: Error #:[q.Error()] - [q.ErrorMsg()]")
|
||||
@@ -859,6 +866,7 @@ AND players.player_slot = ? ;"}, ckey, slot)
|
||||
S["skill_specialization"] << skill_specialization
|
||||
S["organ_data"] << organ_data
|
||||
S["nanotrasen_relation"] << nanotrasen_relation
|
||||
S["bank_security"] << bank_security
|
||||
//Body
|
||||
S["hair_red"] << r_hair
|
||||
S["hair_green"] << g_hair
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
`be_special` TEXT,
|
||||
`disabilities` INTEGER,
|
||||
`nanotrasen_relation` TEXT,
|
||||
`bank_security` INTEGER,
|
||||
UNIQUE(player_ckey, player_slot)
|
||||
);"}
|
||||
if(!hasTable("players"))
|
||||
|
||||
13
code/modules/migrations/SS13_Prefs/013-add-bank-pref.dm
Normal file
13
code/modules/migrations/SS13_Prefs/013-add-bank-pref.dm
Normal file
@@ -0,0 +1,13 @@
|
||||
/datum/migration/sqlite/ss13_prefs/_013
|
||||
id = 13
|
||||
name = "Add Bank Security Preference"
|
||||
|
||||
/datum/migration/sqlite/ss13_prefs/_013/up()
|
||||
if(!hasColumn("players","bank_security"))
|
||||
return execute("ALTER TABLE `players` ADD COLUMN bank_security INTEGER DEFAULT 1")
|
||||
return TRUE
|
||||
|
||||
/datum/migration/sqlite/ss13_prefs/_013/down()
|
||||
if(hasColumn("players","bank_security"))
|
||||
return execute("ALTER TABLE `players` DROP COLUMN bank_security")
|
||||
return TRUE
|
||||
@@ -1422,6 +1422,7 @@
|
||||
#include "code\modules\migrations\SS13_Prefs\010-add-random-body.dm"
|
||||
#include "code\modules\migrations\SS13_Prefs\011-add-flavor.dm"
|
||||
#include "code\modules\migrations\SS13_Prefs\012-add-pull-pref.dm"
|
||||
#include "code\modules\migrations\SS13_Prefs\013-add-bank-pref.dm"
|
||||
#include "code\modules\migrations\SS13_Prefs\_base.dm"
|
||||
#include "code\modules\mining\abandonedcrates.dm"
|
||||
#include "code\modules\mining\debug_shit.dm"
|
||||
|
||||
Reference in New Issue
Block a user