-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
1,503 additions
and
1,544 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,47 @@ | ||
import { PlayerObject } from "../model/PlayerObject"; | ||
import { gameRule } from "../model/rules/rule"; | ||
import * as Tst from "./Translator"; | ||
import * as LangRes from "../resources/strings"; | ||
|
||
export function setDefaultStadiums(): void { | ||
// set stadium maps as default setting | ||
if(gameRule.statsRecord == true && window.isStatRecord == true) { | ||
window.room.setCustomStadium(gameRule.defaultMap); // if game mode is 'stats' | ||
} else { | ||
window.room.setCustomStadium(gameRule.readyMap); // if game mode is 'ready' | ||
} | ||
} | ||
|
||
export function roomPlayersNumberCheck(): number { | ||
// return number of players joined this room | ||
return window.room.getPlayerList().filter((player: PlayerObject) => player.id != 0).length; | ||
} | ||
|
||
export function updateAdmins(): void { | ||
var placeholderUpdateAdmins = { // Parser.maketext(str, placeholder) | ||
playerID: 0, | ||
playerName: '', | ||
gameRuleName: gameRule.ruleName, | ||
gameRuleDescription: gameRule.ruleDescripttion, | ||
gameRuleLimitTime: gameRule.requisite.timeLimit, | ||
gameRuleLimitScore: gameRule.requisite.scoreLimit, | ||
gameRuleNeedMin: gameRule.requisite.minimumPlayers, | ||
possTeamRed: window.ballStack.possCalculate(1), | ||
possTeamBlue: window.ballStack.possCalculate(2), | ||
streakTeamName: window.winningStreak.getName(), | ||
streakTeamCount: window.winningStreak.getCount() | ||
}; | ||
|
||
// Get all players except the host (id = 0 is always the host) | ||
var players = window.room.getPlayerList().filter((player: PlayerObject) => player.id != 0 && window.playerList.get(player.id).permissions.afkmode != true); // only no afk mode players | ||
if (players.length == 0) return; // If no players left, do nothing. | ||
if (players.find((player: PlayerObject) => player.admin) != null) return; // Do nothing if any admin player is still left. | ||
|
||
placeholderUpdateAdmins.playerID = players[0].id; | ||
placeholderUpdateAdmins.playerName = window.playerList.get(players[0].id).name; | ||
|
||
window.room.setPlayerAdmin(players[0].id, true); // Give admin to the first non admin player in the list | ||
window.playerList.get(players[0].id).admin = true; | ||
window.logger.i(`${window.playerList.get(players[0].id).name}#${players[0].id} has been admin(value:${window.playerList.get(players[0].id).admin},super:${window.playerList.get(players[0].id).permissions.superadmin}), because there was no admin players.`); | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.funcUpdateAdmins.newAdmin, placeholderUpdateAdmins), null, 0x00FF00, "normal", 0); | ||
} |
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,16 @@ | ||
export function maketext(str: string, placeholder: any): string { | ||
// find placeholer, and interpolate it. | ||
// if property not found string is not replaced | ||
// from https://stackoverflow.com/questions/19896511/how-to-replace-specific-parts-in-string-with-javascript-with-values-from-object | ||
return String(str).replace((/\\?\{([^{}]+)\}/g), function(match, name) { | ||
return (placeholder[name] != null) ? placeholder[name] : match; | ||
}); | ||
/* usage | ||
var content ="Looks like you have {no_email} or {no_code} provided"; | ||
var Lang = { | ||
'no_email' : "No email", | ||
'no_code' : "No code" | ||
} | ||
var formatted = replace(content, lang); | ||
*/ | ||
} |
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,10 @@ | ||
import { PlayerObject } from "../../model/PlayerObject"; | ||
import * as LangRes from "../../resources/strings"; | ||
import * as Tst from "../Translator"; | ||
|
||
export function cmdAbout(byPlayer: PlayerObject): void { | ||
var placeholder ={ | ||
_LaunchTime: localStorage.getItem('_LaunchTime') | ||
} | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.about, placeholder), byPlayer.id, 0x479947, "normal", 1); | ||
} |
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,28 @@ | ||
import { PlayerObject } from "../../model/PlayerObject"; | ||
import * as LangRes from "../../resources/strings"; | ||
import * as Tst from "../Translator"; | ||
|
||
export function cmdAfk(byPlayer: PlayerObject, message?: string): void { | ||
var placeholder = { | ||
targetName: byPlayer.name | ||
,ticketTarget: byPlayer.id | ||
,targetAfkReason: '' | ||
} | ||
if (window.playerList.get(byPlayer.id).permissions.afkmode == true) { | ||
window.playerList.get(byPlayer.id).permissions.afkmode = false; // return to active mode | ||
window.playerList.get(byPlayer.id).permissions.afkreason = ''; // init | ||
window.playerList.get(byPlayer.id).afktrace = { exemption: false, count: 0 }; // reset for afk trace | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.afk.unAfk, placeholder), null, 0x479947, "normal", 1); | ||
} else { | ||
window.room.setPlayerTeam(byPlayer.id, 0); // Moves this player to Spectators team. | ||
window.room.setPlayerAdmin(byPlayer.id, false); // disqulify admin permission | ||
window.playerList.get(byPlayer.id).admin = false; | ||
window.playerList.get(byPlayer.id).permissions.afkmode = true; // set afk mode | ||
window.playerList.get(byPlayer.id).afktrace = { exemption: false, count: 0}; // reset for afk trace | ||
if(message !== undefined) { // if the reason is not skipped | ||
window.playerList.get(byPlayer.id).permissions.afkreason = message; // set reason | ||
placeholder.targetAfkReason = message; // update placeholder | ||
} | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.afk.setAfk, placeholder), null, 0x479947, "normal", 1); | ||
} | ||
} |
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,16 @@ | ||
import { PlayerObject } from "../../model/PlayerObject"; | ||
import * as LangRes from "../../resources/strings"; | ||
|
||
export function cmdFreeze(byPlayer: PlayerObject): void { | ||
if(window.playerList.get(byPlayer.id).admin == true) { | ||
if(window.isMuteAll == true) { | ||
window.isMuteAll = false; //off | ||
window.room.sendAnnouncement(LangRes.command.freeze.offFreeze, null, 0x479947, "normal", 1); | ||
} else { | ||
window.isMuteAll = true; //on | ||
window.room.sendAnnouncement(LangRes.command.freeze.onFreeze, null, 0x479947, "normal", 1); | ||
} | ||
} else { | ||
window.room.sendAnnouncement(LangRes.command.freeze._ErrorNoPermission, byPlayer.id, 0xFF7777, "normal", 2); | ||
} | ||
} |
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,63 @@ | ||
import { PlayerObject } from "../../model/PlayerObject"; | ||
import * as LangRes from "../../resources/strings"; | ||
|
||
export function cmdHelp(byPlayer: PlayerObject, message?: string): void { | ||
if(message !== undefined) { | ||
switch(message) { | ||
case "about": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.about, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "help": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.help, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "stats": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.stats, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "statsreset": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.statsreset, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "streak": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.streak, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "scout": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.scout, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "poss": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.poss, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "afk": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.afk, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "list": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.list, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "freeze": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.freeze, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "mute": { | ||
window.room.sendAnnouncement(LangRes.command.helpman.mute, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "admin": { | ||
window.room.sendAnnouncement(LangRes.command.helpadmin, byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
default: { | ||
window.room.sendAnnouncement(LangRes.command.helpman._ErrorWrongMan, byPlayer.id, 0xFF7777, "normal", 2); | ||
break; | ||
} | ||
} | ||
} else { | ||
window.room.sendAnnouncement(LangRes.command.help, byPlayer.id, 0x479947, "normal", 1); | ||
} | ||
} |
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,61 @@ | ||
import { PlayerObject } from "../../model/PlayerObject"; | ||
import * as LangRes from "../../resources/strings"; | ||
import * as Tst from "../Translator"; | ||
|
||
export function cmdList(byPlayer: PlayerObject, message?: string): void { | ||
if (message !== undefined) { | ||
var placeholder = { | ||
whoisResult: LangRes.command.list._ErrorNoOne | ||
} | ||
switch (message) { | ||
case "red": { | ||
let players = window.room.getPlayerList().filter((player: PlayerObject) => player.id != 0 && player.team == 1); | ||
if (players.length >= 1) { | ||
players.forEach((player: PlayerObject) => { | ||
let muteFlag: string = ''; | ||
if (window.playerList.get(player.id).permissions.mute == true) { | ||
muteFlag = '🔇'; | ||
} | ||
placeholder.whoisResult += player.name + '#' + player.id + muteFlag + ', '; | ||
}); | ||
} | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.list.whoisList, placeholder), byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "blue": { | ||
let players = window.room.getPlayerList().filter((player: PlayerObject) => player.id != 0 && player.team == 2); | ||
if (players.length >= 1) { | ||
players.forEach((player: PlayerObject) => { | ||
let muteFlag: string = ''; | ||
if (window.playerList.get(player.id).permissions.mute == true) { | ||
muteFlag = '🔇'; | ||
} | ||
placeholder.whoisResult += player.name + '#' + player.id + muteFlag + ', '; | ||
}); | ||
} | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.list.whoisList, placeholder), byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
case "spec": { | ||
let players = window.room.getPlayerList().filter((player: PlayerObject) => player.id != 0 && player.team == 0); | ||
if (players.length >= 1) { | ||
players.forEach((player: PlayerObject) => { | ||
let muteFlag: string = ''; | ||
if (window.playerList.get(player.id).permissions.mute == true) { | ||
muteFlag = '🔇'; | ||
} | ||
placeholder.whoisResult += player.name + '#' + player.id + muteFlag + ', '; | ||
}); | ||
} | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.list.whoisList, placeholder), byPlayer.id, 0x479947, "normal", 1); | ||
break; | ||
} | ||
default: { | ||
window.room.sendAnnouncement(LangRes.command.list._ErrorNoTeam, byPlayer.id, 0xFF7777, "normal", 2); | ||
break; | ||
} | ||
} | ||
} else { | ||
window.room.sendAnnouncement(LangRes.command.list._ErrorNoTeam, byPlayer.id, 0xFF7777, "normal", 2); | ||
} | ||
} |
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,30 @@ | ||
import { PlayerObject } from "../../model/PlayerObject"; | ||
import * as LangRes from "../../resources/strings"; | ||
import * as Tst from "../Translator"; | ||
|
||
export function cmdMute(byPlayer: PlayerObject, message?: string): void { | ||
if(window.playerList.get(byPlayer.id).admin == true) { | ||
if(message !== undefined && message.charAt(0) == "#") { | ||
let target: number = parseInt(message.substr(1), 10); | ||
if(isNaN(target) != true && window.playerList.has(target) == true) { | ||
var placeholder = { | ||
targetName: window.playerList.get(target).name | ||
,ticketTarget: target | ||
} | ||
if(window.playerList.get(target).permissions.mute == true) { | ||
window.playerList.get(target).permissions.mute = false; | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.mute.successUnmute, placeholder), null, 0x479947, "normal", 1); | ||
} else { | ||
window.playerList.get(target).permissions.mute = true; | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.mute.successMute, placeholder), null, 0x479947, "normal", 1); | ||
} | ||
} else { | ||
window.room.sendAnnouncement(LangRes.command.mute._ErrorNoPlayer, byPlayer.id, 0xFF7777, "normal", 2); | ||
} | ||
} else { | ||
window.room.sendAnnouncement(LangRes.command.mute._ErrorNoPlayer, byPlayer.id, 0xFF7777, "normal", 2); | ||
} | ||
} else { | ||
window.room.sendAnnouncement(LangRes.command.mute._ErrorNoPermission, byPlayer.id, 0xFF7777, "normal", 2); | ||
} | ||
} |
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,13 @@ | ||
import { PlayerObject } from "../../model/PlayerObject"; | ||
import * as LangRes from "../../resources/strings"; | ||
import * as Tst from "../Translator"; | ||
import * as StatCalc from "../../controller/Statistics"; | ||
import { gameRule } from "../../model/rules/rule"; | ||
|
||
export function cmdPoss(byPlayer: PlayerObject): void { | ||
let placeholder = { | ||
possTeamRed: window.ballStack.possCalculate(1) | ||
,possTeamBlue: window.ballStack.possCalculate(2), | ||
} | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.poss, placeholder), byPlayer.id, 0x479947, "normal", 1); | ||
} |
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,20 @@ | ||
import { PlayerObject } from "../../model/PlayerObject"; | ||
import * as LangRes from "../../resources/strings"; | ||
import * as Tst from "../Translator"; | ||
import * as StatCalc from "../../controller/Statistics"; | ||
import { gameRule } from "../../model/rules/rule"; | ||
|
||
export function cmdScout(byPlayer: PlayerObject): void { | ||
if (gameRule.statsRecord == true && window.isStatRecord == true) { | ||
let expectations: number[] = StatCalc.getTeamWinningExpectation(); | ||
let placeholder = { | ||
teamExpectationSpec: expectations[0] | ||
,teamExpectationRed: expectations[1] | ||
,teamExpectationBlue: expectations[2] | ||
} | ||
window.room.sendAnnouncement(Tst.maketext(LangRes.command.scout.scouting, placeholder), byPlayer.id, 0x479947, "normal", 1); | ||
} else { | ||
window.room.sendAnnouncement(LangRes.command.scout._ErrorNoMode, byPlayer.id, 0xFF7777, "normal", 2); | ||
} | ||
|
||
} |
Oops, something went wrong.