aboutsummaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authorCerapter <cerap@protonmail.com>2018-10-23 16:15:15 +0200
committerCerapter <cerap@protonmail.com>2018-10-23 16:15:15 +0200
commitde8badc9a6e74ca29cbc04ab5438d6eed2eb8984 (patch)
treeeca5e15e0036fbd117be92029c57f039e2b0606f /server
parent660daf9922e68eb5f5f6bb00eb3bc51d0c460de7 (diff)
Support for case alerts serverside.
- Users can use an ingame button to alert people of cases.
Diffstat (limited to 'server')
-rw-r--r--server/aoprotocol.py2
-rw-r--r--server/client_manager.py15
-rw-r--r--server/commands.py48
3 files changed, 64 insertions, 1 deletions
diff --git a/server/aoprotocol.py b/server/aoprotocol.py
index 1bf9001..0af8f67 100644
--- a/server/aoprotocol.py
+++ b/server/aoprotocol.py
@@ -213,7 +213,7 @@ class AOProtocol(asyncio.Protocol):
self.client.is_ao2 = True
- self.client.send_command('FL', 'yellowtext', 'customobjections', 'flipping', 'fastloading', 'noencryption', 'deskmod', 'evidence', 'modcall_reason', 'cccc_ic_support', 'arup')
+ self.client.send_command('FL', 'yellowtext', 'customobjections', 'flipping', 'fastloading', 'noencryption', 'deskmod', 'evidence', 'modcall_reason', 'cccc_ic_support', 'arup', 'casing_alerts')
def net_cmd_ch(self, _):
""" Periodically checks the connection.
diff --git a/server/client_manager.py b/server/client_manager.py
index f5ef4ef..4a5c1ef 100644
--- a/server/client_manager.py
+++ b/server/client_manager.py
@@ -65,6 +65,15 @@ class ClientManager:
self.flip = 0
self.claimed_folder = ''
+ # Casing stuff
+ self.casing_cm = False
+ self.casing_cases = ""
+ self.casing_def = False
+ self.casing_pro = False
+ self.casing_jud = False
+ self.casing_jur = False
+ self.case_call_time = 0
+
#flood-guard stuff
self.mus_counter = 0
self.mus_mute_time = 0
@@ -359,6 +368,12 @@ class ClientManager:
def can_call_mod(self):
return (time.time() * 1000.0 - self.mod_call_time) > 0
+ def set_case_call_delay(self):
+ self.case_call_time = round(time.time() * 1000.0 + 60000)
+
+ def can_call_case(self):
+ return (time.time() * 1000.0 - self.case_call_time) > 0
+
def disemvowel_message(self, message):
message = re.sub("[aeiou]", "", message, flags=re.IGNORECASE)
return re.sub(r"\s+", " ", message)
diff --git a/server/commands.py b/server/commands.py
index aae12de..49fd979 100644
--- a/server/commands.py
+++ b/server/commands.py
@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#possible keys: ip, OOC, id, cname, ipid, hdid
import random
+import re
import hashlib
import string
from server.constants import TargetType
@@ -767,6 +768,53 @@ def ooc_cmd_uncm(client, arg):
client.send_host_message('{} does not look like a valid ID.'.format(id))
else:
raise ClientError('You must be authorized to do that.')
+
+def ooc_cmd_setcase(client, arg):
+ args = re.findall(r'(?:[^\s,"]|"(?:\\.|[^"])*")+', arg)
+ if len(args) == 0:
+ raise ArgumentError('Please do not call this command manually!')
+ else:
+ client.casing_cases = args[0]
+ client.casing_cm = args[1] == "1"
+ client.casing_def = args[2] == "1"
+ client.casing_pro = args[3] == "1"
+ client.casing_jud = args[4] == "1"
+ client.casing_jur = args[5] == "1"
+
+def ooc_cmd_anncase(client, arg):
+ if client in client.area.owners:
+ if not client.can_call_case():
+ raise ClientError('Please wait 60 seconds between case announcements!')
+ args = re.findall(r'(?:[^\s,"]|"(?:\\.|[^"])*")+', arg)
+ if len(args) == 0:
+ raise ArgumentError('Please do not call this command manually!')
+ elif len(args) == 1:
+ raise ArgumentError('You should probably announce the case to at least one person.')
+ else:
+ if not args[1] == "1" and not args[2] == "1" and not args[3] == "1" and not args[4] == "1":
+ raise ArgumentError('You should probably announce the case to at least one person.')
+ msg = '=== Case Announcement ===\r\n{} [{}] is hosting {}, looking for '.format(client.get_char_name(), client.id, args[0])
+
+ lookingfor = []
+
+ if args[1] == "1":
+ lookingfor.append("defence")
+ if args[2] == "1":
+ lookingfor.append("prosecutor")
+ if args[3] == "1":
+ lookingfor.append("judge")
+ if args[4] == "1":
+ lookingfor.append("juror")
+
+ msg = msg + ', '.join(lookingfor) + '.\r\n=================='
+
+ client.server.send_all_cmd_pred('CASEA', msg, args[1], args[2], args[3], args[4], '1')
+
+ client.set_case_call_delay()
+
+ logger.log_server('[{}][{}][CASE_ANNOUNCEMENT]{}, DEF: {}, PRO: {}, JUD: {}, JUR: {}.'.format(client.area.abbreviation, client.get_char_name(), args[0], args[1], args[2], args[3], args[4]), client)
+ else:
+ raise ClientError('You cannot announce a case in an area where you are not a CM!')
def ooc_cmd_unmod(client, arg):
client.is_mod = False