private GamePlayer CreateAgentFromComboboxObject(InGameForm form, object text, StoneColor color) { TimeControl timeControl = null; if (rbNoTimeControl.Checked) { timeControl = new NoTimeControl(); } else if (rbAbsoluteTiming.Checked) { timeControl = new AbsoluteTimeControl(1); } else if (rbCanadianTiming.Checked) { timeControl = new CanadianTimeControl(TimeSpan.FromSeconds(10), 5, TimeSpan.FromSeconds(10)); } else if (rbJapaneseTiming.Checked) { timeControl = new JapaneseTimeControl(20, 30, 3); } if (text is string && ((string)text) == "Human") { GamePlayer human = new HumanPlayerBuilder(color) .Name(color.ToString()) .Rank("NR") .Clock(timeControl) .Build(); (human.Agent as HumanAgent).MoveRequested += (e, e2) => { form.GuiAgent_PleaseMakeAMove(null, null); }; return(human); } if (text is IAIProgram) { IAIProgram newInstance = (IAIProgram)Activator.CreateInstance(text.GetType()); GamePlayer aiPlayer = new AiPlayerBuilder(color) .Name(text.ToString() + "(" + color.ToIgsCharacterString() + ")") .Rank("NR") .Clock(timeControl) .AiProgram(newInstance) .Build(); return(aiPlayer); } throw new Exception("This agent cannot be handled yet."); }
private static TimeControlTexts TranslateJapaneseSubtext(JapaneseTimeInformation japaneseTimeInformation, JapaneseTimeControl japaneseTimeControl) { return(new TimeControlTexts( string.Format(Localizer.TimeControl_JapaneseSubtext, japaneseTimeInformation.PeriodsLeft, japaneseTimeControl.PeriodLength), Localizer.TimeControl_JapaneseTooltip )); }