-
-
Save daleth90/4b9aab2dbca5555bedd7fec796ed8666 to your computer and use it in GitHub Desktop.
modified for request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Zenject; | |
public class OthelloGame : IInitializable { | |
private readonly OthelloBoardModel othelloBoard; | |
public OthelloGame( OthelloBoardModel othelloBoard ) { | |
this.othelloBoard = othelloBoard; | |
} | |
public void Initialize() { | |
StartNewGame(); | |
} | |
public void StartNewGame() { | |
othelloBoard.SetSide( Disk.DARK ); | |
othelloBoard.PlaceDisk( 4, 5 ); | |
othelloBoard.PlaceDisk( 5, 4 ); | |
othelloBoard.SetSide( Disk.LIGHT ); | |
othelloBoard.PlaceDisk( 4, 4 ); | |
othelloBoard.PlaceDisk( 5, 5 ); | |
othelloBoard.SetSide( Disk.DARK ); | |
othelloBoard.OnRequestDisk += ValidatePlacement; | |
} | |
private void ValidatePlacement( int x, int y, Disk disk ) { | |
othelloBoard.PlaceDisk( x, y ); | |
if ( disk == Disk.DARK ) { | |
othelloBoard.SetSide( Disk.LIGHT ); | |
} | |
else if ( disk == Disk.LIGHT ) { | |
othelloBoard.SetSide( Disk.DARK ); | |
} | |
else { | |
throw new ArgumentException( "Place \"None\" disk which is impossible in the game" ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment