public void pawnToXML() { TestScenerios test = new TestScenerios(); Board board = new Board(); SPlayer p1 = new SPlayer("blue", new List <Tile>()); test.setStartPos(board, p1, new Posn(0, 0, 5)); SPlayer p2 = new SPlayer("hotpink", new List <Tile>()); test.setStartPos(board, p2, new Posn(4, 4, 5)); SPlayer p3 = new SPlayer("green", new List <Tile>()); test.setStartPos(board, p3, new Posn(3, 2, 6)); List <SPlayer> players = new List <SPlayer> { p1, p2, p3 }; XElement playersToXML = XMLEncoder.pawnsToXML(new List <string> { "blue", "hotpink", "green" }, board); XElement playersToXMLExpected = new XElement("map", new XElement("ent", new XElement("color", "blue"), new XElement("pawn-loc", new XElement("h", ""), new XElement("n", 1), new XElement("n", 0))), new XElement("ent", new XElement("color", "hotpink"), new XElement("pawn-loc", new XElement("h", ""), new XElement("n", 5), new XElement("n", 8))), new XElement("ent", new XElement("color", "green"), new XElement("pawn-loc", new XElement("v", ""), new XElement("n", 2), new XElement("n", 7)))); Assert.IsTrue(XNode.DeepEquals(playersToXML, playersToXMLExpected)); }
public void PlayerHand() { List <Vector2Int> testPaths = new List <Vector2Int> (); testPaths.Add(new Vector2Int(0, 5)); testPaths.Add(new Vector2Int(1, 3)); testPaths.Add(new Vector2Int(2, 6)); testPaths.Add(new Vector2Int(4, 7)); Tile t = new Tile(testPaths); SPlayer p = new SPlayer(); p.MyHand.AddToHand(t); Assert.True(p.MyHand.IsInHand(t), "Basic Hand Tile addition"); p.MyHand.RemoveFromHand(t); Assert.False(p.MyHand.IsInHand(t), "Basic Hand Tile Playing"); }
public void PlaceTilePlacesTile() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); SPlayer p1 = new SPlayer("blue", new List <Tile>(), new RandomPlayer()); Board b = new Board(); p1.setPosn(new Posn(0, 0, 3)); Posn endPos = b.placeTile(p1, t1); Assert.IsTrue(endPos.returnCol() == 1); Assert.IsTrue(endPos.returnRow() == 0); Assert.IsTrue(endPos.returnLocationOnTile() == 3); Assert.IsTrue(b.occupied(0, 1)); }
public void PlayerGetsEliminated() { SPlayer p1 = new SPlayer("blue", new List <Tile>()); SPlayer p2 = new SPlayer("red", new List <Tile>()); Board b = new Board(); b.registerPlayer(p1); p1.playerState = SPlayer.State.Playing; b.registerPlayer(p2); b.eliminatePlayer(p1); Assert.IsFalse(b.isOnBoard("blue")); Assert.IsTrue(b.isEliminated("blue")); Assert.IsTrue(b.isOnBoard("red")); }
public void PlayerGetsEliminated() { SPlayer p1 = new SPlayer("blue", new List <Tile>()); SPlayer p2 = new SPlayer("red", new List <Tile>()); p1.playerState = SPlayer.State.Playing; p2.playerState = SPlayer.State.Playing; Admin admin = new Admin(new List <SPlayer> { p1, p2 }, new List <SPlayer>(), null, null); admin.eliminatePlayer("blue"); Assert.IsFalse(admin.isActivePlayer("blue")); Assert.IsTrue(admin.isEliminatedPlayer("blue")); Assert.IsTrue(admin.isActivePlayer("red")); }
public void PlayerHasRotatedVersionOfSameTileInHand() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Admin a = new Admin(); Board b = new Board(); List <Tile> playerHand = test.makeHand(t1, t1.rotate()); SPlayer p1 = new SPlayer("blue", playerHand, new MostSymmetricPlayer()); p1.initialize(b); test.setStartPos00(b, p1); p1.playTurn(b, b.drawPile.Count); Assert.IsInstanceOfType(p1.playerStrategy, typeof(RandomPlayer)); }
public void MakeAMoveCauseMultiplePlayersToMove() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 2, 1, 6, 3, 5, 4, 7); Tile t2 = test.makeTile(0, 1, 2, 7, 3, 4, 5, 6); Admin a = new Admin(); Board b = new Board(); SPlayer p1 = new SPlayer("p1", new List <Tile>()); p1.setPosn(new Posn(1, 0, 2)); SPlayer p2 = new SPlayer("p2", new List <Tile>()); p2.setPosn(new Posn(0, 1, 5)); SPlayer p3 = new SPlayer("p3", new List <Tile>()); p3.setPosn(new Posn(1, 2, 6)); b.registerPlayer(p1); b.registerPlayer(p2); b.registerPlayer(p3); b.grid[1, 2] = t2; TurnResult tr = a.playATurn(b, t1); Posn playerPosn0 = tr.currentPlayers[0].getPlayerPosn(); Posn playerPosn1 = tr.currentPlayers[1].getPlayerPosn(); Posn playerPosn2 = tr.currentPlayers[2].getPlayerPosn(); Assert.IsTrue(playerPosn0.returnRow() == 1); Assert.IsTrue(playerPosn0.returnCol() == 2); Assert.IsTrue(playerPosn0.returnLocationOnTile() == 2); Assert.IsTrue(playerPosn1.returnRow() == 1); Assert.IsTrue(playerPosn1.returnCol() == 1); Assert.IsTrue(playerPosn1.returnLocationOnTile() == 5); Assert.IsTrue(playerPosn2.returnRow() == 1); Assert.IsTrue(playerPosn2.returnCol() == 1); Assert.IsTrue(playerPosn2.returnLocationOnTile() == 4); Assert.IsNull(tr.playResult); }
public void TileInHandRotated() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t2 = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile t3 = test.makeTile(0, 5, 1, 4, 2, 7, 3, 6); List <Tile> hand = test.makeHand(t1, t2, t3); Admin a = new Admin(); Board b = new Board(); SPlayer player1 = new SPlayer("blue", hand); Tile t1_rotated = t1; Assert.IsTrue(player1.tileInHand(t1_rotated.rotate())); }
public void DirectionMatch() { List <Vector2Int> testPaths = new List <Vector2Int> (); testPaths.Add(new Vector2Int(0, 5)); testPaths.Add(new Vector2Int(1, 3)); testPaths.Add(new Vector2Int(2, 6)); testPaths.Add(new Vector2Int(4, 7)); Tile t = new Tile(testPaths); SPlayer p = new SPlayer(); p.MyHand.AddToHand(t); Assert.True(DirectionUtils.DirectionMatch(Direction.RIGHT, 3), "Direction Match"); Assert.False(DirectionUtils.DirectionMatch(Direction.RIGHT, 0), "Direction mismatch found"); Assert.False(DirectionUtils.DirectionMatch(Direction.DOWN, 9), "Not match for invalid positions"); }
public void MakeMoveWhereMultiplePlayersEliminated() { Admin a = new Admin(); Board b = new Board(); TestScenerios test = new TestScenerios(); //tile to be placed Tile t1 = test.makeTile(7, 0, 6, 1, 5, 4, 2, 3); //tile the player is on Tile t2 = test.makeTile(1, 3, 0, 5, 2, 7, 4, 6); test.putTileOnBoard(t2, b, 1, 1); //players to be eliminated SPlayer elim1 = new SPlayer("blue", new List <Tile>()); b.addPlayerToBoard(elim1.getColor(), new Posn(0, 0, 2)); elim1.playerState = SPlayer.State.Playing; SPlayer elim2 = new SPlayer("green", new List <Tile>()); b.addPlayerToBoard(elim2.getColor(), new Posn(0, 0, 3)); elim2.playerState = SPlayer.State.Playing; //player left over SPlayer p1 = new SPlayer("hotpink", new List <Tile>()); b.addPlayerToBoard(p1.getColor(), new Posn(1, 1, 0)); p1.playerState = SPlayer.State.Playing; a.addToActivePlayers(elim1); a.addToActivePlayers(elim2); a.addToActivePlayers(p1); TurnResult tr = a.playATurn(b, t1); Posn playerPosn = b.getPlayerPosn(tr.currentPlayers[0].getColor()); Assert.IsTrue(playerPosn.isEqual(new Posn(1, 1, 3))); Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.getColor() == "blue"), "eliminated player is in eliminated list"); Assert.IsTrue(tr.eliminatedPlayers.Exists(x => x.getColor() == "green"), "eliminated player is in eliminated list"); Assert.IsNotNull(tr.playResult); Assert.IsTrue(tr.playResult.Exists(x => x.getColor() == "hotpink"), "p1 not in the winning list of players"); Assert.AreEqual(tr.playResult.Count, 1); }
private void UpdateRatings() { CSong song = CGame.GetSong(_Round); if (song == null) { return; } Texts[htTexts(TextSong)].Text = song.Artist + " - " + song.Title; if (_Points.NumRounds > 1) { Texts[htTexts(TextSong)].Text += " (" + _Round + "/" + _Points.NumRounds + ")"; } SPlayer[] player = new SPlayer[CGame.NumPlayer]; player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); for (int p = 0; p < player.Length; p++) { Texts[htTexts(TextNames[p, CGame.NumPlayer - 1])].Text = player[p].Name; Texts[htTexts(TextScores[p, CGame.NumPlayer - 1])].Text = ((int)Math.Round(player[p].Points)).ToString("0000") + " " + CLanguage.Translate("TR_SCREENSCORE_POINTS"); Texts[htTexts(TextRatings[p, CGame.NumPlayer - 1])].Text = CLanguage.Translate("TR_SCREENSCORE_RATING") + ": " + CLanguage.Translate(GetRating((int)Math.Round(player[p].Points))); Texts[htTexts(TextDifficulty[p, CGame.NumPlayer - 1])].Text = CLanguage.Translate("TR_SCREENSCORE_GAMEDIFFICULTY") + ": " + CLanguage.Translate(player[p].Difficulty.ToString()); StaticPointsBarDrawnPoints[p] = 0.0; Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H = 0; Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.Y = Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H + Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.Y - Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H; if (player[p].ProfileID >= 0 && player[p].ProfileID < CProfiles.NumProfiles) { Statics[htStatics(StaticAvatar[p, CGame.NumPlayer - 1])].Texture = CProfiles.Profiles[player[p].ProfileID].Avatar.Texture; } } if (CConfig.ScoreAnimationTime < 1) { for (int p = 0; p < CGame.NumPlayer; p++) { Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H = ((float)player[p].Points) * (Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H / 10000); Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.Y = Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H + Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.Y - Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H; StaticPointsBarDrawnPoints[p] = player[p].Points; } } timer = new Stopwatch(); timer.Start(); }
public void PlayerEliminatedOtherPlayersDrawRefilledDeck() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t2 = test.makeTile(0, 7, 2, 3, 4, 5, 6, 1); Tile t3 = test.makeTile(0, 3, 2, 1, 4, 5, 6, 7); List <Tile> hand = test.makeHand(t2, t3); Board board = new Board(); Admin admin = new Admin(); SPlayer p1 = new SPlayer("blue", hand, new RandomPlayer()); SPlayer p2 = new SPlayer("green", new List <Tile>(), new RandomPlayer()); SPlayer p3 = new SPlayer("hotpink", new List <Tile>(), new RandomPlayer()); p1.initialize(board); p2.initialize(board); p3.initialize(board); test.setStartPos00(board, p1); test.setStartPos(board, p2, new Posn(3, 3, 3)); test.setStartPos(board, p3, new Posn(4, 3, 3)); board.setDragonTileHolder(p2); Assert.AreEqual(0, board.drawPile.Count); TurnResult tr = admin.playATurn(board, t1); // Green and hotpink both drew a tile // Green has t2 // Hot pink has t3 // No dragon tile holder Assert.AreEqual(2, board.getNumActive()); SPlayer greenPlayer = board.getFirstActivePlayer(); Assert.AreEqual("green", greenPlayer.returnColor()); Assert.IsTrue(board.isOnBoard("hotpink")); Assert.AreEqual(1, greenPlayer.returnHand().Count); Assert.AreEqual(1, p3.returnHand().Count); Assert.IsTrue(greenPlayer.returnHand().Exists(x => x.isEqual(t2))); Assert.IsTrue(p3.returnHand().Exists(x => x.isEqual(t3))); Assert.IsTrue(board.isDragonTileHolder("green")); }
public void PlayerWithoutDragonTileCausesDragonTileHolderToBeEliminated() { Admin a = new Admin(); Board b = new Board(); TestScenerios test = new TestScenerios(); //tile to be placed Tile t1 = test.makeTile(7, 0, 6, 1, 5, 4, 2, 3); //tile the player is on Tile t2 = test.makeTile(1, 3, 0, 5, 2, 7, 4, 6); Tile t3 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t4 = test.makeTile(1, 2, 3, 4, 5, 6, 7, 0); b.grid[1, 1] = t2; //players to be eliminated List <Tile> elim1Tiles = new List <Tile>() { t3, t4 }; SPlayer elim1 = test.createPlayerAtPos("elim1", elim1Tiles, new RandomPlayer(), new Posn(0, 0, 2), b); //players left over SPlayer p2 = test.createPlayerAtPos("p2", new List <Tile>(), new RandomPlayer(), new Posn(4, 4, 3), b); SPlayer p1 = test.createPlayerAtPos("p1", new List <Tile>(), new RandomPlayer(), new Posn(1, 1, 0), b); b.setDragonTileHolder(elim1); TurnResult tr = a.playATurn(b, t1); Assert.IsTrue(tr.b.isDragonTileHolder("p2")); Assert.AreEqual(1, tr.eliminatedPlayers.Count); Assert.AreEqual(2, tr.currentPlayers.Count); Assert.AreEqual(1, b.returnEliminated().Count); Assert.AreEqual(2, b.getNumActive()); Assert.AreEqual(1, p2.returnHand().Count); Assert.AreEqual(1, p1.returnHand().Count); Assert.IsTrue(p2.returnHand().Contains(t3)); Assert.IsTrue(p1.returnHand().Contains(t4)); }
public void boardToXMLSimple() { Board board = new Board(); TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); board.grid[0, 0] = t1; SPlayer p1 = new SPlayer("red", new List <Tile>(), new RandomPlayer()); p1.initialize(board); test.setStartPos(board, p1, new Posn(0, 0, 3)); XElement boardToXML = XMLEncoder.boardToXML(board); XElement boardToXMLExpected = XElement.Parse("<board><map><ent><xy><x>0</x><y>0</y></xy><tile><connect><n>0</n><n>1</n></connect><connect><n>2</n><n>4</n></connect><connect><n>3</n><n>6</n></connect><connect><n>5</n><n>7</n></connect></tile></ent></map><map><ent><color>red</color><pawn-loc><v></v><n>1</n><n>1</n></pawn-loc></ent></map></board>"); Assert.IsTrue(XNode.DeepEquals(boardToXML, boardToXMLExpected)); }
TurnOutput PlayATurn(List <Tile> DrawPile, List <SPlayer> PlayersIn, List <SPlayer> PlayersOut, Board b, Tile PlacedTile) { TurnOutput to = new TurnOutput(); SPlayer ActivePlayer = PlayersIn[0]; foreach (SPlayer p in b.GetAdjacentPlayers(PlacedTile)) { b.MovePlayer(p, PlacedTile); } b.CurrentDeck.DrawCard(ActivePlayer); to.DrawPile = b.CurrentDeck.DrawDeck; to.PlayersIn = b.CurrentPlayersIn; to.PlayersOut = b.CurrentPlayersOut; to.b = b; Debug.Log(PlayersIn.Count); to.ContinueGame = (PlayersIn.Count > 1); return(to); }
public void PlayerTakesDragonTile() { TestScenerios test = new TestScenerios(); Admin a = new Admin(); Board b = new Board(); SPlayer p1 = test.createPlayerAtPos("p1", new List <Tile>(), new RandomPlayer(), new Posn(3, 3, 1), b); SPlayer p2 = test.createPlayerAtPos("p2", new List <Tile>(), new RandomPlayer(), new Posn(4, 3, 1), b); //tile to be placed Tile t1 = test.makeTile(7, 0, 6, 1, 5, 4, 2, 3); TurnResult tr = a.playATurn(b, t1); Assert.IsTrue(tr.b.isDragonTileHolder("p1")); }
public void MultipleMovements() { Administrator a = new Administrator(); Board b = new Board(new Vector2Int(6, 6)); SPlayer p1 = new SPlayer(); SPlayer p2 = new SPlayer(); b.AddNewPlayer(p1, new PlayerLocation(new Vector2Int(0, 0), 7)); b.AddNewPlayer(p2, new PlayerLocation(new Vector2Int(0, 0), 6)); //making a move where multiple players move at once Tile oldThirdTile = p1.MyHand.RemoveFromHand(p1.MyHand.Pieces[2]); Assert.True(a.PlayATurn(b.CurrentDeck.Pieces, b.CurrentPlayersIn, b.CurrentPlayersOut, b, oldThirdTile).ContinueGame, "Determines that a play did not end the game"); Assert.AreEqual(new Vector2Int(1, 0), p1.Location.Coordinate, "Player one moved to correct location"); Assert.AreEqual(new Vector2Int(0, 1), p2.Location.Coordinate, "Player two moved to correct location"); }
private void AtkPlayer(long atk, long target, int skillid) { SPlayer p1 = GetPlayerById(atk); SPlayer p2 = GetPlayerById(target); //==实际逻辑为下方逻辑 //float tmp = p1.skills[skillid].range; //判断攻击距离 修改伤害数据 //if (tmp >= Vector3.Distance(p1.m_pos,p2.m_pos)) //{ // p2.PropOperation(1, -10); // S2CMsg("atkover", true); // S2CMsg("shouji", p2.m_insid); //} //===临时消息 S2CMsg("atkActionPlay", skillid); //S2CMsg("shouji", p2.m_insid); }
public void LeastSymPlayerChoosesLeastSymTile() { TestScenerios test = new TestScenerios(); Tile mostSymTile = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile medSymTile = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile leastSymTile = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); //purposefully unordered List <Tile> playerTiles = test.makeHand(medSymTile, mostSymTile, leastSymTile); Board b = new Board(); SPlayer lsp1 = new SPlayer("blue", playerTiles, new LeastSymmetricPlayer()); lsp1.initialize(b); test.setStartPos00(b, lsp1); //playturn should return the least symmetric tile Assert.IsTrue(lsp1.playTurn(b, 0).isEqual(leastSymTile)); }
private void LoadScores() { CPoints points = CGame.GetPoints(); if (points == null) { return; } _Pos = 0; for (int round = 0; round < points.NumRounds; round++) { SPlayer player = points.GetPlayer(round, CGame.NumPlayer)[0]; CDataBase.LoadScore(ref _Scores, player); if (round == _Round) { _IsDuet = false; CSong song = CSongs.GetSong(player.SongID); Texts[htTexts(TextSongName)].Text = song.Artist + " - " + song.Title; switch (CGame.GameMode) { case EGameMode.Normal: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; case EGameMode.Medley: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_MEDLEY"; break; case EGameMode.Duet: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_DUET"; _IsDuet = true; break; default: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; } } } }
public void GetAdjacentPlayers() { Board b = new Board(new Vector2Int(6, 6)); List <Tile> tileList = TestTile.GenerateTiles(); SPlayer sp = new SPlayer(); b.AddNewPlayer(sp, new PlayerLocation(new Vector2Int(0, 4), 7)); SPlayer sp2 = new SPlayer(); b.AddNewPlayer(sp2, new PlayerLocation(new Vector2Int(0, 4), 6)); b.PlaceTile(tileList[2], new Vector2Int(1, 4), Direction.UP); b.PlaceTile(tileList[1], new Vector2Int(0, 4), Direction.UP); Assert.AreEqual(0, b.GetAdjacentPlayers(tileList[2]).Count, "Did not incorrectly grab a player"); Assert.AreEqual(2, b.GetAdjacentPlayers(tileList[1]).Count, "Found adjacent player"); }
public List <Tile> GetLegalTiles(SPlayer sp) { List <Tile> legalTiles = new List <Tile> (); foreach (Tile t in sp.MyHand.Pieces) { List <Direction> legalDirs = Admin.LegalTilePlayDirections(sp, t, this); if (legalDirs.Count > 0) { t.LegalDirections = legalDirs; legalTiles.Add(t); } } if (legalTiles.Count == 0) { legalTiles = sp.MyHand.Pieces; } return(legalTiles); }
public void EliminatedPlayerReturnsHandToDrawPile() { TestScenerios test = new TestScenerios(); Tile t1 = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile t2 = test.makeTile(0, 1, 2, 4, 3, 6, 5, 7); Tile t3 = test.makeTile(0, 5, 2, 3, 4, 7, 1, 6); List <Tile> hand = test.makeHand(t1, t2); SPlayer p1 = new SPlayer("blue", hand, new LeastSymmetricPlayer()); Board board = new Board(); test.setStartPos(board, p1, new Posn(-1, 0, 4)); Assert.AreEqual(0, board.drawPile.Count); board.eliminatePlayer(p1); Assert.AreEqual(2, board.drawPile.Count); }
public void PlayerHasTooManyTilesInHand() { TestScenerios test = new TestScenerios(); Tile mostSymTile = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile medSymTile = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile leastSymTile = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); Tile extraTile = test.makeTile(0, 4, 1, 7, 2, 6, 3, 5); Admin a = new Admin(); Board b = new Board(); List <Tile> playerHand = test.makeHand(mostSymTile, medSymTile, leastSymTile, extraTile); SPlayer p1 = new SPlayer("blue", playerHand, new MostSymmetricPlayer()); p1.initialize(b); test.setStartPos00(b, p1); p1.playTurn(b, b.drawPile.Count); Assert.IsInstanceOfType(p1.playerStrategy, typeof(RandomPlayer)); }
public void PlayerHandAlreadyOnBoard() { TestScenerios test = new TestScenerios(); Tile mostSymTile = test.makeTile(0, 1, 2, 3, 4, 5, 6, 7); Tile medSymTile = test.makeTile(0, 6, 1, 5, 2, 4, 3, 7); Tile leastSymTile = test.makeTile(0, 5, 1, 3, 2, 6, 4, 7); Admin a = new Admin(); Board b = new Board(); b.grid[1, 1] = mostSymTile; SPlayer p1 = new SPlayer("blue", test.makeHand(mostSymTile, medSymTile), new MostSymmetricPlayer()); p1.initialize(b); test.setStartPos00(b, p1); p1.playTurn(b, b.drawPile.Count); Assert.IsInstanceOfType(p1.playerStrategy, typeof(RandomPlayer)); }
public void MovesOffAndBackOntoTileEliminatesSelf() { // Set up - player plays a tile that will cause them to move onto another tile, // and then back onto the tile they just played, and eliminate themself TestScenerios test = new TestScenerios(); Tile onBoard = test.makeTile(0, 1, 2, 6, 3, 7, 5, 4); Tile toPlace = test.makeTile(0, 5, 1, 4, 2, 6, 3, 7); Board board = new Board(); board.grid[4, 0] = onBoard; SPlayer p1 = new SPlayer("blue", new List <Tile>()); board.registerPlayer(p1); p1.setPosn(new Posn(6, 0, 1)); Assert.IsFalse(board.isNotEliminationMove(p1, toPlace)); }
public override bool UpdateGame() { SPlayer[] player = new SPlayer[CGame.NumPlayer]; if (_Round != 0) { player = _Points.GetPlayer(_Round - 1, CGame.NumPlayer); } else { for (int i = 0; i < CGame.NumRounds; i++) { SPlayer[] points = _Points.GetPlayer(i, CGame.NumPlayer); for (int p = 0; p < player.Length; p++) { player[p].Points += points[p].Points; } } for (int p = 0; p < player.Length; p++) { player[p].Points = (int)(player[p].Points / CGame.NumRounds); } } for (int p = 0; p < player.Length; p++) { if (StaticPointsBarDrawnPoints[p] < player[p].Points) { if (CConfig.ScoreAnimationTime >= 1) { StaticPointsBarDrawnPoints[p] = (timer.ElapsedMilliseconds / 1000f) / CConfig.ScoreAnimationTime * 10000; if (StaticPointsBarDrawnPoints[p] > player[p].Points) { StaticPointsBarDrawnPoints[p] = player[p].Points; } Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H = ((float)StaticPointsBarDrawnPoints[p]) * (Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H / 10000); Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.Y = Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.H + Statics[htStatics(StaticPointsBarBG[p, CGame.NumPlayer - 1])].Rect.Y - Statics[htStatics(StaticPointsBar[p, CGame.NumPlayer - 1])].Rect.H; } } } return(true); }
private void UpdateRound() { _IsDuet = false; CPoints points = CGame.GetPoints(); SPlayer player = points.GetPlayer(_Round, CGame.NumPlayer)[0]; CSong song = CGame.GetSong(_Round + 1); if (song == null) { return; } Texts[htTexts(TextSongName)].Text = song.Artist + " - " + song.Title; if (points.NumRounds > 1) { Texts[htTexts(TextSongName)].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")"; } switch (CGame.GetGameMode(_Round)) { case EGameMode.TR_GAMEMODE_NORMAL: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; case EGameMode.TR_GAMEMODE_MEDLEY: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_MEDLEY"; break; case EGameMode.TR_GAMEMODE_DUET: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_DUET"; _IsDuet = true; break; case EGameMode.TR_GAMEMODE_SHORTSONG: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_SHORTSONG"; break; default: Texts[htTexts(TextSongMode)].Text = "TR_GAMEMODE_NORMAL"; break; } }
public TurnOutput PlayATurn(List <Tile> DrawPile, List <SPlayer> PlayersIn, List <SPlayer> PlayersOut, Board b, Tile PlacedTile) { b.PlaceTile(PlacedTile); SPlayer ActivePlayer = b.GetCurrentPlayer(); List <SPlayer> eliminatedPlayers = new List <SPlayer> (); foreach (SPlayer p in b.GetAdjacentPlayers(PlacedTile)) { eliminatedPlayers.AddRange(b.MovePlayer(p, PlacedTile)); } foreach (SPlayer sp in eliminatedPlayers) { b.RemovePlayer(sp); } if (b.CurrentPlayersIn.Contains(ActivePlayer) && ActivePlayer.MyHand.Pieces.Count < 3) { b.CurrentDeck.DrawCard(ActivePlayer.MyHand); } return(getTurnOutput(b)); }
public override Vector3 CalculateMove(SPlayer Player, List <Transform> context, STeam team) { //if no neighbors, maintain current alignment if (context.Count == 0) { return(Player.transform.up); } //add all points together and average Vector3 alignmentMove = Vector3.zero; //List<Transform> filteredContext = (filter == null) ? context : filter.Filter(Player, context); foreach (Transform item in context) { alignmentMove += item.transform.up; } alignmentMove /= context.Count; return(alignmentMove); }
public static bool OnPlayerSpawn(SPlayer Player) { return true; }
public static bool OnDialogResponse(SPlayer Player, int DialogId, bool LeftButtunClicked, int ListItem, string Inputtext) { return true; }
public static bool OnPlayerObjectMoved(SPlayer Player, SPlayerObj Object) { return true; }
public static bool OnPlayerEditAttachedObject(SPlayer Player, bool IsSaved, bool IsCancelled, SObjectsEnum Model, string Bone, Point3D Pos, Point3D Rotation, Point3D Scale) { return true; }
public static bool OnPlayerEnterRaceCheckpoint(SPlayer Player) { return true; }
public static bool OnPlayerCommandText(SPlayer Player, string Command) { return true; }
public static bool OnPlayerDeath(SPlayer Player, SPlayer Killer, string UsedWeapon) { return true; }
public static bool OnPlayerUpdate(SPlayer Player) { return true; }
public static bool OnUnoccupiedVehicleUpdate(SPlayer Player, SVehicle Vehicle, VehicleSeats PassengerSeat) { return true; }
public static bool OnPlayerText(SPlayer Player, string Text) { Player.SendMessage((Player.Score++).ToString() + "!"); return true; }
public static bool OnEnterExitModShop(SPlayer Player, bool Entered, int InteriorId) { return true; }
public static bool OnPlayerTakeDamage(SPlayer Player, SPlayer From, float Amount, string UsedWep) { return true; }
public static bool OnPlayerStreamOut(SPlayer Player, SPlayer For) { return true; }
public static bool OnPlayerStateChange(SPlayer Player, PlayerStates NewState, PlayerStates OldState) { return true; }
public static bool OnPlayerClickPlayer(SPlayer Player, SPlayer Clicked, bool UsedScoreBoard) { return true; }
public static bool OnVehicleDamageStatusUpdate(SPlayer Player, SVehicle Vehicle) { return true; }
public static bool OnPlayerClickTextDraw(SPlayer Player, STextDraw TextDraw) { return true; }
public static bool OnVehicleDeath(SVehicle Vehicle, SPlayer Killer) { return true; }
public static bool OnPlayerConnected(SPlayer Player) { Player.SendMessage("zzz"); return true; }
public static bool OnVehicleMod(SPlayer Player, SVehicle Vehicle, VehComponent Component) { return true; }
public static bool OnPlayerDisconnect(SPlayer Player, DisconnectReason Reason) { return true; }
public static bool OnVehiclePaintjob(SPlayer Player, SVehicle Vehicle, int PaintJobId) { return true; }
public static bool OnPlayerEditObject(SPlayer Player, SObj Object, SPlayerObj PObj, bool IsCancelled, bool IsSaved, bool IsUpdate, Point3D Pos, Point3D Rotation) { return true; }
public static bool OnVehicleRespray(SPlayer Player, SVehicle Vehicle, SGColor Color1, SGColor Color2) { return true; }
public static bool OnPlayerRequestClass(SPlayer Player, SPSkin WSkin) { return true; }
public static bool OnVehicleStreamOut(SVehicle Vehicle, SPlayer Player) { return true; }
public static bool OnPlayerPickUpPickup(SPlayer Player, SPickup Pick) { return true; }
public static bool OnPlayerClickMap(SPlayer Player, Point3D Pos) { return true; }
public static bool OnPlayerSelectObject(SPlayer Player, SObj Object, SPlayerObj PObj, SObjectsEnum Model, Point3D Pos) { return true; }
public static bool OnPlayerSelectedMenuRow(SPlayer Player, int Row) { return true; }