<commit_before>/*

SYNDICATE UPLINKS

TO-DO:
	Once wizard is fixed, make sure the uplinks work correctly for it. wizard.dm is right now uncompiled and with broken code in it.

	Clean the code up and comment it. Part of it is right now copy-pasted, with the general Topic() and modifications by Abi79.

		I should take a more in-depth look at both the copy-pasted code for the individual uplinks below, and at each gamemode's code
		to see how uplinks are assigned and if there are any bugs with those.


A list of items and costs is stored under the datum of every game mode, alongside the number of crystals, and the welcoming message.

*/

/obj/item/device/uplink
	var/welcome 					// Welcoming menu message
	var/menu_message = "" 			// The actual menu text
	var/items						// List of items
	var/list/ItemList				// Parsed list of items
	var/uses 						// Numbers of crystals
	// List of items not to shove in their hands.
	var/list/NotInHand = list(/obj/machinery/singularity_beacon/syndicate)

	New()
		welcome = ticker.mode.uplink_welcome
		items = dd_replacetext(ticker.mode.uplink_items, "\n", "")	// Getting the text string of items
		ItemList = dd_text2list(src.items, ";")	// Parsing the items text string
		uses = ticker.mode.uplink_uses

//Let's build a menu!
	proc/generate_menu()
		src.menu_message = "<B>[src.welcome]</B><BR>"
		src.menu_message += "Tele-Crystals left: [src.uses]<BR>"
		src.menu_message += "<HR>"
		src.menu_message += "<B>Request item:</B><BR>"
		src.menu_message += "<I>Each item costs a number of tele-crystals as indicated by the number following their name.</I><br><BR>"

		var/cost
		var/item
		var/name
		var/path_obj
		var/path_text
		var/category_items = 1 //To prevent stupid :P

		for(var/D in ItemList)
			var/list/O = stringsplit(D, ":")
			if(O.len != 3)	//If it is not an actual item, make a break in the menu.
				if(O.len == 1)	//If there is one item, it's probably a title
					src.menu_message += "<b>[O[1]]</b><br>"
					category_items = 0
				else	//Else, it's a white space.
					if(category_items < 1)	//If there were no itens in the last category...
						src.menu_message += "<i>We apologize, as you could not afford anything from this category.</i><br>"
					src.menu_message += "<br>"
				continue

			path_text = O[1]
			cost = text2num(O[2])

			if(cost>uses)
				continue

			path_obj = text2path(path_text)
			item = new path_obj()
			name = O[3]
			del item

			src.menu_message += "<A href='byond://?src=\ref[src];buy_item=[path_text];cost=[cost]'>[name]</A> ([cost])<BR>"
			category_items++

		src.menu_message += "<A href='byond://?src=\ref[src];buy_item=random'>Random Item (??)</A><br>"
		src.menu_message += "<HR>"
		return

	Topic(href, href_list)
		if (href_list["buy_item"])
			if(href_list["buy_item"] == "random")
				var/list/randomItems = list()

				//Sorry for all the ifs, but it makes it 1000 times easier for other people/servers to add or remove items from this list
				//Add only items the player can afford:
				if(uses > 19)
					randomItems.Add("/obj/item/weapon/circuitboard/teleporter") //Teleporter Circuit Board (costs 20, for nuke ops)

				if(uses > 9)
					randomItems.Add("/obj/item/toy/syndicateballoon")//Syndicate Balloon
					randomItems.Add("/obj/item/weapon/storage/syndie_kit/imp_uplink") //Uplink Implanter
					randomItems.add("/obj/item/weapon/storage/box/syndicate") //Syndicate bundle

				//if(uses > 8)	//Nothing... yet.
				//if(uses > 7)	//Nothing... yet.

				if(uses > 6)
					randomItems.Add("/obj/item/weapon/aiModule/syndicate") //Hacked AI Upload Module<commit_msg>Compile -> Commit -> Update -> Can not compile... How does that even happen? Sorry.<commit_after>/*

SYNDICATE UPLINKS

TO-DO:
	Once wizard is fixed, make sure the uplinks work correctly for it. wizard.dm is right now uncompiled and with broken code in it.

	Clean the code up and comment it. Part of it is right now copy-pasted, with the general Topic() and modifications by Abi79.

		I should take a more in-depth look at both the copy-pasted code for the individual uplinks below, and at each gamemode's code
		to see how uplinks are assigned and if there are any bugs with those.


A list of items and costs is stored under the datum of every game mode, alongside the number of crystals, and the welcoming message.

*/

/obj/item/device/uplink
	var/welcome 					// Welcoming menu message
	var/menu_message = "" 			// The actual menu text
	var/items						// List of items
	var/list/ItemList				// Parsed list of items
	var/uses 						// Numbers of crystals
	// List of items not to shove in their hands.
	var/list/NotInHand = list(/obj/machinery/singularity_beacon/syndicate)

	New()
		welcome = ticker.mode.uplink_welcome
		items = dd_replacetext(ticker.mode.uplink_items, "\n", "")	// Getting the text string of items
		ItemList = dd_text2list(src.items, ";")	// Parsing the items text string
		uses = ticker.mode.uplink_uses

//Let's build a menu!
	proc/generate_menu()
		src.menu_message = "<B>[src.welcome]</B><BR>"
		src.menu_message += "Tele-Crystals left: [src.uses]<BR>"
		src.menu_message += "<HR>"
		src.menu_message += "<B>Request item:</B><BR>"
		src.menu_message += "<I>Each item costs a number of tele-crystals as indicated by the number following their name.</I><br><BR>"

		var/cost
		var/item
		var/name
		var/path_obj
		var/path_text
		var/category_items = 1 //To prevent stupid :P

		for(var/D in ItemList)
			var/list/O = stringsplit(D, ":")
			if(O.len != 3)	//If it is not an actual item, make a break in the menu.
				if(O.len == 1)	//If there is one item, it's probably a title
					src.menu_message += "<b>[O[1]]</b><br>"
					category_items = 0
				else	//Else, it's a white space.
					if(category_items < 1)	//If there were no itens in the last category...
						src.menu_message += "<i>We apologize, as you could not afford anything from this category.</i><br>"
					src.menu_message += "<br>"
				continue

			path_text = O[1]
			cost = text2num(O[2])

			if(cost>uses)
				continue

			path_obj = text2path(path_text)
			item = new path_obj()
			name = O[3]
			del item

			src.menu_message += "<A href='byond://?src=\ref[src];buy_item=[path_text];cost=[cost]'>[name]</A> ([cost])<BR>"
			category_items++

		src.menu_message += "<A href='byond://?src=\ref[src];buy_item=random'>Random Item (??)</A><br>"
		src.menu_message += "<HR>"
		return

	Topic(href, href_list)
		if (href_list["buy_item"])
			if(href_list["buy_item"] == "random")
				var/list/randomItems = list()

				//Sorry for all the ifs, but it makes it 1000 times easier for other people/servers to add or remove items from this list
				//Add only items the player can afford:
				if(uses > 19)
					randomItems.Add("/obj/item/weapon/circuitboard/teleporter") //Teleporter Circuit Board (costs 20, for nuke ops)

				if(uses > 9)
					randomItems.Add("/obj/item/toy/syndicateballoon")//Syndicate Balloon
					randomItems.Add("/obj/item/weapon/storage/syndie_kit/imp_uplink") //Uplink Implanter
					randomItems.Add("/obj/item/weapon/storage/box/syndicate") //Syndicate bundle

				//if(uses > 8)	//Nothing... yet.
				//if(uses > 7)	//Nothing... yet.

				if(uses > 6)
					randomItems.Add("/obj/item/weapon/aiModule/syndicate") //Hacked AI Upload Module
{'fraction_non_alphanumeric': 0.13273480662983425, 'fraction_numerical': 0.0071823204419889505, 'mean_word_length': 3.2795508274231677, 'pattern_counts': {'":': 2, '<': 57, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3934084', 'n_tokens_mistral': 2844, 'n_tokens_neox': 2436, 'n_words': 762}