public static void GenerateMissionAtLocationReport(int zoneId) { var randomCategories = new MissionCategory[] { MissionCategory.Combat, MissionCategory.Transport, MissionCategory.Exploration, MissionCategory.Harvesting, MissionCategory.Mining, MissionCategory.Production, MissionCategory.CombatExploration, MissionCategory.ComplexProduction }; var locationsOnZone = _missionDataCache.GetAllLocations.Where(l => l.ZoneConfig.Id == zoneId).ToList(); var allmissions = _missionDataCache.GetAllLiveRandomMissionTemplates.ToList(); foreach (var category in randomCategories) { var randomMissions = allmissions.Where(m => m.missionCategory == category).ToList(); var ids = randomMissions.Select(m => m.id).ArrayToString(); Logger.Info("----------------------"); Logger.Info(randomMissions.Count + " missions in category " + category); foreach (var missionLocation in locationsOnZone) { var qs = "select sum(uniquecases) from missiontolocation where missionid in (" + ids + ") and locationid=@locationID"; var count = Db.Query().CommandText(qs).SetParameter("@locationID", missionLocation.id) .ExecuteScalar <int>(); Logger.Info(count + " out of " + randomMissions.Count + " at " + missionLocation.id); } } }
protected Mission(IDataRecord record) { id = record.GetValue <int>(k.ID.ToLower()); _missionIdOnSuccess = record.GetValue <int?>(k.missionIDOnSuccess.ToLower()); isUnique = record.GetValue <bool>(k.isUnique.ToLower()); _periodMinutes = record.GetValue <int?>(k.periodMinutes.ToLower()); _missionLevel = record.GetValue <int?>(k.missionLevel.ToLower()); title = record.GetValue <string>(k.title); _description = record.GetValue <string>(k.description); _missionType = record.GetValue <int>(k.missionType.ToLower()); durationMinutes = record.GetValue <int>(k.durationMinutes.ToLower()); _successMessage = record.GetValue <string>(k.successMessage.ToLower()); failMessage = record.GetValue <string>(k.failMessage.ToLower()); listable = record.GetValue <bool>(k.listable); rewardFee = record.GetValue <double>(k.rewardFee.ToLower()); _locationId = record.GetValue <int?>("locationid"); behaviourType = (MissionBehaviourType)record.GetValue <int>("behaviourtype"); _difficultyReward = record.GetValue <int?>("difficultyreward"); _difficultymultiplier = record.GetValue <double?>("difficultymultiplier"); missionCategory = MissionDataCache.GetMissionCategoryByType(_missionType); InitIssuer(record); _myTargets = new Lazy <List <MissionTarget> >(CollectMyTargets); _myDictionary = new Lazy <Dictionary <string, object> >(GenerateMyDictionary); }
public static MissionExtensionSelector GetExtensionSelectorByCategory(MissionCategory category) { switch (category) { case MissionCategory.Combat: case MissionCategory.CombatExploration: return(MissionExtensionSelector.combat); case MissionCategory.Harvesting: case MissionCategory.Mining: case MissionCategory.Exploration: case MissionCategory.Industrial: return(MissionExtensionSelector.fieldcraft); case MissionCategory.Production: case MissionCategory.ComplexProduction: return(MissionExtensionSelector.production); case MissionCategory.Transport: return(MissionExtensionSelector.transport); default: return(MissionExtensionSelector.none); } }
public bool IsMissionRunningWithThisCategory(MissionCategory missionCategory) { if (IsCollectorAvailable()) { return(_collector.AnyMissionOfCategotryRunning(missionCategory)); } return(false); }
public void DecreaseBonus(Character character, MissionCategory missionCategory, int missionLevel, MissionAgent agent) { var missionBonus = GetOrAddMissionBonus(character, missionCategory, missionLevel, agent); if (missionBonus.DecreaseBonus()) { SetMissionBonus(missionBonus); } }
public bool IsMissionRunningWithThisCategoryAndLevel(MissionCategory category, int level, MissionAgent agent) { if (IsCollectorAvailable()) { return(_collector.AnyMissionOfCategotryAndLevelRunning(category, level, agent)); } return(false); }
public MissionBonus(Character character, MissionCategory missionCategory, int missionLevel, MissionAgent agent, int bonus) { this.character = character; _missionCategory = missionCategory; _missionLevel = missionLevel; _agentId = agent.id; Bonus = bonus; lastModified = DateTime.Now; }
public bool AnyMissionOfCategotryAndLevelRunning(MissionCategory missionCategory, int missionLevel, MissionAgent agent) { return(_missionInProgress.Values.Any ( p => ( p.MissionLevel == missionLevel && p.myMission.missionCategory == missionCategory && p.myLocation.Agent.id == agent.id ) )); }
public MissionPayOutLogEntry(Guid missionGuid, int missionId, MissionCategory missionCategory, int missionLevel, long?corporationEid, int?characterId, int gangSize, double amount, double sumAmount) { this.missionGuid = missionGuid; this.missionId = missionId; this.missionCategory = missionCategory; this.missionLevel = missionLevel; this.corporationEid = corporationEid; this.characterId = characterId; this.gangSize = gangSize; this.amount = amount; this.sumAmount = sumAmount; }
public MissionBonus GetOrAddMissionBonus(Character character, MissionCategory missionCategory, int missionLevel, MissionAgent agent) { var collector = _missionBonuses.GetOrAdd(character.Id, c => new MissionBonusCollector()); MissionBonus missionBonus; if (!collector.GetBonusWithConditions(missionCategory, missionLevel, agent, out missionBonus)) { return(new MissionBonus(character, missionCategory, missionLevel, agent, 0)); } return(missionBonus); }
public static string GetCorporationPostFixByMissionCategory(MissionCategory missionCategory) { var exs = GetExtensionSelectorByCategory(missionCategory); switch (exs) { case MissionExtensionSelector.fieldcraft: return("_iw"); case MissionExtensionSelector.production: return("_ii"); case MissionExtensionSelector.combat: return("_ww"); case MissionExtensionSelector.transport: return("_ss"); default: return("_ss"); } }
/// <summary> /// map category to issuerAlliance's proper corp ww, ii , ss etc.... /// </summary> /// <param name="missionCategory"></param> /// <param name="issuerCorporationEid"></param> /// <param name="issuerAllianceEid"></param> public void GetIssuerCorporationByCategory(MissionCategory missionCategory, out long issuerCorporationEid, out long issuerAllianceEid) { issuerAllianceEid = Agent.OwnerAlliance.Eid; var corpNamePostFix = MissionDataCache.GetCorporationPostFixByMissionCategory(missionCategory); var corporationEid = DefaultCorporationDataCache.GetPureCorporationFromAllianceByPostFix(issuerAllianceEid, corpNamePostFix); issuerCorporationEid = corporationEid; #if DEBUG if (MissionResolveTester.isTestMode) { return; } var allianceName = DefaultCorporationDataCache.GetAllianceName(issuerAllianceEid); var corporationName = DefaultCorporationDataCache.GetCorporationName(issuerCorporationEid); Logger.Info(missionCategory + " " + allianceName + " mapped to " + corporationName); #endif }
protected void Page_Load(object sender, EventArgs e) { categoryID = _Request.Get <int>("id", Method.All); if (categoryID.HasValue == false) { ShowError("缺少必要参数"); } MissionCategory category = MissionBO.Instance.GetMissionCategory(categoryID.Value); if (category == null) { ShowError("任务分类不存在"); } m_CategoryName = category.Name; if (_Request.IsClick("edit")) { EditCategory(); } }
/// <summary> /// Selects a template and starts it... Random mission start /// </summary> /// <param name="character"></param> /// <param name="spreadInGang"></param> /// <param name="location"></param> /// <param name="level"></param> /// <param name="category"></param> /// <returns></returns> public Dictionary <string, object> SelectAndStartRandomMission(Character character, bool spreadInGang, MissionLocation location, int level, MissionCategory category) { if (location.Zone == null) { Logger.Error("zone config was not found for zoneId:" + location.zoneId); throw new PerpetuumException(ErrorCodes.ZoneNotFound); } var missionAgent = location.Agent; GetFinishedAndLastMissions(character, out List <int> missionsDone, out Dictionary <int, DateTime> periodicMissions).ThrowIfError(); var missionFilter = new MissionFilter(character, periodicMissions, missionsDone, this, location, _missionDataCache); missionFilter.IsMissionRunningWithThisCategoryAndLevel(category, level, missionAgent).ThrowIfTrue(ErrorCodes.MissionRunningWithCategoryAndLevel); MissionHelper.GetStandingData(character, missionAgent.OwnerAlliance.Eid, out double standing, out int playerLevel); //at this location this is the maximum level playerLevel = playerLevel.Clamp(0, location.maxMissionLevel); //not higher pls level = level.Clamp(0, playerLevel); var solvableMissions = location.GetSolvableRandomMissionsAtLocation(); var rndMissionsHere = solvableMissions .Where(m => m.missionCategory == category && missionFilter.IsRandomMissionAvailable(m) ).ToList(); if (rndMissionsHere.Count == 0) { character.CreateErrorMessage(Commands.MissionStart, ErrorCodes.NoMissionAvailableWithConditions) .SetExtraInfo(d => d[k.message] = "no mission was found") .Send(); return(null); } var mission = rndMissionsHere.RandomElement(); mission.ThrowIfNull(ErrorCodes.WTFErrorMedicalAttentionSuggested); var resolveInfo = _missionDataCache.GetAllResolveInfos.FirstOrDefault(ri => ri.missionId == mission.id && ri.locationId == location.id); resolveInfo.ThrowIfNull(ErrorCodes.ConsistencyError); var attempts = resolveInfo.attempts; Dictionary <string, object> info = new Dictionary <string, object>(); var resolved = false; while (attempts-- > 0 && !resolved) { resolved = StartMission(character, spreadInGang, mission, location, level, out info); if (!resolved) { Logger.Warning("mission resolve attempts left " + attempts + " " + mission); } } resolved.ThrowIfFalse(ErrorCodes.WTFErrorMedicalAttentionSuggested); return(info); }
/// <summary> /// This is the actual function that starts a mission, OLD SCHOOL /// </summary> /// <param name="character"></param> /// <param name="agent"></param> /// <param name="category"></param> /// <param name="level"></param> /// <param name="spreadInGang"></param> /// <param name="location"></param> /// <returns></returns> public Dictionary <string, object> SelectAndStartConfigMission(Character character, MissionAgent agent, MissionCategory category, int level, bool spreadInGang, MissionLocation location) { List <int> missionsDone; Dictionary <int, DateTime> periodicMissions; GetFinishedAndLastMissions(character, out missionsDone, out periodicMissions).ThrowIfError(); var missionFilter = new MissionFilter(character, periodicMissions, missionsDone, this, location, _missionDataCache); missionFilter.IsMissionRunningWithThisCategoryAndLevel(category, level, agent).ThrowIfTrue(ErrorCodes.MissionRunningWithCategoryAndLevel); var missions = missionFilter.GetConfigMissionsByCategoryAndLevel(category, level).Where(m => missionFilter.IsConfigMissionAvailable(m, _standingHandler)).ToArray(); missions.Any().ThrowIfFalse(ErrorCodes.NoMissionAvailableWithConditions); var mission = missions.RandomElement(); Dictionary <string, object> info; var resolved = StartMission(character, spreadInGang, mission, location, level, out info); if (!resolved) { Logger.Error("WTF? in config mission start " + location + " " + mission); } return(info); }
/// <summary> /// Starts a mission by client request /// </summary> /// <param name="character"></param> /// <param name="category"></param> /// <param name="level"></param> /// <param name="spreadInGang"></param> /// <param name="location"></param> /// <returns></returns> public Dictionary <string, object> MissionStartForRequest(Character character, MissionCategory category, int level, MissionLocation location) { var gang = character.GetGang(); //fix spreading: //if in gang = always spreading //else = not spreading var spreadInGang = gang != null; var agent = location.Agent; var safeToResolve = location.GetSolvableRandomMissionsAtLocation(); if (level >= 0 && safeToResolve.Count > 0 && category != MissionCategory.Special) { return(SelectAndStartRandomMission(character, spreadInGang, location, level, category)); } //old missions return(SelectAndStartConfigMission(character, agent, category, level, spreadInGang, location)); }
public static void WriteSuccessLog(int zoneId, int x, int y, Guid guid, MissionTargetType targetType, long locationEid, MissionCategory missionCategory) { var res = Db.Query().CommandText("INSERT dbo.missiontargetslog ( zoneid, x, y, targettype, guid, locationeid, missioncategory ) VALUES ( @zoneId, @x, @y, @targetType, @guid, @locationeid, @category )") .SetParameter("@x", x) .SetParameter("@y", y) .SetParameter("@zoneId", zoneId) .SetParameter("@guid", guid) .SetParameter("@targetType", (int)targetType) .SetParameter("@locationeid", locationEid) .SetParameter("@category", (int)missionCategory) .ExecuteNonQuery(); (res == 1).ThrowIfFalse(ErrorCodes.SQLInsertError); }
public void MissionStartFromFieldTerminal(Character character, int locationId, MissionCategory missionCategory, int level) { try { _missionDataCache.GetLocationById(locationId, out MissionLocation location).ThrowIfNull(ErrorCodes.ItemNotFound); var result = MissionStartForRequest(character, missionCategory, level, location); Message.Builder.ToCharacter(character).WithData(result).SetCommand(Commands.MissionStart).Send(); } catch (PerpetuumException exception) { Logger.Exception(exception); character.CreateErrorMessage(Commands.MissionStart, exception.error).Send(); } }
public IEnumerable <Mission> GetConfigMissionsByCategoryAndLevel(MissionCategory missionCategory, int missionLevel) { return(_agent.GetConfigMissionsByCategoryAndLevel(missionCategory, missionLevel)); }
public static long GetKey(MissionCategory missionCategory, int missionLevel, int agentId) { return((int)missionCategory | (missionLevel << 8) | (agentId << 16)); }
public bool AnyMissionOfCategotryRunning(MissionCategory missionCategory) { return(_missionInProgress.Values.Any(p => p.myMission.missionCategory == missionCategory)); }
public IEnumerable <Mission> GetConfigMissionsByCategoryAndLevel(MissionCategory missionCategory, int missionLevel) { return(MyConfigMissions.Where(m => m.missionCategory == missionCategory && m.MissionLevel == missionLevel)); }
private void DrawOneCategory(IRequest request, MissionLocation missionLocation, MissionCategory category) { const string query = "SELECT * FROM dbo.missiontargetslog WHERE zoneid=@zoneId and locationeid=@locationEid and missioncategory=@category"; var entries = Db.Query().CommandText(query) .SetParameter("@zoneId", _zone.Id) .SetParameter("@category", (int)category) .SetParameter("@locationEid", missionLocation.LocationEid) .Execute() .Select(MissionTargetSuccessLogEntry.FromRecord).ToArray(); if (entries.Length == 0) { Logger.Info("no entry at " + missionLocation + " in category: " + category); return; } var bitmap = _zone.CreatePassableBitmap(_passableColor, _islandColor); DrawEntriesOnBitmap(entries, bitmap); var ft = _zone.GetUnit(missionLocation.LocationEid); var littleText = "locationID:" + missionLocation.id; if (ft != null) { littleText += " " + ft.Name; } var category1 = category; bitmap.WithGraphics(gx => gx.DrawString(category1.ToString(), new Font("Tahoma", 15), new SolidBrush(Color.White), new PointF(20, 40))); bitmap.WithGraphics(gx => gx.DrawString(littleText, new Font("Tahoma", 15), new SolidBrush(Color.White), new PointF(20, 60))); var idString = $"{missionLocation.id:0000}"; var fname = "_" + category1 + "_LOC" + idString + "_"; SendBitmapFinished(request, fname); _saveBitmapHelper.SaveBitmap(_zone, bitmap, fname); }
public bool GetBonusWithConditions(MissionCategory missionCategory, int missionLevel, MissionAgent agent, out MissionBonus missionBonus) { var key = MissionBonus.GetKey(missionCategory, missionLevel, agent.id); return(_bonuses.TryGetValue(key, out missionBonus)); }