public CPlayer GetPlayerAuto(string name = "") { CPlayer ph = GetPlayerRealHuman(); if (name == "Human") { return(ph); } return(GetPlayerElo(ph)); }
public int GetIndex(string name) { for (int n = 0; n < list.Count; n++) { CPlayer user = list[n]; if (user.name == name) { return(n); } } return(-1); }
public int LoadFromIni() { list.Clear(); List <string> pl = iniFile.ReadKeyList("player"); foreach (string name in pl) { var p = new CPlayer(name); p.LoadFromIni(); list.Add(p); } return(pl.Count); }
public void Add(CPlayer p) { p.name = p.GetName(); int index = GetIndex(p.name); if (index >= 0) { list[index] = p; } else { list.Add(p); } }
public static CPlayer SelectPlayer() { CPlayer p = playerList.GetPlayer(player); if (p == null) { p = SelectRare(); } if ((games >= repetition) && (games > 0)) { p = playerList.NextTournament(p); games = 0; } return(p); }
public void SortPosition(CPlayer player) { SortElo(); FillPosition(); int position = player.position; foreach (CPlayer p in list) { p.position = Math.Abs(position - p.position); } list.Sort(delegate(CPlayer p1, CPlayer p2) { return(p1.position - p2.position); }); }
public void SetPlayer(string name) { CPlayer p = FormChess.playerList.GetPlayer(name); if (p != null) { tournament = p.tournament; engine = p.engine; book = p.book; elo = p.elo; modeValue.mode = p.modeValue.mode; modeValue.value = p.modeValue.value; hisElo.Assign(p.hisElo); } }
public static CPlayer SelectRare() { int count = 0; CPlayer result = null; foreach (CPlayer p in playerList.list) { int c = tourList.CountGames(p.name); if (count <= c) { count = c; result = p; } } return(result); }
private void ButCreate_Click(object sender, EventArgs e) { string name = tbPlayerName.Text; if (FormChess.playerList.GetPlayer(name) == null) { modeValue.mode = combMode.Text; modeValue.SetValue((int)nudValue.Value); CPlayer player = new CPlayer(name); player.engine = cbEngineList.Text; FormChess.playerList.list.Add(player); SaveToIni(player); MessageBox.Show($"Player {player.name} has been created"); CData.reset = true; } else { MessageBox.Show($"Player {name} already exists"); } }
void SaveToIni(CPlayer p) { p.name = tbPlayerName.Text; p.engine = cbEngineList.Text; p.book = cbBookList.Text; p.SetTournament((int)nudTournament.Value); p.elo = nudElo.Value.ToString(); p.eloOrg = p.elo; p.modeValue.mode = modeValue.mode; p.modeValue.value = modeValue.value; p.SaveToIni(); UpdateListBox(); int index = listBox1.FindString(p.name); if (index == -1) { return; } listBox1.SetSelected(index, true); }
void SelectPlayers(int first, int last, bool t) { int f = first < last ? first : last; int l = first < last ? last : first; bool r = false; for (int n = f; n <= l; n++) { var item = listBox1.Items[n]; string name = item.ToString(); CPlayer pla = FormChess.playerList.GetPlayer(name); if (pla.SetTournament(t)) { r = true; } } if (r) { listBox1.Refresh(); SelectPlayer(); } }
public void SetPlayer(CPlayer p) { player = p; book = FormChess.bookList.GetBook(p.book); engine = FormChess.engineList.GetEngine(p.engine); bookPro.Terminate(); enginePro.Terminate(); if (book == null) { p.book = CData.none; } else { bookPro.SetProgram($@"{AppDomain.CurrentDomain.BaseDirectory}Books\{book.exe}", book.GetParameters(engine)); } if (engine == null) { p.engine = "Human"; } else { enginePro.SetProgram($@"{AppDomain.CurrentDomain.BaseDirectory}Engines\{engine.file}", engine.parameters, FormOptions.spamOff); } }
public void SetPlayer(string name) { CPlayer p = FormChess.playerList.GetPlayer(name); SetPlayer(p); }
void SelectPlayer(CPlayer p) { player = p; SelectPlayer(); }