private void SendTargetStatusToGang(Command command, Dictionary <string, object> info) { var affectedCharacters = myMissionInProgress.GetAffectedCharacters(); Message.Builder.SetCommand(command) .WithData(info) .ToCharacters(affectedCharacters) .Send(); }
private IList <Item> TryFinishMission(MissionInProgress missionInProgress) { if (!missionInProgress.IsMissionFinished) { return(null); } lock (LockObject) { //mission is finished var mission = missionInProgress.myMission; var missionBonus = MissionAdministrator.GetOrAddMissionBonus(missionInProgress.character, mission.missionCategory, missionInProgress.MissionLevel, missionInProgress.myLocation.Agent); Logger.Info("++ Mission is finished " + missionInProgress); var successData = new Dictionary <string, object> { { k.bonusMultiplier, missionBonus.BonusMultiplier }, { "rawBonusMultiplier", (int)Math.Round(missionBonus.RawMultiplier * 100.0) }, { "bonusLevel", missionBonus.Bonus } }; var rewardItems = missionInProgress.SpawnRewardItems(out MissionLocation locationUsed); //online gang members var charactersToInform = missionInProgress.GetAffectedCharacters(); //mission participants var participants = missionInProgress.GetParticipantsVerbose().ToList(); participants = missionInProgress.FilterParticipants(participants); var ep = missionInProgress.CalculateEp(); var epDict = new Dictionary <string, object>(); var count = 0; foreach (var participant in participants) { var oneMansEp = 0; if (ep > 0) { oneMansEp = participant.AddExtensionPointsBoostAndLog(EpForActivityType.Mission, ep); } var oneEpEntry = new Dictionary <string, object> { { k.characterID, participant.Id }, { k.points, oneMansEp } }; epDict.Add("ep" + count++, oneEpEntry); } missionInProgress.GetRewardDivider(participants, out double rewardFraction, out int rewardDivider); successData.Add(k.nofGangMembers, participants.Count); missionInProgress.IncreaseStanding(rewardFraction, participants, charactersToInform, successData); //pay the fee missionInProgress.PayOutMission(rewardFraction, participants, charactersToInform, successData); var isTempTeleportEnabled = false; if (mission.MissionLevel == -1 || mission.behaviourType == MissionBehaviourType.Random) { //set teleport timer missionInProgress.EnableTeleportOnSuccess(participants, missionInProgress.myLocation.ZoneConfig.Id); isTempTeleportEnabled = true; } missionInProgress.WriteSuccessLogAllTargets(); missionInProgress.CleanUpAllTargets(); ArtifactRepository.DeleteArtifactsByMissionGuid(missionInProgress.missionGuid); //write mission log - mission completed missionInProgress.SetSuccessToMissionLog(true).ThrowIfError(); AdvanceBonusInGang(participants, missionInProgress); //remove mission MissionAdministrator.RemoveMissionInProgress(missionInProgress); if (mission.ValidSuccessMissionIdSet) { Logger.Info("++ Begin triggering a mission on success. triggered missionId:" + mission.MissionIdOnSuccess); Transaction.Current.OnCommited(() => { //trigger a new mission with the current location StartAsync(missionInProgress.character, missionInProgress.spreadInGang, mission.MissionIdOnSuccess, missionInProgress.myLocation, missionInProgress.MissionLevel); }); } //add to ram cache AddToFinishedMissions(missionInProgress.character, missionInProgress.MissionId); var resultDict = new Dictionary <string, object> { { k.mission, missionInProgress.ToDictionary() }, { "successData", successData }, { "teleportEnabled", (isTempTeleportEnabled ? 1 : 0) }, { k.extensionPoints, epDict }, }; //reply mission status if (rewardItems.Any()) { resultDict.Add(k.reward, rewardItems.ToDictionary("r", r => r.BaseInfoToDictionary())); if (locationUsed != null) { resultDict.Add("rewardLocation", locationUsed.id); } } missionInProgress.DeleteParticipants(); Transaction.Current.OnCommited(() => Message.Builder.SetCommand(Commands.MissionDone).WithData(resultDict).ToCharacters(charactersToInform).Send()); Logger.Info("++ mission is finished. " + missionInProgress); return(rewardItems); } }