private static void HandleReward(GameSession session, PacketReader packet) { int rank = packet.ReadInt(); if (session.Player.PrestigeRewardsClaimed.Contains(rank)) { return; } // Get reward data PrestigeReward reward = PrestigeMetadataStorage.GetReward(rank); if (reward.Type.Equals("item")) { Item item = new(reward.Id) { CreationTime = TimeInfo.Now(), Rarity = 4 }; session.Player.Inventory.AddItem(session, item, true); } else if (reward.Type.Equals("statPoint")) { session.Player.StatPointDistribution.AddTotalStatPoints(reward.Value); } session.Send(PrestigePacket.Reward(rank)); session.Player.PrestigeRewardsClaimed.Add(rank); }
public static void BlackMarketCancellation(BlackMarketListing listing) { long deposit = 0; if (TimeInfo.Now() > listing.ExpiryTimestamp) { deposit = listing.Deposit; } string senderName = "<ms2><v key=\"s_blackmarket_mail_to_sender\" /></ms2>"; string title = "<ms2><v key=\"s_blackmarket_mail_to_cancel_title\" /></ms2>"; string body = "<ms2><v key=\"s_blackmarket_mail_to_cancel_content\" /></ms2>"; string addParameter1 = $"<ms2><v item=\"{listing.Item.Id}\" ></v></ms2>"; string addParameter2 = "<ms2>" + "<v key=\"s_blackmarket_mail_to_cancel_direct\" ></v>" + $"<v item=\"{listing.Item.Id}\" ></v>" + $"<v str=\"{listing.ListedQuantity}\" ></v>" + $"<v money=\"{listing.Price * listing.ListedQuantity}\" ></v>" + $"<v money=\"{listing.Price}\" ></v>" + $"<v money=\"{deposit}\" ></v>" + "</ms2>"; Mail mail = new(MailType.BlackMarketListingCancel, listing.OwnerCharacterId, 0, senderName, title, body, addParameter1, addParameter2, new() { listing.Item }, deposit, 0); GameServer.MailManager.AddMail(mail); SendNotification(mail); }
public void SetName(string newName) { Name = newName; LastNameChangeTimestamp = TimeInfo.Now(); DatabaseManager.Clubs.Update(this); BroadcastPacketClub(ClubPacket.Rename(this)); }
private static void HandleChatEmoticonAdd(GameSession session, Item item) { long expiration = long.MaxValue; if (item.Function.ChatEmoticonAdd.Duration > 0) { expiration = item.Function.ChatEmoticonAdd.Duration + TimeInfo.Now(); } // sticker exists and no expiration if (session.Player.ChatSticker.Any(p => p.GroupId == item.Function.ChatEmoticonAdd.Id && p.Expiration == long.MaxValue)) { return; } // Add time if the sticker is already in the list ChatSticker sticker = session.Player.ChatSticker.FirstOrDefault(p => p.GroupId == item.Function.ChatEmoticonAdd.Id); if (sticker is not null && sticker.Expiration != long.MaxValue) { expiration += sticker.Expiration - TimeInfo.Now(); } session.Send(ChatStickerPacket.AddSticker(item.Id, item.Function.ChatEmoticonAdd.Id, expiration)); session.Player.ChatSticker.Add(new((byte)item.Function.ChatEmoticonAdd.Id, expiration)); session.Player.Inventory.ConsumeItem(session, item.Uid, 1); }
private static void HandleCompleteNavigator(GameSession session, PacketReader packet) { int questId = packet.ReadInt(); if (!session.Player.QuestData.TryGetValue(questId, out QuestStatus questStatus) || questStatus.State is QuestState.Finished) { return; } foreach (QuestRewardItem rewardItem in questStatus.RewardItems) { Item item = new(rewardItem.Code) { Amount = rewardItem.Count, Rarity = rewardItem.Rank }; session.Player.Inventory.AddItem(session, item, true); } Condition firstCondition = questStatus.Condition.First(); firstCondition.Current++; firstCondition.Completed = true; questStatus.State = QuestState.Finished; questStatus.CompleteTimestamp = TimeInfo.Now(); DatabaseManager.Quests.Update(questStatus); session.Send(QuestPacket.CompleteQuest(questId, false)); }
/// <summary> /// Increase the current condition value by 1. /// If the condition value is already at the maximum, the condition is completed. /// Send the respective quest packets to the player. /// </summary> private static void UpdateConditions(this IEnumerable <Condition> relevantConditions, GameSession session, QuestStatus quest) { foreach (Condition condition in relevantConditions) { if (condition.Goal != 0 && condition.Goal == condition.Current) { continue; } condition.Current++; if (condition.Current >= condition.Goal) { condition.Completed = true; } session.Send(QuestPacket.UpdateCondition(quest.Basic.Id, quest.Condition)); if (!condition.Completed || quest.Basic.QuestType is not QuestType.Exploration) { continue; } quest.State = QuestState.Completed; quest.AmountCompleted++; quest.CompleteTimestamp = TimeInfo.Now(); session.Player.Levels.GainExp(quest.Reward.Exp); session.Player.Wallet.Meso.Modify(quest.Reward.Money); session.Send(QuestPacket.CompleteQuest(quest.Basic.Id, false)); DatabaseManager.Quests.Update(quest); } }
public Item(int id, bool saveToDatabase = true) { Id = id; SetMetadataValues(); Name = ItemMetadataStorage.GetName(id); Level = ItemMetadataStorage.GetLevel(id); ItemSlot = ItemMetadataStorage.GetSlot(id); IsTemplate = ItemMetadataStorage.GetIsTemplate(id); if (GemSlot == GemSlot.TRANS) { TransparencyBadgeBools = new byte[10]; } Rarity = ItemMetadataStorage.GetRarity(id); PlayCount = ItemMetadataStorage.GetPlayCount(id); Color = ItemMetadataStorage.GetEquipColor(id); CreationTime = TimeInfo.Now(); RemainingGlamorForges = ItemExtractionMetadataStorage.GetExtractionCount(id); Slot = -1; Amount = 1; Score = new(); Stats = new(id, Rarity, ItemSlot, Level); if (saveToDatabase) { Uid = DatabaseManager.Items.Insert(this); } }
private static void HandleRename(GameSession session, PacketReader packet) { long clubId = packet.ReadLong(); string clubNewName = packet.ReadUnicodeString(); Club club = GameServer.ClubManager.GetClubById(clubId); if (club is null) { return; } if (club.LastNameChangeTimestamp > TimeInfo.Now() + 3600) // 1 hour restriction to change names { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.CanOnlyBeRenamedOnceAnHour)); return; } if (!ValidClubName(session, clubNewName)) { return; } if (clubNewName == club.Name) { session.Send(ClubPacket.ErrorNotice((int)ClubErrorNotice.NewNameIsCurrentName)); return; } club.SetName(clubNewName); }
public GuildApplication(long player, long guild) { CharacterId = player; GuildId = guild; CreationTimestamp = TimeInfo.Now() + Environment.TickCount; Id = DatabaseManager.GuildApplications.Insert(this); }
private static void HandleCheckIn(GameSession session) { Guild guild = GameServer.GuildManager.GetGuildById(session.Player.Guild.Id); if (guild == null) { return; } GuildMember member = guild.Members.First(x => x.Player == session.Player); // Check if attendance timestamp is today DateTimeOffset date = DateTimeOffset.FromUnixTimeSeconds(member.AttendanceTimestamp); if (date == DateTime.Today) { return; } int contributionAmount = GuildContributionMetadataStorage.GetContributionAmount("attend"); GuildPropertyMetadata property = GuildPropertyMetadataStorage.GetMetadata(guild.Exp); member.AddContribution(contributionAmount); member.AttendanceTimestamp = TimeInfo.Now() + Environment.TickCount; session.Send(GuildPacket.CheckInBegin()); Item guildCoins = new(id : 30000861, amount : property.AttendGuildCoin, rarity : 4); session.Player.Inventory.AddItem(session, guildCoins, true); guild.AddExp(session, property.AttendExp); guild.ModifyFunds(session, property, property.AttendFunds); guild.BroadcastPacketGuild(GuildPacket.UpdatePlayerContribution(member, contributionAmount)); session.Send(GuildPacket.FinishCheckIn(member)); }
private static void PurchaseUgcItem(GameSession session, long ugcMarketItemId) { UgcMarketItem marketItem = GameServer.UgcMarketManager.FindItemById(ugcMarketItemId); if (marketItem is null || marketItem.ListingExpirationTimestamp < TimeInfo.Now()) { return; } if (!HandleMarketItemPay(session, marketItem.Price, MeretMarketCurrencyType.Meret)) { return; } marketItem.SalesCount++; DatabaseManager.UgcMarketItems.Update(marketItem); _ = new UgcMarketSale(marketItem.Price, marketItem.Item.Ugc.Name, marketItem.SellerCharacterId); Item item = new(marketItem.Item) { CreationTime = TimeInfo.Now() }; item.Uid = DatabaseManager.Items.Insert(item); session.Player.Inventory.AddItem(session, item, true); session.Send(MeretMarketPacket.Purchase(0, marketItem.MarketId, marketItem.Price, 1)); }
private static void HandleSaveHair(GameSession session, PacketReader packet) { long hairUid = packet.ReadLong(); Item hair = session.Player.Inventory.Cosmetics.FirstOrDefault(x => x.Value.Uid == hairUid).Value; if (hair == null || hair.ItemSlot != ItemSlot.HR) { return; } if (session.Player.HairInventory.SavedHair.Count > 30) // 30 is the max slots { return; } Item hairCopy = new(hair.Id) { HairData = hair.HairData, Color = hair.Color, CreationTime = TimeInfo.Now() + Environment.TickCount }; session.Player.HairInventory.SavedHair.Add(hairCopy); session.Send(BeautyPacket.SaveHair(hair, hairCopy)); }
public ClubMember(Player player, long clubId) { Player = player; JoinTimestamp = TimeInfo.Now(); ClubId = clubId; InviteResponse = ClubInviteResponse.Pending; DatabaseManager.ClubMembers.Insert(this); }
private static void HandleClose(GameSession session) { if (session.Player.MapId == (int)Map.PrivateResidence) { session.Player.HouseDoctorAccessTime = TimeInfo.Now(); } DatabaseManager.BankInventories.Update(session.Player.Account.BankInventory); }
public static PacketWriter SetInitial2() { PacketWriter pWriter = PacketWriter.Of(SendOp.ResponseTimeSync); pWriter.Write(TimeSyncPacketMode.SetInitial2); pWriter.WriteLong(TimeInfo.Now()); return(pWriter); }
public static PacketWriter UpdatePlayerDonation(/*int totalDonationAmount*/) { PacketWriter pWriter = PacketWriter.Of(SendOp.GUILD); pWriter.Write(GuildPacketMode.UpdatePlayerDonation); pWriter.WriteInt(0x3); // total amount of donations today pWriter.WriteLong(TimeInfo.Now() + Environment.TickCount); return(pWriter); }
public static PacketWriter MemberLoggedOff(Player player) { PacketWriter pWriter = PacketWriter.Of(SendOp.GUILD); pWriter.Write(GuildPacketMode.MemberLoggedOff); pWriter.WriteUnicodeString(player.Name); pWriter.WriteLong(TimeInfo.Now()); return(pWriter); }
// Called first time when starting a new session public void InitPlayer(Player player) { Debug.Assert(player.FieldPlayer == null, "Not allowed to reinitialize player."); Player = player; FieldManager = FieldManagerFactory.GetManager(player); player.FieldPlayer = FieldManager.RequestCharacter(player); player.LastLogTime = TimeInfo.Now(); }
public static PacketWriter SetInitial2() { PacketWriter pWriter = PacketWriter.Of(SendOp.RESPONSE_TIME_SYNC); pWriter.Write(TimeSyncPacketMode.SetInitial2); pWriter.WriteLong(TimeInfo.Now()); return(pWriter); }
/* * In a Visual Studio project create a class Time to hold information about the current time and the current date . * * Make an easy-to-use constructor (from client perspective), that would represent the time and date the client wants to hold in your class. * * Implement the ToString() method, returning the time and date in format : "hh:mm:ss dd.MM.YY". * * Bonus Make a static method Now() for your class, returning the Time at the present moment :) (of type Time) */ static void Main(string[] args) { var ourTime = new TimeInfo(new DateTime(2015, 02, 16, 14, 16, 00)); Console.WriteLine(ourTime.ToString()); var time = TimeInfo.Now(); Console.WriteLine(time.ToString()); }
public static PacketWriter Collect(Mail mail) { PacketWriter pWriter = PacketWriter.Of(SendOp.MAIL); pWriter.Write(MailPacketMode.Collect); pWriter.WriteLong(mail.Id); pWriter.WriteByte(1); pWriter.WriteByte(); pWriter.WriteLong(TimeInfo.Now()); return(pWriter); }
public GuildMember(Player player, byte rank, long guildId) { Id = player.CharacterId; Player = player; Rank = rank; Motto = ""; JoinTimestamp = TimeInfo.Now() + Environment.TickCount; LastLogTimestamp = player.LastLogTime; GuildId = guildId; DatabaseManager.GuildMembers.Insert(this); }
public static PacketWriter FailLikeSkill(long characterId, CoordB coordB) { PacketWriter packetWriter = PacketWriter.Of(SendOp.FunctionCube); packetWriter.Write(FunctionCubeMode.FailLifeSkill); packetWriter.WriteLong(characterId); packetWriter.WriteUnicodeString($"4_{coordB.AsHexadecimal()}"); packetWriter.WriteLong(TimeInfo.Now()); return(packetWriter); }
// Animation: Animates the quest helper public static PacketWriter CompleteQuest(int questId, bool animation) { PacketWriter pWriter = PacketWriter.Of(SendOp.QUEST); pWriter.Write(QuestType.CompleteQuest); pWriter.WriteInt(questId); pWriter.WriteInt(animation ? 1 : 0); pWriter.WriteLong(TimeInfo.Now()); return(pWriter); }
public static PacketWriter SuccessLifeSkill(long characterId, CoordB coordB, int status) { PacketWriter packetWriter = PacketWriter.Of(SendOp.FUNCTION_CUBE); packetWriter.Write(FunctionCubeMode.SuccessLifeSkill); packetWriter.WriteLong(characterId); packetWriter.WriteUnicodeString($"4_{CoordB.AsHexadecimal(coordB)}"); packetWriter.WriteLong(TimeInfo.Now()); packetWriter.WriteInt(status); return(packetWriter); }
public static PacketWriter UpdateArchitectScore(int ownerObjectId, int architectScoreCurrent, int architectScoreTotal) { PacketWriter pWriter = PacketWriter.Of(SendOp.HOME_COMMAND); pWriter.Write(HomeCommandMode.UpdateArchitectScore); pWriter.WriteInt(ownerObjectId); pWriter.WriteLong(TimeInfo.Now()); pWriter.WriteInt(architectScoreCurrent); pWriter.WriteInt(architectScoreTotal); return(pWriter); }
public static PacketWriter AcceptQuest(int questId) { PacketWriter pWriter = PacketWriter.Of(SendOp.QUEST); pWriter.Write(QuestType.AcceptQuest); pWriter.WriteInt(questId); pWriter.WriteLong(TimeInfo.Now()); pWriter.WriteByte(1); pWriter.WriteInt(); return(pWriter); }
public Party(Player partyLeader) { Id = GuidGenerator.Int(); Leader = partyLeader; ReadyCheck = new(); Members = new(); PartyFinderId = 0; Approval = true; CreationTimestamp = TimeInfo.Now() + Environment.TickCount; AddMember(partyLeader); }
public static PacketWriter SetInitial1() { PacketWriter pWriter = PacketWriter.Of(SendOp.ResponseTimeSync); pWriter.Write(TimeSyncPacketMode.SetInitial1); pWriter.WriteInt(Environment.TickCount); pWriter.WriteLong(TimeInfo.Now()); pWriter.WriteByte(); pWriter.WriteInt(); return(pWriter); }
public static PacketWriter Request() { PacketWriter pWriter = PacketWriter.Of(SendOp.RESPONSE_TIME_SYNC); pWriter.Write(TimeSyncPacketMode.Request); pWriter.WriteInt(Environment.TickCount); pWriter.WriteLong(TimeInfo.Now()); pWriter.WriteByte(); pWriter.WriteInt(); return(pWriter); }