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; }
protected FunctionGroup(ChelaModule module) : base(module) { this.name = string.Empty; this.parentScope = null; this.functions = new SimpleSet <FunctionGroupName> (); }
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); }
private static void Main(string[] args) { Console.WriteLine("***** Fun with Set *****"); var simpleSet1 = new SimpleSet <int>(new int[] { 1, 2, 3, 4, 5 }); var simpleSet2 = new SimpleSet <int>(new int[] { 4, 5, 6, 7, 8 }); var simpleSet3 = new SimpleSet <int>(new int[] { 3, 4, 5 }); }
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); }
public static Dictionary <Table, List <long> > GetDistinctSelectionByTable( [NotNull] IEnumerable <BasicFeatureLayer> layers) { var result = new Dictionary <Table, SimpleSet <long> >(); var distinctTableIds = new Dictionary <GdbTableIdentity, Table>(); foreach (BasicFeatureLayer layer in layers.Where(HasSelection)) { IReadOnlyList <long> selection = layer.GetSelection().GetObjectIDs(); Table table = layer.GetTable(); var tableId = new GdbTableIdentity(table); if (!distinctTableIds.ContainsKey(tableId)) { distinctTableIds.Add(tableId, table); result.Add(table, new SimpleSet <long>(selection)); } else { Table distinctTable = distinctTableIds[tableId]; SimpleSet <long> ids = result[distinctTable]; foreach (long id in selection) { ids.TryAdd(id); } } } return(result.ToDictionary(pair => pair.Key, pair => pair.Value.ToList())); }
/// <summary> /// Add new layout's set and add vertex to one /// </summary> /// <param name="vertex2D"></param> public void AddNewSet(Vertex2D vertex2D) { IVisualSet visualSet = null; switch (vertex2D.VertexType) { case VertexType.Vertex: visualSet = new SimpleSet(); break; case VertexType.Brush: visualSet = new BrushSet(); break; case VertexType.Eraser: visualSet = new EraserSet(); break; case VertexType.Image: visualSet = new ImageSet(); break; case VertexType.Spline: visualSet = IsInstrumentChanged ? new SplineSet() : vertex2Ds.Last(x => x is SplineSet); IsInstrumentChanged = false; break; } visualSet?.Add(vertex2D); if (visualSet != null) { vertex2Ds.Add(visualSet); } }
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 CoreTestSimpleCollection() { var source = SimpleSet.Create(10); source.VerySimpleClasses[0] = null; Run(source, x => new DTO.SimpleSet(x)); }
public List <SimpleSet> GetSetNames() { var requestPath = $"/sets"; var request = new RestRequest(requestPath, DataFormat.Json); var jsonString = _client.Get(request).Content; var setData = SetContainer.FromJson(jsonString); var sets = setData.Sets; var simpleSets = new List <SimpleSet>(); foreach (var set in sets) { var simpleSet = new SimpleSet { Name = set.Name, Id = set.Id, SetCode = set.Code }; simpleSets.Add(simpleSet); } return(simpleSets); }
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); }
protected FunctionGroup(ChelaModule module) : base(module) { this.name = string.Empty; this.parentScope = null; this.functions = new SimpleSet<FunctionGroupName> (); }
public static void solve2() { int N = 100; Console.WriteLine("Print two sets"); SimpleSet a1 = new SimpleSet(N); SimpleSet b1 = new SimpleSet(N); Bitset a2 = new Bitset(N); Bitset b2 = new Bitset(N); string st = Console.ReadLine(); a1.Build(st); a2.Build(st); st = Console.ReadLine(); b1.Build(st); b2.Build(st); var c1 = a1 + b1; c1.Print(); var d1 = a1 * b1; d1.Print(); var c2 = a2 + b2; c2.Print(); var d2 = a2 * b2; d2.Print(); }
protected TypeGroup(TypeGroup group) : base(group.GetModule()) { this.name = group.name; this.fullName = null; this.parentScope = group.GetParentScope(); this.types = new SimpleSet<TypeGroupName> (); }
protected TypeGroup(ChelaModule module) : base(module) { this.name = string.Empty; this.fullName = null; this.parentScope = null; this.types = new SimpleSet <TypeGroupName> (); }
protected TypeGroup(TypeGroup group) : base(group.GetModule()) { this.name = group.name; this.fullName = null; this.parentScope = group.GetParentScope(); this.types = new SimpleSet <TypeGroupName> (); }
protected TypeGroup(ChelaModule module) : base(module) { this.name = string.Empty; this.fullName = null; this.parentScope = null; this.types = new SimpleSet<TypeGroupName> (); }
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 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); }
public void AddingIntsTest() { var set = new SimpleSet <int> { 1, 2, 3 }; Assert.AreEqual(3, set.Count); Assert.IsTrue(set.Contains(1)); Assert.IsTrue(set.Contains(2)); Assert.IsTrue(set.Contains(3)); Assert.IsFalse(set.Contains(4)); }
public static SimpleSet operator *(SimpleSet a, SimpleSet b) { SimpleSet ans = new SimpleSet(Math.Min(a.MaxVal, b.MaxVal)); for (int i = 1; i <= Math.Min(a.MaxVal, b.MaxVal); i++) { if (a.CheckEl(i) && b.CheckEl(i)) { ans.AddEl(i); } } return(ans); }
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); }
private static IDictionary GetHierarchic( [NotNull] ICollection <SpecificationDataset> allSpecList, [NotNull] IComparer <DatasetCategoryItem> categoryComparer, [NotNull] IComparer <Dataset> datasetComparer, [NotNull] IComparer <SpecificationDataset> specificationDatasetComparer) { IDictionary categoryList = GetDatasetCategories(allSpecList, categoryComparer, datasetComparer); foreach (SpecificationDataset specificationDataset in allSpecList) { QualityCondition condition = specificationDataset.QualityCondition; if (condition == null) { continue; } foreach (Dataset dataset in condition.GetDatasetParameterValues()) { var datasetList = (IDictionary)categoryList[new DatasetCategoryItem( dataset.DatasetCategory)]; if (datasetList.Contains(dataset)) { continue; } var datasetDict = new Dictionary <object, object>(); var parentDatasets = new SimpleSet <Dataset> { dataset }; ICollection <SpecificationDataset> specificationDatasets = GetSpecifiations(allSpecList, parentDatasets); GetHierarchic(datasetDict, specificationDatasets, parentDatasets, datasetComparer, specificationDatasetComparer, 0); datasetList.Add(dataset, datasetDict); } } SortSpecifications(categoryList, specificationDatasetComparer); return(categoryList); }
static void Main(string[] args) { Person gg = new Person("Peter"); //BigTrouser a = new BigTrouser(); //Suit b = new Suit(); //Tie c = new Tie(); //a.Decorate(gg); //b.Decorate(a); //c.Decorate(b); //c.Show(); SimpleSet ss = new SimpleSet(); ss.Show(); Console.ReadLine(); }
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)); }
private SimpleSet <string> GetVerifiedDatasetNames() { var result = new SimpleSet <string>(StringComparer.OrdinalIgnoreCase); foreach (QualitySpecificationElement element in _qualitySpecification.Elements) { QualityCondition qualityCondition = element.QualityCondition; foreach (Dataset dataset in qualityCondition.GetDatasetParameterValues()) { // TODO REFACTORMODEL result.TryAdd(dataset.Name.ToUpper()); } } return(result); }
/// <summary> /// Initializes a new instance of the <see cref="QualitySpecification"/> class. /// </summary> /// <param name="qualitySpecification">The quality specification.</param> /// <param name="polygon">The area in the spatial reference of the data model.</param> /// <param name="editableDatasets">The editable datasets.</param> public AreaSpecification([NotNull] QualitySpecification qualitySpecification, [NotNull] IPolygon polygon, [NotNull] IEnumerable <Dataset> editableDatasets) { Assert.ArgumentNotNull(qualitySpecification, nameof(qualitySpecification)); Assert.ArgumentNotNull(polygon, nameof(polygon)); Assert.ArgumentNotNull(editableDatasets, nameof(editableDatasets)); _qualitySpecification = qualitySpecification; SetPolygon(polygon); _editableDatasets = new SimpleSet <string>(StringComparer.OrdinalIgnoreCase); foreach (Dataset dataset in editableDatasets) { _editableDatasets.TryAdd(dataset.Name); } }
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); }
private static void Populate( Dictionary <GdbWorkspaceIdentity, SimpleSet <GdbTableIdentity> > tablesByWorkspace, ICollection <XmlWorkListWorkspace> list) { foreach (KeyValuePair <GdbWorkspaceIdentity, SimpleSet <GdbTableIdentity> > pair in tablesByWorkspace) { GdbWorkspaceIdentity workspace = pair.Key; SimpleSet <GdbTableIdentity> tables = pair.Value; var xmlWorkspace = new XmlWorkListWorkspace(); xmlWorkspace.Path = workspace.Path; xmlWorkspace.Tables = tables .Select(table => new XmlTableReference(table.Id, table.Name)) .ToList(); list.Add(xmlWorkspace); } }
private static IEnumerable <int> GetFieldIndicesFromIgnoredFieldNames( [NotNull] ITable table, [NotNull] IEnumerable <string> ignoredFieldNames) { var ignoredFields = new SimpleSet <string>( ignoredFieldNames, StringComparer.InvariantCultureIgnoreCase); int fieldIndex = 0; foreach (IField field in DatasetUtils.GetFields(table)) { if (field.Type == esriFieldType.esriFieldTypeString && !ignoredFields.Contains(field.Name)) { yield return(fieldIndex); } fieldIndex++; } }
private static IEnumerable <int> GetCompareFieldIndexesFromIgnoredFieldNames( [NotNull] IObjectClass objectClass, [NotNull] IEnumerable <string> ignoredFieldNames) { var ignoredFields = new SimpleSet <string>( ignoredFieldNames, StringComparer.InvariantCultureIgnoreCase); var fieldIndex = 0; foreach (IField field in DatasetUtils.GetFields(objectClass)) { if (field.Editable && IsSupportedCompareFieldType(field.Type) && !ignoredFields.Contains(field.Name)) { yield return(fieldIndex); } fieldIndex++; } }
static void Main(string[] args) { Init.InitHMapper(); Init.InitAutomapper(); Init.InitExpressMapper(); var test = AutoMapper.Mapper.Map <PolymorphicSubClass, DTO.PolymorphicSubClass>(PolymorphicSubClass.Create(5)); Run("Very simple class", VerySimpleClass.CreateMany(300000), x => new DTO.VerySimpleClass(x)); Run("Simple class", SimpleClass.CreateMany(40000), x => new DTO.SimpleClass(x)); Run("Simple set", SimpleSet.CreateMany(10000, 100), x => new DTO.SimpleSet(x)); Run("Multiple set", MultipleSets.CreateMany(1000, 100), x => new DTO.MultipleSets(x)); Run("Dictionary", DictionarySet.CreateMany(300, 100), x => new DTO.DictionarySet(x)); Run("Simple generic class of int", SimpleGeneric <int> .CreateMany(Enumerable.Range(1, 300000).Select(i => i).ToArray()), x => new DTO.SimpleGeneric <int>(x)); Run("Mapped object generic class", MappedObjectGeneric <VerySimpleClass> .CreateMany(VerySimpleClass.CreateMany(200000)), x => new DTO.MappedObjectGeneric <DTO.VerySimpleClass>(x)); Run("Multiple generic class", MultipleGenerics <int, string> .CreateMany(Enumerable.Range(1, 200000).Select(i => Tuple.Create(i, Guid.NewGuid().ToString())).ToArray()), x => new DTO.MultipleGenerics <string, int>(x)); Run("Polymorphic class", PolymorphicSubSubClass.CreateMany(300000), x => new DTO.PolymorphicSubClass(x)); Run("Set of polymorphic class", SetOfPolymorphic.CreateMany(150000), x => new DTO.SetOfPolymorphic(x)); Run("Generic of polymorphic class", MappedObjectGeneric <PolymorphicBaseClass> .CreateMany(PolymorphicBaseClass.CreateMany(200000)), x => new DTO.MappedObjectGeneric <DTO.PolymorphicBaseClass>(x)); Run("Set of generic polymorphic classes", SetOfGenericPolymorph.CreateMany(50000), x => new DTO.SetOfGenericPolymorph(x)); }
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; }
public override object Clone() { SimpleSet newObj = new SimpleSet(this); foreach (_ElementType v in this.ArrayList) newObj.ArrayList.Add(v); return newObj; }
private SimpleSet(SimpleSet c) : base(c) { }
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 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; }