// TODO: Change signature? // TODO: TEST public Boolean ApplyValidMove(Position start, Position end) { // Hold both pieces // try: // ask conflict handler for result // try: // put the result at end position // put an empty at start position Piece attacker; ICell defender; try { attacker = (Piece)CellAtPos(start); defender = CellAtPos(end); } catch { return(false); } if (attacker == null || defender == null) { return(false); } ICell winner = ConflictHandler.Handle(attacker, defender); State[end.to_board_index(DefaultBoardSize)] = winner; State[start.to_board_index(DefaultBoardSize)] = new EmptyCell(); return(true); }
public void TestMinerFlag() { Piece att = new Miner(Ownership.FirstPlayer); ICell def = new Flag(Ownership.SecondPlayer); Assert.True(att == ConflictHandler.Handle(att, def)); }
public void TestSpyMarshal() { Piece att = new Spy(Ownership.FirstPlayer); ICell def = new Marshal(Ownership.SecondPlayer); Assert.True(att == ConflictHandler.Handle(att, def)); }
public void TestColonelColonel() { Piece att = new Colonel(Ownership.FirstPlayer); Piece def = new Colonel(Ownership.SecondPlayer); Assert.True(ConflictHandler.Handle(att, def) is EmptyCell); }
public void TestMinerEmpty() { Piece att = new Miner(Ownership.FirstPlayer); ICell def = new EmptyCell(); Assert.True(att == ConflictHandler.Handle(att, def)); }
public void TestMajorGeneral() { Piece att = new Major(Ownership.SecondPlayer); ICell def = new General(Ownership.FirstPlayer); Assert.True(def == ConflictHandler.Handle(att, def)); }
public void TestMinerLieutenant() { Piece att = new Miner(Ownership.FirstPlayer); Piece def = new Lieutenant(Ownership.SecondPlayer); Assert.True(def == ConflictHandler.Handle(att, def)); }
public void TestMinerBomb() { Piece att = new Miner(Ownership.FirstPlayer); Piece def = new Bomb(Ownership.SecondPlayer); ICell ans = ConflictHandler.Handle(att, def); Assert.True(att == ans); }
public void TestFailOnSameSideAttackColonalFlag__ThrowsPieceConflictHandlerException() { Piece att = new Colonel(Ownership.SecondPlayer); ICell def = new Flag(Ownership.SecondPlayer); TestDelegate code = () => ConflictHandler.Handle(att, def); Assert.Throws(typeof(PieceConflictHandlerException), code); }
public void TestFailOnSameSideAttackSpySergeant__ThrowsPieceConflictHandlerException() { Piece att = new Spy(Ownership.FirstPlayer); ICell def = new Sergeant(Ownership.FirstPlayer); TestDelegate code = () => ConflictHandler.Handle(att, def); Assert.Throws(typeof(PieceConflictHandlerException), code); }
public void TestFailOnAttackWaterMiner_ThrowsPieceConflictHandlerException() { Piece att = new Miner(Ownership.SecondPlayer); ICell def = new WaterCell(); TestDelegate code = () => ConflictHandler.Handle(att, def); Assert.Throws(typeof(PieceConflictHandlerException), code); }
public void TestFailOnAttackerBomb_ThrowsPieceConflictHandlerException() { Piece att = new Bomb(Ownership.FirstPlayer); ICell def = new Scout(Ownership.SecondPlayer); TestDelegate code = () => ConflictHandler.Handle(att, def); Assert.Throws(typeof(PieceConflictHandlerException), code); }