//检测可以掉落的 void CheckFallDown() { List <ComBox> allBoxs = boxManager.GetAllRow(); List <ComBox> topBoxs = boxManager.GetBoxListByRow(topRow); //把所有球状态设置为未连接 foreach (ComBox box in allBoxs) { box.link = false; box.check = false; } //遍历检测 foreach (ComBox box in topBoxs) { CheckFallBall(box); } foreach (ComBox box in allBoxs) { if (!box.link) { boxManager.RemoveBox(box); box.FallDown(); } } }
public void Run(IrcMessage theMessage) { try { if (theMessage.CommandArgs[0] == "box") { using (var context = new BotContext()) { User u = context.GetUser(theMessage.CommandArgs[1]); if (u != null) { BoxManager mgr = new BoxManager(u, context); string boxtoadd = theMessage.CommandArgs.Skip(2).Join(" "); if (mgr.HasBox(boxtoadd)) { theMessage.Answer("Diese Box gibt es für diesen User bereits!"); return; } mgr.AddBox(boxtoadd); theMessage.Answer("Hinzugefügt"); return; } theMessage.Answer("User gibbet nicht"); } } if (theMessage.CommandArgs[0] == "boxremove") { using (var context = new BotContext()) { User u = context.GetUser(theMessage.CommandArgs[1]); if (u != null) { BoxManager mgr = new BoxManager(u, context); if (mgr.RemoveBox(theMessage.CommandArgs.Skip(2).Join(" "))) { theMessage.Answer("Erledigt!"); return; } theMessage.Answer("Der Suchstring wurde nicht gefunden und deshalb nicht gelöscht"); return; } theMessage.Answer("User gibbet nicht"); } } } catch (Exception ex) { Log.Error(ex, "Bei einer Datenbank Operation ist eine Exception aufgetreten"); theMessage.Answer("Wups, das hat eine Exception verursacht"); } }
public void Run(IrcMessage theMessage) { using (var context = new BotContext()) { BoxManager mgr = new BoxManager(context.GetUser(theMessage.Nickname), context); if (mgr.RemoveBox(theMessage.CommandLine)) { theMessage.Answer("Erledigt!"); } else { theMessage.Answer("Der Suchstring wurde nicht gefunden und deshalb nicht gelöscht"); } } }