mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-28 07:20:09 +01:00
Syndicate Contracts - Initial Implementation
Adds SQL database based syndicate contracts to be viewed from any uplink. These can be used as IC traitor objectives, but hopefully with more RP and stuff.
This commit is contained in:
@@ -257,6 +257,16 @@ datum/nano_item_lists
|
||||
if(href_list["menu"])
|
||||
nanoui_menu = text2num(href_list["menu"])
|
||||
update_nano_data(href_list["id"])
|
||||
if(href_list["contract_interact"])
|
||||
var/list/params = list("location" = "contract_details", "contract" = href_list["contract_interact"])
|
||||
usr.client.process_webint_link("interface/login/sso_server", list2params(params))
|
||||
if(href_list["contract_page"])
|
||||
nanoui_data["contracts_current_page"] = text2num(href_list["contract_page"])
|
||||
update_nano_data()
|
||||
if(href_list["contract_view"])
|
||||
nanoui_data["contracts_view"] = text2num(href_list["contract_view"])
|
||||
nanoui_data["contracts_current_page"] = 1
|
||||
update_nano_data()
|
||||
|
||||
interact(usr)
|
||||
return 1
|
||||
@@ -292,6 +302,111 @@ datum/nano_item_lists
|
||||
nanoui_data["exploit_exists"] = 1
|
||||
break
|
||||
|
||||
if(nanoui_menu == 2)
|
||||
nanoui_data["contracts_found"] = 0
|
||||
|
||||
establish_db_connection(dbcon)
|
||||
|
||||
if (dbcon.IsConnected())
|
||||
nanoui_data["contracts"] = list()
|
||||
|
||||
if (!nanoui_data["contracts_current_page"])
|
||||
nanoui_data["contracts_current_page"] = 1
|
||||
|
||||
if (!nanoui_data["contracts_view"])
|
||||
nanoui_data["contracts_view"] = 1
|
||||
|
||||
var/query_details[0]
|
||||
|
||||
switch (nanoui_data["contracts_view"])
|
||||
if (1)
|
||||
query_details[":status"] = "open"
|
||||
if (2)
|
||||
query_details[":status"] = "closed"
|
||||
else
|
||||
nanoui_data["contracts_view"] = 1
|
||||
query_details[":status"] = "open"
|
||||
|
||||
var/DBQuery/index_query = dbcon.NewQuery("SELECT count(*) as Total_Contracts FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status")
|
||||
index_query.Execute(query_details)
|
||||
|
||||
var/pages = 0
|
||||
|
||||
if (index_query.NextRow())
|
||||
var/total_contracts = text2num(index_query.item[1])
|
||||
|
||||
pages = total_contracts / 10
|
||||
|
||||
if (total_contracts % 10)
|
||||
pages++
|
||||
|
||||
pages = round(pages)
|
||||
|
||||
var/list/contracts_pages = list()
|
||||
|
||||
for (var/i = 1, i <= pages, i++)
|
||||
contracts_pages.Add(i)
|
||||
|
||||
for (var/a in contracts_pages)
|
||||
|
||||
nanoui_data["contracts_pages"] = contracts_pages
|
||||
|
||||
if (nanoui_data["contracts_current_page"] > pages)
|
||||
return
|
||||
|
||||
query_details[":offset"] = (nanoui_data["contracts_current_page"] - 1) * 10
|
||||
|
||||
var/DBQuery/list_query = dbcon.NewQuery("SELECT contract_id, contractee_name, title FROM ss13_syndie_contracts WHERE deleted_at IS NULL AND status = :status LIMIT 10 OFFSET :offset")
|
||||
list_query.Execute(query_details)
|
||||
|
||||
var/list/contracts = list()
|
||||
while (list_query.NextRow())
|
||||
contracts.Add(list(list("id" = list_query.item[1],
|
||||
"contractee" = list_query.item[2],
|
||||
"title" = list_query.item[3])))
|
||||
|
||||
nanoui_data["contracts"] = contracts
|
||||
|
||||
nanoui_data["contracts_found"] = 1
|
||||
|
||||
if(nanoui_menu == 21)
|
||||
nanoui_data["contracts_found"] = 0
|
||||
|
||||
establish_db_connection(dbcon)
|
||||
|
||||
if (dbcon.IsConnected())
|
||||
var/query_details[0]
|
||||
query_details[":contract_id"] = text2num(id)
|
||||
|
||||
var/DBQuery/select_query = dbcon.NewQuery("SELECT contract_id, contractee_name, status, title, description, reward_other FROM ss13_syndie_contracts WHERE contract_id = :contract_id")
|
||||
select_query.Execute(query_details)
|
||||
|
||||
if (select_query.NextRow())
|
||||
nanoui_data["contracts_found"] = 1
|
||||
|
||||
var/contract[0]
|
||||
contract["id"] = select_query.item[1]
|
||||
contract["contractee"] = select_query.item[2]
|
||||
|
||||
switch (select_query.item[3])
|
||||
if ("open")
|
||||
contract["status"] = "1"
|
||||
else
|
||||
contract["status"] = "0"
|
||||
|
||||
contract["title"] = html_encode(select_query.item[4])
|
||||
contract["description"] = select_query.item[5]
|
||||
|
||||
var/list/nano_blacklist = list("/" = " ", "_" = " ", "\n" = "<br>")
|
||||
|
||||
for (var/a in nano_blacklist)
|
||||
contract["description"] = replacetext(contract["description"], a, nano_blacklist[a])
|
||||
|
||||
contract["description"] = html_encode(contract["description"])
|
||||
contract["reward_other"] = select_query.item[6]
|
||||
|
||||
nanoui_data["contract"] = contract
|
||||
|
||||
// I placed this here because of how relevant it is.
|
||||
// You place this in your uplinkable item to check if an uplink is active or not.
|
||||
// If it is, it will display the uplink menu and return 1, else it'll return false.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
<!--
|
||||
<!--
|
||||
Title: Syndicate Uplink, uses some javascript to change nanoUI up a bit.
|
||||
Used In File(s): \code\game\objects\items\devices\uplinks.dm
|
||||
-->
|
||||
@@ -13,12 +13,13 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm
|
||||
<div class="itemContent">
|
||||
{{:helper.link('Request Items', 'gear', {'menu' : 0}, null, 'fixedLeftWider')}}
|
||||
{{:helper.link('Exploitable Information', 'gear', {'menu' : 1}, null, 'fixedLeftWider')}}
|
||||
{{:helper.link('Extranet Contract Database', 'gear', {'menu' : 2}, null, 'fixedLeftWider')}}
|
||||
{{:helper.link('Return', 'arrowreturn-1-w', {'return' : 1}, null, 'fixedLeft')}}
|
||||
{{:helper.link('Close', 'gear', {'lock' : "1"}, null, 'fixedLeft')}}
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
|
||||
{{if data.menu == 0}}
|
||||
<H2><span class="white">Request items:</span></H2>
|
||||
<span class="white"><i>Each item costs a number of tele-crystals as indicated by the number following their name.</i></span>
|
||||
@@ -39,7 +40,7 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm
|
||||
<div class="item">
|
||||
{{:helper.link( itemValue.Name, 'gear', {'buy_item' : itemValue.obj_path, 'cost' : itemValue.Cost}, itemValue.Cost > data.crystals ? 'disabled' : null, null)}} - <span class="white">{{:itemValue.Cost}}</span>
|
||||
</div>
|
||||
|
||||
|
||||
{{if itemValue.Cost <= data.crystals}}
|
||||
<div class="item">
|
||||
{{:itemValue.Description}}
|
||||
@@ -52,7 +53,7 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm
|
||||
<div class="item">
|
||||
{{:helper.link('Buy Random (??)' , 'gear', {'buy_item' : 'random'}, data.crystals <= 0 ? 'disabled' : null, null)}}
|
||||
</div>
|
||||
|
||||
|
||||
{{else data.menu == 1}}
|
||||
<H2><span class="white">Information Record List:</span></H2>
|
||||
<br>
|
||||
@@ -65,7 +66,7 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm
|
||||
{{:helper.link(value.Name, 'gear', {'menu' : 11, 'id' : value.id}, null, null)}}
|
||||
</div>
|
||||
{{/for}}
|
||||
|
||||
|
||||
{{else data.menu == 11}}
|
||||
<H2><span class="white">Information Record:</span></H2>
|
||||
<br>
|
||||
@@ -96,4 +97,73 @@ Used In File(s): \code\game\objects\items\devices\uplinks.dm
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{else data.menu == 2}}
|
||||
<H2><span class="white">Available Contracts:</span></H2>
|
||||
<br>
|
||||
{{if data.contracts_found == 1}}
|
||||
<div class="item">
|
||||
<center><table class="pmon"><tbody>
|
||||
<tr><th>ID</th><th>Contractor</th><th colspan="2">Title</th>
|
||||
{{if data.contracts_view == 1}}
|
||||
<tr><th colspan="4" class="med">Available Contracts</th></tr>
|
||||
{{else}}
|
||||
<tr><th colspan="4" class="sec">Closed Contracts</th></tr>
|
||||
{{/if}}
|
||||
{{for data.contracts}}
|
||||
<tr><td><span class="white">{{:value.id}}</span></td><td><span class="white">{{:value.contractee}}</span></td><td><span class="white">{{:value.title}}</span></td><td>{{:helper.link('View', null, {'menu' : 21, 'id' : value.id}, null, 'fixedLeft')}}</td></tr>
|
||||
{{/for}}
|
||||
</tbody></table></center>
|
||||
<br>
|
||||
<div class="item" style="text-align:center">
|
||||
{{for data.contracts_pages}}
|
||||
{{:helper.link(value, null, {'contract_page' : value}, null, null)}}
|
||||
{{/for}}
|
||||
<br><br>
|
||||
{{if data.contracts_view == 1}}
|
||||
{{:helper.link('View Expired Contracts', 'gear', {'contract_view' : 2}, null, null)}}
|
||||
{{else}}
|
||||
{{:helper.link('View Open Contracts', 'gear', {'contract_view' : 1}, null, null)}}
|
||||
{{/if}}
|
||||
</div>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="item">
|
||||
<center><span class="bad">No Contracts Available.</span></center>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{else data.menu == 21}}
|
||||
<H2><span class="white">Viewing Contract:</span></H2>
|
||||
<br>
|
||||
<div class="statusDisplayRecords">
|
||||
<div class="item">
|
||||
<div class="itemContent" style="width: 100%;">
|
||||
{{if data.contracts_found == 1}}
|
||||
<span class="good">ID: </span> <span class="average">#{{:data.contract.id}} </span><br>
|
||||
<span class="good">Contractee: </span> <span class="average">{{:data.contract.contractee}} </span><br>
|
||||
<span class="good">Status: </span>
|
||||
{{if data.contract.status == 1}}
|
||||
<span class="good">Open</span><br>
|
||||
{{else}}
|
||||
<span class="bad">Closed</span><br>
|
||||
{{/if}}
|
||||
<span class="good">Title: </span> <span class="average">{{:data.contract.title}} </span><br>
|
||||
<br>
|
||||
<span class="good">Description: </span> <span class="average">{{:data.contract.description}} </span><br>
|
||||
<span class="good">Reward: </span> <span class="average">{{:data.contract.reward_other}} </span><br>
|
||||
{{else}}
|
||||
<span class="bad">Failed to retreive contract information!</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br><br>
|
||||
{{if data.contracts_found == 1}}
|
||||
{{:helper.link('View Reports And Updates', 'extlink', {'contract_interact' : data.contract.id}, null, null)}}
|
||||
{{/if}}
|
||||
|
||||
{{/if}}
|
||||
|
||||
Reference in New Issue
Block a user