Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guild command #2439

Merged
merged 10 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";

export const commandInfo: ITestCommand = {
name: "glorypoints",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Guild from "../../../../core/database/game/models/Guild";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {Players} from "../../../../core/database/game/models/Player";
import {GuildConstants} from "../../../../core/constants/GuildConstants";
import {GuildConstants} from "../../../../../../Lib/src/constants/GuildConstants";

export const commandInfo: ITestCommand = {
name: "forcejoinguild",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Guild from "../../../../core/database/game/models/Guild";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {GuildConstants} from "../../../../core/constants/GuildConstants";
import {GuildConstants} from "../../../../../../Lib/src/constants/GuildConstants";

export const commandInfo: ITestCommand = {
name: "guildlevel",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Guild from "../../../../core/database/game/models/Guild";
import {GuildDailyConstants} from "../../../../core/constants/GuildDailyConstants";
import {GuildDailyConstants} from "../../../../../../Lib/src/constants/GuildDailyConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";

let stringDesc = "Force un gd avec une sortie donnée. Liste des sorties possibles : ";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Guild from "../../../../core/database/game/models/Guild";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {draftBotInstance} from "../../../../index";

export const commandInfo: ITestCommand = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Guild from "../../../../core/database/game/models/Guild";
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";

export const commandInfo: ITestCommand = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Guild from "../../../../core/database/game/models/Guild";
import {getFoodIndexOf} from "../../../../core/utils/FoodUtils";
import {Constants} from "../../../../core/Constants";
import {Constants} from "../../../../../../Lib/src/constants/Constants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";

export const commandInfo: ITestCommand = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Maps} from "../../../../core/maps/Maps";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {TravelTime} from "../../../../core/maps/TravelTime";
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {MapLinkDataController} from "../../../../data/MapLink";

export const commandInfo: ITestCommand = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {PlayerMissionsInfos} from "../../../../core/database/game/models/PlayerMissionsInfo";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {PetEntities} from "../../../../core/database/game/models/PetEntity";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";

export const commandInfo: ITestCommand = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";

export const commandInfo: ITestCommand = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";

export const commandInfo: ITestCommand = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";

export const commandInfo: ITestCommand = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";

export const commandInfo: ITestCommand = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ExecuteTestCommandLike, ITestCommand} from "../../../../core/CommandsTest";
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";

export const commandInfo: ITestCommand = {
name: "playerkill",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Maps} from "../../../../core/maps/Maps";
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand} from "../../../../core/CommandsTest";
import {TravelTime} from "../../../../core/maps/TravelTime";
import {MapLinkDataController} from "../../../../data/MapLink";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {TravelTime} from "../../../../core/maps/TravelTime";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import Player from "../../../../core/database/game/models/Player";
import {BlockingUtils} from "../../../../core/utils/BlockingUtils";
import {BlockingConstants} from "../../../../core/constants/BlockingConstants";
import {BlockingConstants} from "../../../../../../Lib/src/constants/BlockingConstants";

export const commandInfo: ITestCommand = {
name: "blockplayer",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {EffectsConstants} from "../../../../../../Lib/src/constants/EffectsConstants";
import {TravelTime} from "../../../../core/maps/TravelTime";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand, TypeKey} from "../../../../core/CommandsTest";
import {EffectsConstants} from "../../../../../../Lib/src/constants/EffectsConstants";
import {TravelTime} from "../../../../core/maps/TravelTime";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {NumberChangeReason} from "../../../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../../../Lib/src/constants/LogsConstants";
import {ExecuteTestCommandLike, ITestCommand} from "../../../../core/CommandsTest";
import {TravelTime} from "../../../../core/maps/TravelTime";

Expand Down
77 changes: 77 additions & 0 deletions Core/src/commands/guild/GuildCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import {packetHandler} from "../../core/packetHandlers/PacketHandler";
import {WebsocketClient} from "../../../../Lib/src/instances/WebsocketClient";
import {DraftBotPacket, makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPacket";
import {Players} from "../../core/database/game/models/Player";
import {Guild, Guilds} from "../../core/database/game/models/Guild";
import {CommandGuildPacketReq, CommandGuildPacketRes} from "../../../../Lib/src/packets/commands/CommandGuildPacket";
import {Maps} from "../../core/maps/Maps";
import {MapCache} from "../../core/maps/MapCache";

export default class GuildCommand {
@packetHandler(CommandGuildPacketReq)
async execute(client: WebsocketClient, packet: CommandGuildPacketReq, context: PacketContext, response: DraftBotPacket[]): Promise<void> {
let guild: Guild;
const player = packet.askedPlayer.keycloakId ? await Players.getByKeycloakId(packet.askedPlayer.keycloakId) : await Players.getByRank(packet.askedPlayer.rank);
if (packet.askedGuildName) {
try {
guild = await Guilds.getByName(packet.askedGuildName);
}
catch (error) {
guild = null;
}
}
else {
guild = player.guildId ? await Guilds.getById(player.guildId) : null;
}

if (!guild) {
response.push(makePacket(CommandGuildPacketRes, {
foundGuild: false
}));
}
else {
const members = await Players.getByGuild(guild.id);
const rank = await guild.getRanking();
const numberOfGuilds = await Guilds.getTotalRanked();
const membersPveAlliesIds = (await Maps.getGuildMembersOnPveIsland(player)).map((player) => player.id);
const isUnranked = rank > -1;

response.push(makePacket(CommandGuildPacketRes, {
foundGuild: true,
askedPlayerKeycloakId: player.keycloakId,
data: {
name: guild.name,
description: guild.guildDescription,
chiefId: guild.chiefId,
elderId: guild.elderId,
level: guild.level,
experience: {
value: guild.experience,
max: guild.getExperienceNeededToLevelUp()
},
rank: {
unranked: isUnranked,
rank,
numberOfGuilds,
score: guild.score
},
members: await Promise.all(
members.map(async member => ({
id: member.id,
keycloakId: member.keycloakId,
rank: await Players.getRankById(member.id),
score: member.score,
islandStatus: {
isOnPveIsland: Maps.isOnPveIsland(member),
isOnBoat: MapCache.boatEntryMapLinks.includes(member.mapLinkId),
isPveIslandAlly: membersPveAlliesIds.includes(member.id),
isInactive: member.isInactive(),
cannotBeJoinedOnBoat: member.isNotActiveEnoughToBeJoinedInTheBoat()
}
}))
)
}
}));
}
}
}
4 changes: 2 additions & 2 deletions Core/src/commands/player/ProfileCommand.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import {PetEntities} from "../../core/database/game/models/PetEntity";
import PlayerMissionsInfo, {PlayerMissionsInfos} from "../../core/database/game/models/PlayerMissionsInfo";
import {InventorySlots} from "../../core/database/game/models/InventorySlot";
import {FightConstants} from "../../core/constants/FightConstants";
import {FightConstants} from "../../../../Lib/src/constants/FightConstants";
import {packetHandler} from "../../core/packetHandlers/PacketHandler";
import {WebsocketClient} from "../../../../Lib/src/instances/WebsocketClient";
import {DraftBotPacket, makePacket, PacketContext} from "../../../../Lib/src/packets/DraftBotPacket";
import {CommandProfilePacketReq, CommandProfilePacketRes} from "../../../../Lib/src/packets/commands/CommandProfilePacket";
import {Campaign} from "../../core/missions/Campaign";
import {Players} from "../../core/database/game/models/Player";
import {Guilds} from "../../core/database/game/models/Guild";
import {Constants} from "../../core/Constants";
import {Constants} from "../../../../Lib/src/constants/Constants";
import {hoursToMilliseconds} from "../../../../Lib/src/utils/TimeUtils";
import {PetDataController} from "../../data/Pet";

Expand Down
12 changes: 6 additions & 6 deletions Core/src/commands/player/ReportCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ import {Player, Players} from "../../core/database/game/models/Player";
import {EffectsConstants} from "../../../../Lib/src/constants/EffectsConstants";
import {Maps} from "../../core/maps/Maps";
import {MapLink, MapLinkDataController} from "../../data/MapLink";
import {Constants} from "../../core/Constants";
import {Constants} from "../../../../Lib/src/constants/Constants";
import {getTimeFromXHoursAgo, millisecondsToMinutes, millisecondsToSeconds} from "../../../../Lib/src/utils/TimeUtils";
import {BlockingUtils} from "../../core/utils/BlockingUtils";
import {BlockingConstants} from "../../core/constants/BlockingConstants";
import {BlockingConstants} from "../../../../Lib/src/constants/BlockingConstants";
import {MissionsController} from "../../core/missions/MissionsController";
import {FightController} from "../../core/fights/FightController";
import {PVEConstants} from "../../core/constants/PVEConstants";
import {PVEConstants} from "../../../../Lib/src/constants/PVEConstants";
import {MonsterDataController} from "../../data/Monster";
import {PlayerFighter} from "../../core/fights/fighter/PlayerFighter";
import {NumberChangeReason} from "../../core/constants/LogsConstants";
import {NumberChangeReason} from "../../../../Lib/src/constants/LogsConstants";
import {Guilds} from "../../core/database/game/models/Guild";
import {GuildConstants} from "../../core/constants/GuildConstants";
import {GuildConstants} from "../../../../Lib/src/constants/GuildConstants";
import {draftBotInstance} from "../../index";
import {MonsterFighter} from "../../core/fights/fighter/MonsterFighter";
import {EndCallback, ReactionCollectorInstance} from "../../core/utils/ReactionsCollector";
Expand All @@ -44,7 +44,7 @@ import {
import {MapCache} from "../../core/maps/MapCache";
import {TravelTime} from "../../core/maps/TravelTime";
import {SmallEventDataController, SmallEventFuncs} from "../../data/SmallEvent";
import {ReportConstants} from "../../core/constants/ReportConstants";
import {ReportConstants} from "../../../../Lib/src/constants/ReportConstants";
import {BigEvent, BigEventDataController} from "../../data/BigEvent";
import {
ReactionCollectorBigEvent,
Expand Down
4 changes: 2 additions & 2 deletions Core/src/core/bot/DraftBot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import {GameDatabase} from "../database/game/GameDatabase";
import {LogsDatabase} from "../database/logs/LogsDatabase";
import {draftBotInstance} from "../../index";
import {Settings} from "../database/game/models/Setting";
import {PetConstants} from "../constants/PetConstants";
import {PetConstants} from "../../../../Lib/src/constants/PetConstants";
import {Op} from "sequelize";
import PetEntity from "../database/game/models/PetEntity";
import {RandomUtils} from "../utils/RandomUtils";
import {PotionDataController} from "../../data/Potion";
import {getNextDay2AM} from "../../../../Lib/src/utils/TimeUtils";
import {TIMEOUT_FUNCTIONS} from "../constants/TimeoutFunctionsConstants";
import {TIMEOUT_FUNCTIONS} from "../../../../Lib/src/constants/TimeoutFunctionsConstants";
import {MapCache} from "../maps/MapCache";
import {registerAllPacketHandlers} from "../packetHandlers/PacketHandler";

Expand Down
9 changes: 0 additions & 9 deletions Core/src/core/constants/BotConstants.ts

This file was deleted.

53 changes: 0 additions & 53 deletions Core/src/core/constants/PetConstants.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {DataTypes, QueryInterface} from "sequelize";
import {EntityConstants} from "../../../constants/EntityConstants";
import {EntityConstants} from "../../../../../../Lib/src/constants/EntityConstants";
import {entitiesAttributes001} from "./001-initial-database";

export async function up({context}: { context: QueryInterface }): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {DataTypes, QueryInterface} from "sequelize";
import {FightConstants} from "../../../constants/FightConstants";
import {FightConstants} from "../../../../../../Lib/src/constants/FightConstants";

export const leaguesAttributes008 = {
id: {
Expand Down
Loading
Loading