TwoPlayerLogic ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  Drench.Logics Logic
    Drench.Logics TwoPlayerLogic
      Drench.Logics HumanVsAiLogic
      Drench.Logics TwoHumanLogic

Namespace: Drench.Logics
Assembly: Drench (in Drench.exe) Version: 1.1.1.0 (1.1.1)
Syntax

public abstract class TwoPlayerLogic : Logic

The TwoPlayerLogic type exposes the following members.

Constructors

  NameDescription
Protected methodTwoPlayerLogic(Board Data)
Initializes a new instance of the TwoPlayerLogic class
Protected methodTwoPlayerLogic(Int32, Int32)
Initializes a new instance of the TwoPlayerLogic class
Top
Methods

  NameDescription
Protected methodCheckForGameOver (Inherited from Logic.)
Protected methodGameOver (Inherited from Logic.)
Public methodGetPlayerScore (Inherited from Logic.)
Public methodGetPlayerTurnsTaken (Inherited from Logic.)
Public methodMakeMove (Inherited from Logic.)
Public methodPass (Inherited from Logic.)
Public methodReset (Inherited from Logic.)
Top
Fields

  NameDescription
Protected fieldhomeSquares (Inherited from Logic.)
Protected fieldturns (Inherited from Logic.)
Top
Properties

  NameDescription
Public propertyActivePlayer (Inherited from Logic.)
Public propertyIsGameOver (Inherited from Logic.)
Public propertyLastPlayerPassed (Inherited from Logic.)
Top
Events

  NameDescription
Public eventGameFinished (Inherited from Logic.)
Top
Remarks

Tests: Drench.Tests.Logics.TwoPlayerLogicTests
Examples

7 unit tests call Drench.Logics.TwoPlayerLogic
[Test]
public void FirstMoveChangesTopLeftColorAndActivePlayer()
{
    bool isGameFinished = false;
    logic.GameFinished += () => isGameFinished = true;
    logic.MakeMove(Color.Red);
    Assert.AreEqual(Color.Red, logic.Board.GetColor(0, 0));
    Assert.IsFalse(isGameFinished);
    Assert.AreEqual(1, logic.ActivePlayer);
    Assert.AreEqual(1, logic.GetPlayerScore(0));
}
[Test]
public void SecondMoveChangesBottomRightColorAndActivePlayer()
{
    bool isGameFinished = false;
    logic.GameFinished += () => isGameFinished = true;
    logic.MakeMove(Color.Red);
    logic.MakeMove(Color.Green);
    Assert.AreEqual(Color.Green,
        logic.Board.GetColor(BoardTests.Width - 1, BoardTests.Height - 1));
    Assert.IsFalse(isGameFinished);
    Assert.AreEqual(0, logic.ActivePlayer);
    Assert.AreEqual(1, logic.GetPlayerScore(1));
}
[Test]
public void ThirdMoveChangesTopLeftColorAndActivePlayer()
{
    bool isGameFinished = false;
    logic.GameFinished += () => isGameFinished = true;
    logic.MakeMove(Color.Red);
    logic.MakeMove(Color.Green);
    logic.MakeMove(Color.Purple);
    Assert.AreEqual(Color.Purple, logic.Board.GetColor(0, 0));
    Assert.IsFalse(isGameFinished);
    Assert.AreEqual(1, logic.ActivePlayer);
    Assert.AreEqual(1, logic.GetPlayerScore(0));
}
See Also