/// <summary> /// Converts the string representation of the name of a DialogResult to an equivalent DialogResult object. /// A parameter specifies whether the operation is case-sensitive. /// The return value indicates whether the conversion succeeded. /// </summary> public static bool? TryParse(string value, bool ignoreCase, out DialogResult result) { var parseResult = new EnumResult(); var retValue = TryParseDialogResult(value, ignoreCase, ref parseResult); result = parseResult.ParsedEnum; return retValue; }
public void getLootDrops(EnumResult result, Quest theQuest, ref int questBonus) { ChallengeTypes.Loot.AddUncommonResource(theQuest); }
public abstract void OnAttempt(EnumResult result, Quest theQuest, ref int questBonus);
protected override EnumResult OnUpdate() { if (_contenNodeList.Count == 0) { return(EnumResult.Success); } //Run for (int i = 0; i < _contenNodeList.Count; i++) { if (i >= _contenNodeList.Count) { break; } EnumResult result = _contenNodeList[i].Tick(this); if (result != EnumResult.Running) { if (i >= _contenNodeList.Count) { break; } NodeModifier node = _contenNodeList[i]; if (result == EnumResult.Failed) { switch (node.RunMode) { case EnumRunMode.UntilSuccess: continue; case EnumRunMode.ReturnParentNode: _toRemoveNode.Add(node); _toAddNode.Add(node.Parent); continue; case EnumRunMode.StopNodeList: _toRemoveNode.Add(node); continue; } } _toRemoveNode.Add(node); //单独处理Decorator节点运行 //仅运行非单节点 //if (node is Decorator) //{ // NodeModifier child = System.Array.Find<NodeModifier>(node.NextNodes, (n) => n.Parent == node); // if (child != null) // _toAddNode.Add(child); //} //else node.GetNextNodes(_toAddNode); } } //UnityEngine.Profiler.EndSample(); ProcessNode(); return(EnumResult.Running); }
private static bool TryParseEnum(Type enumType, string value, bool ignoreCase, ref EnumResult parseResult) { if (enumType == null) { throw new ArgumentNullException("enumType"); } RuntimeType type = enumType as RuntimeType; if (type == null) { throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType"); } if (!enumType.IsEnum) { throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType"); } if (value == null) { parseResult.SetFailure(ParseFailureKind.ArgumentNull, "value"); return(false); } value = value.Trim(); if (value.Length == 0) { parseResult.SetFailure(ParseFailureKind.Argument, "Arg_MustContainEnumInfo", null); return(false); } ulong num = 0L; if ((char.IsDigit(value[0]) || (value[0] == '-')) || (value[0] == '+')) { Type underlyingType = GetUnderlyingType(enumType); try { object obj2 = Convert.ChangeType(value, underlyingType, CultureInfo.InvariantCulture); parseResult.parsedEnum = ToObject(enumType, obj2); return(true); } catch (FormatException) { } catch (Exception exception) { if (parseResult.canThrow) { throw; } parseResult.SetFailure(exception); return(false); } } string[] strArray = value.Split(enumSeperatorCharArray); HashEntry hashEntry = GetHashEntry(type); string[] names = hashEntry.names; for (int i = 0; i < strArray.Length; i++) { strArray[i] = strArray[i].Trim(); bool flag = false; for (int j = 0; j < names.Length; j++) { ulong num4; if (ignoreCase) { if (string.Compare(names[j], strArray[i], StringComparison.OrdinalIgnoreCase) == 0) { goto Label_0157; } continue; } if (!names[j].Equals(strArray[i])) { continue; } Label_0157: num4 = hashEntry.values[j]; num |= num4; flag = true; break; } if (!flag) { parseResult.SetFailure(ParseFailureKind.ArgumentWithParameter, "Arg_EnumValueNotFound", value); return(false); } } try { parseResult.parsedEnum = ToObject(enumType, num); return(true); } catch (Exception exception2) { if (parseResult.canThrow) { throw; } parseResult.SetFailure(exception2); return(false); } }
public void getLootDrops(EnumResult result, Quest theQuest, ref int questBonus) { }
public ReturnStatus(EnumResult result) { this.Status = result; this.Message = null; }
private static bool TryParseEnum(Type enumType, string value, bool ignoreCase, ref EnumResult parseResult) { if (enumType == null) { throw new ArgumentNullException(nameof(enumType)); } RuntimeType rtType = enumType as RuntimeType; if (rtType == null) { throw new ArgumentException(SR.Arg_MustBeType, nameof(enumType)); } if (!enumType.IsEnum) { throw new ArgumentException(SR.Arg_MustBeEnum, nameof(enumType)); } if (value == null) { parseResult.SetFailure(ParseFailureKind.ArgumentNull, nameof(value)); return(false); } int firstNonWhitespaceIndex = -1; for (int i = 0; i < value.Length; i++) { if (!char.IsWhiteSpace(value[i])) { firstNonWhitespaceIndex = i; break; } } if (firstNonWhitespaceIndex == -1) { parseResult.SetFailure(ParseFailureKind.Argument, nameof(SR.Arg_MustContainEnumInfo), null); return(false); } // We have 2 code paths here. One if they are values else if they are Strings. // values will have the first character as as number or a sign. ulong result = 0; char firstNonWhitespaceChar = value[firstNonWhitespaceIndex]; if (char.IsDigit(firstNonWhitespaceChar) || firstNonWhitespaceChar == '-' || firstNonWhitespaceChar == '+') { Type underlyingType = GetUnderlyingType(enumType); object temp; try { value = value.Trim(); temp = Convert.ChangeType(value, underlyingType, CultureInfo.InvariantCulture); parseResult.parsedEnum = ToObject(enumType, temp); return(true); } catch (FormatException) { // We need to Parse this as a String instead. There are cases // when you tlbimp enums that can have values of the form "3D". // Don't fix this code. } catch (Exception ex) { if (parseResult.canThrow) { throw; } else { parseResult.SetFailure(ex); return(false); } } } // Find the field. Let's assume that these are always static classes // because the class is an enum. TypeValuesAndNames entry = GetCachedValuesAndNames(rtType, true); string[] enumNames = entry.Names; ulong[] enumValues = entry.Values; StringComparison comparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; int valueIndex = firstNonWhitespaceIndex; while (valueIndex <= value.Length) // '=' is to handle invalid case of an ending comma { // Find the next separator, if there is one, otherwise the end of the string. int endIndex = value.IndexOf(enumSeparatorChar, valueIndex); if (endIndex == -1) { endIndex = value.Length; } // Shift the starting and ending indices to eliminate whitespace int endIndexNoWhitespace = endIndex; while (valueIndex < endIndex && char.IsWhiteSpace(value[valueIndex])) { valueIndex++; } while (endIndexNoWhitespace > valueIndex && char.IsWhiteSpace(value[endIndexNoWhitespace - 1])) { endIndexNoWhitespace--; } int valueSubstringLength = endIndexNoWhitespace - valueIndex; // Try to match this substring against each enum name bool success = false; for (int i = 0; i < enumNames.Length; i++) { if (enumNames[i].Length == valueSubstringLength && string.Compare(enumNames[i], 0, value, valueIndex, valueSubstringLength, comparison) == 0) { result |= enumValues[i]; success = true; break; } } // If we couldn't find a match, throw an argument exception. if (!success) { // Not found, throw an argument exception. parseResult.SetFailure(ParseFailureKind.ArgumentWithParameter, nameof(SR.Arg_EnumValueNotFound), value); return(false); } // Move our pointer to the ending index to go again. valueIndex = endIndex + 1; } try { parseResult.parsedEnum = ToObject(enumType, result); return(true); } catch (Exception ex) { if (parseResult.canThrow) { throw; } else { parseResult.SetFailure(ex); return(false); } } }
public bool ExecutePostMpFlex(EnumResult result) { return(true); }
private static bool TryParseEnum(Type enumType, String value, bool ignoreCase, ref EnumResult parseResult) { if (enumType == null) { throw new ArgumentNullException("enumType"); } Contract.EndContractBlock(); RuntimeType rtType = enumType as RuntimeType; if (rtType == null) { throw new ArgumentException(Environment.GetResourceString("Arg_MustBeType"), "enumType"); } if (!enumType.IsEnum) { throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType"); } if (value == null) { parseResult.SetFailure(ParseFailureKind.ArgumentNull, "value"); return(false); } value = value.Trim(); if (value.Length == 0) { parseResult.SetFailure(ParseFailureKind.Argument, "Arg_MustContainEnumInfo", null); return(false); } // We have 2 code paths here. One if they are values else if they are Strings. // values will have the first character as as number or a sign. ulong result = 0; if (Char.IsDigit(value[0]) || value[0] == '-' || value[0] == '+') { Type underlyingType = GetUnderlyingType(enumType); Object temp; try { temp = Convert.ChangeType(value, underlyingType, CultureInfo.InvariantCulture); parseResult.parsedEnum = ToObject(enumType, temp); return(true); } catch (FormatException) { // We need to Parse this as a String instead. There are cases // when you tlbimp enums that can have values of the form "3D". // Don't fix this code. } catch (Exception ex) { if (parseResult.canThrow) { throw; } else { parseResult.SetFailure(ex); return(false); } } } String[] values = value.Split(enumSeperatorCharArray); // Find the field.Lets assume that these are always static classes because the class is // an enum. ValuesAndNames entry = GetCachedValuesAndNames(rtType, true); String[] enumNames = entry.Names; ulong[] enumValues = entry.Values; for (int i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); // We need to remove whitespace characters bool success = false; for (int j = 0; j < enumNames.Length; j++) { if (ignoreCase) { if (String.Compare(enumNames[j], values[i], StringComparison.OrdinalIgnoreCase) != 0) { continue; } } else { if (!enumNames[j].Equals(values[i])) { continue; } } ulong item = enumValues[j]; result |= item; success = true; break; } if (!success) { // Not found, throw an argument exception. parseResult.SetFailure(ParseFailureKind.ArgumentWithParameter, "Arg_EnumValueNotFound", value); return(false); } } try { parseResult.parsedEnum = ToObject(enumType, result); return(true); } catch (Exception ex) { if (parseResult.canThrow) { throw; } else { parseResult.SetFailure(ex); return(false); } } }
public void OnAttempt(EnumResult result, Quest theQuest) { if (type is IMonsterChallenge) { ItemStack rangedStack = theQuest.getHeroItemWith(AidType.RANGED_WEAPON); int mod = 0; if (rangedStack != null) { mod = rangedStack.doesStackHave(RequirementType.PERFECT_AIM) && result < EnumResult.CRIT_SUCCESS ? 1 : 0; //if(mod + result > EnumResult.CRIT_SUCCESS) mod = 0; } int dmg = ((IMonsterChallenge)type).getRangedDamage(result + mod, theQuest, ref questBonus, rangedStack); if (rangedStack != null) { if (rangedStack.doesStackHave(Enchantments.ENHANCEMENT)) { foreach (Enchantment en in rangedStack.enchants) { if (en == Enchantments.ENHANCEMENT) { dmg += 5; } } } if (rangedStack.item.isConsumable && rangedStack.stackSize > 0) { rangedStack.stackSize--; } dmg = (int)Math.Round(rangedStack.getEffectiveness(RequirementType.RANGED) * dmg); if (rangedStack.doesStackHave(RequirementType.PERFECT_AIM)) { dmg *= 2; } rangedStack.onUsedDuringQuest(theQuest); } monsterHealth -= dmg; } int hpBefore = theQuest.heroCurHealth; type.OnAttempt(result, theQuest, ref questBonus); if (type is IMonsterChallenge) { bool tookDamage = hpBefore != theQuest.heroCurHealth; ItemStack meleeStack = theQuest.getHeroItemWith(AidType.WEAPON); int dmg = ((IMonsterChallenge)type).getDamageDealtToMonster(result, theQuest, ref questBonus, meleeStack); if (meleeStack != null) { if (meleeStack.doesStackHave(Enchantments.ENHANCEMENT)) { foreach (Enchantment en in meleeStack.enchants) { if (en == Enchantments.ENHANCEMENT) { dmg += 5; } } } if (meleeStack.doesStackHave(Enchantments.KEEN)) { if (theQuest.testLuck(5) == 0) { dmg *= 2; } } if (meleeStack.item.isConsumable && meleeStack.stackSize > 0) { meleeStack.stackSize--; } dmg = (int)Math.Round(meleeStack.getEffectiveness(RequirementType.WEAPON) * dmg); meleeStack.onUsedDuringQuest(theQuest); } ItemStack thornStack = theQuest.getHeroItemWith(Enchantments.THORNS); if (tookDamage && thornStack != null) { int c = 0; foreach (Enchantment en in thornStack.enchants) { if (en == Enchantments.THORNS) { c++; } } dmg += (c * 5) / 2; thornStack.onUsedDuringQuest(theQuest); } monsterHealth -= dmg; if (monsterHealth > 0) { theQuest.repeatTask(); } else { ((IMonsterChallenge)type).getLootDrops(result, theQuest, ref questBonus); } theQuest.addTime(-50); //combats should be fast } }
public EnumResult InsertCustData(string Verifycode, string jsonDataStr) { BLL.Loger.Log4Net.Info("准备验证:"); string msg = string.Empty; if (BLL.CallRecord_ORIG_Authorizer.Instance.Verify(Verifycode, 0, ref msg, "插入话务与任务关联数据,授权失败。")) { BLL.Loger.Log4Net.Info("验证通过"); JavaScriptSerializer serializer = new JavaScriptSerializer(); CustBussiness info = null; try { BLL.Loger.Log4Net.Info("Json串:" + jsonDataStr); info = serializer.Deserialize <CustBussiness>(jsonDataStr); BLL.Loger.Log4Net.Info("Json格式转换成功"); } catch (Exception ex) { BLL.Loger.Log4Net.Info("Json格式转换失败,失败原因:" + ex.Message); return(EnumResult.JsonPatternError); } Entities.CallRecord_ORIG orig; BitAuto.YanFa.Crm2009.Entities.DMSMember member; EnumResult vefiyResult = VefiyCustData(info, out orig, out member); if (vefiyResult == EnumResult.Success) { try { //0 获取分组分类 SetBGIDAndSCID(info); //1 插入个人信息表 string custId = string.Empty; string errMsg = string.Empty; int custCategory = 4; if (!string.IsNullOrEmpty(info.MemberCode)) { //3-经销商;4-个人 custCategory = 3; } if (BLL.CustBasicInfo.Instance.InsertCustInfo(info.CustName, info.Tels, CommonFunction.ObjectToInteger(info.Sex), (int)orig.CreateUserID, custCategory, null, null, out errMsg, out custId)) { BLL.Loger.Log4Net.Info("插入客户成功"); //删除经销商 BLL.DealerInfo.Instance.Delete(custId); if (!string.IsNullOrEmpty(info.MemberCode)) { //插入 Entities.DealerInfo model_Dealer = new Entities.DealerInfo(); model_Dealer.CustID = custId; model_Dealer.MemberCode = info.MemberCode; model_Dealer.Name = member.Name; model_Dealer.Status = 0; model_Dealer.CreateTime = DateTime.Now; model_Dealer.CreateUserID = (int)orig.CreateUserID; BLL.DealerInfo.Instance.Insert(model_Dealer); BLL.Loger.Log4Net.Info("插入经销商信息成功"); } //2 插入访问记录 string tel = BLL.Util.HaoMaProcess(orig.ANI); long callid = CommonFunction.ObjectToLong(info.CallID, -2); int businesstype = (int)VisitBusinessTypeEnum.S0_其他系统; int tasksource = orig.CallStatus == 2 ? 2 : 1; BitAuto.ISDC.CC2012.Web.AjaxServers.CustBaseInfo.OperPopCustBasicInfo.OperCustVisitBusiness(custId, info.BusinessID, callid, businesstype, tasksource, (int)orig.CreateUserID, tel); //3 插入话务业务表 UpdateBusinessDataByCallID(info); //插入来去电表 CallRecordInfoInfo recordInfo = new CallRecordInfoInfo(); recordInfo.CallID = long.Parse(info.CallID); recordInfo.SCID = int.Parse(info.SCID); recordInfo.TaskID = info.BusinessID; recordInfo.TaskTypeID = (int)ProjectSource.None; recordInfo.BGID = int.Parse(info.BGID); recordInfo.CustID = custId; recordInfo.CustName = info.CustName; recordInfo.Contact = info.CustName; long recId = 0; BLL.CallRecordInfo.Instance.InsertCallRecordInfoToHuiMaiChe(recordInfo, orig, out recId); return(EnumResult.Success); } else { return(EnumResult.Fail); } } catch (Exception ex) { BLL.Loger.Log4Net.Error("【插入客户信息+话务】", ex); return(EnumResult.Fail); } } else { BLL.Loger.Log4Net.Info("Json验证失败:msg=" + vefiyResult.ToString()); return(vefiyResult); } } else { BLL.Loger.Log4Net.Info("验证失败!msg=" + msg); return(EnumResult.VerifyError); } }
private static bool TryParseDialogResult(string value, bool ignoreCase, ref EnumResult parseResult) { if (value == null) { return false; } value = value.Trim(); if (value.Length == 0) { return false; } DialogResult result = null; var values = value.Split(EnumSeperatorCharArray); string[] enumNames = { "Abort", "Cancel", "Ignore", "No", "None", "OK", "Retry", "Yes" }; DialogResult[] enumValues = { Abort, Cancel, Ignore, No, None, OK, Retry, Yes }; for (var i = 0; i < values.Length; i++) { values[i] = values[i].Trim(); // We need to remove whitespace characters var success = false; for (var j = 0; j < enumNames.Length; j++) { if (ignoreCase) { if (string.Compare(enumNames[j], values[i], StringComparison.OrdinalIgnoreCase) != 0) continue; } else { if (!enumNames[j].Equals(values[i])) continue; } result = enumValues[j]; success = true; break; } if (!success) { return false; } } try { parseResult.ParsedEnum = result; return true; } catch (Exception) { //parseResult.SetFailure(ex); return false; } }
internal DataTable GetColumnNames(Server server, Urn urn, bool isDw) { List <string> filterExpressions = new List <string>(); if (server.Version.Major >= 10) { // We don't have to include sparce columns as all the sparce columns data. // Can be obtain from column set columns. filterExpressions.Add("@IsSparse=0"); } // Check if we're called for EDIT for SQL2016+/Sterling+. // We need to omit temporal columns if such are present on this table. if (server.Version.Major >= 13 || (DatabaseEngineType.SqlAzureDatabase == server.DatabaseEngineType && server.Version.Major >= 12)) { // We're called in order to generate a list of columns for EDIT TOP N rows. // Don't return auto-generated, auto-populated, read-only temporal columns. filterExpressions.Add("@GeneratedAlwaysType=0"); } // Check if we're called for SQL2017/Sterling+. // We need to omit graph internal columns if such are present on this table. if (server.Version.Major >= 14 || (DatabaseEngineType.SqlAzureDatabase == server.DatabaseEngineType && !isDw)) { // from Smo.GraphType: // 0 = None // 1 = GraphId // 2 = GraphIdComputed // 3 = GraphFromId // 4 = GraphFromObjId // 5 = GraphFromIdComputed // 6 = GraphToId // 7 = GraphToObjId // 8 = GraphToIdComputed // // We only want to show types 0, 2, 5, and 8: filterExpressions.Add("(@GraphType=0 or @GraphType=2 or @GraphType=5 or @GraphType=8)"); } Request request = new Request(); // If we have any filters on the columns, add them. if (filterExpressions.Count > 0) { request.Urn = String.Format("{0}/Column[{1}]", urn.ToString(), string.Join(" and ", filterExpressions.ToArray())); } else { request.Urn = String.Format("{0}/Column", urn.ToString()); } request.Fields = new String[] { "Name" }; // get the columns in the order they were created OrderBy order = new OrderBy(); order.Dir = OrderBy.Direction.Asc; order.Field = "ID"; request.OrderByList = new OrderBy[] { order }; Enumerator en = new Enumerator(); // perform the query. DataTable dt = null; EnumResult result = en.Process(server.ConnectionContext, request); if (result.Type == ResultType.DataTable) { dt = result; } else { dt = ((DataSet)result).Tables[0]; } return(dt); }
public Quest(SerializationInfo info, StreamingContext context) { questRand = new System.Random(); heroMaxHealth = info.GetInt32("heroMaxHealth"); heroCurHealth = info.GetInt32("heroCurHealth"); heroName = info.GetString("heroName"); STR = info.GetInt32("STR"); AGL = info.GetInt32("AGL"); CHA = info.GetInt32("CHA"); INT = info.GetInt32("INT"); questTimer = (float)info.GetDouble("questTimer"); questTotalTime = (float)info.GetDouble("questTotalTime"); questStep = info.GetInt32("questStep"); int num = info.GetInt32("numObstacles"); questComplete = questStep >= num; _obstacles = new QuestChallenge[num]; for (int o = 0; o < num; o++) { QuestChallenge temp = (QuestChallenge)info.GetValue("obs_" + o, typeof(QuestChallenge)); //_obstacles[o] = (QuestChallenge)info.GetValue("obs_" + o, typeof(QuestChallenge)); fromDisk.Add(new ChallengeLoadWrapper(temp)); } originalGoal = GameRegistry.GetObstacleByID(info.GetString("originalGoal")); num = info.GetInt32("inventorySize"); inventory = new List <ItemStack>(); for (int o = 0; o < num; o++) { inventory.Add((ItemStack)info.GetValue("inven_" + o, typeof(ItemStack))); } timeUntilQuestExpires = (float)info.GetDouble("timeUntilQuestExpires"); numQuestsBefore = info.GetInt64("numQuestsBefore"); rewards = new ItemStack[2]; rewards[0] = (ItemStack)info.GetValue("reward_0", typeof(ItemStack)); rewards[1] = (ItemStack)info.GetValue("reward_1", typeof(ItemStack)); if (Main.saveVersionFromDisk >= 9) { if (info.GetBoolean("hasMiscData")) { miscData = (Dictionary <string, object>)info.GetValue("miscData", typeof(Dictionary <string, object>)); } } if (Main.saveVersionFromDisk >= 16) { finalResult = (EnumResult)info.GetInt32("finalResult"); } if (Main.saveVersionFromDisk >= 24) { num = info.GetInt32("numKnownRequirements"); knownRequirements = new long[num]; for (int o = 0; o < num; o++) { long temp = (long)info.GetValue("knReq_" + o, typeof(long)); knownRequirements[o] = temp; } } else { } }
private HttpResponseMessage CreateQueryResponse(IQueryable query, IEdmType edmType) { IEdmTypeReference typeReference = GetTypeReference(edmType); // TODO, GitHubIssue#328 : 404 should be returned when requesting property of non-exist entity BaseSingleResult singleResult = null; HttpResponseMessage response = null; if (typeReference.IsPrimitive()) { if (this.shouldReturnCount || this.shouldWriteRawValue) { var rawResult = new RawResult(query, typeReference, this.Api.Context); singleResult = rawResult; response = this.Request.CreateResponse(HttpStatusCode.OK, rawResult); } else { var primitiveResult = new PrimitiveResult(query, typeReference, this.Api.Context); singleResult = primitiveResult; response = this.Request.CreateResponse(HttpStatusCode.OK, primitiveResult); } } if (typeReference.IsComplex()) { var complexResult = new ComplexResult(query, typeReference, this.Api.Context); singleResult = complexResult; response = this.Request.CreateResponse(HttpStatusCode.OK, complexResult); } if (typeReference.IsEnum()) { if (this.shouldWriteRawValue) { var rawResult = new RawResult(query, typeReference, this.Api.Context); singleResult = rawResult; response = this.Request.CreateResponse(HttpStatusCode.OK, rawResult); } else { var enumResult = new EnumResult(query, typeReference, this.Api.Context); singleResult = enumResult; response = this.Request.CreateResponse(HttpStatusCode.OK, enumResult); } } if (singleResult != null) { if (singleResult.Result == null) { // Per specification, If the property is single-valued and has the null value, // the service responds with 204 No Content. return(this.Request.CreateResponse(HttpStatusCode.NoContent)); } return(response); } if (typeReference.IsCollection()) { var elementType = typeReference.AsCollection().ElementType(); if (elementType.IsPrimitive() || elementType.IsComplex() || elementType.IsEnum()) { return(this.Request.CreateResponse( HttpStatusCode.OK, new NonEntityCollectionResult(query, typeReference, this.Api.Context))); } return(this.Request.CreateResponse( HttpStatusCode.OK, new EntityCollectionResult(query, typeReference, this.Api.Context))); } var entityResult = new EntityResult(query, typeReference, this.Api.Context); if (entityResult.Result == null) { // TODO GitHubIssue#288: 204 expected when requesting single nav propery which has null value // ~/People(nonexistkey) and ~/People(nonexistkey)/BestFriend, expected 404 // ~/People(key)/BestFriend, and BestFriend is null, expected 204 throw new HttpResponseException( this.Request.CreateErrorResponse( HttpStatusCode.NotFound, Resources.ResourceNotFound)); } // TODO GitHubIssue#43 : support non-Entity ($select/$value) queries return(this.Request.CreateResponse(HttpStatusCode.OK, entityResult)); }
private EnumResult _doQuestStep(float t) { if (questComplete) { timeAftercomplete += t; return(EnumResult.CONTINUE); } questTotalTime -= (1.5f * t); if (questTimer > 0) { questTimer -= t; return(EnumResult.CONTINUE); } int initQuestStep = questStep; //if(questStep >= obstacles.Length || questStep < 0) { //Debug.Log(this.heroName); //foreach(QuestChallenge o in obstacles) { //Debug.Log(" " + o.type.name); //} //} QuestChallenge ob = obstacles[questStep]; List <ItemStack> used = new List <ItemStack>(); while (questTotalTime <= 0 && doesHeroHave(RequirementType.MANA)) { if (doesHeroHave(AidType.MANA_LARGE, ref used)) { questTotalTime += 360; } else if (doesHeroHave(AidType.MANA_MEDIUM, ref used)) { questTotalTime += 270; } else if (doesHeroHave(AidType.MANA_SMALL, ref used)) { questTotalTime += 180; } else if (doesHeroHave(AidType.MANA_TINY, ref used)) { questTotalTime += 90; } else { break; } } int healing = 0; foreach (ItemStack st in used) { healing += (st.doesStackHave(AidType.HEALING_TINY) ? 5 : 0); healing += (st.doesStackHave(AidType.HEALING_SMALL) ? 7 : 0); healing += (st.doesStackHave(AidType.HEALING_MEDIUM) ? 15 : 0); healing += (st.doesStackHave(AidType.HEALING_LARGE) ? 25 : 0); } heal(healing); if (questTotalTime <= 0 || heroCurHealth <= 0) { //hero dies //Debug.Log("FAIL " + heroName + ": " + ob.type.name + " | " + questTotalTime + ", " + heroCurHealth); object corwrap; int cor = 0; if (miscData != null && miscData.TryGetValue("cursed_corruption", out corwrap)) { cor = (int)corwrap; //Debug.Log("Corrupted: " + doesHeroHave(RequirementType.SPELL_RESIST) + ", " + cor); } Main.instance.player.getActiveDeepGoal().onFailedQuest(this); //Debug.Log(" " + obstacles[questStep-1].type.name); return(EnumResult.FAIL); } //Debug.Log("Hero is " + ob.type.desc); int fails = 0; int partials = 0; RequirementType lastType = 0; ItemStack lastStack = null; ItemStack altStack = null; //RequirementType statPot = RequirementType.AGILITY | RequirementType.STRENGTH | RequirementType.CHARISMA | RequirementType.INTELLIGENCE; foreach (RequireWrapper rw in ob.type.requirements) { bool foundAlt = false; bool altIsConsumed = true; foreach (ItemStack stack in inventory) { //forces requiring two *different* stacks for same-type requirements if not consumable if (lastType == rw.req && (stack == lastStack /*&& stack.item.isConsumable*/)) { continue; } lastStack = stack; if (stack.item.hasReqType(rw.req) && stack.stackSize > 0) { if (stack.item.isConsumable) { stack.stackSize--; } stack.onUsedDuringQuest(this); goto ObsList; } if (stack.item.hasReqType(rw.alt) && stack.stackSize > 0) { foundAlt = true; //alt items are ok, but we'd rather find the required one altStack = stack; altIsConsumed = rw.req != 0; } } //this looks so janky //if the loop is exited normally, inc failure or partials if (!foundAlt) { fails++; } else { //decrement used alt-type stack, as it was used if (altStack.item.isConsumable && altIsConsumed) { altStack.stackSize--; } altStack.onUsedDuringQuest(this); partials++; } //go here if success ObsList: //then check next requirement ; lastType = rw.req; } EnumResult result = ob.MakeAttempt(this, fails, partials); if (result == EnumResult.CRIT_FAIL && this.doesHeroHave(AidType.RETRY_FAILURE)) { result = ob.MakeAttempt(this, fails, partials); } ob.OnAttempt(result, this); questTimer += 60; questStep++; if (questStep > initQuestStep) { heal(5); } inventory.RemoveAll(x => x.stackSize <= 0); if (questStep >= obstacles.Length) { if (result < EnumResult.MIXED && ob.type is IQuestGoal) { //rare ending //Debug.Log("QUEST FAILURE " + ob.type.name + "|" + questTotalTime + "," + heroCurHealth); Main.instance.player.getActiveDeepGoal().onFailedQuest(this); return(EnumResult.FAIL); } //Debug.Log("SUCCESS " + ob.type.name + "|" + questTotalTime + "," + heroCurHealth); Main.instance.player.getActiveDeepGoal().onSuccessfulQuest(this); return(EnumResult.SUCCESS); } return(EnumResult.CONTINUE); }
public int getRangedDamage(EnumResult result, Quest theQuest, ref int questBonus, ItemStack rangedItem) { return(0); }
/** * * \param globals in globals are the global variables for the genetic algorithm stored * they can only be changed from the outside, but they can hold any information the genetic algorithm will/can need * for example * * current Index of Something * * current Frame * * ... * */ public abstract void call( List<Datastructures.Variadic> parameters, List<Datastructures.Variadic> globals, out Datastructures.Variadic result, out EnumResult resultCode );
public ReturnStatus(EnumResult result, string msg) { this.Status = result; this.Message = msg; }
private IActionResult CreateQueryResponse(IQueryable query, IEdmType edmType, ETag etag) { var typeReference = GetTypeReference(edmType); BaseSingleResult singleResult = null; IActionResult response = null; if (typeReference.IsPrimitive()) { if (shouldReturnCount || shouldWriteRawValue) { var rawResult = new RawResult(query, typeReference); singleResult = rawResult; response = Ok(rawResult); } else { var primitiveResult = new PrimitiveResult(query, typeReference); singleResult = primitiveResult; response = Ok(primitiveResult); } } if (typeReference.IsComplex()) { var complexResult = new ComplexResult(query, typeReference); singleResult = complexResult; response = Ok(complexResult); } if (typeReference.IsEnum()) { if (shouldWriteRawValue) { var rawResult = new RawResult(query, typeReference); singleResult = rawResult; response = Ok(rawResult); } else { var enumResult = new EnumResult(query, typeReference); singleResult = enumResult; response = Ok(enumResult); } } if (singleResult != null) { if (singleResult.Result == null) { // Per specification, If the property is single-valued and has the null value, // the service responds with 204 No Content. return(NoContent()); } return(response); } if (typeReference.IsCollection()) { var elementType = typeReference.AsCollection().ElementType(); if (elementType.IsPrimitive() || elementType.IsEnum()) { return(Ok(new NonResourceCollectionResult(query, typeReference))); } return(Ok(new ResourceSetResult(query, typeReference))); } var entityResult = query.SingleOrDefault(); if (entityResult == null) { return(NoContent()); } // Check the ETag here if (etag != null) { // request with If-Match header, if match, then should return whole content // request with If-Match header, if not match, then should return 412 // request with If-None-Match header, if match, then should return 304 // request with If-None-Match header, if not match, then should return whole content etag.EntityType = query.ElementType; query = etag.ApplyTo(query); entityResult = query.SingleOrDefault(); if (entityResult == null && !etag.IsIfNoneMatch) { return(StatusCode((int)HttpStatusCode.PreconditionFailed)); } else if (entityResult == null) { return(StatusCode((int)HttpStatusCode.NotModified)); } } return(Ok(entityResult)); }