17c776faec
-> !wants -> !orgs info -> special cmd's -> !assist -> "afk" for players without active account -> !loot add <item_ref> <count> => nolonger breaks !account Changes: -> grouped !tara, !gaunt, .. into !wb -> Display the most recent news entry on logon (default: enabled) -> improved grouping of !items -> Added the option to authentificate WS connections (Datanet module). This is used in special cases, where the Websocket Server requires the clien tto authentificate itself. (Server sends "#auth", client responds with the auth string) -> Add main name to relaying (priv <-> org) [default: disabled] -> Added logon/logoff messages back -> restricted default access to "dangerous" commands to moderator -> Added optional logging (Private Channel, Org Channel, Tells, ... disabled by default) Rewrite of the Tower Module. -> More verbosity, if enabled in config. by default, GAS and Hot timer only. -> !hot displays currently hot (and in penalty) sites, and these which go hot in < 60 minutes -> !attacks filterable by PF and Site -> display current contract QL's grouped by org: !contracts (requires managed cache)
99 lines
4.5 KiB
Python
99 lines
4.5 KiB
Python
from core.chat_blob import ChatBlob
|
|
from core.command_param_types import Regex, Int, Any, Const
|
|
from core.db import DB
|
|
from core.decorators import instance, command
|
|
from core.text import Text
|
|
|
|
|
|
@instance()
|
|
class PlayfieldController:
|
|
def inject(self, registry):
|
|
self.db: DB = registry.get_instance("db")
|
|
self.text: Text = registry.get_instance("text")
|
|
self.command_alias_service = registry.get_instance("command_alias_service")
|
|
|
|
def pre_start(self):
|
|
self.db.load_sql_file(self.module_dir + "/sql/" + "playfields.sql", pre_optimized=True)
|
|
self.db.create_view("playfields")
|
|
|
|
def start(self):
|
|
self.command_alias_service.add_alias("playfields", "playfield")
|
|
|
|
@command(command="playfield", params=[Const("all", is_optional=True)], access_level="member",
|
|
description="Show a list of playfields")
|
|
def playfield_list_command(self, _, const_all):
|
|
if const_all:
|
|
data = self.db.query("SELECT * FROM playfields ORDER BY long_name")
|
|
else:
|
|
data = self.db.query("SELECT * FROM playfields WHERE short_name != '' ORDER BY long_name")
|
|
|
|
blob = ""
|
|
for row in data:
|
|
blob += f"[<highlight>{row.id:d}</highlight>] {row.long_name} ({row.short_name})\n"
|
|
|
|
return ChatBlob("Playfields", blob)
|
|
|
|
@command(command="waypoint",
|
|
params=[Regex("waypoint_data", r"\s+.*?Pos: ([0-9.]+), ([0-9.]+), ([0-9.]+), Area: ([a-zA-Z ]+).*",
|
|
num_groups=4)],
|
|
access_level="member",
|
|
description="Create a waypoint link from F9 output",
|
|
extended_description="Example: <symbol>waypoint Pos: 123.1, 456.1, 789.1, Area: Perpetual Wastelands")
|
|
def waypoint1_command(self, _, regex):
|
|
x_coords, y_coords, _, playfield_arg = regex
|
|
|
|
return self.create_waypoint_blob(x_coords, y_coords, playfield_arg)
|
|
|
|
@command(command="waypoint",
|
|
params=[Regex("waypoint_data", r"\s+.*?([0-9.]+) ([0-9.]+) y ([0-9.]+) ([0-9]+).*",
|
|
num_groups=4)],
|
|
access_level="member",
|
|
description="Create a waypoint link from Shift + F9 output",
|
|
extended_description="Example: <symbol>waypoint 123.1 456.1 y 789.1 570")
|
|
def waypoint2_command(self, _, regex):
|
|
x_coords, y_coords, _, playfield_arg = regex
|
|
|
|
return self.create_waypoint_blob(x_coords, y_coords, playfield_arg)
|
|
|
|
@command(command="waypoint",
|
|
params=[Int("x_coords"), Int("y_coords"), Any("playfield")],
|
|
access_level="member",
|
|
description="Manually create a waypoint link",
|
|
extended_description="Example: !waypoint 123 456 PW")
|
|
def waypoint3_command(self, _, x_coords, y_coords, playfield_arg):
|
|
return self.create_waypoint_blob(x_coords, y_coords, playfield_arg)
|
|
|
|
def create_waypoint_blob(self, x_coords, y_coords, playfield_arg):
|
|
x_coords = int(float(x_coords))
|
|
y_coords = int(float(y_coords))
|
|
playfield = self.get_playfield_by_name(playfield_arg) or self.get_playfield_by_id(playfield_arg)
|
|
|
|
if not playfield:
|
|
return f"Could not find playfield <highlight>{playfield_arg}</highlight>."
|
|
else:
|
|
title = f"waypoint: {x_coords}x{y_coords} {playfield.long_name}"
|
|
blob = f"Zone: {playfield.long_name} ({playfield.id})\n"
|
|
blob += f"Coords: {x_coords} x {y_coords}\n\n"
|
|
waypoint = f'/waypoint {x_coords} {y_coords} {playfield.id:d}'
|
|
blob += f"<center>{self.text.make_chatcmd(self.text.make_image(11336), waypoint)}\n"
|
|
blob += self.text.make_chatcmd("Click for waypoint", f"/waypoint {x_coords} {y_coords} {playfield.id:d}")
|
|
|
|
return ChatBlob(title, blob)
|
|
|
|
def get_playfield_by_name(self, name):
|
|
return self.db.query_single("SELECT * FROM playfields "
|
|
"WHERE long_name LIKE ? "
|
|
"OR short_name LIKE ? "
|
|
"LIMIT 1", [name, name])
|
|
|
|
def get_playfield_by_name_or_id(self, name):
|
|
return self.db.query_single("SELECT * FROM playfields "
|
|
"WHERE long_name LIKE ? "
|
|
"OR short_name LIKE ? "
|
|
"OR id LIKE ? "
|
|
"LIMIT 1", [name, name, name])
|
|
|
|
def get_playfield_by_id(self, playfield_id):
|
|
return self.db.query_single("SELECT * FROM playfields "
|
|
"WHERE id = ?", [playfield_id])
|