Initial commit
This commit is contained in:
@@ -0,0 +1,242 @@
|
||||
const MainPlayerPacket = require("../Packets/MainPlayer");
|
||||
const ObtainedDesignsPacket = require("../Packets/ObtainedDesigns");
|
||||
const PropertyChangedPacket = require("../Packets/PropertyChanged");
|
||||
const AttackInformationPacket = require("../Packets/AttackInformation");
|
||||
const AttackerInformationPacket = require("../Packets/AttackerInformation");
|
||||
const QuestsPacket = require("../Packets/Quests");
|
||||
const QuestsCompletedAmountPacket = require("../Packets/QuestsCompletedAmount");
|
||||
const CannonballsPacket = require("../Packets/Cannonballs");
|
||||
const HarpoonsPacket = require("../Packets/Harpoons");
|
||||
const ItemsPacket = require("../Packets/Items");
|
||||
const EquipmentCapacitiesMaximumPacket = require("../Packets/EquipmentCapacitiesMaximum");
|
||||
const StatusPointsPacket = require("../Packets/StatusPoints");
|
||||
const EconomyPacket = require("../Packets/Economy");
|
||||
const ActiveStatusEffectsPacket = require("../Packets/ActiveStatusEffects");
|
||||
const EquipmentsPacket = require("../Packets/Equipments");
|
||||
const GuildMemberNewPacket = require("../Packets/GuildMemberNew");
|
||||
const WorldMapGuildEntryPacket = require("../Packets/WorldMapGuildEntry");
|
||||
const RankThresholdPointsPacket = require("../Packets/RankThresholdPoints");
|
||||
const RankPointPacket = require("../Packets/RankPoint");
|
||||
const GuildDataMemberChangedPacket = require("../Packets/GuildDataMemberChanged");
|
||||
const ShopEntryPacket = require("../Packets/ShopEntry");
|
||||
|
||||
const Entity = require("../Game/Entity");
|
||||
|
||||
const Game = require("../Game/Game");
|
||||
const { guildIslands } = Game;
|
||||
|
||||
const packet_58 = require("../Packets/packet_58");
|
||||
const packet_57 = require("../Packets/packet_57");
|
||||
|
||||
const BASE_SHOP = require("../Data/shop");
|
||||
const { SHOP, SHOP_ENTRIES_BUY } = BASE_SHOP;
|
||||
|
||||
const leaderboards = require("../Data/leaderboard");
|
||||
|
||||
module.exports = async function (ws, message, player) {
|
||||
if (player.isAvailable) return;
|
||||
|
||||
player.hasUnexpectedlyLeft = false;
|
||||
|
||||
const connectingPlayer = player.getProperties();
|
||||
const connectingPlayerPacket = MainPlayerPacket(connectingPlayer);
|
||||
player.map.registerIndividualNetworkPacket(player.id, connectingPlayerPacket);
|
||||
|
||||
const designIDs = player.inventory.getDesignIDs();
|
||||
const designsPacket = ObtainedDesignsPacket(designIDs);
|
||||
|
||||
const questPacketInitialized = QuestsPacket.init();
|
||||
Object.values(player.quests.list).forEach(quest => {
|
||||
const questPacket = {
|
||||
id: quest.id,
|
||||
progression: quest.getProgression(),
|
||||
currentComplete: quest.currentComplete
|
||||
};
|
||||
|
||||
questPacketInitialized.update(questPacket);
|
||||
});
|
||||
|
||||
const sightPacket = PropertyChangedPacket({
|
||||
typeID: 1,
|
||||
value: player.sight / 12
|
||||
});
|
||||
|
||||
const questsCompletedAmountPacket = QuestsCompletedAmountPacket(player.quests.completedQuestsAmount);
|
||||
|
||||
const ammunitionPacket = CannonballsPacket({
|
||||
ammunition: player.inventory.getAmmunitions(),
|
||||
selected: player.inventory.selectedAmmunition
|
||||
});
|
||||
|
||||
const harpoonPacket = HarpoonsPacket({
|
||||
harpoon: player.inventory.getHarpoons(),
|
||||
selected: player.inventory.selectedHarpoon
|
||||
});
|
||||
|
||||
const items = player.inventory.getItems();
|
||||
const itemPacket = ItemsPacket(items);
|
||||
|
||||
const resourceSharedLimiter = player.inventory.resourceSharedLimiter;
|
||||
const maximumEquipmentCapacities = [resourceSharedLimiter.cannon.quantity.maximum, resourceSharedLimiter.harpooner.quantity.maximum, resourceSharedLimiter.sail.quantity.maximum, resourceSharedLimiter.pirate.quantity.maximum];
|
||||
const propertiesPacket = EquipmentCapacitiesMaximumPacket(maximumEquipmentCapacities);
|
||||
|
||||
const statusPointsPacket = StatusPointsPacket({ statusPoints: player.statusPoints });
|
||||
|
||||
const economy = player.inventory.getEconomy();
|
||||
const currencyPacket = EconomyPacket(economy);
|
||||
|
||||
const activeStatusEffectsPacket = ActiveStatusEffectsPacket(player.activeStatusEffects);
|
||||
|
||||
/*
|
||||
const asd = await gameRedis.keys("*");
|
||||
asd.forEach(key => {
|
||||
const data = gameRedis.getAsync(key);
|
||||
|
||||
});*/
|
||||
|
||||
/*
|
||||
const playerIrrelevantEntries = !global.unavailablePlayerShopEntries[player.id] ? [] : Object.keys(global.unavailablePlayerShopEntries[player.id]);
|
||||
const globalIrrelevantEntries = Object.keys(global.unavailableGlobalShopEntries);
|
||||
const irrelevantShopEntries = [];
|
||||
const shopEntryIDTracker = {};
|
||||
|
||||
playerIrrelevantEntries.forEach(id => {
|
||||
if (!shopEntryIDTracker[id]) irrelevantShopEntries.push(id);
|
||||
shopEntryIDTracker[id] = true;
|
||||
});
|
||||
|
||||
globalIrrelevantEntries.forEach(id => {
|
||||
if (!shopEntryIDTracker[id]) irrelevantShopEntries.push(id);
|
||||
shopEntryIDTracker[id] = true;
|
||||
});
|
||||
*/
|
||||
const irrelevantShopEntriesPacket = packet_58([]);
|
||||
|
||||
const cannons = player.inventory.getCannons();
|
||||
const harpooners = player.inventory.getHarpooners();
|
||||
|
||||
const equipmentsPacket = EquipmentsPacket.init(cannons.length + harpooners.length);
|
||||
cannons.forEach(c => equipmentsPacket.update(c.getProperties()));
|
||||
harpooners.forEach(h => equipmentsPacket.update(h.getProperties()));
|
||||
|
||||
const packets = [statusPointsPacket, designsPacket, sightPacket, equipmentsPacket.get(), questsCompletedAmountPacket, questPacketInitialized.get(), itemPacket, ammunitionPacket, harpoonPacket, propertiesPacket, currencyPacket, activeStatusEffectsPacket, irrelevantShopEntriesPacket];
|
||||
|
||||
/*
|
||||
const currentDate = new Date();
|
||||
const currentMonth = currentDate.getMonth() + 1;
|
||||
const currentDay = currentDate.getDay() - 1;
|
||||
|
||||
const currentLoginReward = loginReward[currentMonth][currentDay];
|
||||
if (currentLoginReward) {
|
||||
const loginReward = new Reward({
|
||||
distributionType: 2,
|
||||
baseReward: currentLoginReward
|
||||
});
|
||||
|
||||
setTimeout(() => loginReward.single(1, player.inventory, rewards => rewardCallback({ isRegular: true, authorID: player.id, rewards })));
|
||||
};
|
||||
*/
|
||||
|
||||
if (player.guild.id) {
|
||||
const guildMemberNew = {
|
||||
playerID: player.id,
|
||||
tag: player.guild.tag
|
||||
};
|
||||
|
||||
const guildMemberNewPacket = GuildMemberNewPacket(guildMemberNew);
|
||||
packets.push(guildMemberNewPacket);
|
||||
|
||||
const guildDataMemberChanged = {
|
||||
id: player.id,
|
||||
isOnline: true
|
||||
};
|
||||
|
||||
const guildDataMemberChangedPacket = GuildDataMemberChangedPacket(guildDataMemberChanged);
|
||||
const topic = Game.getTopic(player.guild.topic);
|
||||
|
||||
topic.push(guildDataMemberChangedPacket);
|
||||
};
|
||||
|
||||
/* const mapped = {
|
||||
5: 2
|
||||
};
|
||||
|
||||
for (categoryID in SHOP) {
|
||||
const category = SHOP[categoryID];
|
||||
|
||||
for (itemID in category) {
|
||||
const entry = category[itemID];
|
||||
const isEntryAvailable = entry.isAvailable(player);
|
||||
if (!isEntryAvailable) continue;
|
||||
|
||||
const irrelevantShopEntry = {
|
||||
id: itemID,
|
||||
shopCategoryID: mapped[categoryID]
|
||||
};
|
||||
|
||||
const packet = packet_57(irrelevantShopEntry);
|
||||
packets.push(packet);
|
||||
};
|
||||
};*/
|
||||
|
||||
player.ready();
|
||||
|
||||
if (player.isAlive) {
|
||||
if (player.target) {
|
||||
const attackInformationPacket = AttackInformationPacket({
|
||||
authorTypeID: player.target.typeID,
|
||||
authorID: player.target.id
|
||||
});
|
||||
|
||||
const attackerPacket = AttackerInformationPacket({
|
||||
authorTypeID: player.target.typeID,
|
||||
authorID: player.target.id,
|
||||
isTarget: true,
|
||||
source: 1
|
||||
});
|
||||
|
||||
packets.push(attackInformationPacket, attackerPacket);
|
||||
};
|
||||
|
||||
player.attackers.forEach(attacker => {
|
||||
const attackerPacket = AttackerInformationPacket({
|
||||
authorTypeID: Entity.getType(attacker.attackerEntry) + 1,
|
||||
authorID: attacker.attackerEntry,
|
||||
isTarget: false,
|
||||
source: 1
|
||||
});
|
||||
|
||||
packets.push(attackerPacket);
|
||||
});
|
||||
};
|
||||
|
||||
guildIslands.forEach(g => {
|
||||
const worldMapGuildEntryPacketData = {
|
||||
locationMapID: g.locationMapID,
|
||||
index: g.index,
|
||||
bufferTag: g.guild.tag
|
||||
};
|
||||
console.info("bufferTag", g.guild.tag)
|
||||
const worldMapGuildEntryPacket = WorldMapGuildEntryPacket(worldMapGuildEntryPacketData);
|
||||
packets.push(worldMapGuildEntryPacket);
|
||||
});
|
||||
|
||||
for (let i = 0, length = player.rankingPoints.length; i < length; i++) {
|
||||
const { id, amount } = player.rankingPoints[i];
|
||||
|
||||
const rankPoint = {
|
||||
rankTypeID: id,
|
||||
value: amount
|
||||
};
|
||||
|
||||
const rankPointPacket = RankPointPacket(rankPoint);
|
||||
packets.push(rankPointPacket);
|
||||
};
|
||||
|
||||
SHOP.forEach(shopEntry => {
|
||||
const shopEntryPacket = ShopEntryPacket(shopEntry);
|
||||
packets.push(shopEntryPacket);
|
||||
});
|
||||
|
||||
player.map.registerIndividualNetworkPacket(player.id, packets);
|
||||
};
|
||||
Reference in New Issue
Block a user