Ejemplo n.º 1
0
        // 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;
        }
Ejemplo n.º 2
0
 static ShipRule()
 {
     mDefSet = new ShipRule();
     mDefSet.ZoneList.Add(new Zone(0, 20, 0, 10, AlignStyle.ALIGN));
 }