/// <summary> /// Vẽ quân cờ /// </summary> /// <param name="graphics"></param> /// <param name="x">Tọa độ trục x</param> /// <param name="y">Tọa độ trục y</param> /// <param name="O">Quân O</param> public void DrawChessman(Graphics graphics, int x, int y, Possessive gone) { if (gone == Possessive.O) { graphics.DrawImage(this.O, x, y); } else { graphics.DrawImage(X, x + 2, y + 2); } }
/// <summary> /// Gets a pronoun based on the referral and referee wildcards /// </summary> /// <returns>A pronoun to refer the wilcard received as referee.</returns> /// <param name="referral">The refering wildcard.</param> /// <param name="referee">The wildcard being referred.</param> public static string FromWildcard(Wildcard referral, Wildcard referee) { if ((referee == null) || (referral == null)) { Console.WriteLine("referral or referee is null"); throw new NullReferenceException("referral or referee is null"); } if (referral.Name != "pron") { Console.WriteLine("referral is not a {pron} wildcard"); throw new InvalidOperationException("referral is not a {pron} wildcard"); } Gender g; switch (referee.Keyword) { case "male": g = Gender.Masculine; break; case "female": g = Gender.Femenine; break; default: g = Gender.Neutral; break; } if (!String.IsNullOrEmpty(referral.Type)) { switch (referral.Type.Substring(0, 3)) { case "sub": return(Personal.Subjective(Form.Singular, Person.Third, g)); case "pab": return(Possessive.PossessiveAbsolute(Form.Singular, Person.Third, g)); case "paj": return(Possessive.PossessiveAdjective(Form.Singular, Person.Third, g)); case "pos": if (referral.Type.StartsWith("posabs")) { return(Possessive.PossessiveAbsolute(Form.Singular, Person.Third, g)); } return(Possessive.PossessiveAdjective(Form.Singular, Person.Third, g)); } } return(Personal.Objective(Form.Singular, Person.Third, g)); }
public static void test_possessive() { var context = new Context("aaaab"); var chara = new Character('a'); var charb = new Character('b'); var alt = new CaptureGroup(new Alternate(new IMatch[] { chara, charb }), 2); var posa = new Possessive(alt, 2); var list = new List(new IMatch[] { new CaptureGroup(posa, 1), alt }); // (((a|b){2,}+)(a|b)) ExecTest(context, list); }
public static void test_charset() { var context = new Context("a1b2c3d4e5f6"); var cset = new Charset(); cset.Include('a'); cset.Include('b', 'e'); cset.Include('0', '9'); var pos = new Possessive(cset, 0); // ([ab-e0-9]*) ExecTest(context, pos); }
public IExpression GetTransitionExpression(object subject, IEnumerable <PropertyDifference> differences) { var subExpression = GetNoun(subject); var diffs = differences.ToArray(); if (!diffs.Any()) { throw new ArgumentException("There were no differences", nameof(differences)); } var diffExps = new List <IExpression>(); for (int i = 0; i < diffs.Length; i++) { var sub = i == 0 ? subExpression : GetPronoun(subject); var poss = new Possessive(sub, GetNoun(diffs[i].Property)); diffExps.Add(new VerbExpression(Verbs.ToBecome, poss, GetNoun(diffs[i].Current))); } return(diffExps.Aggregate((agg, next) => new ConjunctionExpression(agg, "and", next))); }
public Cell(int rowIndex, int colIndex, Possessive possessive) { this.RowIndex = rowIndex; this.ColIndex = colIndex; this.Possessive = possessive; }
private bool BottomTraversal_SecDiagonal(Graphics graphics, int rowIndex, int colIndex, Possessive hadGone) { if (rowIndex > board.RowNumber - 5 || colIndex < 4) { return(false); } for (int i = 1; i <= 4; i++) { if (array[rowIndex + i, colIndex - i].Possessive != hadGone) { return(false); } } DrawWinningLine(graphics, (colIndex + 1) * Cell.Width, rowIndex * Cell.Height, (colIndex - 4) * Cell.Width, (rowIndex + 5) * Cell.Height); return(true); }
private bool TopTraversal_PriDiagonal(Graphics graphics, int rowIndex, int colIndex, Possessive hadGone) { if (rowIndex < 4 || colIndex < 4) { return(false); } for (int i = 1; i <= 4; i++) { if (array[rowIndex - i, colIndex - i].Possessive != hadGone) { return(false); } } DrawWinningLine(graphics, (colIndex + 1) * Cell.Width, (rowIndex + 1) * Cell.Height, (colIndex - 4) * Cell.Width, (rowIndex - 4) * Cell.Height); return(true); }
private bool BottomTraversal_Vertical(Graphics graphics, int rowIndex, int colIndex, Possessive hadGone) { if (rowIndex > board.RowNumber - 5) { return(false); } for (int i = 1; i <= 4; i++) { if (array[rowIndex + i, colIndex].Possessive != hadGone) { return(false); } } DrawWinningLine(graphics, colIndex * Cell.Width + Cell.Width / 2, rowIndex * Cell.Height, colIndex * Cell.Width + Cell.Width / 2, (rowIndex + 5) * Cell.Height); return(true); }
private bool LeftTraversal_Horizontal(Graphics graphics, int rowIndex, int colIndex, Possessive hadGone) { if (colIndex < 4) { return(false); } for (int i = 1; i <= 4; i++) { if (array[rowIndex, colIndex - i].Possessive != hadGone) { return(false); } } DrawWinningLine(graphics, (colIndex + 1) * Cell.Width, rowIndex * Cell.Height + Cell.Height / 2, (colIndex - 4) * Cell.Width, rowIndex * Cell.Height + Cell.Height / 2); return(true); }
private bool RightTraversal_Horizontal(Graphics graphics, int rowIndex, int colIndex, Possessive hadGone) { if (rowIndex > board.ColumnNumber - 5) { return(false); } for (int i = 1; i <= 4; i++) { if (array[rowIndex, colIndex + i].Possessive != hadGone) { return(false); } } DrawWinningLine(graphics, colIndex * Cell.Width, rowIndex * Cell.Height + Cell.Height / 2, (colIndex + 5) * Cell.Width, rowIndex * Cell.Height + Cell.Height / 2); return(true); }