public void GetByNameTest() { //Arrange var wonder = new Wonder { Id = 24, Title = "Wonder4", Description = "This wonder is added as part of integration tests", Country = "Country1" }; _sut.Create(wonder); //Act var result = _sut.Get("Wonder4"); //Assert result.ShouldNotBeNull(); result.ShouldBeOfType <OkObjectResult>(); var content = result as OkObjectResult; content.ShouldNotBeNull(); var actual = content.Value as Wonder; actual.ShouldNotBeNull(); actual.Title.ShouldBe("Wonder4"); }
/// <summary> /// Display basic player's information. /// </summary> /// <param name="player">The player information to display.</param> public void DisplayPlayerStat(Player player) { this.NameLabel.text = player.Name; Wonder playerWonder = player.WonderManager.Wonder; this.WonderLabel.text = playerWonder.Name + " - " + playerWonder.Side; }
public void ChoosenWonder(Wonder w) { _currentPlayer._Wonders.Add(w); _choosenWondersCount++; StateDependingOnChoosenWondersCount(); _wondersBar.SetWonders(_currentPlayer._Wonders); }
public void GetAllWondersTest() { //Arrange var wonder = new Wonder { Id = 14, Title = "Wonder2", Description = "This wonder is added as part of integration tests", Country = "Country1" }; _sut.Create(wonder); //Act var result = _sut.Get(); //Assert result.ShouldNotBeNull(); result.ShouldBeOfType <OkObjectResult>(); var content = result as OkObjectResult; content.ShouldNotBeNull(); var wonders = content.Value as IEnumerable <Wonder>; wonders.ShouldNotBeNull(); wonders.Any(w => w.Title == "Wonder2").ShouldBeTrue(); }
public void GetByNameShouldReturnOkObjectResultIfQueryReturnsElements() { //Arrange var wonder = new Wonder { Id = 1, Title = "Test1" }; _repositoryMock .Setup(x => x.One("Test1")) .Returns(Task.FromResult(wonder)); //Act var result = _sut.Get("Test1").Result; //Assert result.ShouldNotBeNull(); result.ShouldBeOfType <OkObjectResult>(); var content = result as OkObjectResult; content.ShouldNotBeNull(); content.Value.ShouldBeOfType <Wonder>(); content.Value.ShouldBe(wonder); }
public Unit[][] GenerateGrid(int xSize, int ySize) { Console.WriteLine("===Abstract Factory==="); goldMinePrototype = (GoldMine)mapFactory.CreateSuperObstacle("Gold Mine", 0, 0); wonderPrototype = (Wonder)mapFactory.CreateSuperObstacle("Wonder", 0, 0); stonePrototype = (Stone)mapFactory.CreateObstacle("Stone", 0, 0); Console.WriteLine("========"); Console.WriteLine("===Prototype==="); //----------Testavimui //stonePrototype.TakeUnit(new Player()); //goldMinePrototype.TakeUnit(new Player()); //---------- Grid = new Unit[ySize][]; for (int y = 0; y < ySize; y++) { Grid[y] = new Unit[xSize]; for (int x = 0; x < xSize; x++) { double obstacleValue = random.NextDouble(); if (obstacleValue > CWonderThreshold && !IsInOuterZone(x, y) && !isNearbyObstacle(x, y)) { Grid[y][x] = (Unit)wonderPrototype.ShallowCopy(); Grid[y][x].SetCoordinates(x, y); //----------Testavimui //Console.WriteLine("Wonder original address " + wonderPrototype.GetHashCode() + " Wonder copy address " + Grid[y][x].GetHashCode()); //---------- } else if (obstacleValue > CGoldMineThreshold && !IsInOuterZone(x, y) && !isNearbyObstacle(x, y)) { Grid[y][x] = (Unit)goldMinePrototype.ShallowCopy(); Grid[y][x].SetCoordinates(x, y); //----------Testavimui //Console.WriteLine("Gold Mine original address " + goldMinePrototype.GetHashCode() + " Gold Mine copy address " + Grid[y][x].GetHashCode()); //Console.WriteLine("Gold Mine Player original address " + goldMinePrototype.GetPlayer().GetHashCode() + " Gold Mine Player copy address " + Grid[y][x].GetPlayer().GetHashCode()); //---------- } else if (obstacleValue > CStoneThreshold && !IsInOuterZone(x, y) && !isNearbyObstacle(x, y)) { //----------Testavimui //Grid[y][x] = (Unit)stonePrototype.DeepCopy(); //---------- Grid[y][x] = (Unit)stonePrototype.ShallowCopy(); Grid[y][x].SetCoordinates(x, y); //----------Testavimui //Console.WriteLine("Stone original address " + stonePrototype.GetHashCode() + " Stone copy address " + Grid[y][x].GetHashCode()); //Console.WriteLine("Stone Player original address " + stonePrototype.GetPlayer().GetHashCode() + " Stone Player copy address " + Grid[y][x].GetPlayer().GetHashCode()); //---------- } else { Grid[y][x] = new Unit(x, y); } } } Console.WriteLine("========"); return(Grid); }
static void Main(string[] args) { ChinaWall chinaWall = new ChinaWall(); HangingGardens hangingGardens = new HangingGardens(); Kolosus kolosus = new Kolosus(); Piramids piramids = new Piramids(); TadjMahal tadjMahal = new TadjMahal(); Wonder wonder = new Wonder(); ZeusStatue zeusStatue = new ZeusStatue(); }
/// <summary> /// Constructor /// </summary> /// <param name="otherside">Name of the other side of this Wonder. Kind of useless</param> /// <param name="name">Name of the active side of the Wonder (e.g. "Giza (B)")</param> /// <param name="effect">This is the starting resource or effect that the Wonder Board provides</param> /// <param name="nStages">The number of stages this wonder has (1, 2, 3, 4)</param> public Board(ExpansionSet e, Wonder otherside, string name, CardId cardId, Effect boardEffect, int nStages) { this.expansionSet = e; this.otherSide = otherside; this.name = name; this.startingResourceCard = new Card(cardId, name, boardEffect); this.numOfStages = nStages; inPlay = false; }
public override bool PlayerMeetsCondition(Player p) { bool res = p && !p.IsDead(); if (res) { Wonder w = p.buildings.GetComponentInChildren <Wonder> (); res = w && !w.UnderConstruction(); } return(res); }
public void DisplayWonder(Wonder wonder) { if (InvokeRequired) { Delegate d = new DisplayWonderCallBack(DisplayWonder); this.Invoke(d, wonder); } else { string image_path = String.Format("D:/planchik/pics/Wonders/{0}.jpg", wonder.Id); wonderBox.BackgroundImage = (Image) new Bitmap(Image.FromFile(image_path), new Size(wonderBox.Width, wonderBox.Height)); } }
/// <summary> /// Distribute cards to start a new age. /// </summary> /// <param name="age">The age to be started.</param> /// <param name="AILevel">The AI level of cleverness.</param> public void StartAge(int age, int AILevel = 0) { if (age > 3) { this.RefreshAIBoards(); this.CleanLastMove(); PlayerBoardController.DisplayScoreBoard(this.GameManager.Players); } else { GameManager.Age = age; this.GameManager.DistributeCards(); this.GameManager.ResetFreeBuildCount(); PlayerBoardController.RefreshHand(); PlayerBoardController.RefreshDiscardPiles(age); if (age == 1) { this.GameManager.LoadWonders(); Player humanPlayer = this.GameManager.GetHumanPlayer(); Wonder humanWonder = humanPlayer.WonderManager.Wonder; PlayerBoardController.RefreshWonderBoard(humanWonder.ID, humanWonder.Steps.Count); this.GameManager.LoadAI(AILevel); this.LeftPlayer = PlayerBoardController.GetLeftAIBoard(); this.RightPlayer = PlayerBoardController.GetRightAIBoard(); Player[] distantPlayers = this.GameManager.GetDistantPlayers(); if (distantPlayers.Length > 0) { this.DistantPlayers = PlayerBoardController.SetExtraPlayers(distantPlayers); } foreach (Player p in this.GameManager.Players) { if (p == this.GameManager.GetLeftPlayer(humanPlayer)) { this.LeftPlayer.InitializeAIBoard(p); } else if (p == this.GameManager.GetRightPlayer(humanPlayer)) { this.RightPlayer.InitializeAIBoard(p); } else if (!p.IsHuman) { this.DistantPlayers.Reverse().Where(dp => dp.Player == null).First().InitializeAIBoard(p); } } this.RefreshAIBoards(); } } }
private SelectList GetWonderSelectList(Wonder selectedValue = null) { // Some sample data to display as a drop down on the view. List <Wonder> wonders = DataAccess.DummyDataAccess.GetWonders(); if (selectedValue == null) { return(new SelectList(wonders, "Id", "Name", null)); } else { return(new SelectList(wonders, "Id", "Name", wonders.Single(t => t.Id.Equals(selectedValue.Id)))); } }
public override bool CommanderMeetsConditions(AgentCommander commander) { Wonder wonder = commander.GetComponentInChildren <Wonder>(); RTSAgent[] agents = commander.GetComponentInChildren <RTSAgents>().GetComponentsInChildren <RTSAgent>(); foreach (RTSAgent agent in agents) { if (agent.GetAbility <Wonder>()) { return(commander && !commander.IsDead() && agent && !agent.GetAbility <Structure>().UnderConstruction()); } } return(false); }
public async Task <IActionResult> Post([FromBody] Wonder wonder) { if (wonder == null) { return(BadRequest()); } await _repository.New(wonder); return(CreatedAtRoute("GetByTitle", new { title = wonder.Title }, wonder)); }
public async Task New(Wonder wonder) { var existingWonder = await One(wonder.Title); if (existingWonder != null) { throw new ArgumentException("Already exists"); } existingWonder = await One(wonder.Id); if (existingWonder != null) { throw new ArgumentException("Id already used"); } _wondersDb.Wonders.Add(wonder); }
public void AddWondersTest() { //Arrange var wonder = new Wonder { Id = 12, Title = "Wonder1", Description = "This wonder is added as part of integration tests", Country = "Country1" }; //Act var result = _sut.Create(wonder); //Assert result.ShouldNotBeNull(); result.ShouldBeOfType <OkResult>(); }
/// <summary> /// Distribute randomly a wonder to all players. /// </summary> /// <param name="side">Choose A/B side of wonders (both if not mentionned)</param> public void LoadWonders(char side = '\0') { List <Wonder> wonders = WondersDAO.GetWonders(side); Random rand = new Random(); foreach (Player player in this.Players) { Wonder wonder = wonders.ElementAt(rand.Next(wonders.Count)); List <Wonder> wondersToRemove = wonders.Where(w => w.Name.Contains(wonder.Name)).ToList(); foreach (Wonder wonderToRemove in wondersToRemove) { wonders.Remove(wonderToRemove); // Remove A & B side. } player.WonderManager.Wonder = wonder; ResourceQuantity baseResource = new ResourceQuantity { Type = wonder.BaseResource, Quantity = 1 }; player.City.AddToResourceTree(new ResourceQuantity[] { baseResource }, false, false); } }
private void Start() { attack = GetComponent <Attack>(); pursuit = GetComponent <OffsetPursuit>(); wonder = GetComponent <Wonder>(); }
public void CreatePlayer(Wonder wonder) { MessageBox.Show("Я получил чудо: " + wonder.Name); }
public override bool PlayerMeetsConditions(Player player) { Wonder wonder = player.GetComponentInChildren <Wonder>(); return(player && !player.IsDead() && wonder && !wonder.UnderConstruction()); }
public IActionResult Create(Wonder wonder) { return(_client.PostAsJsonAsync("api/wonders", wonder).Result); }
private void Awake() { _image = GetComponent <Image>(); _wonder = _wonderManager.ReturnRandomWonder(); _image.sprite = _wonder.sprite; }
public void completeWonder(Wonder wdr) { string a = wdr.ToString(); }
public void BuildWonder(Card c, Wonder w) { // moves Card to Wonder // Pay // Do: Wonder Action }
public static string oneMoreTurn() { //초기화 Function fn = new Function(); string Reader; //본격적인 시작부입니다. 스파게티 코드를 주의하세요. Console.WriteLine("명령을 입력하세요."); if (MainClass.pd.NewPlayer == true) { Console.WriteLine("도움말을 보시려면 ?을 입력하세요.\n또한 도움말을 제외한 모든 명령은 턴을 소모합니다.\n이 설명은 단 한 번만 표시됩니다."); } Main: Reader = Console.ReadLine(); switch (Reader.ToUpper()) { case "?": Line(); Console.WriteLine("군사창 열기: MIL\n통계창 열기: STAT\n생산창 열기: PROD\n외교창 열기: DP\n건설창 열기: CON\n기술 계층도 열기: SCN\n게임 종료: OFF\n지금 이 창 띄우기: ?"); Line(); goto Main; //'GOTO Statement Considered Harmful' Considered Harmful. case "PROD": Line(); Console.WriteLine(); Line(); break; case "MIL": Line(); Console.WriteLine(""); Line(); break; case "DP": int WPV = MainClass.pd.WarmongerPenalty; string WP = ""; string[] nationInWar = { "", "" }; if (WPV > 100) { WP = "철혈의 전쟁광"; } if (WPV > 70) { WP = "전쟁 애호가"; } if (WPV > 40) { WP = "전쟁 반대자"; } if (WPV > 10) { WP = "평화주의자"; } if (WPV < 11) { WP = "전쟁 혐오자"; } Line(); Console.WriteLine("현재 외교 관계: {0}", MainClass.pd.DiplomancyState); Console.WriteLine("현재 전쟁광 인식도: {0} 페널티 수치: {1} ", WP, WPV); Console.WriteLine("전쟁 중인 문명: {0}", nationInWar); Line(); break; case "CON": Line(); Console.WriteLine(); var v = Console.ReadLine(); if (v.ToUpper() == "Y") { fn.completeCity(); Console.WriteLine("정상적으로 건설되었습니다."); } else if (v.ToUpper() == "N") { Console.WriteLine("건설을 미룹니다."); } else { Console.WriteLine("Y/N으로만 답해주세요."); } Line(); break; case "STAT": Console.WriteLine("도시 숫자: {0}", MainClass.pd.NumberOfCity); break; case "SCN": Console.WriteLine(); break; case "OFF": return("OFF"); Wonder wonder = new Wonder(); fn.completeWonder(wonder); break; default: Console.WriteLine("올바른 명령이 아닙니다."); goto Main; } MainClass.pd.NewPlayer = false; return("NORMAL" ); }