mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 20:25:51 +12:00
Remove " " space from the names
This commit is contained in:
parent
bef3032886
commit
8e451633dc
59 changed files with 391 additions and 391 deletions
97
Horse Isle Server/HorseIsleServer/Player/Award.cs
Normal file
97
Horse Isle Server/HorseIsleServer/Player/Award.cs
Normal file
|
@ -0,0 +1,97 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class Award
|
||||
{
|
||||
public struct AwardEntry
|
||||
{
|
||||
public int Id;
|
||||
public int Sort;
|
||||
public string Title;
|
||||
public int IconId;
|
||||
public int MoneyBonus;
|
||||
public string CompletionText;
|
||||
public string Description;
|
||||
}
|
||||
|
||||
public static AwardEntry[] GlobalAwardList;
|
||||
|
||||
public static AwardEntry GetAwardById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
AwardEntry award = GlobalAwardList[id - 1];
|
||||
if (award.Id == id)
|
||||
return award;
|
||||
}
|
||||
catch (Exception) { };
|
||||
|
||||
foreach(AwardEntry award in GlobalAwardList)
|
||||
{
|
||||
if (award.Id == id)
|
||||
return award;
|
||||
}
|
||||
|
||||
throw new KeyNotFoundException("Award ID " + id + " Does not exist.");
|
||||
}
|
||||
|
||||
|
||||
private List<AwardEntry> awardsEarned;
|
||||
private User baseUser;
|
||||
public AwardEntry[] AwardsEarned
|
||||
{
|
||||
get
|
||||
{
|
||||
return awardsEarned.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasAward(AwardEntry award)
|
||||
{
|
||||
foreach(AwardEntry awardEntry in AwardsEarned)
|
||||
{
|
||||
if (awardEntry.Id == award.Id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddAward(AwardEntry award,bool addToDatabase=true)
|
||||
{
|
||||
if (HasAward(award))
|
||||
return;
|
||||
|
||||
if (addToDatabase)
|
||||
{
|
||||
Database.AddAward(baseUser.Id, award.Id);
|
||||
|
||||
baseUser.Money += award.MoneyBonus;
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(award.CompletionText, PacketBuilder.CHAT_BOTTOM_RIGHT);
|
||||
baseUser.LoggedinClient.SendPacket(chatPacket);
|
||||
}
|
||||
|
||||
|
||||
awardsEarned.Add(award);
|
||||
}
|
||||
|
||||
public Award(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
int[] awards = Database.GetAwards(user.Id);
|
||||
awardsEarned = new List<AwardEntry>();
|
||||
|
||||
foreach (int awardid in awards)
|
||||
{
|
||||
AddAward(GetAwardById(awardid), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
using HISP.Game;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player.Equips
|
||||
{
|
||||
class CompetitionGear
|
||||
{
|
||||
public const int MISC_FLAG_HEAD = 1;
|
||||
public const int MISC_FLAG_BODY = 2;
|
||||
public const int MISC_FLAG_LEGS = 3;
|
||||
public const int MISC_FLAG_FEET = 4;
|
||||
|
||||
private int playerId;
|
||||
public CompetitionGear(int PlayerId)
|
||||
{
|
||||
playerId = PlayerId;
|
||||
if (!Database.HasCompetitionGear(PlayerId))
|
||||
Database.InitCompetitionGear(PlayerId);
|
||||
int itemId = Database.GetCompetitionGearHeadPeice(PlayerId);
|
||||
if (itemId != 0)
|
||||
head = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetCompetitionGearBodyPeice(PlayerId);
|
||||
if (itemId != 0)
|
||||
body = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetCompetitionGearLegPeice(PlayerId);
|
||||
if (itemId != 0)
|
||||
legs = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetCompetitionGearFeetPeice(PlayerId);
|
||||
if (itemId != 0)
|
||||
feet = Item.GetItemById(itemId);
|
||||
|
||||
}
|
||||
public Item.ItemInformation Head
|
||||
{
|
||||
get
|
||||
{
|
||||
return head;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
head = null;
|
||||
Database.SetCompetitionGearHeadPeice(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetCompetitionGearHeadPeice(playerId, value.Id);
|
||||
head = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Body
|
||||
{
|
||||
get
|
||||
{
|
||||
return body;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
body = null;
|
||||
Database.SetCompetitionGearBodyPeice(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetCompetitionGearBodyPeice(playerId, value.Id);
|
||||
body = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Legs
|
||||
{
|
||||
get
|
||||
{
|
||||
return legs;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
legs = null;
|
||||
Database.SetCompetitionGearLegPeice(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetCompetitionGearLegPeice(playerId, value.Id);
|
||||
legs = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Feet
|
||||
{
|
||||
get
|
||||
{
|
||||
return feet;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
feet = null;
|
||||
Database.SetCompetitionGearFeetPeice(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetCompetitionGearFeetPeice(playerId, value.Id);
|
||||
feet = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Item.ItemInformation head;
|
||||
private Item.ItemInformation body;
|
||||
private Item.ItemInformation legs;
|
||||
private Item.ItemInformation feet;
|
||||
|
||||
}
|
||||
}
|
112
Horse Isle Server/HorseIsleServer/Player/Equips/Jewelry.cs
Normal file
112
Horse Isle Server/HorseIsleServer/Player/Equips/Jewelry.cs
Normal file
|
@ -0,0 +1,112 @@
|
|||
using HISP.Game;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player.Equips
|
||||
{
|
||||
class Jewelry
|
||||
{
|
||||
|
||||
private int playerId;
|
||||
public Jewelry(int PlayerId)
|
||||
{
|
||||
playerId = PlayerId;
|
||||
if (!Database.HasJewelry(PlayerId))
|
||||
Database.InitJewelry(PlayerId);
|
||||
int itemId = Database.GetJewelrySlot1(PlayerId);
|
||||
if (itemId != 0)
|
||||
slot1 = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetJewelrySlot2(PlayerId);
|
||||
if (itemId != 0)
|
||||
slot2 = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetJewelrySlot3(PlayerId);
|
||||
if (itemId != 0)
|
||||
slot3 = Item.GetItemById(itemId);
|
||||
|
||||
itemId = Database.GetJewelrySlot4(PlayerId);
|
||||
if (itemId != 0)
|
||||
slot4 = Item.GetItemById(itemId);
|
||||
|
||||
}
|
||||
public Item.ItemInformation Slot1
|
||||
{
|
||||
get
|
||||
{
|
||||
return slot1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
slot1 = null;
|
||||
Database.SetJewelrySlot1(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetJewelrySlot1(playerId, value.Id);
|
||||
slot1 = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Slot2
|
||||
{
|
||||
get
|
||||
{
|
||||
return slot2;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
slot2 = null;
|
||||
Database.SetJewelrySlot2(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetJewelrySlot2(playerId, value.Id);
|
||||
slot2 = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Slot3
|
||||
{
|
||||
get
|
||||
{
|
||||
return slot3;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
slot3 = null;
|
||||
Database.SetJewelrySlot3(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetJewelrySlot3(playerId, value.Id);
|
||||
slot3 = value;
|
||||
}
|
||||
}
|
||||
public Item.ItemInformation Slot4
|
||||
{
|
||||
get
|
||||
{
|
||||
return slot4;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
slot4 = null;
|
||||
Database.SetJewelrySlot4(playerId, 0);
|
||||
return;
|
||||
}
|
||||
Database.SetJewelrySlot4(playerId, value.Id);
|
||||
slot4 = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Item.ItemInformation slot1;
|
||||
private Item.ItemInformation slot2;
|
||||
private Item.ItemInformation slot3;
|
||||
private Item.ItemInformation slot4;
|
||||
|
||||
}
|
||||
}
|
65
Horse Isle Server/HorseIsleServer/Player/Friends.cs
Normal file
65
Horse Isle Server/HorseIsleServer/Player/Friends.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
using System.Collections.Generic;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class Friends
|
||||
{
|
||||
private User baseUser;
|
||||
public List<int> List;
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return List.Count;
|
||||
}
|
||||
}
|
||||
|
||||
public Friends(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
List = new List<int>();
|
||||
|
||||
int[] friends = Database.GetBuddyList(user.Id);
|
||||
foreach(int friendId in friends)
|
||||
{
|
||||
List.Add(friendId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void RemoveFriend(int userid)
|
||||
{
|
||||
Database.RemoveBuddy(baseUser.Id, userid);
|
||||
|
||||
// Remove buddy from there list if they are logged in
|
||||
try
|
||||
{
|
||||
|
||||
User removeFrom = GameServer.GetUserById(userid);
|
||||
removeFrom.Friends.List.Remove(baseUser.Id);
|
||||
}
|
||||
catch (KeyNotFoundException) { /* User is ofline, remove from database is sufficent */ };
|
||||
|
||||
|
||||
baseUser.Friends.List.Remove(userid);
|
||||
}
|
||||
public void AddFriend(User userToFriend)
|
||||
{
|
||||
bool pendingRequest = Database.IsPendingBuddyRequestExist(baseUser.Id, userToFriend.Id);
|
||||
if (pendingRequest)
|
||||
{
|
||||
Database.AcceptBuddyRequest(baseUser.Id, userToFriend.Id);
|
||||
|
||||
List.Add(userToFriend.Id);
|
||||
userToFriend.Friends.List.Add(baseUser.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
Database.AddPendingBuddyRequest(baseUser.Id, userToFriend.Id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
106
Horse Isle Server/HorseIsleServer/Player/Highscore.cs
Normal file
106
Horse Isle Server/HorseIsleServer/Player/Highscore.cs
Normal file
|
@ -0,0 +1,106 @@
|
|||
using HISP.Server;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class Highscore
|
||||
{
|
||||
public class HighscoreTableEntry
|
||||
{
|
||||
public int UserId;
|
||||
public string GameName;
|
||||
public int Wins;
|
||||
public int Looses;
|
||||
public int TimesPlayed;
|
||||
public int Score;
|
||||
public string Type;
|
||||
}
|
||||
public HighscoreTableEntry[] HighscoreList
|
||||
{
|
||||
get
|
||||
{
|
||||
return highScoreList.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private User baseUser;
|
||||
private List<HighscoreTableEntry> highScoreList = new List<HighscoreTableEntry>();
|
||||
|
||||
public Highscore(User user)
|
||||
{
|
||||
baseUser = user;
|
||||
HighscoreTableEntry[] highscores = Database.GetPlayerHighScores(user.Id);
|
||||
foreach (HighscoreTableEntry highscore in highscores)
|
||||
highScoreList.Add(highscore);
|
||||
}
|
||||
public HighscoreTableEntry GetHighscore(string gameTitle)
|
||||
{
|
||||
foreach (HighscoreTableEntry highscore in HighscoreList)
|
||||
{
|
||||
if (highscore.GameName == gameTitle)
|
||||
{
|
||||
return highscore;
|
||||
}
|
||||
}
|
||||
throw new KeyNotFoundException("Highscore for " + gameTitle + " Not found.");
|
||||
}
|
||||
public bool HasHighscore(string gameTitle)
|
||||
{
|
||||
foreach(HighscoreTableEntry highscore in HighscoreList)
|
||||
{
|
||||
if(highscore.GameName == gameTitle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool UpdateHighscore(string gameTitle, int score, bool time)
|
||||
{
|
||||
bool isNewScore = true;
|
||||
|
||||
if (!HasHighscore(gameTitle))
|
||||
{
|
||||
string type = time ? "TIME" : "SCORE";
|
||||
Database.AddNewHighscore(baseUser.Id, gameTitle, score, type);
|
||||
|
||||
HighscoreTableEntry newHighscore = new HighscoreTableEntry();
|
||||
newHighscore.UserId = baseUser.Id;
|
||||
newHighscore.GameName = gameTitle;
|
||||
newHighscore.Wins = 0;
|
||||
newHighscore.Looses = 0;
|
||||
newHighscore.TimesPlayed = 1;
|
||||
newHighscore.Score = score;
|
||||
newHighscore.Type = type;
|
||||
highScoreList.Add(newHighscore);
|
||||
|
||||
return isNewScore;
|
||||
}
|
||||
else
|
||||
{
|
||||
int currentScore = GetHighscore(gameTitle).Score;
|
||||
if (score < currentScore)
|
||||
{
|
||||
score = currentScore;
|
||||
isNewScore = false;
|
||||
}
|
||||
|
||||
Database.UpdateHighscore(baseUser.Id, gameTitle, score);
|
||||
|
||||
for(int i = 0; i < highScoreList.Count; i++)
|
||||
{
|
||||
|
||||
if(highScoreList[i].GameName == gameTitle)
|
||||
{
|
||||
highScoreList[i].TimesPlayed += 1;
|
||||
highScoreList[i].Score = score;
|
||||
}
|
||||
}
|
||||
|
||||
return isNewScore;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
16
Horse Isle Server/HorseIsleServer/Player/Mailbox.cs
Normal file
16
Horse Isle Server/HorseIsleServer/Player/Mailbox.cs
Normal file
|
@ -0,0 +1,16 @@
|
|||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class Mailbox
|
||||
{
|
||||
private User baseUser;
|
||||
public int MailCount;
|
||||
|
||||
public Mailbox(User user)
|
||||
{
|
||||
MailCount = Database.CheckMailcount(user.Id);
|
||||
baseUser = user;
|
||||
}
|
||||
}
|
||||
}
|
53
Horse Isle Server/HorseIsleServer/Player/PlayerQuests.cs
Normal file
53
Horse Isle Server/HorseIsleServer/Player/PlayerQuests.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System.Collections.Generic;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class PlayerQuests
|
||||
{
|
||||
private List<TrackedQuest> trackedQuests = new List<TrackedQuest>();
|
||||
public User BaseUser;
|
||||
public TrackedQuest[] QuestList
|
||||
{
|
||||
get
|
||||
{
|
||||
return trackedQuests.ToArray();
|
||||
}
|
||||
}
|
||||
public void Add(int questId, int timesCompleted)
|
||||
{
|
||||
TrackedQuest quest = new TrackedQuest(BaseUser.Id, questId, 0);
|
||||
quest.TimesCompleted = timesCompleted;
|
||||
trackedQuests.Add(quest);
|
||||
}
|
||||
public int GetTrackedQuestAmount(int questId)
|
||||
{
|
||||
foreach(TrackedQuest quest in QuestList)
|
||||
{
|
||||
if (quest.QuestId == questId)
|
||||
return quest.TimesCompleted;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void TrackQuest(int questId)
|
||||
{
|
||||
foreach (TrackedQuest quest in QuestList)
|
||||
{
|
||||
if (quest.QuestId == questId)
|
||||
{
|
||||
quest.TimesCompleted++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Add(questId, 1);
|
||||
}
|
||||
public PlayerQuests(User user)
|
||||
{
|
||||
BaseUser = user;
|
||||
TrackedQuest[] quests = Database.GetTrackedQuests(user.Id);
|
||||
foreach (TrackedQuest quest in quests)
|
||||
trackedQuests.Add(quest);
|
||||
}
|
||||
}
|
||||
}
|
30
Horse Isle Server/HorseIsleServer/Player/TrackedQuest.cs
Normal file
30
Horse Isle Server/HorseIsleServer/Player/TrackedQuest.cs
Normal file
|
@ -0,0 +1,30 @@
|
|||
using System;
|
||||
using HISP.Server;
|
||||
namespace HISP
|
||||
{
|
||||
class TrackedQuest
|
||||
{
|
||||
public TrackedQuest(int playerID, int questID, int timesComplete)
|
||||
{
|
||||
playerId = playerID;
|
||||
QuestId = questID;
|
||||
timesCompleted = timesComplete;
|
||||
}
|
||||
public int QuestId;
|
||||
private int playerId;
|
||||
public int TimesCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
return timesCompleted;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetTrackedQuestCompletedCount(playerId, QuestId, value);
|
||||
timesCompleted = value;
|
||||
}
|
||||
}
|
||||
private int timesCompleted;
|
||||
|
||||
}
|
||||
}
|
455
Horse Isle Server/HorseIsleServer/Player/User.cs
Normal file
455
Horse Isle Server/HorseIsleServer/Player/User.cs
Normal file
|
@ -0,0 +1,455 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HISP.Game;
|
||||
using HISP.Server;
|
||||
using HISP.Player.Equips;
|
||||
using HISP.Game.Services;
|
||||
using HISP.Game.Inventory;
|
||||
using HISP.Game.Horse;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
class User
|
||||
{
|
||||
|
||||
public int Id;
|
||||
public string Username;
|
||||
public bool Administrator;
|
||||
public bool Moderator;
|
||||
public bool NewPlayer = false;
|
||||
public GameClient LoggedinClient;
|
||||
public CompetitionGear EquipedCompetitionGear;
|
||||
public Jewelry EquipedJewelry;
|
||||
public bool MuteAds = false;
|
||||
public bool MuteGlobal = false;
|
||||
public bool MuteIsland = false;
|
||||
public bool MuteNear = false;
|
||||
public bool MuteHere = false;
|
||||
public bool MuteBuddy = false;
|
||||
public bool MutePrivateMessage = false;
|
||||
public bool MuteBuddyRequests = false;
|
||||
public bool MuteSocials = false;
|
||||
public bool MuteAll = false;
|
||||
public bool MuteLogins = false;
|
||||
public bool NoClip = false;
|
||||
public string Gender;
|
||||
public bool MetaPriority = false;
|
||||
|
||||
public bool Idle;
|
||||
public int Facing;
|
||||
public Mailbox MailBox;
|
||||
public Friends Friends;
|
||||
public string Password; // For chat filter.
|
||||
public PlayerInventory Inventory;
|
||||
public Npc.NpcEntry LastTalkedToNpc;
|
||||
public Shop LastShoppedAt;
|
||||
public Inn LastVisitedInn;
|
||||
public HorseInventory HorseInventory;
|
||||
public HorseInstance LastViewedHorse;
|
||||
public HorseInstance CurrentlyRidingHorse;
|
||||
public Tracking TrackedItems;
|
||||
public PlayerQuests Quests;
|
||||
public Highscore Highscores;
|
||||
public Award Awards;
|
||||
public int CapturingHorseId;
|
||||
public DateTime LoginTime;
|
||||
|
||||
public DateTime SubscribedUntil
|
||||
{
|
||||
get
|
||||
{
|
||||
return Converters.UnixTimeStampToDateTime(subscribedUntil);
|
||||
}
|
||||
}
|
||||
public int FreeMinutes
|
||||
{
|
||||
get
|
||||
{
|
||||
int freeTime = Database.GetFreeTime(Id);
|
||||
return freeTime;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetFreeTime(Id, value);
|
||||
}
|
||||
}
|
||||
public bool Subscribed
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ConfigReader.AllUsersSubbed)
|
||||
return true;
|
||||
|
||||
int Timestamp = Convert.ToInt32(new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds());
|
||||
if(Timestamp > subscribedUntil && subscribed) // sub expired.
|
||||
{
|
||||
Logger.InfoPrint(Username + "'s Subscription expired. (timestamp now: " + Timestamp + " exp date: " + subscribedUntil+" )");
|
||||
Database.SetUserSubscriptionStatus(this.Id, false);
|
||||
subscribed = false;
|
||||
}
|
||||
|
||||
return subscribed;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetUserSubscriptionStatus(this.Id, value);
|
||||
}
|
||||
}
|
||||
public bool Stealth
|
||||
{
|
||||
get
|
||||
{
|
||||
return stealth;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
Database.RemoveOnlineUser(this.Id);
|
||||
else
|
||||
Database.AddOnlineUser(this.Id, this.Administrator, this.Moderator, this.Subscribed);
|
||||
|
||||
stealth = value;
|
||||
}
|
||||
}
|
||||
public int ChatViolations
|
||||
{
|
||||
get
|
||||
{
|
||||
return chatViolations;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetChatViolations(value,Id);
|
||||
chatViolations = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string PrivateNotes
|
||||
{
|
||||
get
|
||||
{
|
||||
return privateNotes;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
Database.SetPlayerNotes(Id, value);
|
||||
privateNotes = value;
|
||||
}
|
||||
}
|
||||
public string ProfilePage {
|
||||
get
|
||||
{
|
||||
return profilePage;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
||||
Database.SetPlayerProfile(value, Id);
|
||||
profilePage = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Money
|
||||
{
|
||||
get
|
||||
{
|
||||
return money;
|
||||
}
|
||||
set
|
||||
{
|
||||
money = value;
|
||||
Database.SetPlayerMoney(value, Id);
|
||||
GameServer.UpdatePlayer(LoggedinClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Experience
|
||||
{
|
||||
get
|
||||
{
|
||||
return experience;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetExperience(Id, value);
|
||||
experience = value;
|
||||
}
|
||||
}
|
||||
public int QuestPoints
|
||||
{
|
||||
get
|
||||
{
|
||||
return questPoints;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPlayerQuestPoints(value, Id);
|
||||
questPoints = value;
|
||||
}
|
||||
}
|
||||
|
||||
public double BankInterest
|
||||
{
|
||||
get
|
||||
{
|
||||
return Database.GetPlayerBankInterest(Id);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 9999999999.9999)
|
||||
value = 9999999999.9999;
|
||||
|
||||
Database.SetPlayerBankInterest(value, Id);
|
||||
}
|
||||
}
|
||||
public double BankMoney
|
||||
{
|
||||
get
|
||||
{
|
||||
return bankMoney;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value > 9999999999.9999)
|
||||
value = 9999999999.9999;
|
||||
|
||||
Database.SetPlayerBankMoney(value, Id);
|
||||
bankMoney = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int X
|
||||
{
|
||||
get
|
||||
{
|
||||
return x;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPlayerX(value, Id);
|
||||
x = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return y;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPlayerY(value, Id);
|
||||
y = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int CharacterId
|
||||
{
|
||||
get
|
||||
{
|
||||
return charId;
|
||||
}
|
||||
set
|
||||
{
|
||||
Database.SetPlayerCharId(value, Id);
|
||||
charId = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Hunger
|
||||
{
|
||||
get
|
||||
{
|
||||
return hunger;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value >= 1000)
|
||||
value = 1000;
|
||||
if (value <= 0)
|
||||
value = 0;
|
||||
Database.SetPlayerHunger(Id, value);
|
||||
hunger = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Thirst
|
||||
{
|
||||
get
|
||||
{
|
||||
return thirst;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value >= 1000)
|
||||
value = 1000;
|
||||
if (value <= 0)
|
||||
value = 0;
|
||||
Database.SetPlayerThirst(Id, value);
|
||||
thirst = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Tiredness
|
||||
{
|
||||
get
|
||||
{
|
||||
return tired;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value >= 1000)
|
||||
value = 1000;
|
||||
if (value <= 0)
|
||||
value = 0;
|
||||
Database.SetPlayerTiredness(Id, value);
|
||||
tired = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private int chatViolations;
|
||||
private int charId;
|
||||
private int subscribedUntil;
|
||||
private bool subscribed;
|
||||
private string profilePage;
|
||||
private string privateNotes;
|
||||
private int x;
|
||||
private bool stealth = false;
|
||||
private int y;
|
||||
private int money;
|
||||
private int questPoints;
|
||||
private double bankMoney;
|
||||
private int experience;
|
||||
private int hunger;
|
||||
private int thirst;
|
||||
private int tired;
|
||||
|
||||
|
||||
public byte[] SecCodeSeeds = new byte[3];
|
||||
public int SecCodeInc = 0;
|
||||
public int SecCodeCount = 0;
|
||||
|
||||
|
||||
public int GetPlayerListIcon()
|
||||
{
|
||||
int icon = -1;
|
||||
if (NewPlayer)
|
||||
icon = Messages.NewUserIcon;
|
||||
if (Subscribed)
|
||||
{
|
||||
int months = (DateTime.UtcNow.Month - SubscribedUntil.Month) + 12 * (DateTime.UtcNow.Year - SubscribedUntil.Year);
|
||||
if (months <= 1)
|
||||
icon = Messages.MonthSubscriptionIcon;
|
||||
else if (months <= 3)
|
||||
icon = Messages.ThreeMonthSubscripitionIcon;
|
||||
else
|
||||
icon = Messages.YearSubscriptionIcon;
|
||||
}
|
||||
if (Moderator)
|
||||
icon = Messages.ModeratorIcon;
|
||||
if (Administrator)
|
||||
icon = Messages.AdminIcon;
|
||||
|
||||
return icon;
|
||||
}
|
||||
public void Teleport(int newX, int newY)
|
||||
{
|
||||
Logger.DebugPrint("Teleporting: " + Username + " to: " + newX.ToString() + "," + newY.ToString());
|
||||
|
||||
X = newX;
|
||||
Y = newY;
|
||||
|
||||
byte[] MovementPacket = PacketBuilder.CreateMovementPacket(X, Y, CharacterId, Facing, PacketBuilder.DIRECTION_TELEPORT, true);
|
||||
LoggedinClient.SendPacket(MovementPacket);
|
||||
GameServer.Update(LoggedinClient);
|
||||
}
|
||||
|
||||
public byte[] GenerateSecCode()
|
||||
{
|
||||
var i = 0;
|
||||
SecCodeCount++;
|
||||
SecCodeSeeds[SecCodeCount % 3] = (byte)(SecCodeSeeds[SecCodeCount % 3] + SecCodeInc);
|
||||
SecCodeSeeds[SecCodeCount % 3] = (byte)(SecCodeSeeds[SecCodeCount % 3] % 92);
|
||||
i = SecCodeSeeds[0] + SecCodeSeeds[1] * SecCodeSeeds[2] - SecCodeSeeds[1];
|
||||
i = Math.Abs(i);
|
||||
i = i % 92;
|
||||
|
||||
byte[] SecCode = new byte[4];
|
||||
SecCode[0] = (byte)(SecCodeSeeds[0] + 33);
|
||||
SecCode[1] = (byte)(SecCodeSeeds[1] + 33);
|
||||
SecCode[2] = (byte)(SecCodeSeeds[2] + 33);
|
||||
SecCode[3] = (byte)(i + 33);
|
||||
Logger.DebugPrint("Expecting "+Username+" To send Sec Code: "+BitConverter.ToString(SecCode).Replace("-", " "));
|
||||
return SecCode;
|
||||
}
|
||||
|
||||
|
||||
public User(GameClient baseClient, int UserId)
|
||||
{
|
||||
if (!Database.CheckUserExist(UserId))
|
||||
throw new KeyNotFoundException("User " + UserId + " not found in database!");
|
||||
|
||||
if (!Database.CheckUserExtExists(UserId))
|
||||
{
|
||||
Database.CreateUserExt(UserId);
|
||||
NewPlayer = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
EquipedCompetitionGear = new CompetitionGear(UserId);
|
||||
EquipedJewelry = new Jewelry(UserId);
|
||||
|
||||
Id = UserId;
|
||||
Username = Database.GetUsername(UserId);
|
||||
|
||||
Administrator = Database.CheckUserIsAdmin(Username);
|
||||
Moderator = Database.CheckUserIsModerator(Username);
|
||||
|
||||
chatViolations = Database.GetChatViolations(UserId);
|
||||
x = Database.GetPlayerX(UserId);
|
||||
y = Database.GetPlayerY(UserId);
|
||||
charId = Database.GetPlayerCharId(UserId);
|
||||
|
||||
Facing = PacketBuilder.DIRECTION_DOWN;
|
||||
experience = Database.GetExperience(UserId);
|
||||
money = Database.GetPlayerMoney(UserId);
|
||||
bankMoney = Database.GetPlayerBankMoney(UserId);
|
||||
questPoints = Database.GetPlayerQuestPoints(UserId);
|
||||
subscribed = Database.IsUserSubscribed(UserId);
|
||||
subscribedUntil = Database.GetUserSubscriptionExpireDate(UserId);
|
||||
profilePage = Database.GetPlayerProfile(UserId);
|
||||
privateNotes = Database.GetPlayerNotes(UserId);
|
||||
hunger = Database.GetPlayerHunger(UserId);
|
||||
thirst = Database.GetPlayerThirst(UserId);
|
||||
tired = Database.GetPlayerTiredness(UserId);
|
||||
|
||||
Gender = Database.GetGender(UserId);
|
||||
MailBox = new Mailbox(this);
|
||||
Highscores = new Highscore(this);
|
||||
Awards = new Award(this);
|
||||
TrackedItems = new Tracking(this);
|
||||
HorseInventory = new HorseInventory(this);
|
||||
|
||||
// Generate SecCodes
|
||||
|
||||
|
||||
SecCodeSeeds[0] = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
|
||||
SecCodeSeeds[1] = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
|
||||
SecCodeSeeds[2] = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
|
||||
SecCodeInc = (byte)GameServer.RandomNumberGenerator.Next(40, 60);
|
||||
|
||||
|
||||
Friends = new Friends(this);
|
||||
LoginTime = DateTime.UtcNow;
|
||||
LoggedinClient = baseClient;
|
||||
Inventory = new PlayerInventory(this);
|
||||
Quests = new PlayerQuests(this);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue