示例#1
0
        public static bool IsWinning(Red7Game game, Color canvasColorPlayed)
        {
            var colorRule    = ColorRules.GetRuleByColor(canvasColorPlayed);
            var activePlayer = game.Players.Where(x => x.Active).First();

            var activePlayerPalette = activePlayer.Palette.CloneJson();
            var opponentPalettes    = game.Players.Where(x => !x.Active).Select(y => y.Palette).ToList();

            return(IsWinningPalette(canvasColorPlayed, activePlayerPalette, opponentPalettes, colorRule));
        }
示例#2
0
        public LogPanel(string fullName)
        {
            InitializeComponent();

            this.Dock = DockStyle.Fill;

            ColorRules = new ColorRules();

            _reader = new Reader(fullName);

            statusStripFileName.SizingGrip = false;
            tbxLog.CaretVisible            = true;
            tbxLog.ShowCaretWhenInactive   = true;

            tbxLogCompatibility.ReadOnly = true;

            tsslFullName.Text = fullName;

            toolTipCompatibility.SetToolTip(cbxCompatibility, "if text is loaded but there are some character not displayed (example: 𐍈 is not correctly displayed) you can try check this");
        }
示例#3
0
        private static void ReadInstructions(MethodDef method)
        {
            if (!method.Body.HasInstructions)
            {
                return;
            }

            var i    = 0;
            var rows = new List <DataGridViewRow>();

            foreach (Instruction instruction in method.Body.Instructions)
            {
                var cells = new List <object>();

                cells.Add(i++);                               // Column 1
                cells.Add(Functions.GetAddress(instruction)); // Column 2
                cells.Add(instruction.OpCode);                // Column 3

                #region Column 4

                if (instruction.Operand is Instruction)
                {
                    cells.Add(string.Format("{0}",
                                            Functions.FormatFullInstruction(method.Body.Instructions.ToList(),
                                                                            method.Body.Instructions.IndexOf(instruction))));
                }
                else
                {
                    cells.Add(Functions.GetOperandText(method.Body.Instructions.ToList(),
                                                       method.Body.Instructions.ToList().IndexOf(instruction)));
                }

                #endregion Column 4

                #region Application

                for (var j = 0; j < cells.Count; j++)
                {
                    if (cells[j] == null || string.IsNullOrWhiteSpace(cells[j].ToString()))
                    {
                        continue;
                    }

                    cells[j] = string.Format("   {0}", cells[j]);
                }

                var row = new DataGridViewRow();

                for (var j = 0; j < cells.Count; j++)
                {
                    row.Cells.Add(new DataGridViewTextBoxCell());
                    row.Cells[j].Value = cells[j];
                }

                #endregion Application

                string definition;
                Functions.OpCodeDictionary.TryGetValue(Functions.GetOpCode(instruction.OpCode.ToString().Trim()),
                                                       out definition);

                if (definition != null)
                {
                    row.Cells[2].ToolTipText = definition;
                }

                row.Tag    = instruction;
                row.Height = 16;

                row.ContextMenuStrip = MainForm.InstructionMenuStrip;

                rows.Add(row);
            }

            MainForm.DgBody.Rows.AddRange(rows.ToArray());

            ColorRules.MarkBlocks(MainForm.DgBody);
            ColorRules.ApplyColors(MainForm.DgBody);
        }
示例#4
0
        static void Main(string[] args)
        {
            var activePalette = new Palette(1)
            {
                Cards = new List <Card>
                {
                    new Card
                    {
                        Color = Color.Orange,
                        Value = 2
                    },
                    new Card
                    {
                        Color = Color.Blue,
                        Value = 4
                    },
                    new Card
                    {
                        Color = Color.Indigo,
                        Value = 5
                    },
                    new Card
                    {
                        Color = Color.Blue,
                        Value = 2
                    },
                    new Card
                    {
                        Color = Color.Green,
                        Value = 5
                    },
                }
            };

            var opponentPalettes = new List <Palette>();

            opponentPalettes.Add(new Palette(2)
            {
                Cards = new List <Card>
                {
                    new Card
                    {
                        Color = Color.Green,
                        Value = 4
                    },
                    new Card
                    {
                        Color = Color.Violet,
                        Value = 2
                    },
                    new Card
                    {
                        Color = Color.Yellow,
                        Value = 2
                    },
                    new Card
                    {
                        Color = Color.Red,
                        Value = 5
                    },
                    new Card
                    {
                        Color = Color.Yellow,
                        Value = 6
                    },
                }
            });
            opponentPalettes.Add(new Palette(3)
            {
                Cards = new List <Card>
                {
                    new Card
                    {
                        Color = Color.Green,
                        Value = 5
                    },
                    new Card
                    {
                        Color = Color.Violet,
                        Value = 5
                    },
                    new Card
                    {
                        Color = Color.Yellow,
                        Value = 1
                    },
                    new Card
                    {
                        Color = Color.Red,
                        Value = 7
                    },
                    new Card
                    {
                        Color = Color.Green,
                        Value = 6
                    },
                }
            });

            GameLogic.IsWinningBlueRule(activePalette, opponentPalettes);

            GameLogic.IsWinningPalette(Color.Orange, activePalette, opponentPalettes, ColorRules.GetRuleByColor(Color.Orange));

            Console.ReadLine();
        }
示例#5
0
        public static bool IsWinning(Color canvasColor, Palette activePlayerPalette, List <Palette> opponentPalettes)
        {
            var colorRule = ColorRules.GetRuleByColor(canvasColor);

            return(IsWinningPalette(canvasColor, activePlayerPalette, opponentPalettes, colorRule));
        }