Skip to content

Commit

Permalink
[MIRROR] Unit test for black market items. Added missing bulwark modu…
Browse files Browse the repository at this point in the history
…le and jawed hook to the market. (#2384) (#3239)

* Unit test for black market items. Added missing bulwark module and jawed hook to the market. (#82972)

## About The Pull Request
Jacq has come up with the suggestion of adding a unit test to the
blackmarket. I agreed ~~and I think I deserve the NO GBP label because
both of these missing items are actually my fault~~.

## Why It's Good For The Game
Let's avoid issues like this in the future.

## Changelog

:cl:
fix: Added the missing bulwark MOD module and the jawed fishing hook to
the black market.
/:cl:

* Unit test for black market items. Added missing bulwark module and jawed hook to the market.

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: Ghom <[email protected]>
  • Loading branch information
3 people authored May 9, 2024
1 parent 4a1b162 commit 369c715
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 1 deletion.
5 changes: 4 additions & 1 deletion code/modules/cargo/markets/market_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
/// Path to or the item itself what this entry is for, this should be set even if you override spawn_item to spawn your item.
var/atom/movable/item

/// Used to exclude abstract/special paths from the unit test if the value matches the type itself.
var/abstract_path

/// Minimum price for the item if generated randomly.
var/price_min = 0
/// Maximum price for the item if generated randomly.
Expand All @@ -25,7 +28,7 @@
/// Maximum amount that there should be of this item in the market if generated randomly.
var/stock_max = 0
/// Probability for this item to be available. Used by SSblackmarket on init.
var/availability_prob = 0
var/availability_prob

///The identifier for the market item, generated on runtime and used to access them in the market categories.
var/identifier
Expand Down
1 change: 1 addition & 0 deletions code/modules/cargo/markets/market_items/clothing.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/datum/market_item/clothing
category = "Clothing"
abstract_path = /datum/market_item/clothing

/datum/market_item/clothing/ninja_mask
name = "Space Ninja Mask"
Expand Down
1 change: 1 addition & 0 deletions code/modules/cargo/markets/market_items/consumables.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/datum/market_item/consumable
category = "Consumables"
abstract_path = /datum/market_item/consumable

/datum/market_item/consumable/clown_tears
name = "Bottle of Clown's Tears"
Expand Down
1 change: 1 addition & 0 deletions code/modules/cargo/markets/market_items/hostages.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
///A special category for mobs captured by pirates, tots and contractors, should someone ever want to get them back in advance.
/datum/market_item/hostage
category = "Hostages"
abstract_path = /datum/market_item/hostage
stock = 1
availability_prob = 100
shipping_override = list(SHIPPING_METHOD_LTSRBT = 0, SHIPPING_METHOD_SUPPLYPOD = 350)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/cargo/markets/market_items/misc.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/datum/market_item/misc
category = "Miscellaneous"
abstract_path = /datum/market_item/misc

/datum/market_item/misc/Clear_PDA
name = "Clear PDA"
Expand Down Expand Up @@ -53,6 +54,7 @@
/datum/market_item/misc/shove_blocker
name = "MOD Bulwark Module"
desc = "You have no idea how much effort it took us to extract this module from that damn safeguard MODsuit last shift."
item = /obj/item/mod/module/shove_blocker
price_min = CARGO_CRATE_VALUE * 4
price_max = CARGO_CRATE_VALUE * 5.75
stock_max = 1
Expand Down Expand Up @@ -108,6 +110,7 @@
/datum/market_item/misc/jawed_hook
name = "Jawed Fishing Hook"
desc = "The thing ya use if y'are strugglin' with fishes. Just rememeber to whoop yer rod before it's too late, 'cause this thing's gonna hurt them like an Arkansas toothpick."
item = /obj/item/fishing_hook/jaws
price_min = CARGO_CRATE_VALUE * 0.75
price_max = CARGO_CRATE_VALUE * 2
stock_max = 3
Expand Down
1 change: 1 addition & 0 deletions code/modules/cargo/markets/market_items/stolen_goods.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
///A special category for goods stolen by spies for their bounties.
/datum/market_item/stolen_good
category = "Fenced Goods"
abstract_path = /datum/market_item/stolen_good
stock = 1
availability_prob = 100

Expand Down
1 change: 1 addition & 0 deletions code/modules/cargo/markets/market_items/tools.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/datum/market_item/tool
category = "Tools"
abstract_path = /datum/market_item/tool

/datum/market_item/tool/blackmarket_telepad
name = "Black Market LTSRBT"
Expand Down
1 change: 1 addition & 0 deletions code/modules/cargo/markets/market_items/weapons.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/datum/market_item/weapon
category = "Weapons"
abstract_path = /datum/market_item/weapon

/datum/market_item/weapon/bear_trap
name = "Bear Trap"
Expand Down
1 change: 1 addition & 0 deletions code/modules/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
#include "bespoke_id.dm"
#include "binary_insert.dm"
#include "bitrunning.dm"
#include "blackmarket.dm"
#include "blindness.dm"
#include "bloody_footprints.dm"
#include "breath.dm"
Expand Down
23 changes: 23 additions & 0 deletions code/modules/unit_tests/blackmarket.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/// Ensures black market items have acceptable variable values.
/datum/unit_test/blackmarket

/datum/unit_test/blackmarket/Run()
for(var/datum/market_item/prototype as anything in subtypesof(/datum/market_item))
if(prototype::abstract_path == prototype) //skip abstract paths
continue
if(!prototype::category)
TEST_FAIL("[prototype] doesn't have a set category (or the abstract path var isn't correctly set)")
continue
if(!prototype::item)
TEST_FAIL("[prototype] doesn't have a set item (or the abstract path var isn't correctly set)")
continue
if(isnull(prototype::price) && prototype::price_max <= prototype::price_min)
TEST_FAIL("[prototype] doesn't have a correctly set random price (price_max should be higher than price_min)")
if(isnull(prototype::stock) && prototype::stock_max < prototype::stock_min)
TEST_FAIL("[prototype] doesn't have a correctly set random stock (stock_max shouldn't be lower than stock_min)")
if(!isnum(prototype::availability_prob))
TEST_FAIL("[prototype] doesn't have a set availability_prob (must be a number)")
if(!prototype::name)
TEST_FAIL("[prototype] doesn't have a set name")
if(!prototype::desc)
TEST_FAIL("[prototype] doesn't have a set desc")

0 comments on commit 369c715

Please sign in to comment.