Skip to content

Commit

Permalink
Adds a few more feedback stats and fixes some others (shiptest-ss13#3655
Browse files Browse the repository at this point in the history
)

<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->
Now that I have the statbus working to show off feedback stats properly,
I figured I'd touch up our feedback stat logging and add a little bit
more.

- Makes adjust_money() use defines mostly for consistency
- Adds feedback for ordering crates from outposts
- Records ship renames
- Records encounter spawns (to see what people go to the most)
- Records mission stats (successes, failures, etc)
Lets coders get a better read on what players are doing, allows me to
add even more stuff to statbus

:cl:
server: Logs a few more stats for use in the Statbus at
https://shiptest.net/stats
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
MarkSuckerberg authored and MrCat15352 committed Dec 27, 2024
1 parent 4ab1c79 commit c7f3366
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 50 deletions.
26 changes: 11 additions & 15 deletions code/__DEFINES/economy.dm
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#define ACCOUNT_CIV "CIV"
#define ACCOUNT_CIV_NAME "Civil Budget"
#define ACCOUNT_ENG "ENG"
#define ACCOUNT_ENG_NAME "Engineering Budget"
#define ACCOUNT_SCI "SCI"
#define ACCOUNT_SCI_NAME "Scientific Budget"
#define ACCOUNT_MED "MED"
#define ACCOUNT_MED_NAME "Medical Budget"
#define ACCOUNT_SRV "SRV"
#define ACCOUNT_SRV_NAME "Service Budget"
#define ACCOUNT_CAR "CAR"
#define ACCOUNT_CAR_NAME "Cargo Budget"
#define ACCOUNT_SEC "SEC"
#define ACCOUNT_SEC_NAME "Defense Budget"
#define CREDIT_LOG_WITHDRAW "cash"
#define CREDIT_LOG_TRANSFER_IN "transfer"
#define CREDIT_LOG_TRANSFER_OUT "transfer_out"
#define CREDIT_LOG_DEPOSIT "deposit"
#define CREDIT_LOG_STARTING_MONEY "starting_money"
#define CREDIT_LOG_VENDOR_PURCHASE "vendor_purchase"
#define CREDIT_LOG_MISSION "mission"
#define CREDIT_LOG_CARGO "cargo_purchase"
#define CREDIT_LOG_BOUNTY "bounty"
#define CREDIT_LOG_SYNDICATE_CONTRACT "syndicate_contract"
#define CREDIT_LOG_SELLING_PAD "selling_pad"

#define NO_FREEBIES "commies go home"
1 change: 1 addition & 0 deletions code/controllers/subsystem/overmap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ SUBSYSTEM_DEF(overmap)

var/datum/map_generator/mapgen = new dynamic_datum.mapgen
var/datum/map_template/ruin/used_ruin = ispath(ruin_type) ? (new ruin_type) : ruin_type
SSblackbox.record_feedback("tally", "encounter_spawned", 1, "[dynamic_datum.mapgen]")

// name is random but PROBABLY unique
var/encounter_name = dynamic_datum.planet_name || "\improper Uncharted Space [dynamic_datum.x]/[dynamic_datum.y]-[rand(1111, 9999)]"
Expand Down
2 changes: 1 addition & 1 deletion code/controllers/subsystem/shuttle.dm
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ SUBSYSTEM_DEF(shuttle)
user.forceMove(new_ship.get_jump_to_turf())
message_admins("[key_name_admin(user)] loaded [new_ship] ([S]) with the shuttle manipulator.")
log_admin("[key_name(user)] loaded [new_ship] ([S]) with the shuttle manipulator.</span>")
SSblackbox.record_feedback("text", "shuttle_manipulator", 1, "[S]")
SSblackbox.record_feedback("tally", "shuttle_manipulator_spawned", 1, "[S]")

if("edit_template")
if(S)
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/bank_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
if(value)
var/datum/bank_account/ship_account = ship_account_ref.resolve()
if(ship_account)
ship_account.adjust_money(value, "deposit")
ship_account.adjust_money(value, CREDIT_LOG_DEPOSIT)
to_chat(user, "<span class='notice'>You deposit [I]. The [ship_account.account_holder] Budget is now [ship_account.account_balance] cr.</span>")
qdel(I)
return
Expand All @@ -53,7 +53,7 @@

playsound(src, 'sound/items/poster_being_created.ogg', 100, TRUE)
syphoning_credits += 200
ship_account.adjust_money(-200)
ship_account.adjust_money(-200, "siphon")
if(next_warning < world.time && prob(15))
var/area/A = get_area(loc)
var/message = "Unauthorized credit withdrawal underway in [initial(A.name)]!!"
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/roulette_machine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@

var/remaining_payout = payout

my_card.registered_account.adjust_money(-payout)
my_card.registered_account.adjust_money(-payout, CREDIT_LOG_WITHDRAW)

for(var/cash_type in cash_values) //Loop through all bundles from most valuable to least valuable. Try to give as much of that bundle as possible until you can't anymore, then move to the next.
var/value = cash_values[cash_type] //Change this to use initial value once we change to the right bundle
Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/bank_card.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
to_chat(user, "<span class='warning'>[src] doesn't have a linked account to deposit [I] into!</span>")
return

registered_account.adjust_money(cash_money)
registered_account.adjust_money(cash_money, CREDIT_LOG_DEPOSIT)
SSblackbox.record_feedback("amount", "credits_inserted", cash_money)
log_econ("[cash_money] credits were inserted into [src] owned by [src.registered_name]")
if(physical_currency)
Expand All @@ -69,7 +69,7 @@

total += cash_money

registered_account.adjust_money(cash_money)
registered_account.adjust_money(cash_money, CREDIT_LOG_DEPOSIT)
SSblackbox.record_feedback("amount", "credits_inserted", total)
log_econ("[total] credits were inserted into [src] owned by [src.registered_name]")
QDEL_LIST(money)
Expand Down Expand Up @@ -132,7 +132,7 @@
return
if(!alt_click_can_use_id(user))
return
if(registered_account.adjust_money(-amount_to_remove))
if(registered_account.adjust_money(-amount_to_remove, CREDIT_LOG_WITHDRAW))
var/obj/item/holochip/holochip = new (user.drop_location(), amount_to_remove)
user.put_in_hands(holochip)
to_chat(user, "<span class='notice'>You withdraw [amount_to_remove] credits into a holochip.</span>")
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/traitor/syndicate_contract.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
C = H.get_bankcard()

if(C && C.registered_account)
C.registered_account.adjust_money(ransom * 0.35, "syndicate_contract")
C.registered_account.adjust_money(ransom * 0.35, CREDIT_LOG_SYNDICATE_CONTRACT)

C.registered_account.bank_card_talk("We've processed the ransom, agent. Here's your cut - your balance is now \
[C.registered_account.account_balance] cr.", TRUE)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/cargo/bounty.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ GLOBAL_LIST_EMPTY(bounties_list)
// Called when the claim button is clicked. Override to provide fancy rewards.
/datum/bounty/proc/claim(datum/bank_account/claimer_account)
if(can_claim() && claimer_account)
claimer_account.adjust_money(reward, "bounty")
claimer_account.adjust_money(reward, CREDIT_LOG_BOUNTY)
claimed = TRUE

// If an item sent in the cargo shuttle can satisfy the bounty.
Expand Down
8 changes: 4 additions & 4 deletions code/modules/cargo/console.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
// no giving yourself money
if(!charge_account || !val || val <= 0)
return
if(charge_account.adjust_money(-val))
if(charge_account.adjust_money(-val, CREDIT_LOG_WITHDRAW))
var/obj/item/holochip/cash_chip = new /obj/item/holochip(drop_location(), val)
if(ishuman(usr))
var/mob/living/carbon/human/user = usr
Expand Down Expand Up @@ -215,7 +215,7 @@
if (beacon)
beacon.update_status(SP_READY) //turns on the beacon's ready light
if("printBeacon")
if(charge_account?.adjust_money(-BEACON_COST))
if(charge_account?.adjust_money(-BEACON_COST, "cargo_beacon"))
cooldown = 10//a ~ten second cooldown for printing beacons to prevent spam
var/obj/item/supplypod_beacon/C = new /obj/item/supplypod_beacon(drop_location())
C.link_console(src, usr)//rather than in beacon's Initialize(), we can assign the computer to the beacon by reusing this proc)
Expand Down Expand Up @@ -251,7 +251,7 @@
// note that, because of CHECK_TICK above, we aren't sure if we can
// afford the pack, even though we checked earlier. luckily adjust_money
// returns false if the account can't afford the price
if(landing_turf && charge_account.adjust_money(-pack.cost))
if(landing_turf && charge_account.adjust_money(-pack.cost, CREDIT_LOG_CARGO))
var/name = "*None Provided*"
var/rank = "*None Provided*"
if(ishuman(usr))
Expand Down Expand Up @@ -324,7 +324,7 @@
/obj/machinery/computer/cargo/attackby(obj/item/W, mob/living/user, params)
var/value = W.get_item_credit_value()
if(value && charge_account)
charge_account.adjust_money(value)
charge_account.adjust_money(value, CREDIT_LOG_DEPOSIT)
to_chat(user, "<span class='notice'>You deposit [W]. The Vessel Budget is now [charge_account.account_balance] cr.</span>")
qdel(W)
return TRUE
Expand Down
2 changes: 2 additions & 0 deletions code/modules/cargo/order.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
src.orderer_ckey = orderer_ckey
src.reason = reason
src.paying_account = paying_account
if(pack && paying_account)
SSblackbox.record_feedback("tally", "crate_ordered", 1, pack.name)

/datum/supply_order/proc/generateRequisition(turf/T)
var/obj/item/paper/requisition_paper = new(T)
Expand Down
8 changes: 4 additions & 4 deletions code/modules/economy/account.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/datum/bank_account/proc/has_money(amt)
return account_balance >= amt

/datum/bank_account/proc/adjust_money(amt, reason = "cash")
/datum/bank_account/proc/adjust_money(amt, reason = CREDIT_LOG_WITHDRAW)
if((amt < 0 && has_money(-amt)) || amt > 0)
SSblackbox.record_feedback("tally", "credits", amt, reason)
SSeconomy.bank_money += amt
Expand All @@ -39,10 +39,10 @@

/datum/bank_account/proc/transfer_money(datum/bank_account/from, amount)
if(from.has_money(amount))
adjust_money(amount, "transfer")
adjust_money(amount, CREDIT_LOG_TRANSFER_IN)
SSblackbox.record_feedback("amount", "credits_transferred", amount)
log_econ("[amount] credits were transferred from [from.account_holder]'s account to [src.account_holder]")
from.adjust_money(-amount, "transfer_out")
from.adjust_money(-amount, CREDIT_LOG_TRANSFER_OUT)
return TRUE
return FALSE

Expand Down Expand Up @@ -83,4 +83,4 @@

/datum/bank_account/ship/New(newname, budget)
account_holder = newname
adjust_money(budget, "starting_money")
adjust_money(budget, CREDIT_LOG_STARTING_MONEY)
4 changes: 2 additions & 2 deletions code/modules/economy/pay_stand.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
if(momsdebitcard < 1)
to_chat(user, "<span class='warning'>ERROR: Invalid amount designated.</span>")
return
if(vbucks.registered_account.adjust_money(-momsdebitcard, "transfer"))
if(vbucks.registered_account.adjust_money(-momsdebitcard, CREDIT_LOG_TRANSFER_IN))
purchase(vbucks.registered_account.account_holder, momsdebitcard)
to_chat(user, "Thanks for purchasing! The vendor has been informed.")
return
Expand Down Expand Up @@ -117,7 +117,7 @@
return ..()

/obj/machinery/paystand/proc/purchase(buyer, price)
my_card.registered_account.adjust_money(price, "transfer")
my_card.registered_account.adjust_money(price, CREDIT_LOG_TRANSFER_IN)
my_card.registered_account.bank_card_talk("Purchase made at your vendor by [buyer] for [price] credits.")
amount_deposited = amount_deposited + price
if(signaler && amount_deposited >= signaler_threshold)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/economy/selling_pad.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/obj/machinery/computer/selling_pad_control/attackby(obj/item/I, mob/user)
var/value = I.get_item_credit_value()
if(value)
sell_account.adjust_money(value, "selling_pad")
sell_account.adjust_money(value, CREDIT_LOG_SELLING_PAD)
to_chat(user, "<span class='notice'>You deposit [I]. The Vessel Budget is now [sell_account.account_balance] cr.</span>")
qdel(I)
return TRUE
Expand Down Expand Up @@ -150,7 +150,7 @@
total_report.total_amount[E] += ex.total_amount[E]
total_report.total_value[E] += ex.total_value[E]

sell_account.adjust_money(value, "selling_pad")
sell_account.adjust_money(value, CREDIT_LOG_SELLING_PAD)

if(!value)
status_report += "Nothing"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/jobs/job_types/_job.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
return FALSE
if(!visualsOnly)
var/datum/bank_account/bank_account = new(H.real_name, H.age)
bank_account.adjust_money(officer ? 250 : 100, "starting_money") //just a little bit of money for you
bank_account.adjust_money(officer ? 250 : 100, CREDIT_LOG_STARTING_MONEY) //just a little bit of money for you
H.account_id = bank_account.account_id

//Equip the rest of the gear
Expand Down
1 change: 0 additions & 1 deletion code/modules/mob/living/simple_animal/bot/secbot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
var/fair_market_price_arrest = 25 // On arrest, charges the violator this much. If they don't have that much in their account, the securitron will beat them instead
var/fair_market_price_detain = 5 // Charged each time the violator is stunned on detain
var/weapon_force = 20 // Only used for NAP violation beatdowns on non-grievous securitrons
var/payment_department = ACCOUNT_SEC

/mob/living/simple_animal/bot/secbot/beepsky
name = "Commander Beep O'sky"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/modular_computers/laptop_vendor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
var/obj/item/card/bank/ID = I
var/datum/bank_account/account = ID.registered_account
var/target_credits = total_price - credits
if(!account.adjust_money(-target_credits, "laptop_vendor"))
if(!account.adjust_money(-target_credits, CREDIT_LOG_VENDOR_PURCHASE))
say("Insufficient credits on card to purchase!")
return
credits += target_credits
Expand Down
6 changes: 5 additions & 1 deletion code/modules/overmap/missions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
return ..()

/datum/mission/proc/accept(datum/overmap/ship/controlled/acceptor, turf/accept_loc)
SSblackbox.record_feedback("tally", "mission_accepted", 1, name)
accepted = TRUE
servant = acceptor
LAZYREMOVE(source_outpost.missions, src)
Expand All @@ -63,10 +64,13 @@
return ..()

/datum/mission/proc/turn_in()
servant.ship_account.adjust_money(value, "mission")
SSblackbox.record_feedback("tally", "mission_succeeded", 1, name)
SSblackbox.record_feedback("tally", "mission_payout", value, name)
servant.ship_account.adjust_money(value, CREDIT_LOG_MISSION)
qdel(src)

/datum/mission/proc/give_up()
SSblackbox.record_feedback("tally", "mission_abandoned", 1, name)
qdel(src)

/datum/mission/proc/can_complete()
Expand Down
1 change: 1 addition & 0 deletions code/modules/overmap/ships/controlled_ship_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
return FALSE
message_admins("[key_name_admin(usr)] renamed vessel '[oldname]' to '[new_name]'")
log_admin("[key_name(src)] has renamed vessel '[oldname]' to '[new_name]'")
SSblackbox.record_feedback("text", "ship_renames", 1, new_name)
shuttle_port?.name = new_name
ship_account.account_holder = new_name
if(shipkey)
Expand Down
26 changes: 16 additions & 10 deletions code/modules/vending/_vending.dm
Original file line number Diff line number Diff line change
Expand Up @@ -815,16 +815,22 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C
// else
// account.adjust_money(-price_to_use, "vendor_purchase")
// SSblackbox.record_feedback("amount", "vending_spent", price_to_use) // CELADON-EDIT - ORIGINAL
var/datum/bank_account/account = C.registered_account
if(price_to_use)
if(account.has_money(price_to_use))
var/datum/bank_account/owner = private_a
if(owner)
owner.transfer_money(account, price_to_use)
else
account.adjust_money(-price_to_use, "vendor_purchase")
SSblackbox.record_feedback("amount", "vending_spent", price_to_use)
// var/datum/bank_account/account = C.registered_account
// if(price_to_use)
// if(account.has_money(price_to_use))
// var/datum/bank_account/owner = private_a
// if(owner)
// owner.transfer_money(account, price_to_use)
// else
// account.adjust_money(-price_to_use, "vendor_purchase")
// SSblackbox.record_feedback("amount", "vending_spent", price_to_use) // НАШЕ
// [/CELADON-EDIT]
var/datum/bank_account/payment_account = payment_account_ref.resolve()
if(payment_account)
payment_account.transfer_money(account, price_to_use)
else
account.adjust_money(-price_to_use, CREDIT_LOG_VENDOR_PURCHASE)
SSblackbox.record_feedback("amount", "vending_spent", price_to_use)
log_econ("[price_to_use] credits were inserted into [src] by [H] to buy [R].")
if(last_shopper != REF(usr) || purchase_message_cooldown < world.time)
say("Thank you for shopping with [src]!")
Expand Down Expand Up @@ -1088,7 +1094,7 @@ IF YOU MODIFY THE PRODUCTS LIST OF A MACHINE, MAKE SURE TO UPDATE ITS RESUPPLY C
if(owner)
owner.transfer_money(account, S.custom_price)
else
account.adjust_money(-S.custom_price, "vendor_purchase")
account.adjust_money(-S.custom_price, CREDIT_LOG_VENDOR_PURCHASE)
SSblackbox.record_feedback("amount", "vending_spent", S.custom_price)
log_econ("[S.custom_price] credits were spent on [src] buying a [S] by [owner.account_holder], owned by [private_a.account_holder].")
vending_machine_input[N] = max(vending_machine_input[N] - 1, 0)
Expand Down

0 comments on commit c7f3366

Please sign in to comment.