private bool UpdateFlop(IDatavObj obj) { Flop flop = obj as Flop; var existFlops = Flops.Where(p => p.Name() == flop.Name()); if (existFlops.Any()) { Flop existFlop = existFlops.First(); if (existFlop.Same(flop)) { return(false); } else { Logger.Log($"[Datav][{Name}]更新翻牌器:"); Logger.Log(flop.ToString()); Logger.Log($"[Datav][{Name}]--------------"); Flops.Remove(existFlop); Flops.Add(flop); return(true); } } else { Flops.Add(flop); return(true); } }
public ActionResult <List <FlopReturnValue> > UpdateFlop(string datavName, string flopName, int startNumber, int variation, int changeInterval) { Flop flop = new Flop(flopName, datavName, startNumber, startNumber, variation, changeInterval); Flop existFlop = Backend.Instance.Controller().GetFlop(datavName, flopName); FlopReturnValue ret = new FlopReturnValue("", 0); if (existFlop == null) { bool succ = Backend.Instance.Controller().NewObj(datavName, flop); if (succ) { ret.value = flop.CurrentNumber; } } else { if (flop.Same(existFlop)) { ret.value = existFlop.CurrentNumber; } else { Backend.Instance.Controller().UpdateObj(datavName, flop); ret.value = startNumber; } } List <FlopReturnValue> retlist = new List <FlopReturnValue>(); retlist.Add(ret); return(retlist); }