Exemplo n.º 1
0
        public void Setup()
        {
            _fromInfo = typeof(Entity).GetProperty("SubEntities");
            _toInfo = typeof(Model).GetProperty("subEntities");

            _map = new ListMap();
            _map.ToComponents.Add(_toInfo);
            _map.FromComponents.Add(_fromInfo);

            _entity = new Entity
            {
                SubEntities = new List<SubEntity>
                                                {
                                                    new SubEntity
                                                        {
                                                            Name = "Dillon"
                                                        }
                                                }
            };

            _model = new Model
            {
                subEntities = new List<SubModel>
                                               {
                                                   new SubModel
                                                       {
                                                           name = "Not Dillon"
                                                       }
                                               }
            };
        }
Exemplo n.º 2
0
 // Get sources.
 static string[] GetSources(ListMap <string> args)
 {
     string[] o = null;
     if (args.ContainsKey(""))
     {
         o = new string[] { String.Join(" ", args[""].ToArray()) };
         if (args.ContainsKey("-s"))
         {
             o[0] = INLINE_SOURCE.Replace("%i", o[0]);
         }
         else if (!args.ContainsKey("-c"))
         {
             o[0] = INLINE_SOURCE.Replace("%i", "Console.WriteLine(" + o[0] + ")");
         }
     }
     else if (args.ContainsKey("-i"))
     {
         o = args["-i"].ToArray();
         for (int i = 0; i < o.Length; i++)
         {
             o[i] = File.ReadAllText(o[i]);
         }
     }
     return(o);
 }
Exemplo n.º 3
0
        private IEnumerable <HBaseCell> ProcessCfAsObject(ListMap map, ObjectAccessor accessor, string key,
                                                          IList <string> descriptors)
        {
            if (!(accessor[map.Name] is IList target))
            {
                return(new List <HBaseCell>());
            }

            var acc  = TypeAccessor.Create(map.ActingObjectType);
            var list = new ConcurrentBag <HBaseCell>();

            Parallel.ForEach((IEnumerable <object>)target, item =>
            {
                var fullName = $"{map.ColumnFamily}:{acc[item, map.ColumnName.name]}";
                if ((descriptors.Count > 0 && descriptors.Contains(fullName)) || descriptors.Count == 0)
                {
                    list.Add(new HBaseCell
                    {
                        FullColumnName = fullName,
                        ValueString    = acc[item, map.ColumnValue.name].ToString(),
                        RowKey         = key
                    });
                }
            });

            return(list);
        }
Exemplo n.º 4
0
        public LProcess(LGame game) : base()
        {
            this._game = game;
            LSetting setting = _game.setting;

            setting.UpdateScale();
            LSystem.viewSize.SetSize(setting.width, setting.height);
            this._bundle       = new ObjectBundle();
            this._currentInput = new SysInputFactory();
            this._screens      = new TArray <Screen>();
            this._screenMap    = new ListMap <string, Screen>();
            this.Clear();
            InputMake input = game.Input();

            if (input != null)
            {
                //这部分与Java版没必要1:1实现,因为XNA有TouchPanel.GetCapabilities().IsConnected方法判定是否支持触屏
                if (!game.setting.emulateTouch && !_game.Input().HasTouch())
                {
                    input.mouseEvents.Connect(new ButtonPort(this));
                }
                else
                {
                    input.touchEvents.Connect(new TouchPort(this));
                }
                input.keyboardEvents.Connect(new KeyPort(this));
            }
            game.status.Connect(new StatusPort(this));
        }
        private void EntireCfAsObject(ListMap map, ObjectAccessor accessor, Dictionary <byte[], TCell> input, ConcurrentDictionary <string, long> ts)
        {
            var targetedCells = input.Where(x => x.Key.StartsWith(map.ColumnFamily.GetBytes())).ToList();

            if (targetedCells.Count <= 0)
            {
                return;
            }

            var ltype = typeof(List <>).MakeGenericType(map.ActingObjectType);

            var list = (IList)Activator.CreateInstance(ltype);

            foreach (var targetedCell in targetedCells) //TODO: paralelize this?
            {
                var target         = Activator.CreateInstance(map.ActingObjectType);
                var targetAccessor = ObjectAccessor.Create(target);


                targetAccessor[map.ColumnName.name] =
                    GenerateValue(map.ColumnName.type, targetedCell.Key.GetString().RemoveCf(map.ColumnFamily));
                targetAccessor[map.ColumnValue.name] =
                    GenerateValue(map.ColumnValue.type, targetedCell.Value.Value.GetString());

                ts.TryAdd(targetedCell.Key.GetString(), targetedCell.Value.Timestamp);

                list.Add(target);
            }

            accessor[map.Name] = list;
        }
Exemplo n.º 6
0
 public void TakeHex_ShouldChangeTheOwnerProperty_WhenHexIsUnowned()
 {
     map = new ListMap(11);
     map.TakeHex(PlayerType.Blue, 1, 3);
     Assert.AreEqual(PlayerType.Blue, map.HexAt(1, 3).Owner);
     Assert.AreEqual(120, map.Board.Count(x => x.Owner == PlayerType.White));
 }
Exemplo n.º 7
0
        public void TakeHex_ShouldAttachAllMatrices_WhenAttachingToMultiples()
        {
            map = new ListMap(11);
            map.TakeHex(PlayerType.Red, 1, 1);
            map.TakeHex(PlayerType.Red, 1, 2);
            map.TakeHex(PlayerType.Red, 1, 3);
            map.TakeHex(PlayerType.Red, 1, 4);
            map.TakeHex(PlayerType.Red, 1, 5);

            map.TakeHex(PlayerType.Red, 1, 7);
            map.TakeHex(PlayerType.Red, 1, 8);
            map.TakeHex(PlayerType.Red, 1, 9);
            map.TakeHex(PlayerType.Red, 1, 10);

            Assert.AreEqual(112, map.Board.Count(x => x.Owner == PlayerType.White));

            Assert.AreSame(map.HexAt(1, 1).Attached, map.HexAt(1, 4).Attached);

            map.TakeHex(PlayerType.Red, 1, 6);
            Assert.AreSame(map.HexAt(1, 1).Attached, map.HexAt(1, 10).Attached);
            Assert.IsTrue(map.HexAt(1, 1).IsAttachedToRight);
            Assert.IsFalse(map.HexAt(1, 1).IsAttachedToLeft);
            map.TakeHex(PlayerType.Red, 1, 0);
            Assert.IsTrue(map.HexAt(1, 1).IsAttachedToLeft);
            Assert.IsTrue(map.HexAt(1, 1).IsAttachedToBothEnds());
        }
Exemplo n.º 8
0
        public void GetPlayerMatrix_ShouldBeAbleToMakeAMatrix_WhenCalledUpon()
        {
            map = new ListMap(11);
            map.TakeHex(PlayerType.Red, 1, 1);
            map.TakeHex(PlayerType.Red, 1, 2);
            map.TakeHex(PlayerType.Red, 1, 3);
            map.TakeHex(PlayerType.Red, 1, 4);
            map.TakeHex(PlayerType.Red, 1, 5);

            map.TakeHex(PlayerType.Blue, 1, 7);
            map.TakeHex(PlayerType.Blue, 1, 8);
            map.TakeHex(PlayerType.Blue, 1, 9);
            map.TakeHex(PlayerType.Blue, 1, 10);

            var blueMap = new ListMap(map.Size);

            blueMap.InjectFrom <CloneInjection>(map);

            var matrixForPlayer1 = blueMap.GetPlayerMatrix(PlayerType.Blue);

            TestContext.WriteLine("Player 1 matrix");
            TestContext.WriteLine(matrixForPlayer1.ToString());

            var matrixForPlayer2 = blueMap.GetPlayerMatrix(PlayerType.Red);

            TestContext.WriteLine("Player 2 matrix");
            TestContext.WriteLine(matrixForPlayer2.ToString());

            Assert.AreEqual(matrixForPlayer1, blueMap.HexAt(1, 7).Attached);
        }
Exemplo n.º 9
0
 public static void AddResourcesInDec(string key, List <NewsPreviewModel> instance)
 {
     if (!ListMap.ContainsKey(key))
     {
         ListMap.Add(key, instance);
     }
 }
Exemplo n.º 10
0
        public ActionResult ReturnMap()
        {
            List <ListMap>             map = new List <ListMap>();
            IEnumerable <ObjectCorona> tmp = null;
            string json = GetStr();

            if (json != "[]")
            {
                tmp = JsonConvert.DeserializeObject <IEnumerable <ObjectCorona> >(json);
            }
            if (tmp != null && tmp.Count() > 0)
            {
                foreach (var it in tmp)
                {
                    ListMap ite = new ListMap();
                    ite.cases   = it.cases;
                    ite.deaths  = it.deaths;
                    ite.country = it.country;
                    ite._long   = it.countryInfo._long;
                    ite.lat     = it.countryInfo.lat;
                    map.Add(ite);
                }
            }
            return(Json(map, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 11
0
        public void TakeHex_ShouldFail_IfHexAskedForIsOutOfBounds()
        {
            map = new ListMap(11);
            var didItWork = map.TakeHex(PlayerType.Blue, -13, 5000);

            Assert.AreEqual(false, didItWork);
            Assert.AreEqual(121, map.Board.Count(x => x.Owner == PlayerType.White));
        }
Exemplo n.º 12
0
        // Get invalid option details.
        static string GetInvalidOptions(ListMap <string> args)
        {
            StringBuilder str = new StringBuilder("invalid option(s): ");

            foreach (string opt in args["_invalid"])
            {
                str.Append(opt).Append(' ');
            }
            return(str.ToString());
        }
Exemplo n.º 13
0
 private void listView_Map_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         Point ms = new Point();
         ms.X = Control.MousePosition.X;
         ms.Y = Control.MousePosition.Y;
         ListMap.Show(ms);
     }
 }
Exemplo n.º 14
0
 public void TestListMapAddAndFind()
 {
     _listMap = _listMap.add("hello", 1);
     _listMap = _listMap.add("hello 2", 2);
     Assert.IsTrue(_listMap.contains("hello"));
     Assert.IsTrue(_listMap.contains("hello 2"));
     Assert.IsFalse(_listMap.contains("hello 3"));
     Assert.IsTrue(_listMap.contains("hello", 1));
     Assert.IsFalse(_listMap.contains("hello", 2));
 }
Exemplo n.º 15
0
        public void TestListMapAddAndGet()
        {
            _listMap = _listMap.add("hello", 1);
            _listMap = _listMap.add("hello 2", 2);
            Option <int> v = _listMap.get("hello");

            Assert.IsTrue(v is Some <int>);
            Assert.IsTrue(v.nonEmpty());
            Assert.AreEqual(1, ((Some <int>)v).get());
        }
Exemplo n.º 16
0
 public void TestListMapCheckSize()
 {
     Assert.AreEqual(1, _listMap.size());
     _listMap = _listMap.add("hello", 1);
     Assert.AreEqual(2, _listMap.size());
     _listMap = _listMap.add("hello 2", 2);
     Assert.AreEqual(3, _listMap.size());
     _listMap = _listMap.remove("hello");
     Assert.AreEqual(2, _listMap.size());
 }
Exemplo n.º 17
0
 public static void replaceKeys(ListMap <string, string> src, Dictionary <string, string> replaces)
 {
     for (int i = 0; i < src.Count; i++)
     {
         var str = src[i];
         if (replaces.ContainsKey(str.Key.ToLowerInvariant()))
         {
             src[i] = new KeyValuePair <string, string>(replaces[str.Key], str.Value);
         }
     }
 }
Exemplo n.º 18
0
        public void TestListMapIsEmpty()
        {
            Assert.IsFalse(_listMap.isEmpty());
            var emptyListMap = new ListMap <string, int> .EmptyListMap();

            Assert.IsTrue(emptyListMap.isEmpty());
            foreach (var kvp in emptyListMap)
            {
                Assert.Fail("Code should never get here");
            }
        }
Exemplo n.º 19
0
        public static Dictionary <string, string> split_config_game(string src)
        {
            var split = new ListMap <string, string>(Q3Utils.split_config(src));

            Dictionary <string, string> replaces = new Dictionary <string, string>();

            replaces.Add("defrag_clfps", "com_maxfps");
            replaces.Add("defrag_svfps", "sv_fps");

            replaceKeys(split, replaces);
            return(split.ToDictionary());
        }
Exemplo n.º 20
0
        public void TestListMapAddAndEnumerate()
        {
            int i = 2;

            _listMap = _listMap.add("hello", 1);
            _listMap = _listMap.add("hello 2", 2);
            foreach (var kvp in _listMap)
            {
                Assert.AreEqual(i--, kvp.Value);
            }
            Assert.AreEqual(-1, i);
        }
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public BaseItemState(IBaseItem pItem, BaseInteractionSettings pSettings) {
			Item = pItem;
			vSettings = pSettings;
			vPoints = new BaseItemPointsState();

			vCursorWorldPosMap = new ListMap<CursorType, Vector3?>(
				EnumIntKeyComparer.CursorType, false, true);
			vHighlightDistanceMap = new ListMap<CursorType, float>(EnumIntKeyComparer.CursorType);
			vHighlightProgressMap = new ListMap<CursorType, float>(EnumIntKeyComparer.CursorType);
			vIsNearestHighlightMap = new ListMap<CursorType, bool>(EnumIntKeyComparer.CursorType);
			vPreventSelectionViaDisplayMap = new ListMap<string, bool>(null);
			
			ResetAllCursorInteractions();
		}
Exemplo n.º 22
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public BaseItemState(IBaseItem pItem, BaseInteractionSettings pSettings)
        {
            Item      = pItem;
            vSettings = pSettings;
            vPoints   = new BaseItemPointsState();

            vCursorWorldPosMap = new ListMap <CursorType, Vector3?>(
                EnumIntKeyComparer.CursorType, false, true);
            vHighlightDistanceMap          = new ListMap <CursorType, float>(EnumIntKeyComparer.CursorType);
            vHighlightProgressMap          = new ListMap <CursorType, float>(EnumIntKeyComparer.CursorType);
            vIsNearestHighlightMap         = new ListMap <CursorType, bool>(EnumIntKeyComparer.CursorType);
            vPreventSelectionViaDisplayMap = new ListMap <string, bool>(null);

            ResetAllCursorInteractions();
        }
Exemplo n.º 23
0
        public void Inquisitor_ShouldWork()
        {
            var map    = new ListMap(6);
            var player = new ListPlayer(1, map.Size, new Config());

            map.TakeHex(PlayerType.Red, 3, 3);
            var inquisitor = new Inquisitor();
            var testMap    = new ListMap(map.Size);

            testMap.InjectFrom(map);
            inquisitor.StartInquisition(testMap, player);


//            Assert.AreEqual(1, 2);
        }
Exemplo n.º 24
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public HoverboardState(ItemPanel[] pItemPanels, HovercursorSetup pHovercusorSetup,
                               InteractionSettings pInterSett, Transform pBaseTx)
        {
            vInteractSett    = pInterSett;
            vHovercusorSetup = pHovercusorSetup;
            vBaseTx          = pBaseTx;
            vProjectionMap   = new ListMap <CursorType, ProjectionState>(EnumIntKeyComparer.CursorType);

            ////

            var panels   = new List <PanelState>();
            var allItems = new List <ItemTree>();

            foreach (ItemPanel itemPanel in pItemPanels)
            {
                var panel = new PanelState(itemPanel, vInteractSett);
                panel.InteractionPlane = new PlaneData("Hoverboard.Panel-" + panels.Count,
                                                       ((GameObject)panel.ItemPanel.DisplayContainer).transform, Vector3.up);
                panels.Add(panel);

                foreach (LayoutState layout in panel.FullLayouts)
                {
                    layout.ItemLayout.SetRadioSiblingsFunc(GetRadioSiblings);

                    foreach (BaseItemState item in layout.FullItems)
                    {
                        var tree = new ItemTree {
                            Panel  = panel,
                            Layout = layout,
                            Item   = item
                        };

                        allItems.Add(tree);
                    }
                }
            }

            vAllItems    = allItems.ToArray();
            vActiveItems = new List <ItemTree>();
            vActiveCursorInteractions = new ReadList <IBaseItemInteractionState>();
            vActiveCursorPlanes       = new ReadList <PlaneData>();

            FullPanels        = panels.ToArray();
            Panels            = new ReadOnlyCollection <IHoverboardPanelState>(FullPanels);
            ActiveCursorTypes = new ReadOnlyCollection <CursorType>(vInteractSett.Cursors);
        }
Exemplo n.º 25
0
        private void ProcessListMap(ListMap map, ObjectAccessor accessor, Dictionary <byte[], TCell> input, ConcurrentDictionary <string, long> ts)
        {
            switch (map.MappingStrategy)
            {
            case MappingStrategy.EntireCfAsObject:
                EntireCfAsObject(map, accessor, input, ts);
                break;

            case MappingStrategy.RegexColumnsAsObject:
                break;

            case MappingStrategy.ColumnAsList:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 26
0
        public void GetPathForPlayerTest()
        {
            var map       = new ListMap(11);
            var player    = new ListPlayer(1, 11, new Config());
            var redPlayer = new ListPlayer(2, 11, new Config());

            var pathfinder = new Pathfinder(map, player.Me);



            //map.TakeHex(PlayerType.Red, 5, 1);
            pathfinder = new Pathfinder(map, player.Me);
            var path = pathfinder.GetPathForPlayer();

            //Assert.AreEqual(11, path.Count);


            map.TakeHex(PlayerType.Red, 3, 2);
            map.TakeHex(PlayerType.Red, 2, 2);
            map.TakeHex(PlayerType.Red, 2, 0);
            map.TakeHex(PlayerType.Red, 2, 1);
            map.TakeHex(PlayerType.Red, 2, 3);
            map.TakeHex(PlayerType.Red, 2, 4);
            map.TakeHex(PlayerType.Red, 2, 5);

            var blueMap = new ListMap(map.Size);

            blueMap.InjectFrom <CloneInjection>(map);

            pathfinder = new Pathfinder(map, redPlayer.Me);
            path       = pathfinder.GetPathForPlayer();
            TestContext.WriteLine(pathfinder.GetLog());
            path.ForEach(x => map.TakeHex(PlayerType.Red, x.Row, x.Column));
            TestContext.WriteLine(map.GetMapMatrix().ToString().Replace('0', '_'));

            //pathfinder = new Pathfinder(blueMap, player, true);
            //path = pathfinder.GetPathForPlayer();
            //path.ForEach(x => blueMap.TakeHex(PlayerType.Blue, x.Row, x.Column));
            //TestContext.WriteLine(pathfinder.GetLog());

            //TestContext.WriteLine(blueMap.GetMapMatrix().ToString().Replace('0', '_'));

            //Assert.AreEqual(11, path.Count);
        }
Exemplo n.º 27
0
        public static Dictionary <string, string> split_config_player(string src)
        {
            var split = new ListMap <string, string>(Q3Utils.split_config(src));
            Dictionary <string, string> replaces = new Dictionary <string, string>();

            replaces.Add("n", "name");
            replaces.Add("dfn", "df_name");
            replaces.Add("t", "team");
            replaces.Add("c1", "color1");
            replaces.Add("c2", "color2");
            replaces.Add("hc", "maxHealth");
            replaces.Add("w", "wins");
            replaces.Add("l", "losses");
            replaces.Add("tt", "teamTask");
            replaces.Add("tl", "teamLeader");

            replaceKeys(split, replaces);
            var nameIndex = Ext.IndexOf(split, x => x.Key.ToLowerInvariant() == "name");

            if (nameIndex >= 0)
            {
                var    name          = split[nameIndex].Value;
                string unColoredName = removeColors(name);
                if (!name.Equals(unColoredName))
                {
                    split.Insert(nameIndex + 1, new KeyValuePair <string, string>("uncoloredName", unColoredName));
                }
            }

            Dictionary <string, string> res = split.ToDictionary();

            if (res.ContainsKey("team"))
            {
                int teamvalue;
                int.TryParse(res["team"], out teamvalue);
                if (teamvalue >= 0 && teamvalue < teamsFrendlyInfo.Length)
                {
                    res["team"] = teamsFrendlyInfo[teamvalue];
                }
            }
            return(res);
        }
		////////////////////////////////////////////////////////////////////////////////////////////////
		/*--------------------------------------------------------------------------------------------*/
		public HoverboardState(ItemPanel[] pItemPanels, HovercursorSetup pHovercusorSetup,
													InteractionSettings pInterSett, Transform pBaseTx) {
			vInteractSett = pInterSett;
			vHovercusorSetup = pHovercusorSetup;
			vBaseTx = pBaseTx;
			vProjectionMap = new ListMap<CursorType, ProjectionState>(EnumIntKeyComparer.CursorType);

			////

			var panels = new List<PanelState>();
			var allItems = new List<ItemTree>();

			foreach ( ItemPanel itemPanel in pItemPanels ) {
				var panel = new PanelState(itemPanel, vInteractSett);
				panel.InteractionPlane = new PlaneData("Hoverboard.Panel-"+panels.Count, 
					((GameObject)panel.ItemPanel.DisplayContainer).transform, Vector3.up);
				panels.Add(panel);

				foreach ( LayoutState layout in panel.FullLayouts ) {
					layout.ItemLayout.SetRadioSiblingsFunc(GetRadioSiblings);

					foreach ( BaseItemState item in layout.FullItems ) {
						var tree = new ItemTree {
							Panel = panel,
							Layout = layout,
							Item = item
						};

						allItems.Add(tree);
					}
				}
			}

			vAllItems = allItems.ToArray();
			vActiveItems = new List<ItemTree>();
			vActiveCursorInteractions = new ReadList<IBaseItemInteractionState>();
			vActiveCursorPlanes = new ReadList<PlaneData>();

			FullPanels = panels.ToArray();
			Panels = new ReadOnlyCollection<IHoverboardPanelState>(FullPanels);
			ActiveCursorTypes = new ReadOnlyCollection<CursorType>(vInteractSett.Cursors);
		}
Exemplo n.º 29
0
        public override bool FillFromAttribute(BaseAttribute attr)
        {
            if (base.FillFromAttribute(attr))
            {
                return(true);
            }

            //Property Map
            if (attr is ListMap)
            {
                //Aggiunge il mapping
                var oAttrMap = (ListMap)attr;

                //Se non ci sono nomi errore
                if (oAttrMap.Names == null || oAttrMap.Names.Length == 0)
                {
                    throw new SchemaReaderException(this, Resources.SchemaMessages.Prop_PropertyMapMissingNames);
                }

                //Check classe dal puntata
                var listType = this.Type.BaseType;
                while (!listType.IsGenericType)
                {
                    listType = listType.BaseType;
                }

                this.mDalTypeOrig = listType.GetGenericArguments()[1];
                //Viene modificato il tipo di proprieta'
                this.ExcludeInsert = true;
                this.ExcludeUpdate = true;

                //Salva i nomi delle property target
                this.mAttr = oAttrMap;
            }
            else
            {
                throw new NotImplementedException();
            }

            return(true);
        }
Exemplo n.º 30
0
        private KeyValuePair <int, ClientEvent>?getCorrectFinishEvent()
        {
            var correctFinishes = new ListMap <int, ClientEvent>();

            for (int i = clientEvents.Count - 1; i >= 0; i--)
            {
                int isCorrect = isEventCorrect(clientEvents, i);
                if (isCorrect > 0)
                {
                    correctFinishes.Add(isCorrect, clientEvents[i]);
                }
            }
            if (correctFinishes.Count > 0)
            {
                return(Ext.MinOf(correctFinishes, x => x.Value.time));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 31
0
        public void GetPossibleMoves_ShouldGivePriorities_Appropriately()
        {
            var map     = new ListMap(6);
            var player  = new ListPlayer(1, map.Size, new Config());
            var player2 = new ListPlayer(2, map.Size, new Config());

            map.TakeHex(PlayerType.Blue, 0, 3);
            map.TakeHex(PlayerType.Red, 3, 3);
            map.TakeHex(PlayerType.Blue, 2, 3);
            map.TakeHex(PlayerType.Red, 3, 2);
            map.TakeHex(PlayerType.Blue, 1, 3);
            map.TakeHex(PlayerType.Red, 3, 1);

            var scout    = new Pathfinder(map, player.Me);
            var redScout = new Pathfinder(map, player2.Me);

            var path    = scout.GetPathForPlayer();
            var redPath = redScout.GetPathForPlayer();

            var inquisitor           = new Inquisitor();
            var possibleMovesForBlue = inquisitor.GetPossibleMoves(redPath, path, player.Me, map);

            TestContext.WriteLine("Blue =========");
            foreach (var move in path.Where(x => x.Owner == PlayerType.White))
            {
                TestContext.WriteLine(move);
            }
            TestContext.WriteLine("Red ========");
            foreach (var move in redPath.Where(x => x.Owner == PlayerType.White))
            {
                TestContext.WriteLine(move);
            }
            TestContext.WriteLine("Result =========");
            foreach (var move in possibleMovesForBlue)
            {
                TestContext.WriteLine(move + " " + move.Priority);
            }
        }
Exemplo n.º 32
0
        public void ScoreBoard_ShouldWork()
        {
            var map = new ListMap(11);

            var bluePlayer = new ListPlayer(1, map.Size, new Config());
            var redPlayer  = new ListPlayer(2, map.Size, new Config());

            map.TakeHex(PlayerType.Red, 1, 1);
            map.TakeHex(PlayerType.Red, 1, 2);
            map.TakeHex(PlayerType.Red, 1, 3);
            map.TakeHex(PlayerType.Red, 1, 4);
            map.TakeHex(PlayerType.Red, 1, 5);

            map.TakeHex(PlayerType.Blue, 1, 7);
            map.TakeHex(PlayerType.Blue, 1, 8);
            map.TakeHex(PlayerType.Blue, 1, 9);
            map.TakeHex(PlayerType.Blue, 1, 10);

            var matrixForPlayer1 = map.GetPlayerMatrix(PlayerType.Blue);

            TestContext.WriteLine("Player 1 matrix");
            TestContext.WriteLine(matrixForPlayer1.ToString());

            var matrixForPlayer2 = map.GetPlayerMatrix(PlayerType.Red);

            TestContext.WriteLine("Player 2 matrix");
            TestContext.WriteLine(matrixForPlayer2.ToString());

            var appraiser = new Appraiser();

            var player1score = appraiser.ScoreFromBoard(map, bluePlayer);
            var player2score = appraiser.ScoreFromBoard(map, redPlayer);

            Assert.AreNotEqual(player1score, player2score);

            Assert.AreEqual(4, player2score);
            Assert.AreEqual(-4, player1score);
        }
Exemplo n.º 33
0
        private IEnumerable <HBaseCell> ProcessListMap(ListMap map, ObjectAccessor accessor, string key,
                                                       IList <string> descriptors)
        {
            var output = new List <HBaseCell>();

            switch (map.MappingStrategy)
            {
            case MappingStrategy.EntireCfAsObject:
                output.AddRange(ProcessCfAsObject(map, accessor, key, descriptors));

                break;

            case MappingStrategy.RegexColumnsAsObject:
                break;

            case MappingStrategy.ColumnAsList:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(output);
        }
 protected ListMap(ListMap old) 
 {
   foreach(object key in old.Keys) 
   {
     object value = old[key];
     ICopyable cvalue = value as ICopyable;
     if (cvalue != null) 
     {
       this[key] = cvalue.Copy();
     }
     else 
     {
       this[key] = value;
     }
   }
 }