public void CheckTestTheory(rsp player1, rsp player2, int exceptedResult) { AdditionalWinnerChecker winnerChecker = new AdditionalWinnerChecker(); var result = winnerChecker.Play(player1, player2); Assert.Equal(exceptedResult, result); }
public void RequestProcessing(TcpClient client, string mess) { String[] req = mess.Split(":"); switch (req[0]) { case "name": // запись в клиенты clients.Add(client, req[1]); foreach (var x in clients.Keys) { if (x != client) { SendMessage(x, $"player:{req[1]}"); } } Console.WriteLine($"New player is {req[1]}"); break; case "choice": rsp choice = rsp.Lizard; switch (req[1]) { case "paper": choice = rsp.Paper; break; case "lizard": choice = rsp.Lizard; break; case "rock": choice = rsp.Rock; break; case "scissors": choice = rsp.Scissors; break; case "spoke": choice = rsp.Spoke; break; } players.Add(client, choice); foreach (var x in clients.Keys) { if (true /*x != client*/) { SendMessage(x, $"choised:{clients[client]}"); } } break; case "continue": break; default: Console.WriteLine($"Unknow request: {mess}"); break; } }
public int Play(rsp first, rsp second) { switch (first) { case rsp.Paper: if (second == rsp.Paper) { return(0); } else if (second == rsp.Rock) { return(1); } else if (second == rsp.Scissors) { return(2); } break; case rsp.Rock: if (second == rsp.Paper) { return(2); } else if (second == rsp.Rock) { return(0); } else if (second == rsp.Scissors) { return(1); } break; case rsp.Scissors: if (second == rsp.Paper) { return(1); } else if (second == rsp.Rock) { return(2); } else if (second == rsp.Scissors) { return(0); } break; default: return(-1); break; } return(-1); }
protected override XResp Execute() { var q = from g in DB.x_goods where g.status == 2 select g; if (!string.IsNullOrEmpty(key)) { q = q.Where(o => o.name.Contains(key) || o.alias.Contains(key) || o.remark.Contains(key)); } if (!string.IsNullOrEmpty(cate)) { var cids = DB.x_dict.Where(o => o.code == "goods.cate" && o.upval.Contains(cate) || o.value == cate).Select(o => o.value); q = q.Where(o => cids.Contains(o.cate_id)); } if (cu != null) { q = q.Where(o => o.city == cu.city); } if (!string.IsNullOrEmpty(md)) { q = q.Where(o => o.alias.Contains(md)); } if (bd > 0) { q = q.Where(o => o.brand == bd); } var r = new rsp(); r.page = page; r.count = q.Count(); r.mds = q.GroupBy(o => o.alias).Select(o => o.Key).ToArray(); r.bds = q.GroupBy(o => o.brand).Select(o => new { id = o.Key, name = GetDictName("goods.brand", o.Key) }).ToArray(); r.items = q .OrderByDescending(o => o.sort).ThenByDescending(o => o.ctime) .Skip((page - 1) * limit) .Take(limit) .ToList() .Select(o => new { id = o.goods_id, o.name, o.alias, price = o.new_price, o.cover, o.unit, count = getcount(o.goods_id) }); return(r); }
public int Play(rsp first, rsp second) { if ((int)first <= 5 && (int)second <= 5) { if (first == second) { return(0); } else if (d[first].Contains <rsp>(second)) { return(1); } else { return(2); } } return(-1); }