-
Notifications
You must be signed in to change notification settings - Fork 55
Trade Beacons, Imports and Exports #438
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
Merged
Merged
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
cc17549
add trade_beacon.dm
michaelchessall 392de09
Create trade_beacon.tmpl
michaelchessall 658b1b1
Update tradebeacon.dm
michaelchessall 72510d8
Update trade_beacon.tmpl
michaelchessall a4f7f9a
Fix SQL file
michaelchessall 9f9d035
update trade beacon
michaelchessall b4e1ba8
Update trade_beacon.tmpl
michaelchessall c9a97bf
Update tradebeacon.dm
michaelchessall 409aaad
updates
michaelchessall c892e67
Merge branch 'PersistentSS13:dev' into dev
michaelchessall 44936b6
update files
michaelchessall 034bd06
TRADE BEACON UPDATE
michaelchessall e0814fe
Merge branch 'dev' of https://github.com/FaurnsGoldberg/Nebula into dev
michaelchessall dc44d19
removed old files
michaelchessall ac18716
Delete tradebeacon.dm
michaelchessall 4e23eaa
Update _persistence.dme
michaelchessall 7dc1b2e
Update trade_beacon_program.dm
michaelchessall 7261a26
fix map units tests
michaelchessall 0500438
Fix unit tests, all_trade_beacons list
michaelchessall f500804
fix unit tests
michaelchessall b8a8350
Update _persistence.dme
michaelchessall 6085c60
Update network.dm
michaelchessall 9f21dda
Update cargo_telepads.dm
michaelchessall 3fcae62
Merge branch 'dev' of https://github.com/FaurnsGoldberg/Nebula into dev
michaelchessall 3c60d1b
Update cargo_telepads.dm
michaelchessall 9f61421
fix unit tests, improve readability
michaelchessall 69bc0a2
include return on init
michaelchessall b276e77
Update trade_beacons.dm
michaelchessall 66e5a60
fix unit tests
michaelchessall a4b2754
fix unit tests????
michaelchessall 8b9a391
Update trade_beacons.dm
michaelchessall 3ea5d8f
Update trade_beacons.dm
michaelchessall 0d5da55
Update trade_beacons.dm
michaelchessall 1378028
fix unit tests??
michaelchessall 4628ef5
Update trade_beacons.dm
michaelchessall 6d2347b
Update trade_beacons.dm
michaelchessall b57d1c1
Update trade_beacons.dm
michaelchessall 4095407
fix unit tests
michaelchessall bc08eb5
Update trade_beacons.dm
michaelchessall 62536d2
fix unit tests
michaelchessall eca3ad0
fix err
michaelchessall 84d7567
Update trade_beacons.dm
michaelchessall 7ec419f
Update trade_beacons.dm
michaelchessall b6e288c
Update trade_beacons.dm
michaelchessall 70a4976
z
michaelchessall 921a612
Update trade_beacons.dm
michaelchessall 6d2ad29
Update trade_beacons.dm
michaelchessall 7db1021
Update mods/persistence/modules/trade_beacons/trade_beacons.dm
michaelchessall 4dfa4b2
Update code/modules/economy/cargo_telepads.dm
michaelchessall d8da389
Update code/modules/economy/cargo_telepads.dm
michaelchessall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /obj/machinery/telepad_cargo | ||
| name = "cargo telepad" | ||
| desc = "A telepad used to recieve imports and send exports." | ||
| icon = 'icons/obj/machines/telepad.dmi' | ||
| icon_state = "pad-idle" | ||
| anchored = 1 | ||
| use_power = 1 | ||
| idle_power_usage = 20 | ||
| active_power_usage = 500 | ||
| var/telepad_id = 0 | ||
| obj_flags = OBJ_FLAG_ANCHORABLE | ||
|
|
||
| /obj/machinery/telepad_cargo/Initialize() | ||
| telepad_id = random_id(type,10000,99999) | ||
| . = ..() | ||
|
|
||
| /obj/machinery/telepad_cargo/attackby(obj/item/O as obj, mob/user as mob, params) | ||
| if(IS_MULTITOOL(O)) | ||
michaelchessall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| var/id = input(user, "Enter a new telepad ID", "Telepad ID") as text|null | ||
| id = sanitize(id) | ||
| if(CanInteract(user, DefaultTopicState()) && id) telepad_id = id | ||
michaelchessall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return TRUE | ||
|
|
||
| . = ..() | ||
|
|
||
| /obj/machinery/telepad_cargo/examine(mob/user) | ||
| . = ..() | ||
| to_chat(user, "It has a telepad ID of [telepad_id].") | ||
89 changes: 89 additions & 0 deletions
89
code/modules/modular_computers/hardware/trade_controller.dm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| /datum/extension/network_device/trade_controller | ||
| var/obj/effect/overmap/trade_beacon/linked_beacon | ||
| var/import_tax = 0 | ||
| var/export_tax = 0 | ||
| var/beacon_restrict = 0 // Restriction to ALL beacon functions, import/export/log. 0 = no restricton, 1 = restricted to the network | ||
| var/log_restrict = 0 // Restriction of the transaction log. 0 = no restricton, 1 = restricted to the network | ||
| var/access = 0 // Which access will allow for general beacon functions | ||
| var/log_access = 0 // which access will allow for viewing the transaction log | ||
|
|
||
| /datum/extension/network_device/trade_controller/proc/Unlink() | ||
| if(linked_beacon) | ||
| linked_beacon.linked_controller = null | ||
| linked_beacon = null | ||
| /datum/extension/network_device/trade_controller/Destroy() | ||
| Unlink() | ||
| . = ..() | ||
|
|
||
| /datum/extension/network_device/trade_controller/disconnect(net_down) | ||
| Unlink() | ||
| . = ..() | ||
|
|
||
| /datum/extension/network_device/trade_controller/proc/toggle_beacon_restrict() | ||
| if(!linked_beacon) | ||
| beacon_restrict = 0 | ||
| return | ||
| beacon_restrict = !beacon_restrict | ||
| var/datum/computer_network/network = get_network() | ||
| if(network.trade_controller == src) | ||
| network.add_log("Trade Control Device toggled beacon restriction for [linked_beacon.name].", network_tag) | ||
| return 1 | ||
|
|
||
|
|
||
| /datum/extension/network_device/trade_controller/proc/select_beacon_access(var/mob/M, var/obj/machinery/network/trade_controller/machine) | ||
| var/list/access_choices = list() | ||
| var/datum/computer_network/network = get_network() | ||
| var/datum/extension/network_device/acl/D | ||
| if(network) | ||
| D = network.access_controller | ||
| if(!linked_beacon) | ||
| access = 0 | ||
| return | ||
| if(!D) | ||
| to_chat(M, SPAN_WARNING("Cannot restrict access! No access controller detected on network!")) | ||
| return | ||
| for(var/parent_group in D.group_dict) | ||
| access_choices |= parent_group | ||
| for(var/child_group in D.group_dict[parent_group]) | ||
| access_choices |= child_group | ||
| access_choices |= "*NONE*" | ||
| var/chosen = input(M, "Select an Access for the Trade Beacon.", "Beacon Access Selection") as null|anything in access_choices | ||
| if(chosen && (!machine || machine.CanUseTopic(M))) | ||
| if(chosen == "*NONE*") | ||
| access = 0 | ||
| network.add_log("Trade Control Device unset beacon access for [linked_beacon.name].", network_tag) | ||
| else | ||
| access = chosen | ||
| network.add_log("Trade Control Device set beacon access to [chosen] for [linked_beacon.name].", network_tag) | ||
| return 1 | ||
| /datum/extension/network_device/trade_controller/proc/select_import_tax(var/mob/M, var/obj/machinery/network/trade_controller/machine) | ||
| var/datum/computer_network/network = get_network() | ||
| if(!linked_beacon) | ||
| import_tax = 0 | ||
| return | ||
| var/chosen_tax = input(M, "Enter the import tax% to charge for this beacon. (30% MAX)", "Import Tax") as num|null | ||
| if(!machine || machine.CanUseTopic(M)) | ||
| import_tax = clamp(chosen_tax, 0, 30) | ||
| network.add_log("Trade Control Device changed the import tax rate to [import_tax] for [linked_beacon.name].", network_tag) | ||
| return 1 | ||
|
|
||
| /datum/extension/network_device/trade_controller/proc/select_export_tax(var/mob/M, var/obj/machinery/network/trade_controller/machine) | ||
| var/datum/computer_network/network = get_network() | ||
| if(!linked_beacon) | ||
| export_tax = 0 | ||
| return | ||
| var/chosen_tax = input(M, "Enter the export tax% to charge for this beacon. (30% MAX)", "Export Tax") as num|null | ||
| if(!machine || machine.CanUseTopic(M)) | ||
| export_tax = clamp(chosen_tax, 0, 30) | ||
| network.add_log("Trade Control Device changed the export tax rate to [export_tax] for [linked_beacon.name].", network_tag) | ||
| return 1 | ||
|
|
||
| /datum/extension/network_device/trade_controller/proc/toggle_log_restrict() | ||
| if(!linked_beacon) | ||
| log_restrict = 0 | ||
| return | ||
| log_restrict = !log_restrict | ||
| var/datum/computer_network/network = get_network() | ||
| if(network.trade_controller == src) | ||
| network.add_log("Trade Control Device toggled transaction log restriction for [linked_beacon.name].", network_tag) | ||
| return 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
code/modules/modular_computers/networking/machinery/trade_controller.dm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| /obj/machinery/network/trade_controller | ||
| name = "trade control device" | ||
| desc = "A device used for controlling trade beacons and adding import/export tax. It must remain in a gravity well near the trade beacon" | ||
| icon = 'icons/obj/machines/tcomms/hub.dmi' | ||
| icon_state = "hub" | ||
| network_device_type = /datum/extension/network_device/trade_controller | ||
| main_template = "trade_controller.tmpl" | ||
| construct_state = /decl/machine_construction/default/panel_closed | ||
| uncreated_component_parts = null | ||
| base_type = /obj/machinery/network/trade_controller | ||
|
|
||
|
|
||
| /obj/machinery/network/trade_controller/OnTopic(mob/user, href_list, datum/topic_state/state) | ||
| . = ..() | ||
| if(.) | ||
| return | ||
| var/datum/extension/network_device/trade_controller/D = get_extension(src, /datum/extension/network_device) | ||
| var/datum/computer_network/network = D.get_network() | ||
| if(!network || network.trade_controller != D) | ||
| error = "NETWORK ERROR: Connection lost. Another trade controller may be active on the network." | ||
| return TOPIC_REFRESH | ||
|
|
||
| if(href_list["connect_beacon"]) | ||
| var/list/possible_trade_beacons = get_adjacent_trade_beacons() | ||
| possible_trade_beacons += "*DISCONNECT*" | ||
| var/selected_beacon = input(usr, "Select a nearby trade beacon.", "Pick a beacon") as null|anything in possible_trade_beacons | ||
| if(!CanInteract(user, global.default_topic_state) || !selected_beacon) | ||
| return TOPIC_REFRESH | ||
| if(selected_beacon == "*DISCONNECT*") | ||
| D.Unlink() | ||
| else | ||
| var/obj/effect/overmap/trade_beacon/a = selected_beacon | ||
| if(a.linked_controller) | ||
| to_chat(user, SPAN_NOTICE("This beacon is already connected to a trade control device. The existing trade control device must be removed first.")) | ||
| return TOPIC_REFRESH | ||
| else | ||
| a.linked_controller = D | ||
| D.linked_beacon = a | ||
| return TOPIC_REFRESH | ||
|
|
||
| if(href_list["toggle_beacon_restrict"]) | ||
| D.toggle_beacon_restrict() | ||
| return TOPIC_REFRESH | ||
| if(href_list["select_beacon_access"]) | ||
| D.select_beacon_access(usr, src) | ||
| return TOPIC_REFRESH | ||
| if(href_list["change_import_tax"]) | ||
| D.select_import_tax(usr, src) | ||
| return TOPIC_REFRESH | ||
| if(href_list["change_export_tax"]) | ||
| D.select_export_tax(usr, src) | ||
| return TOPIC_REFRESH | ||
| if(href_list["toggle_log_restrict"]) | ||
| D.toggle_log_restrict() | ||
| return TOPIC_REFRESH | ||
|
|
||
| if(href_list["info"]) | ||
| switch(href_list["info"]) | ||
| if("connect_beacon") | ||
| to_chat(user, SPAN_NOTICE("The Trade Controller can take control of trade beacons that you are within 1 tile of in space. A beacon can only be controlled by one Trade Controller, and will remaiin controlled until that controller is brought offline.")) | ||
| if("restrict_beacon_access") | ||
| to_chat(user, SPAN_NOTICE("If Beacon restriction is turned on, only devices connected to this network and with the appropriate access will be able to use the beacon for imports, exports or viewing the transaction log.")) | ||
| if("select_beacon_access") | ||
| to_chat(user, SPAN_NOTICE("You can set this access to any group in the network, in which case it will be required to access the Import/Export/Log functions for the beacon. If this is unset any device on this network will be able to access the beacon.")) | ||
| if("import_tax") | ||
| to_chat(user, SPAN_NOTICE("This is a percentage added to the cost of all imports done, except those done by the primary money account on this network. The added percentage will be deposited into the primary money account.")) | ||
| if("export_tax") | ||
| to_chat(user, SPAN_NOTICE("This is a percentage taken from the revenue of all exports done, except those done by the primary money account on this network. The added percentage will be deposited into the primary money account.")) | ||
| if("restrict_log_access") | ||
| to_chat(user, SPAN_NOTICE("If Transaction Log restriction is turned on, only devices connected to this network and with the appropriate access will be able to view the transaction log.")) | ||
| if("select_log_access") | ||
| to_chat(user, SPAN_NOTICE("You can set this access to any group in the network, in which case it will be required to access the Log functions for the beacon. If this is unset any device on this network will be able to access the transaction log.")) | ||
|
|
||
| /obj/machinery/network/trade_controller/ui_data(mob/user, ui_key) | ||
| . = ..() | ||
|
|
||
| if(error) | ||
| .["error"] = error | ||
| return | ||
|
|
||
| var/datum/extension/network_device/trade_controller/D = get_extension(src, /datum/extension/network_device) | ||
| if(!D.get_network()) | ||
| .["connected"] = FALSE | ||
| return | ||
| .["connected"] = TRUE | ||
| if(D.linked_beacon) | ||
| .["connected_beacon"] = D.linked_beacon.name | ||
| .["valid_beacon"] = TRUE | ||
| .["beacon_restrict"] = D.beacon_restrict | ||
| if(D.beacon_restrict) | ||
| if(D.access) | ||
| .["selected_beacon_access"] = D.access | ||
| else | ||
| .["selected_beacon_access"] = "*NONE*" | ||
| .["import_tax"] = D.import_tax | ||
| .["export_tax"] = D.export_tax | ||
| .["log_restrict"] = D.log_restrict | ||
| if(D.log_restrict) | ||
| if(D.log_access) | ||
| .["selected_log_access"] = D.log_access | ||
| else | ||
| .["selected_log_access"] = "*NONE*" | ||
| else | ||
| .["connected_beacon"] = "*DISCONNECTED*" |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| SUBSYSTEM_DEF(trade_beacons) | ||
| name = "Trade Beacons" | ||
| wait = 5 MINUTES | ||
| priority = SS_PRIORITY_MONEY_ACCOUNTS | ||
| var/list/all_trade_beacons = list() | ||
| var/list/wanted_trade_beacons = list(/obj/effect/overmap/trade_beacon/test_beacon, /obj/effect/overmap/trade_beacon/test_beacon2) // list(//obj/effect/overmap/trade_beacon/example, /obj/effect/overmap/trade_beacon/steel, /obj/effect/overmap/trade_beacon/xandahar) | ||
| var/last_cycle = 0 | ||
|
|
||
| /datum/controller/subsystem/trade_beacons/Destroy() | ||
| QDEL_NULL_LIST(all_trade_beacons) | ||
| . = ..() | ||
|
|
||
| /datum/controller/subsystem/trade_beacons/Initialize() | ||
| all_trade_beacons = list() | ||
| #ifndef UNIT_TEST | ||
| for(var/x in wanted_trade_beacons) | ||
michaelchessall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| var/obj/effect/overmap/trade_beacon/beacon = new x() | ||
| all_trade_beacons |= beacon | ||
| #endif | ||
| . = ..() | ||
|
|
||
| /datum/controller/subsystem/trade_beacons/fire(resumed = FALSE) | ||
| if(REALTIMEOFDAY >= (last_cycle + 2 HOURS)) | ||
michaelchessall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| last_cycle = REALTIMEOFDAY | ||
| for(var/obj/effect/overmap/trade_beacon/x in all_trade_beacons) | ||
| x.regenerate_imports() | ||
| x.regenerate_exports() | ||
| return | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.