static Question GetQuestionInfoWeapon() { string[] eids = { "atf", "skill", "star", "attr" }; string[] cids = { "初始攻/防", "技能", "星级", "属性" }; int type = MathTool.GetRandom(eids.Length); int weaponId = WeaponBook.GetRandWeaponId(); Question question = new Question(); question.info = string.Format("|以下哪一个武器的{0}是|Yellow|{1}||?", cids[type], WeaponBook.GetAttrByString(weaponId, eids[type])); question.ans = new string[4]; question.ans[MathTool.GetRandom(4)] = ConfigData.GetWeaponConfig(weaponId).Name; int idx = 0; SimpleSet <string> set = new SimpleSet <string>(); set.Add(WeaponBook.GetAttrByString(weaponId, eids[type])); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = WeaponBook.GetRandWeaponId(); if (!set.Has(ConfigData.GetWeaponConfig(guessId).Name) && WeaponBook.GetAttrByString(guessId, eids[type]) != WeaponBook.GetAttrByString(weaponId, eids[type])) { question.ans[idx] = ConfigData.GetWeaponConfig(guessId).Name; set.Add(ConfigData.GetWeaponConfig(guessId).Name); idx++; } } question.result = ConfigData.GetWeaponConfig(weaponId).Name; return(question); }
static Question GetQuestionMonsterInfo() { string[] eids = { "hp", "race", "star", "type","atk","def"}; string[] cids = { "初始生命值", "种族", "星级", "属性", "初始攻击", "初始防御" }; int type = MathTool.GetRandom(eids.Length); int monsterId = MonsterBook.GetRandMonsterId(); Question question = new Question(); question.info = string.Format("|怪物|Red|{0}||的{1}是?", ConfigData.GetMonsterConfig(monsterId).Name, cids[type]); question.ans = new string[4]; question.ans[MathTool.GetRandom(4)] = MonsterBook.GetAttrByString(monsterId, eids[type]); int idx = 0; SimpleSet<string> set = new SimpleSet<string>(); set.Add(MonsterBook.GetAttrByString(monsterId, eids[type])); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = MonsterBook.GetRandMonsterId(); string guessStr = MonsterBook.GetAttrByString(guessId, eids[type]); if (!set.Has(guessStr)) { question.ans[idx] = guessStr; set.Add(guessStr); idx++; } } question.result = MonsterBook.GetAttrByString(monsterId, eids[type]); return question; }
static Question GetQuestionInfoMonster() { string[] eids = { "hp", "race", "star", "type", "atk", "def" }; string[] cids = { "初始生命值", "种族", "星级", "属性", "初始攻击", "初始防御" }; int type = MathTool.GetRandom(eids.Length); MonsterConfig monsterConfig = ConfigData.GetMonsterConfig(MonsterBook.GetRandMonsterId()); Question question = new Question(); question.info = string.Format("|以下哪一个怪物的{0}是|Yellow|{1}||?", cids[type], MonsterBook.GetAttrByString(monsterConfig.Id, eids[type])); question.ans = new string[4]; question.ans[MathTool.GetRandom(4)] = monsterConfig.Name; int idx = 0; SimpleSet <string> set = new SimpleSet <string>(); set.Add(MonsterBook.GetAttrByString(monsterConfig.Id, eids[type])); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } MonsterConfig guessConfig = ConfigData.GetMonsterConfig(MonsterBook.GetRandMonsterId()); if (!set.Has(guessConfig.Name) && MonsterBook.GetAttrByString(monsterConfig.Id, eids[type]) != MonsterBook.GetAttrByString(guessConfig.Id, eids[type])) { question.ans[idx] = guessConfig.Name; set.Add(guessConfig.Name); idx++; } } question.result = monsterConfig.Name; return(question); }
public void AddingContainedElementThrowsException() { var set = new SimpleSet <object>(); var member = new TestMember("hello"); set.Add(member); Assert.Catch(() => set.Add(member)); Assert.True(set.Contains(member)); }
public void CannotAddNull() { var set = new SimpleSet <object>(); set.Add("cannot"); set.Add("add"); Assert.Catch <ArgumentNullException>(() => set.Add(null)); // but can test for null: it's always false Assert.False(set.Contains(null)); }
private void AppendLevelContent(FunctionGroup level, bool isNamespaceLevel) { level.MakeConcrete(); foreach (FunctionGroupName gname in level.functions) { // Check if the object belongs to the included namespace level bool isNamespace = gname.IsNamespaceLevel || isNamespaceLevel; // Read the name data. FunctionType type = gname.GetFunctionType(); bool isStatic = gname.IsStatic(); // Find a similar group. FunctionGroupName old = Find(gname); if (old == null) { FunctionGroupName newName = new FunctionGroupName(type, isStatic); newName.IsNamespaceLevel = isNamespace; newName.SetFunction(gname.GetFunction()); functions.Add(newName); continue; } // Ignore names of lower scopes. if (!isNamespace || !old.IsNamespaceLevel) { continue; } // Now the old name is a namespace level, and we are adding another // namespace level function, in other words, we have detected an ambiguity. Function oldFunction = old.GetFunction(); FunctionAmbiguity amb; if (!oldFunction.IsAmbiguity()) { amb = new FunctionAmbiguity(oldFunction.GetName(), oldFunction.GetFlags(), oldFunction.GetParentScope()); amb.AddCandidate(oldFunction); old.SetFunction(amb); } else { amb = (FunctionAmbiguity)oldFunction; } // Add the new function into the ambiguity list. amb.AddCandidate(gname.GetFunction()); } }
static Question GetQuestionInfoMonster() { string[] eids = { "hp", "race", "star", "type", "atk", "def" }; string[] cids = { "初始生命值", "种族", "星级", "属性", "初始攻击", "初始防御" }; int type = MathTool.GetRandom(eids.Length); MonsterConfig monsterConfig = ConfigData.GetMonsterConfig(MonsterBook.GetRandMonsterId()); Question question = new Question(); question.info = string.Format("|以下哪一个怪物的{0}是|Yellow|{1}||?", cids[type], MonsterBook.GetAttrByString(monsterConfig.Id, eids[type])); question.ans = new string[4]; question.ans[MathTool.GetRandom(4)] = monsterConfig.Name; int idx = 0; SimpleSet<string> set = new SimpleSet<string>(); set.Add(MonsterBook.GetAttrByString(monsterConfig.Id, eids[type])); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } MonsterConfig guessConfig = ConfigData.GetMonsterConfig(MonsterBook.GetRandMonsterId()); if (!set.Has(guessConfig.Name) && MonsterBook.GetAttrByString(monsterConfig.Id, eids[type]) != MonsterBook.GetAttrByString(guessConfig.Id, eids[type])) { question.ans[idx] = guessConfig.Name; set.Add(guessConfig.Name); idx++; } } question.result = monsterConfig.Name; return question; }
public void ReferenceEqualityTest() { var set = new SimpleSet <TestMember>(); var theObject = new TestMember("hello"); var equalObject = new TestMember("HELLO"); Assert.IsTrue(theObject.Equals(equalObject)); Assert.IsFalse(theObject == equalObject); set.Add(theObject); TestMember containedObject; bool isContained = set.Contains(equalObject, out containedObject); Assert.IsTrue(isContained); Assert.IsTrue(containedObject.Equals(equalObject)); Assert.IsTrue(containedObject == theObject); Assert.IsTrue(containedObject != equalObject); bool isChanged = set.TryAdd(equalObject, out containedObject); Assert.IsFalse(isChanged); Assert.IsTrue(containedObject.Equals(equalObject)); Assert.IsTrue(containedObject == theObject); Assert.IsTrue(containedObject != equalObject); TestMember removedObject; bool wasContained = set.Remove(equalObject, out removedObject); Assert.IsTrue(wasContained); Assert.IsTrue(removedObject.Equals(theObject)); Assert.IsTrue(removedObject == theObject); Assert.IsTrue(removedObject != equalObject); }
private static IEnumerable <Dataset> GetVerifiedDatasets( [NotNull] QualitySpecification qualitySpecification, [NotNull] IDatasetContext datasetContext) { var datasets = new SimpleSet <Dataset>(); foreach ( QualitySpecificationElement qualitySpecificationElement in qualitySpecification.Elements) { QualityCondition qualityCondition = qualitySpecificationElement.QualityCondition; if (qualityCondition == null) { continue; } foreach (Dataset dataset in qualityCondition.GetDatasetParameterValues()) { if (!datasets.Contains(dataset) && datasetContext.CanOpen(dataset)) { datasets.Add(dataset); } } } return(datasets); }
public void AppendLevel(TypeGroup level, bool isNamespaceLevel) { foreach (TypeGroupName gname in level.types) { // Check if the object belongs to the included namespace level bool isNamespace = gname.IsNamespaceLevel || isNamespaceLevel; // Add not found types. TypeGroupName old = Find(gname); if (old == null) { TypeGroupName newName = new TypeGroupName(gname); newName.IsNamespaceLevel = isNamespace; types.Add(newName); continue; } // Ignore names of lower scopes. if (!isNamespace || !old.IsNamespaceLevel) { continue; } // Now the old name is a namespace level, and we are adding another // namespace level type, in other words, we have detected an ambiguity. Structure oldType = old.GetBuilding(); AmbiguousStructure amb; if (!oldType.IsAmbiguity()) { amb = new AmbiguousStructure(oldType.GetName(), oldType.GetFlags(), oldType.GetParentScope()); amb.AddCandidate(oldType); old.SetBuilding(oldType); } else { amb = (AmbiguousStructure)oldType; } // Add the new function into the ambiguity list. amb.AddCandidate(gname.GetBuilding()); } }
private int CheckDuplicateDescriptions( [NotNull] IEnumerable <DomainUsage> domainUsages) { Assert.ArgumentNotNull(domainUsages, nameof(domainUsages)); IWorkspace targetWorkspace = DatasetUtils.GetWorkspace(_targetWorkspaceTable ?? _table); // TODO also search for duplicates in the source workspace? Or would this be a separate test instance? Dictionary <string, List <IDomain> > domainsByDescription = GetDomainsByDescription(targetWorkspace); var descriptions = new SimpleSet <string>(StringComparer.InvariantCultureIgnoreCase); foreach (DomainUsage domainUsage in domainUsages) { string description = domainUsage.Domain.Description; if (description != null && !descriptions.Contains(description)) { descriptions.Add(description); } } int errorCount = 0; foreach (string domainDescription in descriptions) { List <IDomain> domainsWithSameDescription; if (!domainsByDescription.TryGetValue(domainDescription, out domainsWithSameDescription)) { continue; } if (domainsWithSameDescription.Count <= 1) { continue; } string description = string.Format( LocalizableStrings .QaSchemaFieldDomainDescriptions_DomainDescriptionNotUnique, domainDescription, StringUtils.Concatenate(GetDomainNames(domainsWithSameDescription), ", ")); errorCount += ReportSchemaError(Codes[Code.NotUnique], description); } return(errorCount); }
static Question GetQuestionWeaponInfo() { string[] eids = { "atf", "skill", "star", "attr" }; string[] cids = { "初始攻/防", "技能", "星级", "属性" }; int type = MathTool.GetRandom(eids.Length); int weaponId = WeaponBook.GetRandWeaponId(); Question question = new Question(); question.info = string.Format("|武器|Green|{0}||的{1}是?", ConfigData.GetWeaponConfig(weaponId).Name, cids[type]); question.ans = new string[4]; string weaponStr = WeaponBook.GetAttrByString(weaponId, eids[type]); question.ans[MathTool.GetRandom(4)] = weaponStr; int idx = 0; SimpleSet <string> set = new SimpleSet <string>(); set.Add(weaponStr); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = WeaponBook.GetRandWeaponId(); string guessStr = WeaponBook.GetAttrByString(guessId, eids[type]); if (!set.Has(guessStr)) { question.ans[idx] = guessStr; set.Add(guessStr); idx++; } } question.result = weaponStr; return(question); }
static Question GetQuestionSpellInfo() { string[] eids = { "star", "des" }; string[] cids = { "星级", "描述" }; int type = MathTool.GetRandom(eids.Length); int spellId = SpellBook.GetRandSpellId(); Question question = new Question(); question.info = string.Format("|魔法|Blue|{0}||的{1}是?", ConfigData.GetSpellConfig(spellId).Name, cids[type]); question.ans = new string[4]; string attrStr = SpellBook.GetAttrByString(spellId, eids[type]); question.ans[MathTool.GetRandom(4)] = attrStr; int idx = 0; SimpleSet <string> set = new SimpleSet <string>(); set.Add(attrStr); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = SpellBook.GetRandSpellId(); string guessStr = SpellBook.GetAttrByString(guessId, eids[type]); if (!set.Has(guessStr)) { question.ans[idx] = guessStr; set.Add(guessStr); idx++; } } question.result = attrStr; return(question); }
static Question GetQuestionSkillInfo() { string[] eids = { "type", "des" }; string[] cids = { "类型", "描述" }; int type = MathTool.GetRandom(eids.Length); SkillConfig luk = ConfigData.GetSkillConfig(SkillBook.GetRandSkillId()); Question question = new Question(); question.info = string.Format("|技能|Gold|{0}||的{1}是?", luk.Name, cids[type]); question.ans = new string[4]; string attrType = SkillBook.GetAttrByString(luk.Id, eids[type]); question.ans[MathTool.GetRandom(4)] = attrType; int idx = 0; SimpleSet <string> set = new SimpleSet <string>(); set.Add(SkillBook.GetAttrByString(luk.Id, eids[type])); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } SkillConfig guess = ConfigData.GetSkillConfig(SkillBook.GetRandSkillId()); string guessType = SkillBook.GetAttrByString(guess.Id, eids[type]); if (!set.Has(guessType)) { question.ans[idx] = guessType; set.Add(guessType); idx++; } } question.result = attrType; return(question); }
static Question GetQuestionInfoSpell() { string[] eids = { "star", "des" }; string[] cids = { "星级", "描述" }; int type = MathTool.GetRandom(eids.Length); int spellId = SpellBook.GetRandSpellId(); string attrStr = SpellBook.GetAttrByString(spellId, eids[type]); Question question = new Question(); question.info = string.Format("|以下哪一个魔法的{0}是|Yellow|{1}||?", cids[type], attrStr); question.ans = new string[4]; question.ans[MathTool.GetRandom(4)] = ConfigData.GetSpellConfig(spellId).Name; int idx = 0; SimpleSet <string> set = new SimpleSet <string>(); set.Add(attrStr); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = SpellBook.GetRandSpellId(); string guessStr = SpellBook.GetAttrByString(guessId, eids[type]); if (!set.Has(ConfigData.GetSpellConfig(guessId).Name) && guessStr != attrStr) { question.ans[idx] = ConfigData.GetSpellConfig(guessId).Name; set.Add(ConfigData.GetSpellConfig(guessId).Name); idx++; } } question.result = ConfigData.GetSpellConfig(spellId).Name; return(question); }
private int CheckUniqueNames([NotNull] DomainUsage domainUsage, [NotNull] ICollection <CodedValue> codedValues) { SimpleSet <string> uniqueNames = CreateUniqueNamesSet(_uniqueNamesConstraint); if (uniqueNames == null) { return(NoError); } var nonUniqueNames = new List <string>(); foreach (CodedValue codedValue in codedValues) { // gather non-unique names, uniqueness check will be done at end string name = codedValue.Name.Trim(); if (uniqueNames.Contains(name)) { nonUniqueNames.Add(name); } else { uniqueNames.Add(name); } } bool caseSensitive = _uniqueNamesConstraint == UniqueStringsConstraint.UniqueExactCase; int errorCount = 0; foreach (string nonUniqueName in nonUniqueNames) { string description = string.Format( "Name '{0}' in coded value domain '{1}' is non-unique. The following values have the same name: {2}", nonUniqueName, domainUsage.DomainName, StringUtils.Concatenate( GetValuesForName(nonUniqueName, codedValues, caseSensitive), ", ")); errorCount += ReportSchemaPropertyError(Codes[Code.NamesNotUnique], domainUsage.DomainName, new object[] { nonUniqueName }, description); } return(errorCount); }
static Question GetQuestionMonsterInfo() { string[] eids = { "hp", "race", "star", "type", "atk", "def" }; string[] cids = { "初始生命值", "种族", "星级", "属性", "初始攻击", "初始防御" }; int type = MathTool.GetRandom(eids.Length); int monsterId = MonsterBook.GetRandMonsterId(); Question question = new Question(); question.info = string.Format("|怪物|Red|{0}||的{1}是?", ConfigData.GetMonsterConfig(monsterId).Name, cids[type]); question.ans = new string[4]; question.ans[MathTool.GetRandom(4)] = MonsterBook.GetAttrByString(monsterId, eids[type]); int idx = 0; SimpleSet <string> set = new SimpleSet <string>(); set.Add(MonsterBook.GetAttrByString(monsterId, eids[type])); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = MonsterBook.GetRandMonsterId(); string guessStr = MonsterBook.GetAttrByString(guessId, eids[type]); if (!set.Has(guessStr)) { question.ans[idx] = guessStr; set.Add(guessStr); idx++; } } question.result = MonsterBook.GetAttrByString(monsterId, eids[type]); return(question); }
public bool Contains([NotNull] QualityCondition qualityCondition) { if (_qualityConditions == null) { IList <QualitySpecificationElement> elements = _qualitySpecification.Elements; _qualityConditions = new SimpleSet <QualityCondition>(elements.Count); foreach (QualitySpecificationElement element in elements) { _qualityConditions.Add(element.QualityCondition); } } return(_qualityConditions.Contains(qualityCondition)); }
public void AddIssue(Issue issue, IGeometry errorGeometry) { QualityCondition qualityCondition = issue.QualityCondition; if (_processedQualityConditions.Contains(qualityCondition.Name)) { return; } _processedQualityConditions.Add(qualityCondition.Name); foreach (Dataset dataset in qualityCondition.GetDatasetParameterValues()) { _involvedDatasets.TryAdd(dataset); } }
private static void AssertUniqueFieldNames( [NotNull] IEnumerable <FieldSpecification> fieldSpecifications) { var fieldNames = new SimpleSet <string>(StringComparer.InvariantCultureIgnoreCase); foreach (FieldSpecification fieldSpecification in fieldSpecifications) { if (fieldNames.Contains(fieldSpecification.FieldName)) { Assert.Fail( "There exists more than one field specification for field name '{0}'", fieldSpecification.FieldName); } fieldNames.Add(fieldSpecification.FieldName); } }
private static SortableBindingList <VerifiedDatasetItem> GetVerifiedDatasetItems( [NotNull] QualityVerification qualityVerification, [NotNull] Predicate <QualityConditionVerification> includeConditionVerification, out double maximumTime) { var result = new SortableBindingList <VerifiedDatasetItem>(); maximumTime = 0; foreach ( QualityConditionVerification conditionVerification in qualityVerification.ConditionVerifications) { if (!includeConditionVerification(conditionVerification)) { continue; } var datasets = new SimpleSet <Dataset>(); QualityCondition condition = conditionVerification.DisplayableCondition; foreach (Dataset dataset in condition.GetDatasetParameterValues()) { if (datasets.Contains(dataset)) { continue; } datasets.Add(dataset); VerifiedDatasetItem item = CreateVerifiedDatasetItem( qualityVerification, dataset, conditionVerification); if (item.TotalTime > maximumTime) { maximumTime = item.TotalTime; } result.Add(item); } } return(result); }
public void DeleteOrphanedErrors(bool deleteErrorsForUnreferencedQualityConditions) { var totalCount = 0; string message = deleteErrorsForUnreferencedQualityConditions ? "Deleting orphaned issues (including issues for unreferenced quality conditions)" : "Deleting orphaned issues"; using (_msg.IncrementIndentation(message)) { IQueryFilter filter = CreateIssueDeletionFilter(null, FieldNameErrorType); var qualityConditionIds = new SimpleSet <int>(); foreach ( QualityCondition qualityCondition in GetActiveQualityConditions(_qualityConditionRepository, deleteErrorsForUnreferencedQualityConditions)) { qualityConditionIds.Add(qualityCondition.Id); } // delete all errors that don't belong to a condition in the list foreach (IssueDatasetWriter issueWriter in IssueDatasets.GetIssueWriters()) { totalCount += issueWriter.DeleteOrphanedErrorObjects(filter, qualityConditionIds); } } _msg.InfoFormat(totalCount != 1 ? "{0:N0} orphaned issues have been deleted" : "{0:N0} orphaned issue has been deleted", totalCount); }
static Question GetQuestionSpellInfo() { string[] eids = { "star", "des"}; string[] cids = { "星级", "描述"}; int type = MathTool.GetRandom(eids.Length); int spellId = SpellBook.GetRandSpellId(); Question question = new Question(); question.info = string.Format("|魔法|Blue|{0}||的{1}是?", ConfigData.GetSpellConfig(spellId).Name, cids[type]); question.ans = new string[4]; string attrStr = SpellBook.GetAttrByString(spellId, eids[type]); question.ans[MathTool.GetRandom(4)] = attrStr; int idx = 0; SimpleSet<string> set = new SimpleSet<string>(); set.Add(attrStr); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = SpellBook.GetRandSpellId(); string guessStr = SpellBook.GetAttrByString(guessId, eids[type]); if (!set.Has(guessStr)) { question.ans[idx] = guessStr; set.Add(guessStr); idx++; } } question.result = attrStr; return question; }
static Question GetQuestionInfoSpell() { string[] eids = { "star", "des" }; string[] cids = { "星级", "描述" }; int type = MathTool.GetRandom(eids.Length); int spellId = SpellBook.GetRandSpellId(); string attrStr = SpellBook.GetAttrByString(spellId, eids[type]); Question question = new Question(); question.info = string.Format("|以下哪一个魔法的{0}是|Yellow|{1}||?", cids[type], attrStr); question.ans = new string[4]; question.ans[MathTool.GetRandom(4)] = ConfigData.GetSpellConfig(spellId).Name; int idx = 0; SimpleSet<string> set = new SimpleSet<string>(); set.Add(attrStr); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = SpellBook.GetRandSpellId(); string guessStr = SpellBook.GetAttrByString(guessId, eids[type]); if (!set.Has(ConfigData.GetSpellConfig(guessId).Name) && guessStr != attrStr) { question.ans[idx] = ConfigData.GetSpellConfig(guessId).Name; set.Add(ConfigData.GetSpellConfig(guessId).Name); idx++; } } question.result = ConfigData.GetSpellConfig(spellId).Name; return question; }
static Question GetQuestionInfoSkill() { string[] eids = { "type", "des" }; string[] cids = { "类型", "描述" }; int type = MathTool.GetRandom(eids.Length); SkillConfig luk = ConfigData.GetSkillConfig(SkillBook.GetRandSkillId()); Question question = new Question(); string attrType = SkillBook.GetAttrByString(luk.Id, eids[type]); question.info = string.Format("|以下哪一个技能的{0}是|Yellow|{1}||?", cids[type], attrType); question.ans = new string[4]; question.ans[MathTool.GetRandom(4)] = luk.Name; int idx = 0; SimpleSet<string> set = new SimpleSet<string>(); set.Add(attrType); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } SkillConfig guess = ConfigData.GetSkillConfig(SkillBook.GetRandSkillId()); string guessType = SkillBook.GetAttrByString(guess.Id, eids[type]); if (!set.Has(guess.Name) && guessType != attrType) { question.ans[idx] = guess.Name; set.Add(guess.Name); idx++; } } question.result = luk.Name; return question; }
static Question GetQuestionWeaponInfo() { string[] eids = { "atf", "skill", "star", "attr" }; string[] cids = { "初始攻/防", "技能", "星级", "属性" }; int type = MathTool.GetRandom(eids.Length); int weaponId = WeaponBook.GetRandWeaponId(); Question question = new Question(); question.info = string.Format("|武器|Green|{0}||的{1}是?", ConfigData.GetWeaponConfig(weaponId).Name, cids[type]); question.ans = new string[4]; string weaponStr = WeaponBook.GetAttrByString(weaponId, eids[type]); question.ans[MathTool.GetRandom(4)] = weaponStr; int idx = 0; SimpleSet<string> set = new SimpleSet<string>(); set.Add(weaponStr); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = WeaponBook.GetRandWeaponId(); string guessStr = WeaponBook.GetAttrByString(guessId, eids[type]); if (!set.Has(guessStr)) { question.ans[idx] = guessStr; set.Add(guessStr); idx++; } } question.result = weaponStr; return question; }
static void Main(string[] args) { SimpleSet <int> simpleSet1 = new SimpleSet <int>(); SimpleSet <int> simpleSet2 = new SimpleSet <int>(); SimpleSet <int> simpleSet3 = new SimpleSet <int>(); simpleSet1.Add(1); simpleSet1.Add(2); simpleSet1.Add(3); simpleSet1.Add(4); simpleSet1.Add(5); simpleSet2.Add(4); simpleSet2.Add(5); simpleSet2.Add(6); simpleSet2.Add(7); simpleSet3.Add(1); simpleSet3.Add(2); simpleSet3.Add(3); Console.WriteLine(); Console.WriteLine("Union: "); //1-2-3-5-4-5-6-7; Console.WriteLine(); foreach (var item in simpleSet1.Union(simpleSet2)) { Console.Write(item + " "); } Console.WriteLine(); Console.WriteLine("Difference: "); //1-2-3 Console.WriteLine(); foreach (var item in simpleSet1.Difference(simpleSet2)) { Console.Write(item + " "); } Console.WriteLine(); Console.WriteLine("Intersection: "); //4-5 Console.WriteLine(); foreach (int item in simpleSet2.Intersection(simpleSet1)) { Console.Write(item + " "); } Console.WriteLine(); Console.WriteLine("SubSet: " + simpleSet3.Subset(simpleSet1)); //True; Console.WriteLine(); Console.WriteLine(); Console.WriteLine("SymmetricDifference: "); //1-2-3-6-7 Console.WriteLine(); foreach (int item in simpleSet1.SymmetricDifference(simpleSet2)) { Console.Write(item + " "); } Console.ReadLine(); }
/// <summary> /// Adds an <see cref="ILimit"/> to the set of limits included in the composition /// </summary> /// <param name="limit"> /// The <see cref="ILimit"/> to add /// </param> public void AddLimit(ILimit limit) { limits.Add(limit); }
static Question GetQuestionInfoWeapon() { string[] eids = { "atf", "skill", "star", "attr" }; string[] cids = { "初始攻/防", "技能", "星级", "属性" }; int type = MathTool.GetRandom(eids.Length); int weaponId = WeaponBook.GetRandWeaponId(); Question question = new Question(); question.info = string.Format("|以下哪一个武器的{0}是|Yellow|{1}||?", cids[type], WeaponBook.GetAttrByString(weaponId, eids[type])); question.ans = new string[4]; question.ans[MathTool.GetRandom(4)] = ConfigData.GetWeaponConfig(weaponId).Name; int idx = 0; SimpleSet<string> set = new SimpleSet<string>(); set.Add(WeaponBook.GetAttrByString(weaponId, eids[type])); while (idx < 4) { if (question.ans[idx] != null) { idx++; continue; } int guessId = WeaponBook.GetRandWeaponId(); if (!set.Has(ConfigData.GetWeaponConfig(guessId).Name) && WeaponBook.GetAttrByString(guessId, eids[type]) != WeaponBook.GetAttrByString(weaponId, eids[type])) { question.ans[idx] = ConfigData.GetWeaponConfig(guessId).Name; set.Add(ConfigData.GetWeaponConfig(guessId).Name); idx++; } } question.result = ConfigData.GetWeaponConfig(weaponId).Name; return question; }