private bool MoveCard(ComparerList <byte, KeyValuePair <List <Karta>, List <CardSocketUI> > > .Transition item) { var Socket = item.To.Value.First(X => X.InnerCard == null); var Card = item.From.Value.FirstOrDefault(X => X.InnerCard?.Card == (Karta)item.target).InnerCard; if (Socket != null && Card != null) { CardUI.BindCardToSocket(Socket, Card, false); return(true); } return(false); }
private bool FromEmpty(ComparerList <byte, KeyValuePair <List <Karta>, List <CardSocketUI> > > .Transition item) { var Socket = item.To.Value.FirstOrDefault(X => X.InnerCard == null); if (Socket != null) { CardUI.BindCardToSocket(Socket, GetCard(item.From, item.To, (Karta)item.target), false); return(true); } else { return(false); } }
private bool ToEmpty(ComparerList <byte, KeyValuePair <List <Karta>, List <CardSocketUI> > > .Transition item) { var Card = item.From.Value.FirstOrDefault(X => X.InnerCard?.Card == (Karta)item.target).InnerCard; if (Card != null) { CardUI.BindCardToSocket(GetEmptySocket(item.From, item.To, (Karta)item.target), Card, false); return(true); } else { return(false); } }
private bool ExecuteMove(ComparerList <byte, KeyValuePair <List <Karta>, List <CardSocketUI> > > .Transition item) { if (Object.Equals(item.From, null) || Object.Equals(item.From.Key, null)) { return(FromEmpty(item)); } else if (Object.Equals(item.To, null) || Object.Equals(item.To.Key, null)) { return(ToEmpty(item)); } else { return(MoveCard(item)); } }
public void Execute(BaseTable date) { ComparerList <byte, KeyValuePair <List <Karta>, List <CardSocketUI> > > com = new ComparerList <byte, KeyValuePair <List <Karta>, List <CardSocketUI> > >(X => X.Key.Cast <byte>()); var diff = com.Comparer(date.list, list); for (int i = 0; i < 10; i++) { HashSet <object> toRemove = new HashSet <object>(); foreach (var item in diff) { if (ExecuteMove(item)) { toRemove.Add(item); } } diff.RemoveAll(X => toRemove.Contains(X)); } }