-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from AttorneyOnline/playerlist
Playerlist
- Loading branch information
Showing
11 changed files
with
165 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}#%`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", "Being annoying"); | ||
length = Number(prompt("Please enter the ban length in minutes", "60")); | ||
|
||
client.sender.sendMA(id, length, reason); | ||
} | ||
window.banPlayer = banPlayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { client } from "../../client"; | ||
import { banPlayer } from '../../dom/banPlayer' | ||
|
||
function addPlayer(playerID: number) { | ||
const list = <HTMLTableElement>document.getElementById("client_playerlist"); | ||
const playerRow = list.insertRow(); | ||
playerRow.id = `client_playerlist_entry${playerID}`; | ||
|
||
const imgCell = playerRow.insertCell(0); | ||
const img = document.createElement('img'); | ||
imgCell.appendChild(img); | ||
|
||
const name = document.createTextNode('Unknown'); | ||
|
||
const charNameCell = playerRow.insertCell(1); | ||
charNameCell.appendChild(name); | ||
const showNameCell = playerRow.insertCell(2); | ||
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) { | ||
const playerRow = <HTMLTableElement>document.getElementById(`client_playerlist_entry${playerID}`); | ||
playerRow.remove(); | ||
} | ||
|
||
/** | ||
* Handles a player joining or leaving | ||
* @param {Array} args packet arguments | ||
*/ | ||
export const handlePR = (args: string[]) => { | ||
const playerID = Number(args[1]); | ||
if (Number(args[2]) === 0) | ||
addPlayer(playerID); | ||
else if (Number(args[2]) === 1) | ||
removePlayer(playerID); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { getCharIcon } from "../../client/handleCharacterInfo"; | ||
|
||
/** | ||
* Handles a playerlist update | ||
* @param {Array} args packet arguments | ||
*/ | ||
export const handlePU = (args: string[]) => { | ||
const playerRow = <HTMLTableElement>document.getElementById(`client_playerlist_entry${Number(args[1])}`); | ||
const type = Number(args[2]); | ||
const data = args[3]; | ||
switch (type) { | ||
case 0: | ||
const oocName = <HTMLElement>playerRow.childNodes[3]; | ||
oocName.innerText = data; | ||
break; | ||
case 1: | ||
const playerImg = <HTMLImageElement>playerRow.childNodes[0].firstChild; | ||
getCharIcon(playerImg, data); | ||
const charName = <HTMLElement>playerRow.childNodes[1]; | ||
charName.innerText = data; | ||
break; | ||
case 2: | ||
const showName = <HTMLElement>playerRow.childNodes[2]; | ||
showName.innerText = data; | ||
break; | ||
default: | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters