Spielmodell-Stubs: GameMove, GameResult, GameState, IGameStateObserver, IMoveProvider, MoveResult, Occupation, Phase, Player

This commit is contained in:
Markus Himmel
2016-08-24 11:59:08 +02:00
parent 1ba8b3c92a
commit 84b2a5a3d6
11 changed files with 264 additions and 0 deletions

80
Morris/GameMove.cs Normal file
View File

@@ -0,0 +1,80 @@
/*
* GameMove.cs
* Copyright (c) 2016 Markus Himmel
* This file is distributed under the terms of the MIT license
*/
namespace Morris
{
/// <summary>
/// Repräsentiert einen potentiell ungültigen Spielzug
/// </summary>
public class GameMove
{
/// <summary>
/// Falls in dem Zug ein Stein bewegt wird, die Position des Steines vor dem Zug
/// </summary>
public int? From { get; private set; }
/// <summary>
/// Die Position eines neuen oder bewegten Steines nach dem Zug
/// </summary>
public int To { get; private set; }
/// <summary>
/// Falls der Zug eine Mühle schließt, die Position des infolgedessen entfernten gegnerischen Steines
/// </summary>
public int? Remove { get; private set; }
private GameMove(int? from, int to, int? remove)
{
From = from;
To = to;
Remove = remove;
}
/// <summary>
/// Erstellt einen neuen Zug, der das Setzen eines neuen Steines repräsentiert
/// </summary>
/// <param name="position">Wo der neue Stein platziert werden soll</param>
/// <returns>Einen nicht zwangsläufig gütligen Spielzug</returns>
public static GameMove Place(int position)
{
return new GameMove(null, position, null);
}
/// <summary>
/// Erstellt einen neuen Zug, der das Setzen eines neuen Steines und das Schließen einer Mühle repräsentiert
/// </summary>
/// <param name="position">Wo der neue Stein platziert werden soll</param>
/// <param name="remove">Welcher gegnerische Stein entfernt werden soll</param>
/// <returns>Einen nicht zwangsläufig gültigen Spielzug</returns>
public static GameMove PlaceRemove(int position, int remove)
{
return new GameMove(null, position, remove);
}
/// <summary>
/// Erstellt einen neuen Zug, der das Bewegen eines Steines repräsentiert
/// </summary>
/// <param name="from">Wo sich der Stein vor dem Zug befindet</param>
/// <param name="to">Wo sich der Stein nach dem Zug befinden soll</param>
/// <returns>Einen nicht zwangsläufig gültigen Spielzug</returns>
public static GameMove Move(int from, int to)
{
return new GameMove(from, to, null);
}
/// <summary>
/// Erstellt einen neuen Zug, der das Bewegen eines Steines und das Schließen einer Mühle repräsentiert
/// </summary>
/// <param name="from">Wo sich der Stein vor dem Zug befindet</param>
/// <param name="to">Wo sich der Stein nach dem Zug befindet</param>
/// <param name="remove">Welcher gegnerische Stein bewegt werden soll</param>
/// <returns>Einen nicht zwangsläufig gültigen Spielzug</returns>
public static GameMove MoveRemove(int from, int to, int remove)
{
return new GameMove(from, to, remove);
}
}
}

19
Morris/GameResult.cs Normal file
View File

@@ -0,0 +1,19 @@
/*
* GameResult.cs
* Copyright (c) 2015 Markus Himmel
* This file is distributed under the terms of the MIT license
*/
namespace Morris
{
/// <summary>
/// Beschreibt, ob ein Spiel beendet ist und wie es ausgegangen ist
/// </summary>
public enum GameResult
{
Running,
WhiteVictory,
BlackVictory,
Draw
}
}

36
Morris/GameState.cs Normal file
View File

@@ -0,0 +1,36 @@
/*
* GameState.cs
* Copyright (c) 2016 Markus Himmel
* This file is distributed under the terms of the MIT license
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Morris
{
/// <summary>
/// Repräsentiert eine Mühle-Spielsituation
/// </summary>
public class GameState
{
public Occupation[] Board { get; private set; }
public Player NextToMove { get; private set; }
public GameResult Result { get; private set; }
public GameState()
{
// Leeres Feld
Board = Enumerable.Repeat(Occupation.Free, 24).ToArray();
NextToMove = Player.White;
Result = GameResult.Running;
}
public bool IsValidMove()
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Morris
{
interface IGameStateObserver
{
}
}

12
Morris/IMoveProvider.cs Normal file
View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Morris
{
interface IMoveProvider
{
}
}

21
Morris/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Markus Himmel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -43,6 +43,16 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="GameResult.cs" />
<Compile Include="GameState.cs" />
<None Include="LICENSE" />
<Compile Include="IGameStateObserver.cs" />
<Compile Include="IMoveProvider.cs" />
<Compile Include="GameMove.cs" />
<Compile Include="MoveResult.cs" />
<Compile Include="Occupation.cs" />
<Compile Include="Phase.cs" />
<Compile Include="Player.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

21
Morris/MoveResult.cs Normal file
View File

@@ -0,0 +1,21 @@
/*
* MoveResult.cs
* Copyright (c) 2016 Markus Himmel
* This file is distributed under the terms of the MIT license
*/
namespace Morris
{
/// <summary>
/// Resultate eines Zuges, die für den <see cref="IMoveProvider"/> relevant sind.
/// Insbesondere gibt MoveResult keine Information darüber, ob das Spiel durch
/// aktuellen Zug beendet wurde, da diese Informationen durch einen geeigneten
/// <see cref="IGameStateObserver"/> an den Benutzer weitergegeben werden soll.
/// </summary>
public enum MoveResult
{
GameNotRunning,
InvalidMove,
OK
}
}

18
Morris/Occupation.cs Normal file
View File

@@ -0,0 +1,18 @@
/*
* Occupation.cs
* Copyright (c) 2016 Markus Himmel
* This file is distributed under the terms of the MIT license
*/
namespace Morris
{
/// <summary>
/// Zustand, den eine Stelle auf dem Spielfeld einnehmen kann
/// </summary>
public enum Occupation
{
Free,
White,
Black
}
}

18
Morris/Phase.cs Normal file
View File

@@ -0,0 +1,18 @@
/*
* Phase.cs
* Copyright (c) 2016 Markus Himmel
* This file is distributed under the terms of the MIT license
*/
namespace Morris
{
/// <summary>
/// Eine Phase, in der sich ein Spieler während des Mühlespiels befinden kann
/// </summary>
public enum Phase
{
Placing,
Moving,
Flying
}
}

17
Morris/Player.cs Normal file
View File

@@ -0,0 +1,17 @@
/*
* Player.cs
* Copyright (c) 2016 Markus Himmel
* This file is distributed under the terms of the MIT license
*/
namespace Morris
{
/// <summary>
/// Repräsentiert einen Spieler
/// </summary>
public enum Player
{
White,
Black
}
}