Skip to content

Commit

Permalink
add ban button
Browse files Browse the repository at this point in the history
  • Loading branch information
stonedDiscord committed Aug 7, 2024
1 parent 8bbb979 commit 73373ce
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 5 deletions.
5 changes: 4 additions & 1 deletion webAO/client/sender/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {sendZZ} from './sendZZ'
import {sendEE} from './sendEE'
import {sendDE} from './sendDE'
import {sendPE} from './sendPE'
import {sendMA} from './sendMA'
export interface ISender {
sendIC: (deskmod: number,
preanim: string,
Expand Down Expand Up @@ -50,6 +51,7 @@ export interface ISender {
sendEE: (id: number, name: string, desc: string, img: string) => void
sendDE: (id: number) => void
sendPE: (name: string, desc: string, img: string) => void
sendMA: (id: number, length: number, reason: string) => void
}
export const sender = {
sendIC,
Expand All @@ -64,5 +66,6 @@ export const sender = {
sendZZ,
sendEE,
sendDE,
sendPE
sendPE,
sendMA
}
11 changes: 11 additions & 0 deletions webAO/client/sender/sendMA.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { client } from "../../client";

/**
* Sends mod command.
* @param {number} id player id
* @param {number} length in hours
* @param {string} reason player message
*/
export const sendMA = (id: number, length: number, reason: string) => {
client.sender.sendServer(`MA#${id}#${length}#${reason}#%`);
}
14 changes: 14 additions & 0 deletions webAO/dom/banPlayer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { client } from '../client'
/**
* Tries to ban a player from the playerlist
* @param {Number} id the players id
*/
export function banPlayer(id: number) {
let reason;
let length;
reason = prompt("Please enter the ban reason", "");
length = Number(prompt("Please enter the ban length in hours", ""));

client.sender.sendMA(id, length, reason);
}
window.banPlayer = banPlayer;
3 changes: 2 additions & 1 deletion webAO/dom/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ declare global {
editEvidence: () => void;
addEvidence: () => void;
pickEvidence: (evidence: any) => void;
pickEmotion: (emo: any) => void;
pickEmotion: (emo: number) => void;
pickChar: (ccharacter: any) => void;
chartable_filter: (_event: any) => void;
ReconnectButton: (_event: any) => void;
Expand All @@ -52,6 +52,7 @@ declare global {
onEnter: (event: any) => void;
onReplayGo: (_event: any) => void;
onOOCEnter: (_event: any) => void;
banPlayer: (id: number) => void;
hcallback: (_event: any) => void;
}
}
Expand Down
11 changes: 9 additions & 2 deletions webAO/packets/handlers/handlePR.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { client } from "../../client";
import { banPlayer } from '../../dom/banPlayer'

function addPlayer(playerID: Number) {
function addPlayer(playerID: number) {
const list = <HTMLTableElement>document.getElementById("client_playerlist");
const playerRow = list.insertRow();
playerRow.id = `client_playerlist_entry${playerID}`;
Expand All @@ -17,9 +18,15 @@ function addPlayer(playerID: Number) {
showNameCell.appendChild(name);
const oocNameCell = playerRow.insertCell(3);
oocNameCell.appendChild(name);

const banCell = playerRow.insertCell(4);
const ban = <HTMLButtonElement>document.createElement("button");
ban.innerText = "Ban";
ban.onclick = () => { window.banPlayer(playerID) }
banCell.appendChild(ban);
}

function removePlayer(playerID: Number) {
function removePlayer(playerID: number) {
const playerRow = <HTMLTableElement>document.getElementById(`client_playerlist_entry${playerID}`);
playerRow.remove();
}
Expand Down
2 changes: 1 addition & 1 deletion webAO/packets/handlers/handlePV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { updateActionCommands } from '../../dom/updateActionCommands'
import { pickEmotion } from '../../dom/pickEmotion'
import { AO_HOST } from "../../client/aoHost";

function addEmoteButton(i: Number, imgurl: string, desc: string) {
function addEmoteButton(i: number, imgurl: string, desc: string) {
const emotesList = document.getElementById("client_emo");
const emote_item = new Image();
emote_item.id = "emo_" + i;
Expand Down

0 comments on commit 73373ce

Please sign in to comment.