I created the difference:
In Progress <>
Finished <>
![]()
I created the difference:
In Progress <>
Finished <>
![]()
It nice to see you use Linq code.
Achievement Progress:
Yes it not super else.Code:public void GetResponse(OutMessage Message, Character Character) { var Achievements = StorageHandler.GetCharacterAchievements(Character.Id); var Details = StorageHandler.GetAchievementDetailsSorted(Id); var QueryA = (from item in Achievements where item.AchievementId == Id select item); var MaxLevel = Details.Count() > 0 ? Details.Count() : 1; var MyProgress = QueryA.Count() > 0 ? QueryA.First() : new CharacterAchievement(-1, Character.Id, Id, 0); var CurrentLevel = MyProgress.CurrentLevel; var NextLevel = (CurrentLevel + 1); if (NextLevel > MaxLevel) { NextLevel= MaxLevel; } if (CurrentLevel >= MaxLevel) { CurrentLevel = MaxLevel; } var QueryB = (from item in Details where item.Level == NextLevel select item); var NextRequired = QueryB.Count() > 0 ? QueryB.First().RequiredAmmount : 1; Message.Append(Id); Message.Append(NextLevel); Message.Append(GetBadge(NextLevel)); Message.Append(NextRequired); Message.Append(GetPixelReward(NextLevel)); Message.Append(0); // TODO <> BadgeId Message.Append(0); // TODO <> GotAlready Message.Append(CurrentLevel == MaxLevel); Message.Append(AchievementHandler.GetCategory(ParentId).Caption.ToLower()); Message.Append(MaxLevel); }
Debug result: (Dictionary progressing <int,string> of 100 items)
Code:00:00:00.0200000 Linq 00:00:00 Loop
Im liking acheivements Squard. GOOD JOB!
Sent from my mobile via Tapatalk.
Removed Linq lines. Replaced them with Loops.
Its Faster I tested it.
Special achievement-score calculator.
Spares MySQL
Code:public int GetAchievementScore() { var Result = 0; foreach (var AchievementProgress in StorageHandler.GetCharacterAchievements(Id)) { var Achievement = AchievementHandler.GetAchievement(AchievementProgress.Id); Result += (AchievementProgress.CurrentLevel * Achievement.ScorePerLevel); } return Result; }
So i guess it's better to use loops i guess.
Anyhow why not try out Lua style.
Why do you use the variable name 'var' for everything?
Short-cut and cannot be null. ;D
Stabilized Achievements and added:
Code:class BadgePointLimitsComposer : IMessageComposer { public OutMessage Invoke(params object[] Parameters) { var Message = new OutMessage(627); Message.Append(AchievementHandler.Achievements.Count); foreach (var Achievement in AchievementHandler.Achievements.Values) { var Items = StorageHandler.GetAchievementDetailsSorted(Achievement.Id); Message.Append(Achievement.Badge); Message.Append(Items.Count()); foreach (var Item in (from item in Items orderby item.Level ascending select item)) { Message.Append(Item.Level); Message.Append(Item.RequiredAmmount); } } return Message; } }
Yeah it can't be null when your coding it or the compiler complains, but it doesn't somewhere in the code which returns something can't set it to null.
All the compiler does with "var" is when its compiled it turns that "var" into whichever class its defined with. aka var becomes Socket etc.
So really it is just a short-cut, most coders are against it, usually when working in teams because scanning through code can be a pain when all you see is "var" everyone and not knowing what var is.
Avoid using byte[] arrays where possible too, now I know that isn't possible in the Socket code but there is a way around it using the SocketAsyncEventArgs which you need to look into it and learn.
Using byte[] causes heap fragmentation which can cause out of memory errors, .NET has a buffer pool for use (http://msdn.microsoft.com/en-us/libr...ermanager.aspx) but you can code your own
:l who cares if you need to pay? None but you obviously gtfo if you can't talk about the dev itself btw nice dev!
Posted via Mobile Device
:l who cares if you need to pay? None but you obviously gtfo if you can't talk about the dev itself btw nice dev!
Posted via Mobile Device
Posted via Mobile Device
Posted via Mobile Device
Dev stopped again?D