public void insTux(ushort ut) { Tux.Add(ut); Base.Card.Tux tux = Tuple.TL.DecodeTux(ut); Card.Ruban ruban = null; pb.Dispatcher.BeginInvoke((Action)(() => { if (tux != null) { Image image = pb.TryFindResource("tuxCard" + tux.Code) as Image; if (image != null) ruban = new Card.Ruban(image, ut); } if (ruban == null) ruban = new Card.Ruban(pb.TryFindResource("tuxCard000") as Image, ut); ruban.ToolTip = Tips.IchiDisplay.GetTuxTip(Tuple, ut); ruban.Loc = Card.Ruban.Location.BAG; ruban.Cat = Card.Ruban.Category.ACTIVE; pb.InsTux(ruban); })); }
internal bool Switch(int from, Ruban to) { List<Ruban> list = new List<Ruban>(); foreach (var elem in mainBoard.Children) { Ruban ru = elem as Ruban; if (ru != null) list.Add(ru); } foreach (Ruban ru in list) mainBoard.Children.Remove(ru); Ruban ichi = list.Find(p => p.UT == to.UT); if (ichi == null) ichi = list.Find(p => p.UT == 0); if (ichi != null) list.Remove(ichi); Ruban ni = list.Find(p => p.UT == from); if (ni == null) return false; list.Remove(ni); // Update $to to.Loc = Ruban.Location.DEAL; to.Cat = Ruban.Category.ACTIVE; to.LengthLimit = (int)(mainGrid.Width - 30); to.cardBody.Checked += delegate(object sender, RoutedEventArgs e) { if (input != null) input(to.UT.ToString()); to.cardBody.IsChecked = false; }; to.Index = ni.Index; to.Jndex = ni.Jndex; list.Add(to); foreach (Ruban ru in list) { mainBoard.Children.Add(ru); if (ichi != null && ru.Jndex == ichi.Jndex && ru.Index >= ichi.Index) --ru.Index; int count = list.Count(p => p.Jndex == ru.Jndex); ru.SetOfIndex(ru.Index, ru.Jndex, count); } return true; }
internal void PuckBack(Ruban ruban) { int ti = 0, tj = 0; // Jndex, List of Index IDictionary<int, List<int>> dict = new Dictionary<int, List<int>>(); foreach (var elem in mainBoard.Children) { Ruban ru = elem as Ruban; if (ru != null) { if (!dict.ContainsKey(ru.Jndex)) dict.Add(ru.Jndex, new List<int>()); dict[ru.Jndex].Add(ru.Index); } } int shortIndex = -1, shortLen = 48; foreach (var pair in dict) { List<int> lst = pair.Value; lst.Sort(); for (int i = 1; i < lst.Count; ++i) if (lst[i] - lst[i - 1] != 1) { ti = i; tj = pair.Key; goto handle; } if (lst.Count < shortLen) { shortIndex = pair.Key; shortLen = lst.Count; } } if (shortLen < 48) { ti = shortLen; tj = shortIndex; } else { ti = 0; tj = 0; } handle: ruban.Loc = Ruban.Location.DEAL; ruban.Cat = Ruban.Category.ACTIVE; ruban.LengthLimit = (int)(mainGrid.Width - 30); mainBoard.Children.Add(ruban); ruban.cardBody.Checked += delegate(object sender, RoutedEventArgs e) { if (input != null) input(ruban.UT.ToString()); ruban.cardBody.IsChecked = false; }; ruban.SetOfIndex(ti, tj, Line); return; }
// operatable internal void CstCongress(List<Ruban> xme, List<Ruban> xop, Ruban me, Ruban right, Ruban left, bool captain, bool operatable) { mainBoard.Children.Clear(); //selectedList = new ObservableCollection<Ruban>(); int csz = xme.Count; Line = 9; int idx = 0; mainGrid.Height = 422; mainGrid.Width = 850; mainGrid.Background = FindResource("dt05Bg") as ImageBrush; ShipRule shipRule = new ShipRule(); shipRule.ZoneList.Add(new ShipRule.Zone(0, Line, 2, 2, ShipRule.AlignStyle.ALIGN)); shipRule.ZoneList.Add(new ShipRule.Zone(4, 4, 1, 1, ShipRule.AlignStyle.STAY)); if (captain) { shipRule.ZoneList.Add(new ShipRule.Zone(2, 2, 1, 1, ShipRule.AlignStyle.STAY)); shipRule.ZoneList.Add(new ShipRule.Zone(6, 6, 1, 1, ShipRule.AlignStyle.STAY)); } foreach (Ruban ruban in xme) { ruban.Loc = Ruban.Location.DEAL; if (operatable) ruban.Cat = Ruban.Category.PISTON; else ruban.Cat = Ruban.Category.SOUND; ruban.ShipRule = shipRule; ruban.LengthLimit = (int)(mainGrid.Width - 30); mainBoard.Children.Add(ruban); ruban.cardBody.Checked += delegate(object sender, RoutedEventArgs e) { if (input != null) input(ruban.UT.ToString()); ruban.cardBody.IsChecked = false; }; ruban.moveCaller += delegate(int oI, int oJ, int nI, int nJ) { if (nJ == 1) { if (captain) { if (nI == 2 || nI == 4 || nI == 6) { int target = Rank + (nI - 4); if (target <= 0) target += 6; if (target > 6) target -= 6; if (input != null) input(target + "," + ruban.UT.ToString()); } } else { if (nI == 4 && input != null) input(ruban.UT.ToString()); } } else if (oJ == 1 && nJ == 2) { if (captain) { if (nI == 2 || nI == 4 || nI == 6) { int target = Rank + (nI - 4); if (input != null) input(target + ",0"); } } else { if (input != null) input("0"); } } }; ruban.SetOfIndex(idx++, 2, Line); } idx = 0; foreach (Ruban ruban in xop) { ruban.Loc = Ruban.Location.DEAL; ruban.Cat = Ruban.Category.SOUND; ruban.LengthLimit = (int)(mainGrid.Width - 30); mainBoard.Children.Add(ruban); ruban.SetOfIndex(idx++, 0, Line); } Ruban[] friends = new Ruban[] { me, right, left }; int[] fridx = new int[] { 4, 6, 2 }; for (int i = 0; i < 3; ++i) { Ruban ruban = friends[i]; if (ruban != null) { ruban.Loc = Ruban.Location.DEAL; ruban.Cat = Ruban.Category.PISTON; ruban.LengthLimit = (int)(mainGrid.Width - 30); ruban.ShipRule = shipRule; mainBoard.Children.Add(ruban); ruban.SetOfIndex(fridx[i], 1, Line); ruban.moveCaller += delegate(int oI, int oJ, int nI, int nJ) { if (nJ == 1) { if (captain) { if (nI == 2 || nI == 4 || nI == 6) { int target = Rank + (nI - 4); if (target <= 0) target += 6; if (target > 6) target -= 6; if (input != null) input(target + "," + ruban.UT.ToString()); } } else { if (nI == 4 && input != null) input(ruban.UT.ToString()); } } else if (oJ == 1 && nJ == 2) { if (captain) { if (nI == 2 || nI == 4 || nI == 6) { int target = Rank + (nI - 4); if (input != null) input(target + ",0"); } } else { if (input != null) input("0"); } } }; } } if (operatable) okButton.Visibility = Visibility.Visible; else okButton.Visibility = Visibility.Hidden; this.Visibility = Visibility.Visible; }
private static Ruban GenRuban(string str, FrameworkElement uc, Base.LibGroup tuple, bool gray) { Ruban rb = null; if (str == "C0") rb = new Ruban(uc.TryFindResource("tuxCard000") as Image, 0); else if (str.StartsWith("C")) { ushort ut = ushort.Parse(str.Substring(1)); Tux tux = tuple.TL.DecodeTux(ut); if (tux != null) { Image image = uc.TryFindResource("tuxCard" + tux.Code) as Image; if (image != null) rb = new Ruban(image, ut); else rb = new Ruban(uc.TryFindResource("tuxCard000") as Image, ut); } else rb = new Ruban(uc.TryFindResource("tuxCard000") as Image, ut); rb.ToolTip = Tips.IchiDisplay.GetTuxTip(tuple, ut); } else if (str.StartsWith("M")) { ushort ut = ushort.Parse(str.Substring(1)); NMB nmb = NMBLib.Decode(ut, tuple.ML, tuple.NL); if (nmb != null) { Image image = uc.TryFindResource("monCard" + nmb.Code) as Image; Image2Gray(ref image, gray); if (image != null) rb = new Ruban(image, ut); else rb = new Ruban(uc.TryFindResource("monCard000") as Image, ut); if (nmb.IsMonster()) rb.ToolTip = Tips.IchiDisplay.GetMonTip(tuple, NMBLib.OriginalMonster(ut)); else if (nmb.IsNPC()) rb.ToolTip = Tips.IchiDisplay.GetNPCTip(tuple, NMBLib.OriginalNPC(ut)); } else rb = new Ruban(uc.TryFindResource("monCard000") as Image, ut); } else if (str.StartsWith("H0")) rb = new Ruban(uc.TryFindResource("hroCard000") as Image, 0); else if (str.StartsWith("H")) { ushort ut = ushort.Parse(str.Substring("H".Length)); Hero hro = tuple.HL.InstanceHero(ut); if (hro != null) { Image image = uc.TryFindResource("hroCard" + hro.Ofcode) as Image; Image2Gray(ref image, gray); if (image != null) rb = new Ruban(image, ut); else rb = new Ruban(uc.TryFindResource("hroCard000") as Image, ut); } else rb = new Ruban(uc.TryFindResource("hroCard000") as Image, ut); rb.ToolTip = Tips.IchiDisplay.GetHeroTip(tuple, ut); } else if (str.StartsWith("D")) { ushort ut = ushort.Parse(str.Substring("D".Length)); Image image = uc.TryFindResource("diceImg" + ut) as Image; if (image != null) rb = new Ruban(image, ut); else rb = new Ruban(uc.TryFindResource("diceImg000") as Image, ut); rb.ToolTip = null; } else if (str.StartsWith("G")) { ushort dbSerial = ushort.Parse(str.Substring("G".Length)); Tux tux = tuple.TL.EncodeTuxDbSerial(dbSerial); if (tux != null) { Image image = uc.TryFindResource("tuxCard" + tux.Code) as Image; Image2Gray(ref image, gray); if (image != null) rb = new Ruban(image, dbSerial); else rb = new Ruban(uc.TryFindResource("tuxCard000") as Image, dbSerial); rb.ToolTip = Tips.IchiDisplay.GetTuxDbSerialTip(tuple, dbSerial); } else rb = new Ruban(uc.TryFindResource("tuxCard000") as Image, dbSerial); } else if (str.StartsWith("I")) { ushort ut = ushort.Parse(str.Substring("I".Length)); Image image = uc.TryFindResource("exspCard" + ut) as Image; if (image != null) rb = new Ruban(image, ut); else rb = new Ruban(uc.TryFindResource("diceImg000") as Image, ut); rb.ToolTip = Tips.IchiDisplay.GetExspTip(tuple, "I" + ut); } else if (str.StartsWith("E0")) { Image image = uc.TryFindResource("eveCard000") as Image; image.RenderTransform = new RotateTransform(90); rb = new Ruban(image, 0); } else if (str.StartsWith("E")) { ushort ut = ushort.Parse(str.Substring("E".Length)); Evenement eve = tuple.EL.DecodeEvenement(ut); Image image = uc.TryFindResource("eveCard" + eve.Code) as Image ?? uc.TryFindResource("eveCard000") as Image; FormatConvertedBitmap bp = new FormatConvertedBitmap(); bp.BeginInit(); bp.Source = image.Source as BitmapSource; bp.EndInit(); TransformedBitmap tb = new TransformedBitmap(); tb.BeginInit(); tb.Source = bp; tb.Transform = new RotateTransform(90); tb.EndInit(); image = new Image() { Source = tb }; Image2Gray(ref image, gray); rb = new Ruban(image, ut); rb.ToolTip = Tips.IchiDisplay.GetEveTip(tuple, ut); } else if (str.StartsWith("R")) { ushort ut = ushort.Parse(str.Substring("R".Length)); Image image = uc.TryFindResource("runeCard" + ut) as Image; if (image != null) rb = new Ruban(image, ut); else rb = new Ruban(uc.TryFindResource("runeCard000") as Image, ut); rb.ToolTip = Tips.IchiDisplay.GetRuneTip(tuple, ut); } else if (str.StartsWith("V")) { ushort ut = ushort.Parse(str.Substring("V".Length)); Image image = uc.TryFindResource("fiveImg" + ut) as Image; if (image != null) rb = new Ruban(image, ut); else rb = new Ruban(uc.TryFindResource("diceImg000") as Image, ut); rb.ToolTip = Tips.IchiDisplay.GetFiveTip(tuple, ut); } return rb; }
public Ruban Clone() { Ruban ruban = new Ruban(Face, UT); ruban.Loc = Loc; ruban.Cat = Cat; return ruban; }
protected Ruban GenRuban(int hr) { Ruban ruban = null; if (hr != 0) { Base.Card.Hero hro = Tuple.HL.InstanceHero(hr); if (hro != null) { Image image = ar.TryFindResource("hroCard" + hro.Ofcode) as Image; if (image != null) ruban = new Ruban(image, (ushort)hr); } } if (ruban == null) ruban = new Ruban(ar.TryFindResource("hroCard000") as Image, 0); ruban.ToolTip = Tips.IchiDisplay.GetHeroTip(Tuple, hr); ruban.Loc = Ruban.Location.DEAL; return ruban; }
public void FlashMon1(Ruban ruban, ushort from) { double x, y; ParseCord(Orch.AD.Player2Position(from), out x, out y); FlyingUp(ruban, x, y, 24, -118); }
private void SetMonster(ushort value, int rank, ushort from) { Image boardImage = (rank == 1) ? pb.cornerMon1 : pb.cornerMon2; Base.Card.NMB nmb = Base.Card.NMBLib.Decode(value, Tuple.ML, Tuple.NL); if (nmb != null) { pb.Dispatcher.BeginInvoke((Action)(() => { Image img = pb.TryFindResource("monCard" + nmb.Code) as Image; if (img == null) img = pb.TryFindResource("monCard000") as Image; boardImage.Source = img.Source; Card.Ruban ruban = new Card.Ruban(img, value); if (nmb.IsMonster()) boardImage.ToolTip = Tips.IchiDisplay.GetMonTip(Tuple, Base.Card.NMBLib.OriginalMonster(value)); else if (nmb.IsNPC()) boardImage.ToolTip = Tips.IchiDisplay.GetNPCTip(Tuple, Base.Card.NMBLib.OriginalNPC(value)); if (rank == 1) AD.yfOrchis40.FlashMon1(ruban, from); else if (rank == 2) AD.yfOrchis40.FlashMon2(ruban, from); })); } else { pb.Dispatcher.BeginInvoke((Action)(() => { boardImage.Source = (pb.TryFindResource("monCard000") as Image).Source; boardImage.ToolTip = null; })); } }