Skip to content

Commit

Permalink
v0.4.4
Browse files Browse the repository at this point in the history
0.4.4 update
  • Loading branch information
dapucita authored Feb 10, 2021
2 parents c1b45ee + 8709a8b commit e3b2ebc
Show file tree
Hide file tree
Showing 32 changed files with 431 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ jobs:
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: true
draft: true
prerelease: false

- name: Upload Release Asset
id: upload-release-asset
Expand Down
1 change: 1 addition & 0 deletions core/game/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ window.gameRoom = {
,antiTrollingChatFloodCount: []
,antiInsufficientStartAbusingCount: []
,antiPlayerKickAbusingCount: []
,notice: ''
,onEmergency: EmergencyTools
}

Expand Down
5 changes: 5 additions & 0 deletions core/game/controller/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { cmdMute } from "./commands/mute";
import { cmdVote } from "./commands/vote";
import { cmdSuper } from "./commands/super";
import { cmdTier } from "./commands/tier";
import { cmdNotice } from "./commands/notice";

// if given string is command chat, this function returns true, nor false.
export function isCommandString(message: string): boolean {
Expand Down Expand Up @@ -115,6 +116,10 @@ export function parseCommand(byPlayer: PlayerObject, message: string): void {
cmdTier(byPlayer);
break;
}
case window.gameRoom.config.commands.notice: {
cmdNotice(byPlayer);
break;
}
case window.gameRoom.config.commands.super: {
if(msgChunk[1] !== undefined) {
if(msgChunk[2] !== undefined) {
Expand Down
4 changes: 4 additions & 0 deletions core/game/controller/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export function cmdHelp(byPlayer: PlayerObject, message?: string): void {
window.gameRoom._room.sendAnnouncement(LangRes.command.helpman.tier, byPlayer.id, 0x479947, "normal", 1);
break;
}
case window.gameRoom.config.commands._helpMannotice: {
window.gameRoom._room.sendAnnouncement(LangRes.command.helpman.notice, byPlayer.id, 0x479947, "normal", 1);
break;
}
default: {
window.gameRoom._room.sendAnnouncement(LangRes.command.helpman._ErrorWrongMan, byPlayer.id, 0xFF7777, "normal", 2);
break;
Expand Down
10 changes: 10 additions & 0 deletions core/game/controller/commands/notice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as LangRes from "../../resource/strings";
import { PlayerObject } from "../../model/GameObject/PlayerObject";

export function cmdNotice(byPlayer: PlayerObject): void {
if(window.gameRoom.notice) {
window.gameRoom._room.sendAnnouncement(window.gameRoom.notice, byPlayer.id, 0x479947, "normal", 1);
} else {
window.gameRoom._room.sendAnnouncement(LangRes.command.notice._ErrorNoMessage, byPlayer.id, 0xFF7777, "normal", 1);
}
}
5 changes: 5 additions & 0 deletions core/game/controller/events/onPlayerJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ export async function onPlayerJoinListener(player: PlayerObject): Promise<void>
// send welcome message to new player. other players cannot read this message.
window.gameRoom._room.sendAnnouncement(Tst.maketext(LangRes.onJoin.welcome, placeholderJoin), player.id, 0x00FF00, "normal", 0);

// send notice
if(window.gameRoom.notice !== '') {
window.gameRoom._room.sendAnnouncement(window.gameRoom.notice, player.id, 0x55AADD, "bold", 0);
}

// check number of players joined and change game mode
let activePlayersNumber: number = roomActivePlayersNumberCheck();
if (window.gameRoom.config.rules.statsRecord === true && activePlayersNumber >= window.gameRoom.config.rules.requisite.minimumPlayers) {
Expand Down
2 changes: 2 additions & 0 deletions core/game/model/Configuration/GameCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface GameCommands {
_helpMantier: string
_helpMansuper: string
_helpManadmin: string
_helpMannotice: string

_listSubafk: string
_listSubmute: string
Expand Down Expand Up @@ -46,4 +47,5 @@ export interface GameCommands {
super: string
vote: string
tier: string
notice: string
}
8 changes: 6 additions & 2 deletions core/game/resource/strings.sample.en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const command = {
_ErrorWrongCommand : '❌ You did wrong command. 📑 !help or !help COMMAND for detail.'
,_ErrorNoPermission: '❌ You are not admin. You can\'t use this command.'
,_ErrorDisabled: '❌ This command is disabled. You can\'t use this command.'
,help: '📄 !about, stats, statsreset, tier, afk, vote, poss, streak, scout, list\n📑 !help COMMAND for detail. (eg. !help stats)\n📑 !help admin shows you commands list for administrator.'
,help: '📄 !about, notice, stats, statsreset, tier, afk, vote, poss, streak, scout, list\n📑 !help COMMAND for detail. (eg. !help stats)\n📑 !help admin shows you commands list for administrator.'
,helpadmin: '📄 !freeze, mute\n📑 !help COMMAND for detail.'
,helpman: { // detailed description for a command
_ErrorWrongMan : '❌ Failed to read manual about that command.'
Expand All @@ -71,6 +71,7 @@ export const command = {
,scout: '📑 !scout shows you expectation of each teams by customed Pythagorean Expectation.'
,vote: '📑 !vote shows you progress of the vote.\n📑 !vote #ID : vote for kick that player. (eg: !vote #12)'
,tier: '📑 !tier shows you information of tier and rating system.'
,notice: '📑 !notice shows you notice message.'
}
,about: '📄 {RoomName} ({_LaunchTime})\n💬 This room is powered by Haxbotron🤖 bot. https://github.com/dapucita/haxbotron\n💬 Discord https://discord.gg/qfg45B2 Donate https://www.patreon.com/dapucita'
,stats: {
Expand All @@ -91,7 +92,7 @@ export const command = {
,mute: {
_ErrorNoPermission: '❌ You are not admin. You can\'t do this command.'
,_ErrorNoPlayer: '❌ Wrong player ID. You can only target numeric ID.(eg: !mute #12)\n📑 You can check IDs by command !list red,blue,spec,mute'
,successMute: '🔇 {targetName}#{ticketTarget} player is muted.(30mins) You can command it againt for release.'
,successMute: '🔇 {targetName}#{ticketTarget} player is muted.(3mins) You can command it againt for release.'
,successUnmute: '🔊 Player {targetName}#{ticketTarget} is unmuted.'
,muteAbusingWarn: '❌ You can\'t mute again this player in too short time. (3mins)'
}
Expand Down Expand Up @@ -153,6 +154,9 @@ export const command = {
,voteAutoNotify: '🗳️ Voting to ban is in progress: {voteList}'
}
,tier: '📄 Tier is determined by the rating score. (!stats shows your rating)\n📑 {tierAvatar9}{tierCutoff9} {tierAvatar8}{tierCutoff8} {tierAvatar7}{tierCutoff7} {tierAvatar6}{tierCutoff6} {tierAvatar5}{tierCutoff5} {tierAvatar4}{tierCutoff4} {tierAvatar3}{tierCutoff3} {tierAvatar2}{tierCutoff2} {tierAvatar1}{tierCutoff1}'
,notice: {
_ErrorNoMessage: '❌ No notice message.'
}
}

export const funcUpdateAdmins = {
Expand Down
8 changes: 6 additions & 2 deletions core/game/resource/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const command = {
_ErrorWrongCommand : '❌ 잘못된 명령어입니다. 📑 !help 또는 !help COMMAND로 자세히 알아보세요.'
,_ErrorNoPermission: '❌ 관리자만 이 명령어를 사용할 수 있습니다.'
,_ErrorDisabled: '❌ 현재 방에서는 사용할 수 없는 명령어입니다.'
,help: '📄 !about, stats, statsreset, tier, afk, vote, poss, streak, scout, list\n📑 !help COMMAND로 자세히 보기 (예: !help stats)\n📑 !help admin 을 입력하여 관리자용 명령어를 볼 수 있습니다.'
,help: '📄 !about, notice, stats, statsreset, tier, afk, vote, poss, streak, scout, list\n📑 !help COMMAND로 자세히 보기 (예: !help stats)\n📑 !help admin 을 입력하여 관리자용 명령어를 볼 수 있습니다.'
,helpadmin: '📄 !freeze, mute\n📑 !help COMMAND로 자세히 보기'
,helpman: { // detailed description for a command
_ErrorWrongMan : '❌ 요청하신 명령어에 대한 설명이 없습니다.'
Expand All @@ -71,6 +71,7 @@ export const command = {
,scout: '📑 !scout : 각 팀의 기대승률치를 보여줍니다. 팀 간의 비교는 아니며, 피타고리안 승률 공식의 변형을 사용합니다.'
,vote: '📑 !vote : 현재 추방 투표 현황과 본인의 투표 상태를 보여줍니다.\n📑 !vote #ID : 해당 ID의 플레이어에 대해 추방 투표를 하거나 취소합니다. ID는 숫자이어야 합니다. (예: !vote #12)'
,tier: '📑 !tier : 티어와 레이팅 시스템에 대한 정보를 보여줍니다.'
,notice: '📑 !notice : 공지사항을 보여줍니다.'
}
,about: '📄 방 이름 : {RoomName} ({_LaunchTime})\n💬 이 방은 Haxbotron🤖 봇에 의해 운영됩니다. https://github.com/dapucita/haxbotron\n💬 [디스코드] https://discord.gg/qfg45B2 [후원하기] https://www.patreon.com/dapucita'
,stats: {
Expand All @@ -91,7 +92,7 @@ export const command = {
,mute: {
_ErrorNoPermission: '❌ 관리자만 이 명령어를 사용할 수 있습니다.'
,_ErrorNoPlayer: '❌ 접속중이지 않습니다. #숫자아이디 의 형식으로 지정해야 합니다. (예: !mute #12)\n📑 !list red,blue,spec,mute 명령어로 숫자아이디를 확인할 수 있습니다.'
,successMute: '🔇 {targetName}#{ticketTarget}님을 음소거했습니다.(30분) 해제하려면 mute 명령어를 다시 사용하세요.'
,successMute: '🔇 {targetName}#{ticketTarget}님을 음소거했습니다.(3분) 해제하려면 mute 명령어를 다시 사용하세요.'
,successUnmute: '🔊 {targetName}#{ticketTarget}님의 음소거를 해제했습니다.'
,muteAbusingWarn: '❌ 해당 플레이어에 대해 곧바로 음소거할 수 없습니다.(3분)'
}
Expand Down Expand Up @@ -153,6 +154,9 @@ export const command = {
,voteAutoNotify: '🗳️ 현재 추방 투표가 진행중입니다 : {voteList}'
}
,tier: '📄 티어는 레이팅 점수에 따라 결정됩니다. 레이팅 점수는 !stats 명령어로 봅니다.\n📑 {tierAvatar9}{tierCutoff9} {tierAvatar8}{tierCutoff8} {tierAvatar7}{tierCutoff7} {tierAvatar6}{tierCutoff6} {tierAvatar5}{tierCutoff5} {tierAvatar4}{tierCutoff4} {tierAvatar3}{tierCutoff3} {tierAvatar2}{tierCutoff2} {tierAvatar1}{tierCutoff1}'
,notice: {
_ErrorNoMessage: '❌ 현재 공지사항이 없습니다.'
}
}

export const funcUpdateAdmins = {
Expand Down
2 changes: 2 additions & 0 deletions core/lib/browser.hostconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export interface BrowserHostRoomCommands {
_helpMantier: string
_helpMansuper: string
_helpManadmin: string
_helpMannotice: string

_listSubafk: string
_listSubmute: string
Expand Down Expand Up @@ -193,4 +194,5 @@ export interface BrowserHostRoomCommands {
super: string
vote: string
tier: string
notice: string
}
25 changes: 25 additions & 0 deletions core/lib/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,29 @@ export class HeadlessBrowser {
window.gameRoom.logger.i('system', `[Broadcast] ${message}`);
}, message);
}

/**
* Get notice message.
* @param ruid Game room's UID
*/
public async getNotice(ruid: string): Promise<string|undefined> {
return await this._PageContainer.get(ruid)!.evaluate(() => {
if(window.gameRoom.notice) {
return window.gameRoom.notice;
} else {
return undefined;
}
})
}

/**
* Set notice message.
* @param ruid Game room's UID
* @param message Notice Content
*/
public async setNotice(ruid: string, message: string): Promise<void> {
await this._PageContainer.get(ruid)!.evaluate((message: string) => {
window.gameRoom.notice = message;
},message)
}
}
2 changes: 1 addition & 1 deletion core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haxbotron-core",
"version": "0.4.3",
"version": "0.4.4",
"description": "Haxbotron is a headless host server application for Haxball.",
"main": "out/app.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions core/react/component/Admin/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import RoomSuperAdmin from './RoomSuperAdmin';
import RoomInfo from './RoomInfo';
import RoomBanList from './RoomBanList';
import RoomPlayerList from './RoomPlayerList';
import RoomSocial from './RoomSocial';

const drawerWidth = 240;

Expand Down Expand Up @@ -230,6 +231,7 @@ function Dashboard({ match }: RouteComponentProps) {
<Route path={`${match.path}/room/:ruid/info`}><RoomInfo styleClass={styleClass} /></Route>
<Route path={`${match.path}/room/:ruid/power`}><RoomPower styleClass={styleClass} /></Route>
<Route path={`${match.path}/room/:ruid/player`}><RoomPlayerList styleClass={styleClass} /></Route>
<Route path={`${match.path}/room/:ruid/social`}><RoomSocial styleClass={styleClass} /></Route>
<Route component={NotFound} />
</Switch>
</main>
Expand Down
2 changes: 1 addition & 1 deletion core/react/component/Admin/RoomBanList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect, useState } from 'react';
import React, { useEffect, useState } from 'react';
import clsx from 'clsx';
import Box from '@material-ui/core/Box';
import Container from '@material-ui/core/Container';
Expand Down
6 changes: 1 addition & 5 deletions core/react/component/Admin/RoomList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import Container from '@material-ui/core/Container';
import Grid from '@material-ui/core/Grid';
import Paper from '@material-ui/core/Paper';
import Copyright from '../common/Footer.Copyright';
import Table from '@material-ui/core/Table';
import TableBody from '@material-ui/core/TableBody';
import TableCell from '@material-ui/core/TableCell';
import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import { Table, TableBody, TableCell, TableHead, TableRow, TextField } from '@material-ui/core';
import Title from './common/Widget.Title';
import client from '../../lib/client';
import { WSocketContext } from '../../context/ws';
Expand Down
9 changes: 7 additions & 2 deletions core/react/component/Admin/RoomLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import Copyright from '../common/Footer.Copyright';
import Title from './common/Widget.Title';
import { WSocketContext } from '../../context/ws';
import { useParams } from 'react-router-dom';
import { Button, TextField, Typography } from '@material-ui/core';
import { Button, TextField } from '@material-ui/core';
import client from '../../lib/client';
import Alert, { AlertColor } from '../common/Alert';

interface styleClass {
styleClass: any
Expand Down Expand Up @@ -40,6 +41,8 @@ export default function RoomLog({ styleClass }: styleClass) {
const [recentLogMessage, setRecentLogMessage] = useState({} as LogMessage);

const [flashMessage, setFlashMessage] = useState('');
const [alertStatus, setAlertStatus] = useState("success" as AlertColor);

const [broadcastMessage, setBroadcastMessage] = useState('');

const handleBroadcast = async (event: React.FormEvent<HTMLFormElement>) => {
Expand All @@ -48,12 +51,14 @@ export default function RoomLog({ styleClass }: styleClass) {
const result = await client.post(`/api/v1/room/${matchParams.ruid}/chat`, { message: broadcastMessage });
if (result.status === 201) {
setFlashMessage('Successfully sent.');
setAlertStatus('success');
setBroadcastMessage('');
setTimeout(() => {
setFlashMessage('');
}, 3000);
}
} catch (error) {
setAlertStatus('error');
switch (error.response.status) {
case 400: {
setFlashMessage('No message.');
Expand Down Expand Up @@ -101,7 +106,7 @@ export default function RoomLog({ styleClass }: styleClass) {
<Grid item xs={12}>
<Paper className={fixedHeightPaper}>
<React.Fragment>
<Typography variant="body1">{flashMessage}</Typography>
{flashMessage && <Alert severity={alertStatus}>{flashMessage}</Alert>}
<Title>Broadcast</Title>
<form className={classes.form} onSubmit={handleBroadcast} method="post">
<TextField
Expand Down
Loading

0 comments on commit e3b2ebc

Please sign in to comment.