예제 #1
0
        static bool DeleteCharAccessories(uint charId)
        {
            try
            {
                SpellRecord.DeleteAll("OwnerId = " + charId);
                AuraRecord.DeleteAll("OwnerId = " + charId);
                ItemRecord.DeleteAll("OwnerId = " + charId);
                SkillRecord.DeleteAll("OwnerId = " + charId);
                SpecProfile.DeleteAll("CharacterId = " + charId);
                ReputationRecord.DeleteAll("OwnerId = " + charId);
                QuestRecord.DeleteAll("OwnerId = " + charId);
                SummonedPetRecord.DeleteAll("OwnerLowId = " + charId);
                PermanentPetRecord.DeleteAll("OwnerLowId = " + charId);

                MailMgr.ReturnValueMailFor(charId);
                MailMessage.DeleteAll("ReceiverId = " + charId);

                RelationMgr.Instance.RemoveRelations(charId);
                InstanceMgr.RemoveLog(charId);
                GroupMgr.Instance.RemoveOfflineCharacter(charId);
                AchievementRecord.DeleteAll("CharacterId = " + charId);
                AchievementProgressRecord.DeleteAll("CharacterId = " + charId);

                return(true);
            }
            catch (Exception ex)
            {
                LogUtil.ErrorException(ex, "Failed to delete character with Id: " + charId);

                return(false);
            }
        }
예제 #2
0
    public PlayerData()
    {
        DO = 0;
        finishedLevelCount = 0;

        int levelCount = 30;
        int itemCount  = 5;
        int AcCount    = 20;

        levelStar       = new int[levelCount];
        itemNum         = new int[itemCount];
        achievementList = new AchievementRecord[AcCount];
        //levelStar = new List<int>();
        for (int i = 0; i < levelCount; i++)
        {
            levelStar[i] = 0;
        }


        //itemNum = new List<int>();
        for (int k = 0; k < itemCount; k++)
        {
            itemNum[k] = 0;
        }


        //achievementList = new List<AchievementRecord>();
        for (int j = 0; j < AcCount; j++)
        {
            achievementList[j] = new AchievementRecord();
        }
    }
예제 #3
0
        //填充一个成就数据到数据源
        private void FillAccomplishment(AchievementRecord table, AchievementItemDataModel achievement)
        {
            achievement.Id    = table.Id;
            achievement.Title = table.Name;
            if (-1 != table.Exdata)
            {
                var _progress = Mathf.Min(PlayerDataManager.Instance.GetAccomplishmentProgress(achievement.Id), table.ExdataCount);
                achievement.Progress      = _progress * 1.0f / table.ExdataCount;
                achievement.ProgressLabel = string.Format("{0}/{1}", GameUtils.GetBigValueStr(_progress),
                                                          GameUtils.GetBigValueStr(table.ExdataCount));

                if (GameUtils.GetBigValueStr(table.ExdataCount) == "1")
                {
                    achievement.ShowPorgress = false;
                }
                else
                {
                    achievement.ShowPorgress = true;
                }
            }
            else
            {
                achievement.ShowPorgress = false;
            }

            var _state = PlayerDataManager.Instance.GetAccomplishmentStatus(achievement.Id);

            achievement.State = (int)_state;

            /*
             *  if (eRewardState.HasGot == state)
             *  {
             *          achievement.State = GameUtils.GetDictionaryText(1035);
             *          achievement.CanGetReward = false;
             *  }
             *  else if (eRewardState.CanGet == state)
             *  {
             *          achievement.State = GameUtils.GetDictionaryText(1036);
             *          achievement.CanGetReward = true;
             *  }
             *  else if (eRewardState.CannotGet == state)
             *  {
             *          achievement.State = GameUtils.GetDictionaryText(1037);
             *          achievement.CanGetReward = false;
             *  }
             */
            var _tableItemIdLength0 = table.ItemId.Length;

            for (var i = 0; i < _tableItemIdLength0; i++)
            {
                var _itemId = table.ItemId[i];
                achievement.Rewards[i].ItemId = _itemId;
                achievement.Rewards[i].Count  = table.ItemCount[i];
            }
        }
예제 #4
0
        static bool Add(CommandHandler handler, AchievementRecord achievementEntry)
        {
            Player target = handler.GetSelectedPlayer();

            if (!target)
            {
                handler.SendSysMessage(CypherStrings.NoCharSelected);
                return(false);
            }

            target.CompletedAchievement(achievementEntry);

            return(true);
        }
 GameAchievement BuildLifetimeStatAchievement(AchievementRecord x)
 {
     return(new LifetimeStatAchievement(
                new LifetimeStatAchievementSetting
     {
         Id = x.Id,
         Name = x.Name,
         Description = x.Description,
         LifetimeStatName = x.LifetimeStatName,
         MinCount = x.Threshold,
         RewardIds = GetRewardIds(x).ToList()
     },
                gameState
                ));
 }
 GameAchievement BuildInventoryAchievement(AchievementRecord x)
 {
     return(new InventoryAchievement(
                new InventoryAchievementSetting
     {
         Id = x.Id,
         Name = x.Name,
         Description = x.Description,
         InventoryItemName = x.InventoryItemName,
         MinAmount = x.Threshold,
         RewardIds = GetRewardIds(x).ToList()
     },
                gameState
                ));
 }
    //填充一个成就数据到数据源
    public void AssignAchievement(AchievementRecord table, AchievementItemDataModel achievement)
    {
        achievement.Id    = table.Id;
        achievement.Title = table.Name;
        if (-1 != table.Exdata)
        {
            var progress = Mathf.Min(GetAchievementProgress(achievement.Id), table.ExdataCount);
            achievement.Progress      = progress * 1.0f / table.ExdataCount;
            achievement.ProgressLabel = string.Format("{0}/{1}", GameUtils.GetBigValueStr(progress),
                                                      GameUtils.GetBigValueStr(table.ExdataCount));
            achievement.ShowPorgress = true;
        }
        else
        {
            achievement.ShowPorgress = false;
        }

        var state = GetAchievementState(achievement.Id);

        achievement.State = (int)state;

        /*
         *      if (eRewardState.HasGot == state)
         *      {
         *              achievement.State = GameUtils.GetDictionaryText(1035);
         *              achievement.CanGetReward = false;
         *      }
         *      else if (eRewardState.CanGet == state)
         *      {
         *              achievement.State = GameUtils.GetDictionaryText(1036);
         *              achievement.CanGetReward = true;
         *      }
         *      else if (eRewardState.CannotGet == state)
         *      {
         *              achievement.State = GameUtils.GetDictionaryText(1037);
         *              achievement.CanGetReward = false;
         *      }
         */
        var tableItemIdLength0 = table.ItemId.Length;

        for (var i = 0; i < tableItemIdLength0; i++)
        {
            var itemId = table.ItemId[i];
            achievement.Rewards[i].ItemId = itemId;
            achievement.Rewards[i].Count  = table.ItemCount[i];
        }
    }
        IEnumerable <int> GetRewardIds(AchievementRecord x)
        {
            if (x.RewardId1.HasValue)
            {
                yield return(x.RewardId1.Value);
            }

            if (x.RewardId2.HasValue)
            {
                yield return(x.RewardId2.Value);
            }

            if (x.RewardId3.HasValue)
            {
                yield return(x.RewardId3.Value);
            }
        }
예제 #9
0
        //构造所有成就被什么所影响的列表(当某个条件被触发时,可以快速知道哪个成就有更新了)
        private void InitOneAchievement(AchievementRecord tbAchievement)
        {
            List <int> tempList;
            var        nExdataId = tbAchievement.Exdata;

            if (nExdataId != -1)
            {
//计数型
                if (AchievementManager.ExdataAchievement.TryGetValue(nExdataId, out tempList))
                {
                    tempList.Add(tbAchievement.Id);
                }
                else
                {
                    tempList = new List <int> {
                        tbAchievement.Id
                    };
                    AchievementManager.ExdataAchievement[nExdataId] = tempList;
                }
            }
            else
            {
                foreach (var i in tbAchievement.FlagList)
                {
                    if (i < 0)
                    {
                        continue;
                    }
                    if (AchievementManager.FlagAchievement.TryGetValue(i, out tempList))
                    {
                        tempList.Add(tbAchievement.Id);
                    }
                    else
                    {
                        tempList = new List <int> {
                            tbAchievement.Id
                        };
                        AchievementManager.FlagAchievement[i] = tempList;
                    }
                }
            }
        }
예제 #10
0
        public static Achievement FromTableRecord(AchievementRecord achievementRecord)
        {
            DateTimeOffset?updatedAt = null;

            if (achievementRecord.UpdatedAt != null)
            {
                updatedAt = DateTimeOffset.FromUnixTimeMilliseconds(achievementRecord.UpdatedAt.Value);
            }

            return(new Achievement
            {
                Id = new Guid(achievementRecord.Id),
                UserId = new Guid(achievementRecord.UserId),
                MaturityLevelId = new Guid(achievementRecord.MaturityLevelId),
                AchievementDate = DateTimeOffset.FromUnixTimeMilliseconds(achievementRecord.AchievementDate),
                Comment = achievementRecord.Comment,
                CreatedAt = DateTimeOffset.FromUnixTimeMilliseconds(achievementRecord.CreatedAt),
                UpdatedAt = updatedAt
            });
        }
예제 #11
0
        public bool Meets(ConditionSourceInfo sourceInfo)
        {
            Cypher.Assert(ConditionTarget < SharedConst.MaxConditionTargets);
            WorldObject obj = sourceInfo.mConditionTargets[ConditionTarget];

            // object not present, return false
            if (obj == null)
            {
                Log.outDebug(LogFilter.Condition, "Condition object not found for condition (Entry: {0} Type: {1} Group: {2})", SourceEntry, SourceType, SourceGroup);
                return(false);
            }
            bool condMeets = false;

            Player player = obj.ToPlayer();
            Unit   unit   = obj.ToUnit();

            switch (ConditionType)
            {
            case ConditionTypes.None:
                condMeets = true;                                        // empty condition, always met
                break;

            case ConditionTypes.Aura:
                if (unit != null)
                {
                    condMeets = unit.HasAuraEffect(ConditionValue1, (byte)ConditionValue2);
                }
                break;

            case ConditionTypes.Item:
                if (player != null)
                {
                    // don't allow 0 items (it's checked during table load)
                    Cypher.Assert(ConditionValue2 != 0);
                    bool checkBank = ConditionValue3 != 0 ? true : false;
                    condMeets = player.HasItemCount(ConditionValue1, ConditionValue2, checkBank);
                }
                break;

            case ConditionTypes.ItemEquipped:
                if (player != null)
                {
                    condMeets = player.HasItemOrGemWithIdEquipped(ConditionValue1, 1);
                }
                break;

            case ConditionTypes.Zoneid:
                condMeets = obj.GetZoneId() == ConditionValue1;
                break;

            case ConditionTypes.ReputationRank:
                if (player != null)
                {
                    var faction = CliDB.FactionStorage.LookupByKey(ConditionValue1);
                    if (faction != null)
                    {
                        condMeets = Convert.ToBoolean(ConditionValue2 & (1 << (int)player.GetReputationMgr().GetRank(faction)));
                    }
                }
                break;

            case ConditionTypes.Achievement:
                if (player != null)
                {
                    condMeets = player.HasAchieved(ConditionValue1);
                }
                break;

            case ConditionTypes.Team:
                if (player != null)
                {
                    condMeets = (uint)player.GetTeam() == ConditionValue1;
                }
                break;

            case ConditionTypes.Class:
                if (unit != null)
                {
                    condMeets = Convert.ToBoolean(unit.GetClassMask() & ConditionValue1);
                }
                break;

            case ConditionTypes.Race:
                if (unit != null)
                {
                    condMeets = Convert.ToBoolean(SharedConst.GetMaskForRace(unit.GetRace()) & ConditionValue1);
                }
                break;

            case ConditionTypes.Gender:
                if (player != null)
                {
                    condMeets = player.GetGender() == (Gender)ConditionValue1;
                }
                break;

            case ConditionTypes.Skill:
                if (player != null)
                {
                    condMeets = player.HasSkill((SkillType)ConditionValue1) && player.GetBaseSkillValue((SkillType)ConditionValue1) >= ConditionValue2;
                }
                break;

            case ConditionTypes.QuestRewarded:
                if (player != null)
                {
                    condMeets = player.GetQuestRewardStatus(ConditionValue1);
                }
                break;

            case ConditionTypes.QuestTaken:
                if (player != null)
                {
                    QuestStatus status = player.GetQuestStatus(ConditionValue1);
                    condMeets = (status == QuestStatus.Incomplete);
                }
                break;

            case ConditionTypes.QuestComplete:
                if (player != null)
                {
                    QuestStatus status = player.GetQuestStatus(ConditionValue1);
                    condMeets = (status == QuestStatus.Complete && !player.GetQuestRewardStatus(ConditionValue1));
                }
                break;

            case ConditionTypes.QuestNone:
                if (player != null)
                {
                    QuestStatus status = player.GetQuestStatus(ConditionValue1);
                    condMeets = (status == QuestStatus.None);
                }
                break;

            case ConditionTypes.ActiveEvent:
                condMeets = Global.GameEventMgr.IsActiveEvent((ushort)ConditionValue1);
                break;

            case ConditionTypes.InstanceInfo:
            {
                var map = obj.GetMap();
                if (map.IsDungeon())
                {
                    InstanceScript instance = ((InstanceMap)map).GetInstanceScript();
                    if (instance != null)
                    {
                        switch ((InstanceInfo)ConditionValue3)
                        {
                        case InstanceInfo.Data:
                            condMeets = instance.GetData(ConditionValue1) == ConditionValue2;
                            break;

                        case InstanceInfo.Data64:
                            condMeets = instance.GetData64(ConditionValue1) == ConditionValue2;
                            break;

                        case InstanceInfo.BossState:
                            condMeets = instance.GetBossState(ConditionValue1) == (EncounterState)ConditionValue2;
                            break;
                        }
                    }
                }
                break;
            }

            case ConditionTypes.Mapid:
                condMeets = obj.GetMapId() == ConditionValue1;
                break;

            case ConditionTypes.Areaid:
                condMeets = obj.GetAreaId() == ConditionValue1;
                break;

            case ConditionTypes.Spell:
                if (player != null)
                {
                    condMeets = player.HasSpell(ConditionValue1);
                }
                break;

            case ConditionTypes.Level:
                if (unit != null)
                {
                    condMeets = MathFunctions.CompareValues((ComparisionType)ConditionValue2, unit.GetLevel(), ConditionValue1);
                }
                break;

            case ConditionTypes.DrunkenState:
                if (player != null)
                {
                    condMeets = (uint)Player.GetDrunkenstateByValue(player.GetDrunkValue()) >= ConditionValue1;
                }
                break;

            case ConditionTypes.NearCreature:
                condMeets = obj.FindNearestCreature(ConditionValue1, ConditionValue2, ConditionValue3 == 0 ? true : false) != null;
                break;

            case ConditionTypes.NearGameobject:
                condMeets = obj.FindNearestGameObject(ConditionValue1, ConditionValue2) != null;
                break;

            case ConditionTypes.ObjectEntryGuid:
                if ((uint)obj.GetTypeId() == ConditionValue1)
                {
                    condMeets = ConditionValue2 == 0 || (obj.GetEntry() == ConditionValue2);

                    if (ConditionValue3 != 0)
                    {
                        switch (obj.GetTypeId())
                        {
                        case TypeId.Unit:
                            condMeets &= obj.ToCreature().GetSpawnId() == ConditionValue3;
                            break;

                        case TypeId.GameObject:
                            condMeets &= obj.ToGameObject().GetSpawnId() == ConditionValue3;
                            break;
                        }
                    }
                }
                break;

            case ConditionTypes.TypeMask:
                condMeets = Convert.ToBoolean((TypeMask)ConditionValue1 & obj.ObjectTypeMask);
                break;

            case ConditionTypes.RelationTo:
            {
                WorldObject toObject = sourceInfo.mConditionTargets[ConditionValue1];
                if (toObject != null)
                {
                    Unit toUnit = toObject.ToUnit();
                    if (toUnit != null && unit != null)
                    {
                        switch ((RelationType)ConditionValue2)
                        {
                        case RelationType.Self:
                            condMeets = unit == toUnit;
                            break;

                        case RelationType.InParty:
                            condMeets = unit.IsInPartyWith(toUnit);
                            break;

                        case RelationType.InRaidOrParty:
                            condMeets = unit.IsInRaidWith(toUnit);
                            break;

                        case RelationType.OwnedBy:
                            condMeets = unit.GetOwnerGUID() == toUnit.GetGUID();
                            break;

                        case RelationType.PassengerOf:
                            condMeets = unit.IsOnVehicle(toUnit);
                            break;

                        case RelationType.CreatedBy:
                            condMeets = unit.GetCreatorGUID() == toUnit.GetGUID();
                            break;
                        }
                    }
                }
                break;
            }

            case ConditionTypes.ReactionTo:
            {
                WorldObject toObject = sourceInfo.mConditionTargets[ConditionValue1];
                if (toObject != null)
                {
                    Unit toUnit = toObject.ToUnit();
                    if (toUnit != null && unit != null)
                    {
                        condMeets = Convert.ToBoolean((1 << (int)unit.GetReactionTo(toUnit)) & ConditionValue2);
                    }
                }
                break;
            }

            case ConditionTypes.DistanceTo:
            {
                WorldObject toObject = sourceInfo.mConditionTargets[ConditionValue1];
                if (toObject != null)
                {
                    condMeets = MathFunctions.CompareValues((ComparisionType)ConditionValue3, obj.GetDistance(toObject), ConditionValue2);
                }
                break;
            }

            case ConditionTypes.Alive:
                if (unit != null)
                {
                    condMeets = unit.IsAlive();
                }
                break;

            case ConditionTypes.HpVal:
                if (unit != null)
                {
                    condMeets = MathFunctions.CompareValues((ComparisionType)ConditionValue2, unit.GetHealth(), ConditionValue1);
                }
                break;

            case ConditionTypes.HpPct:
                if (unit != null)
                {
                    condMeets = MathFunctions.CompareValues((ComparisionType)ConditionValue2, unit.GetHealthPct(), ConditionValue1);
                }
                break;

            case ConditionTypes.WorldState:
                condMeets = (ConditionValue2 == Global.WorldMgr.GetWorldState((WorldStates)ConditionValue1));
                break;

            case ConditionTypes.PhaseId:
                condMeets = obj.GetPhaseShift().HasPhase(ConditionValue1);
                break;

            case ConditionTypes.Title:
                if (player != null)
                {
                    condMeets = player.HasTitle(ConditionValue1);
                }
                break;

            case ConditionTypes.UnitState:
                if (unit != null)
                {
                    condMeets = unit.HasUnitState((UnitState)ConditionValue1);
                }
                break;

            case ConditionTypes.CreatureType:
            {
                Creature creature = obj.ToCreature();
                if (creature)
                {
                    condMeets = (uint)creature.GetCreatureTemplate().CreatureType == ConditionValue1;
                }
                break;
            }

            case ConditionTypes.RealmAchievement:
            {
                AchievementRecord achievement = CliDB.AchievementStorage.LookupByKey(ConditionValue1);
                if (achievement != null && Global.AchievementMgr.IsRealmCompleted(achievement))
                {
                    condMeets = true;
                }
                break;
            }

            case ConditionTypes.InWater:
                if (unit)
                {
                    condMeets = unit.IsInWater();
                }
                break;

            case ConditionTypes.TerrainSwap:
                condMeets = obj.GetPhaseShift().HasVisibleMapId(ConditionValue1);
                break;

            case ConditionTypes.StandState:
            {
                if (unit)
                {
                    if (ConditionValue1 == 0)
                    {
                        condMeets = (unit.GetStandState() == (UnitStandStateType)ConditionValue2);
                    }
                    else if (ConditionValue2 == 0)
                    {
                        condMeets = unit.IsStandState();
                    }
                    else if (ConditionValue2 == 1)
                    {
                        condMeets = unit.IsSitState();
                    }
                }
                break;
            }

            case ConditionTypes.DailyQuestDone:
            {
                if (player)
                {
                    condMeets = player.IsDailyQuestDone(ConditionValue1);
                }
                break;
            }

            case ConditionTypes.Charmed:
            {
                if (unit)
                {
                    condMeets = unit.IsCharmed();
                }
                break;
            }

            case ConditionTypes.PetType:
            {
                if (player)
                {
                    Pet pet = player.GetPet();
                    if (pet)
                    {
                        condMeets = (((1 << (int)pet.GetPetType()) & ConditionValue1) != 0);
                    }
                }
                break;
            }

            case ConditionTypes.Taxi:
            {
                if (player)
                {
                    condMeets = player.IsInFlight();
                }
                break;
            }

            case ConditionTypes.Queststate:
            {
                if (player)
                {
                    if (
                        (Convert.ToBoolean(ConditionValue2 & (1 << (int)QuestStatus.None)) && (player.GetQuestStatus(ConditionValue1) == QuestStatus.None)) ||
                        (Convert.ToBoolean(ConditionValue2 & (1 << (int)QuestStatus.Complete)) && (player.GetQuestStatus(ConditionValue1) == QuestStatus.Complete)) ||
                        (Convert.ToBoolean(ConditionValue2 & (1 << (int)QuestStatus.Incomplete)) && (player.GetQuestStatus(ConditionValue1) == QuestStatus.Incomplete)) ||
                        (Convert.ToBoolean(ConditionValue2 & (1 << (int)QuestStatus.Failed)) && (player.GetQuestStatus(ConditionValue1) == QuestStatus.Failed)) ||
                        (Convert.ToBoolean(ConditionValue2 & (1 << (int)QuestStatus.Rewarded)) && player.GetQuestRewardStatus(ConditionValue1))
                        )
                    {
                        condMeets = true;
                    }
                }
                break;
            }

            case ConditionTypes.ObjectiveComplete:
            {
                if (player)
                {
                    QuestObjective questObj = Global.ObjectMgr.GetQuestObjective(ConditionValue1);
                    if (questObj == null)
                    {
                        break;
                    }

                    condMeets = (!player.GetQuestRewardStatus(questObj.QuestID) && player.IsQuestObjectiveComplete(questObj));
                }
                break;
            }

            case ConditionTypes.DifficultyId:
            {
                condMeets = (uint)obj.GetMap().GetDifficultyID() == ConditionValue1;
                break;
            }

            default:
                condMeets = false;
                break;
            }

            if (NegativeCondition)
            {
                condMeets = !condMeets;
            }

            if (!condMeets)
            {
                sourceInfo.mLastFailedCondition = this;
            }

            bool script = Global.ScriptMgr.OnConditionCheck(this, sourceInfo); // Returns true by default.

            return(condMeets && script);
        }
예제 #12
0
 public void CompletedAchievement(AchievementRecord entry)
 {
     m_achievementSys.CompletedAchievement(entry, this);
 }
예제 #13
0
 /// <summary>
 /// Removes achievement from the player.
 /// </summary>
 /// <param name="achievementRecord"></param>
 public void RemoveAchievement(AchievementRecord achievementRecord)
 {
     m_completedAchievements.Remove(achievementRecord.AchievementEntryId);
 }
예제 #14
0
 /// <summary>
 /// Adds a new achievement to the list.
 /// </summary>
 /// <param name="achievementRecord"></param>
 public void AddAchievement(AchievementRecord achievementRecord)
 {
     m_completedAchievements.Add(achievementRecord.AchievementEntryId, achievementRecord);
 }
 public async Task UpdateAsync(AchievementRecord achievement)
 {
     await RepositoryHelper.UpdateAsync <AchievementRecord>(achievement);
 }
 public async Task CreateAsync(AchievementRecord achievement)
 {
     await RepositoryHelper.InsertAsync <AchievementRecord>(achievement);
 }