public void NotifyMovePlayed(GoColor color) { m_stopwatch.Stop(); // check the color TimeSettings toUse = color == GoColor.BLACK ? BlackTime : WhiteTime; if (toUse.MainTime.TotalSeconds <= 0) { toUse.Byoyomi -= m_stopwatch.Elapsed; --toUse.NumberOfMovesPerByoyomi; if (toUse.NumberOfMovesPerByoyomi <= 0) { // reset byoyomi time toUse.Byoyomi = OrginialTime.Byoyomi; toUse.NumberOfMovesPerByoyomi = OrginialTime.NumberOfMovesPerByoyomi; } } else { toUse.Byoyomi -= m_stopwatch.Elapsed; } m_stopwatch.Reset(); m_stopwatch.Start(); }
public GoGameInfo() { m_size = 9; m_komi = 0.5f; m_handicap = 0; m_timeSettings = new TimeSettings(); }
public GoClock(TimeSettings settings) { BlackInfiniteTime = false; WhiteInfiniteTime = false; CanLooseOnTime = true; BlackTime = new TimeSettings(settings); WhiteTime = new TimeSettings(settings); OrginialTime = new TimeSettings(settings); m_stopwatch = new Stopwatch(); }
// get remaining byoyomi moves to play, 0 if not in byoyomi public int getByoyomiMove(GoColor color) { TimeSettings toUse = color == GoColor.BLACK ? BlackTime : WhiteTime; if (toUse.MainTime.TotalSeconds > 0) { return(0); } else { return(toUse.NumberOfMovesPerByoyomi); } }
public TimeSpan getRemainingTime(GoColor color) { TimeSettings toUse = color == GoColor.BLACK ? BlackTime : WhiteTime; if (toUse.MainTime.TotalSeconds > 0) { return(toUse.MainTime); } else { return(toUse.Byoyomi.TotalMilliseconds > 0 ? toUse.Byoyomi : new TimeSpan()); } }
// return true if the player run out of time! public bool update(GoColor color) { m_stopwatch.Stop(); bool colorCanLooseOnTime = CanLooseOnTime; // check the color if (color == GoColor.BLACK) { colorCanLooseOnTime &= !BlackInfiniteTime; } else { colorCanLooseOnTime &= !WhiteInfiniteTime; } TimeSettings toUse = color == GoColor.BLACK ? BlackTime : WhiteTime; TimeSpan remaingTime = toUse.MainTime; if (toUse.MainTime.TotalSeconds > 0) { toUse.MainTime -= m_stopwatch.Elapsed; remaingTime = toUse.MainTime; if (remaingTime.TotalMilliseconds < 0) { //toUse.Byoyomi += toUse.MainTime; // report what we put too much on main time toUse.Byoyomi = OrginialTime.Byoyomi; remaingTime = toUse.Byoyomi; } } else { toUse.Byoyomi -= m_stopwatch.Elapsed; remaingTime = toUse.Byoyomi; } m_stopwatch.Reset(); m_stopwatch.Start(); if (remaingTime.TotalMilliseconds >= -1990) // more time for pachi... { return(false); } return(colorCanLooseOnTime); }
public TimeSettings(TimeSettings other) { m_mainTime = new TimeSpan(other.MainTime.Hours, other.MainTime.Minutes, other.MainTime.Seconds); m_byoyomi = new TimeSpan(other.Byoyomi.Hours, other.Byoyomi.Minutes, other.Byoyomi.Seconds); m_numberOfMovesPerByoyomi = other.NumberOfMovesPerByoyomi; }