/// <summary> /// Generate an <see cref="AbstractItem"/> of the specified kind starting from a specified correct item. /// The every element of <see cref="E_ItemType"/> is associated an index of the <see cref="attPopulationMatrix"/> /// so that the vector corresponding to the passed index is used in creating the new <see cref="AbstractItem"/> /// </summary> /// <param name="CorrectItem">The <see cref="AbstractItem"/> which is considered as correct</param> /// <param name="ItemTypeToGenerate">The <see cref="E_ItemType"/> which must be generated</param> /// <returns></returns> private AbstractItem InvertByItemType(AbstractItem CorrectItem, E_ItemType ItemTypeToGenerate) { ItemGraficalProperty wvIgp; AbstractItem wvInvertedAbstractItem = new AbstractItem(ItemTypeToGenerate, CorrectItem.ItemKind); bool[] wvVctor = attPopulationMatrix[(int)ItemTypeToGenerate]; for(int i = 0; i<CorrectItem.PropertiesCount; i++) { ItemGraficalProperty wvProperty = new ItemGraficalProperty(); wvIgp = CorrectItem.ItemProperties[i]; if(wvVctor[i]) { wvProperty.SetContent(wvIgp.PropertyKind, wvIgp.Content); } else { wvProperty.SetContent(InvertProperty(wvIgp)); } wvInvertedAbstractItem.AddProperty(wvProperty); } return wvInvertedAbstractItem; }
public Game GetGameForProf() { string wvPlayerID = "15-01-2016-10-50-42_alberto"; string wvPlayerName = "alberto"; ItemGraficalProperty wvProperty = new ItemGraficalProperty(); Solution wvSolution = new Solution(); List<Room> wvRooms = new List<Room>(); List<Item> wvItems; AbstractItem wvAbstract; wvRooms.Add(new Room(E_RoomsName.START_ROOM)); #region Room = LIVINGROOM wvItems = new List<Item>(); #region A -> ID 19 wvAbstract = new AbstractItem(E_ItemType.A, E_ItemKind.TROUSERS); wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.BLUE); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.LIGHT); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.SCOTTISH); wvAbstract.AddProperty(wvProperty); wvItems.Add(GetItem(wvAbstract, E_Items.AOne)); wvSolution.AddItem(wvAbstract); #endregion #region B One -> 18 wvAbstract = new AbstractItem(E_ItemType.B, E_ItemKind.TROUSERS); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.BLUE); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.LIGHT); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.PLAINCOLOR); wvAbstract.AddProperty(wvProperty); wvItems.Add(GetItem(wvAbstract, E_Items.BOne)); #endregion wvRooms.Add(new Room(E_RoomsName.LIVINGROOM, wvItems)); #endregion #region Room = KITCHEN wvItems = new List<Item>(); #region A Two -> 71 wvAbstract = new AbstractItem(E_ItemType.A, E_ItemKind.HAT); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.GREEN); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.DARK); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.STRIPES); wvAbstract.AddProperty(wvProperty); wvSolution.AddItem(wvAbstract); wvItems.Add(GetItem(wvAbstract, E_Items.ATwo)); #endregion #region B Two -> 68 wvAbstract = new AbstractItem(E_ItemType.B, E_ItemKind.HAT); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.GREEN); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.DARK); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.POIS); wvAbstract.AddProperty(wvProperty); wvItems.Add(GetItem(wvAbstract, E_Items.BTwo)); #endregion wvRooms.Add(new Room(E_RoomsName.KITCHEN, wvItems)); #endregion #region Room = BEDROOM wvItems = new List<Item>(); #region A Three -> 127 wvAbstract = new AbstractItem(E_ItemType.A, E_ItemKind.T_SHIRT); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.PURPLE); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.LIGHT); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.POIS); wvAbstract.AddProperty(wvProperty); wvSolution.AddItem(wvAbstract); wvItems.Add(GetItem(wvAbstract, E_Items.AThree)); #endregion #region B Three -> 121 wvAbstract = new AbstractItem(E_ItemType.B, E_ItemKind.T_SHIRT); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.COLOR, E_Color.PURPLE); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.GRADIATION, E_Gradiation.LIGHT); wvAbstract.AddProperty(wvProperty); wvProperty = new ItemGraficalProperty(); wvProperty.SetContent(E_PropertiesKind.TEXTURE, E_Texture.FLOWERS); wvAbstract.AddProperty(wvProperty); wvItems.Add(GetItem(wvAbstract, E_Items.BThree)); #endregion wvRooms.Add(new Room(E_RoomsName.BEDROOM, wvItems)); #endregion //return null; return new Game(wvPlayerID, wvPlayerName, wvRooms, wvSolution); }
/// <summary> /// Generate an <see cref="AbstractItem"/> that is correct for the game solution /// </summary> /// <param name="ItemKind"></param> /// <returns></returns> private AbstractItem GenerateCorrectAbstractItem(E_ItemKind ItemKind) { int wvRandom; E_Gradiation wvGradiation; E_Shape wvShape; E_Color wvColor; E_Texture wvTexture; AbstractItem wvAbstractItem = new AbstractItem(E_ItemType.A, ItemKind); ItemGraficalProperty wvProperty = new ItemGraficalProperty(); List <E_PropertiesKind> wvPropertiesKind = new List<E_PropertiesKind>(); wvRandom = attRandom.Next((int)E_PropertiesKind._NULL + 1 ,(int)E_PropertiesKind._END); if (ItemKind == E_ItemKind.HAT)//Because in our DB only HATS have the E_PropertyKind.SHAPE implemented { for (int i = (int)E_PropertiesKind._NULL + 1; i < (int)E_PropertiesKind._END ; i++) { if (i != wvRandom) wvPropertiesKind.Add((E_PropertiesKind)i); } } else { for (int i = (int)E_PropertiesKind._NULL + 1; i < (int)E_PropertiesKind._END; i++) { if (i != (int)E_PropertiesKind.SHAPE) wvPropertiesKind.Add((E_PropertiesKind)i); } } wvGradiation = E_Gradiation._NULL; foreach (E_PropertiesKind pk in wvPropertiesKind) { wvProperty = new ItemGraficalProperty(); switch (pk) { case E_PropertiesKind.COLOR: #region Color from Gradiation List<E_Color> wvColors = new List<E_Color>(); if(wvGradiation == E_Gradiation._NULL)//This because is no possible to have WHITE items with DARK graiation or DARK item with LIGHT gradaition { for (int i = (int)E_Color._NULL + 1; i < (int)E_Color._END; i++) { wvColors.Add((E_Color)i); } } else { for (int i = (int)E_Color._NULL + 1; i < (int)E_Color._END; i++) { if ((E_Color)i != E_Color.BLACK && (E_Color)i != E_Color.WHITE) wvColors.Add((E_Color)i); } } wvRandom = attRandom.Next(wvColors.Count); wvColor = wvColors[wvRandom]; #endregion wvProperty.SetContent(pk, wvColor); break; case E_PropertiesKind.GRADIATION: wvRandom = attRandom.Next(1 + (int)E_Gradiation._NULL, (int)E_Gradiation._END); wvGradiation = (E_Gradiation)wvRandom; wvProperty.SetContent(pk, wvGradiation); break; case E_PropertiesKind.SHAPE: wvRandom = attRandom.Next(1 + (int)E_Shape._NULL, (int)E_Shape._END); wvShape = (E_Shape)wvRandom; wvProperty.SetContent(pk, wvShape); break; default: //TEXTURE wvRandom = attRandom.Next(1 + (int)E_Texture._NULL, (int)E_Texture._END); wvTexture = (E_Texture)wvRandom; wvProperty.SetContent(pk, wvTexture); break; } wvAbstractItem.AddProperty(wvProperty); } return wvAbstractItem; }