// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); Castling = new ChoiceVariable(); Castling.AddChoice("Standard", "King starting on e or f file slides three squares either direction, " + "subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("Long", "King starting on e or f file slides three squares when castling short " + "or four when castling long, subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("Flexible", "King starting on e or f file slides two or more squares, subject to the usual " + "restrictions, to castle with the piece in the corner"); Castling.AddChoice("Close-Rook", "King starting on e or f file slides two squares either direction, " + "subject to the usual restrictions, to castle with the piece on the b or i file"); Castling.AddChoice("Close-Rook Flexible", "King starting on e or f file slides two or more squares, " + "subject to the usual restrictions, to castle with the piece on the b or i file"); Castling.AddChoice("2R Standard", "King starting on e or f file on the second rank slides three squares either direction, " + "subject to the usual restrictions, to castle with the piece on the edge"); Castling.AddChoice("2R Long", "King starting on e or f file on the second rank slides three squares when castling short " + "or four when castling long, subject to the usual restrictions, to castle with the piece on the edge"); Castling.AddChoice("2R Flexible", "King starting on e or f file on the second rank slides two or more squares, subject to the usual " + "restrictions, to castle with the piece on the edge"); Castling.AddChoice("2R Close-Rook", "King starting on e or f file on the second rank slides two squares either direction, " + "subject to the usual restrictions, to castle with the piece on the b or i file on the second rank"); Castling.AddChoice("2R Close-Rook Flexible", "King starting on e or f file on the second rank slides two or more squares, " + "subject to the usual restrictions, to castle with the piece on the b or i file"); Castling.AddChoice("None", "No castling"); Castling.Value = "None"; PromotionRule.AddChoice("Grand"); }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); Castling = new ChoiceVariable(); Castling.AddChoice("3-3", "King starting on f or g file slides three squares either direction, " + "subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("3-4", "King starting on f or g file slides three squares when castling short " + "or four when castling long, subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("4-4", "King starting on f or g file slides four squares either direction, " + "subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("4-5", "King starting on f or g file slides four squares when castling short " + "or five when castling long, subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("Close-Rook 2-2", "King starting on f or g file slides two squares either direction, " + "subject to the usual restrictions, to castle with the piece on the b or k file"); Castling.AddChoice("Close-Rook 2-3", "King starting on f or g file slides two squares when castling short " + "or three when castling long, subject to the usual restrictions, to castle with the piece on the b or k file"); Castling.AddChoice("Close-Rook 3-3", "King starting on f or g file slides three squares either direction, " + "subject to the usual restrictions, to castle with the piece on the b or k file"); Castling.AddChoice("Close-Rook 3-4", "King starting on f or g file slides three squares when castling short " + "or four when castling long, subject to the usual restrictions, to castle with the piece on the b or k file"); Castling.AddChoice("Flexible", "King starting on f or g file slides two or more squares, subject to the usual " + "restrictions, to castle with the piece in the corner"); Castling.AddChoice("Close-Rook Flexible", "King starting on f or g file slides two or more squares, subject to the usual " + "restrictions, to castle with the piece on the b or k file"); Castling.AddChoice("None", "No castling"); Castling.Value = "None"; }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); Castling = new ChoiceVariable(); Castling.AddChoice("Standard", "King starting on the f file slides three squares either direction, " + "subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("Long", "King starting on the f file slides four squares either direction, " + "subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("Flexible", "King starting on the f file slides two or more squares, subject to the usual " + "restrictions, to castle with the piece in the corner"); Castling.AddChoice("Wildebeest", "King starting on the f file slides one or more squares, subject to the usual " + "restrictions, to castle with the piece in the corner"); Castling.AddChoice("Close-Rook", "King starting on the f file slides three squares either direction, " + "subject to the usual restrictions, to castle with the piece on the b or j file"); Castling.AddChoice("Close-Rook Flexible", "King starting on the f file slides two or more squares either direction, " + "subject to the usual restrictions, to castle with the piece on the b or j file"); Castling.AddChoice("2R Standard", "King starting on the f file of the second rank slides three squares either direction, " + "subject to the usual restrictions, to castle with the piece on the edge"); Castling.AddChoice("2R Long", "King starting on the f file of the second rank slides four squares either direction, " + "subject to the usual restrictions, to castle with the piece on the edge"); Castling.AddChoice("2R Flexible", "King starting on the f file of the second rank slides two or more squares, subject to the usual " + "restrictions, to castle with the piece on the edge"); Castling.AddChoice("2R Wildebeest", "King starting on the f file of the second rank slides one or more squares, subject to the usual " + "restrictions, to castle with the piece on the edge"); Castling.AddChoice("2R Close-Rook", "King starting on the f file of the second rank slides three squares either direction, " + "subject to the usual restrictions, to castle with the piece on the b or j file"); Castling.AddChoice("2R Close-Rook Flexible", "King starting on the f file of the second rank slides two or more squares either direction, " + "subject to the usual restrictions, to castle with the piece on the b or j file"); Castling.AddChoice("None", "No castling"); Castling.Value = "None"; }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); Variant = new ChoiceVariable(new string[] { "Great Shatranj D", "Great Shatranj R" }); PromotionTypes = "G"; BareKing = true; }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); Array = "rnbqkgabnr/ppppccpppp/4pp4/10/10/10/10/4PP4/PPPPCCPPPP/RNBQKGABNR"; Variant = new ChoiceVariable(new string[] { "Classic", "Faster Pawns", "Faster Pawns and Castling" }, "Classic"); PromotionRule.Value = "Standard"; PromotionTypes = "Q"; }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); FENFormat = "{array} {current player} {castling} {en-passant} {half-move clock} {turn number}"; FENStart = "#{Array} w #default #default 0 1"; StalemateResult = new ChoiceVariable(new string[] { "Draw", "Win", "Loss" }); StalemateResult.Value = "Draw"; PromotionRule = new ChoiceVariable(new string[] { "None", "Standard", "Replacement", "Custom" }); PromotionRule.Value = "Standard"; PromotionTypes = ""; BareKing = false; }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); Array = "#{BlackArray}/8/8/8/8/#{WhiteArray}"; Castling.RemoveChoice("Flexible"); WhiteArmy = new ChoiceVariable(new string[] { "Fabulous FIDEs", "Colorbound Clobberers", "Remarkable Rookies", "Nutty Knights" }); BlackArmy = new ChoiceVariable(new string[] { "Fabulous FIDEs", "Colorbound Clobberers", "Remarkable Rookies", "Nutty Knights" }); PawnDoubleMove = true; EnPassant = true; Castling.AddChoice("CwDA", "Standard castling with the extra exception to prevent color-bound pieces from changing square colors"); Castling.Value = "CwDA"; }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); Castling = new ChoiceVariable(); Castling.AddChoice("Standard", "King starting on d or e file slides two squares either direction, " + "subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("Long", "King starting on d or e file slides two squares when castling short " + "or three when castling long, subject to the usual restrictions, to castle with the piece in the corner"); Castling.AddChoice("Flexible", "King starting on d or e file slides two or more squares, subject to the usual " + "restrictions, to castle with the piece in the corner"); Castling.AddChoice("None", "No castling"); Castling.Value = "None"; }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); PawnMultipleMove = new ChoiceVariable(); PawnMultipleMove.AddChoice("None", "Pawns can never move more than a single space"); PawnMultipleMove.AddChoice("Double", "Pawns on the second rank can move two spaces"); PawnMultipleMove.AddChoice("Triple", "Pawns on the second rank can move up to three spaces"); PawnMultipleMove.AddChoice("Great", "Pawns on the second or third rank can move two spaces"); PawnMultipleMove.AddChoice("Grand", "Pawns on the third rank can move two spaces"); PawnMultipleMove.AddChoice("Wildebeest", "Pawns on the second rank can move up to three spaces and pawns on the third rank can move two spaces"); PawnMultipleMove.AddChoice("Unicorn", "Pawns on the second rank can move two spaces as well as pawns on the third rank of the centermost file(s)"); PawnMultipleMove.AddChoice("Fast Pawn", "Pawns can move two spaces from any location"); PawnMultipleMove.AddChoice("Custom", "Indicates a custom rule implemented by derived class"); PawnMultipleMove.Value = "None"; }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); PawnMultipleMove = new ChoiceVariable(); PawnMultipleMove.AddChoice("None", "Pawns can never move more than a single space"); PawnMultipleMove.AddChoice("@2(2)", "Pawns can move two spaces when on the second rank"); PawnMultipleMove.AddChoice("@2(2,3)", "Pawns can move two or three spaces when on the second rank"); PawnMultipleMove.AddChoice("@2(2,3,4)", "Pawns can move up to four spaces when on the second rank"); PawnMultipleMove.AddChoice("@3(2)", "Pawns can move two spaces when on the third rank"); PawnMultipleMove.AddChoice("@3(2,3)", "Pawns can move two or three spaces when on the third rank"); PawnMultipleMove.AddChoice("@4(2)", "Pawns can move two spaces when on the fourth rank"); PawnMultipleMove.AddChoice("Fast Pawn", "Pawns can move two spaces from any location"); PawnMultipleMove.AddChoice("Custom", "Indicates a custom rule implemented by derived class"); PawnMultipleMove.Value = "None"; }
private string getCurrentValue(Game game, GameVariableAttribute gva, PropertyInfo pi) { if (pi.PropertyType == typeof(bool)) { bool val = (bool)pi.GetValue(game); return(val ? "true" : "false"); } else if (pi.PropertyType == typeof(string)) { string val = (string)pi.GetValue(game); if (val == null) { return("<i>dynamic</i>"); } else { return("\"" + val + "\""); } } else if (pi.PropertyType == typeof(int)) { int val = (int)pi.GetValue(game); return(val.ToString()); } else if (pi.PropertyType == typeof(ChoiceVariable)) { ChoiceVariable val = (ChoiceVariable)pi.GetValue(game); return(val.Value); } else if (pi.PropertyType == typeof(IntRangeVariable)) { IntRangeVariable val = (IntRangeVariable)pi.GetValue(game); return("<i>integer</i> between " + val.MinValue.ToString() + " and " + val.MaxValue.ToString()); } else if (pi.PropertyType == typeof(PieceType)) { PieceType pt = (PieceType)pi.GetValue(game); if (pt != null) { return(pt.Name + (pt.Name != pt.InternalName ? " (" + pt.InternalName + ")" : "")); } else { return("null"); } } return(""); }
public ActionResult MadLibs(string verb, string noun, string adj, string pNoun, string game, string verbing, string plant, string bodyPart, string place, int number) { ChoiceVariable myChoiceVariable = new ChoiceVariable(); myChoiceVariable.Noun = noun; myChoiceVariable.Verb = verb; myChoiceVariable.Adjective = adj; myChoiceVariable.PNoun = pNoun; myChoiceVariable.Game = game; myChoiceVariable.Verbing = verbing; myChoiceVariable.Plant = plant; myChoiceVariable.BodyPart = bodyPart; myChoiceVariable.Place = place; myChoiceVariable.Number = number; return(View(myChoiceVariable)); }
// *** INITIALIZATION *** // #region SetGameVariables public override void SetGameVariables() { base.SetGameVariables(); Variant = new ChoiceVariable(new string[] { "Grand Shatranj D", "Grand Shatranj R", "Gilded Grand Shatranj" }); Array = "#{BlackArray}/10/10/10/10/#{WhiteArray}"; }
private string getPotentialValues(Game game, GameVariableAttribute gva, PropertyInfo pi, out bool paragraph, bool fullDescription = false) { paragraph = false; if (pi.PropertyType == typeof(bool)) { return("<i>boolean</i>"); } else if (pi.PropertyType == typeof(string)) { string val = (string)pi.GetValue(game); if (val == null) { return("<i>dynamic</i>"); } else { return("<i>string</i>"); //"\"" + val + "\""; } } else if (pi.PropertyType == typeof(int)) { return("<i>integer</i>"); } else if (pi.PropertyType == typeof(ChoiceVariable)) { ChoiceVariable val = (ChoiceVariable)pi.GetValue(game); if (val.HasDescriptions) { paragraph = true; string s = "choice of: <blockquote><ul>"; foreach (string choice in val.Choices) { s += "<li><b>" + choice + "</b>"; string desc = val.DescribeChoice(choice); if (desc != null) { s += ": " + desc; } s += "</li>"; } s += "</ul></blockquote>"; return(s); } else { string s = "choice of { "; bool first = true; foreach (string choice in val.Choices) { if (first) { first = false; } else { s += ", "; } s += choice; } s += " }"; if (val.DefaultValue != null) { s += " default: " + val.DefaultValue; } return(s); } } else if (pi.PropertyType == typeof(PieceType)) { return("<i>PieceType</i>"); } else if (pi.PropertyType == typeof(IntRangeVariable)) { IntRangeVariable val = (IntRangeVariable)pi.GetValue(game); return("<i>integer</i> between " + val.MinValue.ToString() + " and " + val.MaxValue.ToString()); } return(""); }
protected void PreviewHelper(Game game, object helperObject) { int unassignedCount = 0; PropertyInfo[] properties = game.GetType().GetProperties(); foreach (PropertyInfo property in properties) { object[] attributes = property.GetCustomAttributes(typeof(GameVariableAttribute), false); if (attributes.Length > 0) { if (property.PropertyType == typeof(ChoiceVariable)) { ChoiceVariable choice = (ChoiceVariable)property.GetValue(game, null); if (choice.Choices.Count > 0 && choice.Value == null) { // this property is unassigned if (unassignedCount == 0) { choice.Value = (string)pickVariable1.SelectedItem; } else if (unassignedCount == 1) { choice.Value = (string)pickVariable2.SelectedItem; } unassignedCount++; } } else if (property.PropertyType == typeof(IntRangeVariable)) { IntRangeVariable val = (IntRangeVariable)property.GetValue(game, null); if (val.Value == null) { // this property is unassigned if (unassignedCount == 0) { int textvalue; val.Value = null; if (Int32.TryParse(txtVariable1.Text, out textvalue)) { if (textvalue >= val.MinValue && textvalue <= val.MaxValue) { val.Value = textvalue; } } } else if (unassignedCount == 1) { int textvalue; val.Value = null; if (Int32.TryParse(txtVariable2.Text, out textvalue)) { if (textvalue >= val.MinValue && textvalue <= val.MaxValue) { val.Value = textvalue; } } } unassignedCount++; } } } } }
private void GameVariablesForm_Load(object sender, EventArgs e) { // Determine background color - this is typically the // first square color (light square color) but if that // color isn't light enough, we will scale it up to make // it lighter. Things look bad if the backgrounds for // all the tool windows aren't fairly light Theme theme = ThemeFactory.CreateTheme(game); Color WindowBackgroundColor = theme.ColorScheme.SquareColors[0]; int brightness = (WindowBackgroundColor.R + WindowBackgroundColor.G + WindowBackgroundColor.B) / 3; if (brightness < 250) { double scaleFactor = 250.0 / (double)brightness; WindowBackgroundColor = Color.FromArgb( (int)(WindowBackgroundColor.R + ((255 - WindowBackgroundColor.R) * (scaleFactor - 1.0))), (int)(WindowBackgroundColor.G + ((255 - WindowBackgroundColor.G) * (scaleFactor - 1.0))), (int)(WindowBackgroundColor.B + ((255 - WindowBackgroundColor.B) * (scaleFactor - 1.0)))); } BackColor = WindowBackgroundColor; int unassignedCount = 0; PropertyInfo[] properties = game.GetType().GetProperties(); foreach (PropertyInfo property in properties) { object[] attributes = property.GetCustomAttributes(typeof(GameVariableAttribute), false); if (attributes.Length > 0) { if (property.PropertyType == typeof(ChoiceVariable)) { ChoiceVariable choice = (ChoiceVariable)property.GetValue(game, null); if (choice.Choices.Count > 0 && choice.Value == null) { // this property is unassigned if (unassignedCount == 0) { choiceProperty1 = property; lblGameVariable1.Visible = true; lblGameVariable1.Text = ConvertVariableNameToDisplay(property.Name); pickVariable1.Visible = true; foreach (string choicename in choice.Choices) { pickVariable1.Items.Add(choicename); } if (choice.DefaultValue != null) { pickVariable1.SelectedItem = choice.DefaultValue; } else { pickVariable1.SelectedIndex = Program.Random.Next(pickVariable1.Items.Count); } } else if (unassignedCount == 1) { choiceProperty2 = property; lblGameVariable2.Visible = true; lblGameVariable2.Text = ConvertVariableNameToDisplay(property.Name); pickVariable2.Visible = true; foreach (string choicename in choice.Choices) { pickVariable2.Items.Add(choicename); } if (choice.DefaultValue != null) { pickVariable2.SelectedItem = choice.DefaultValue; } else { pickVariable2.SelectedIndex = Program.Random.Next(pickVariable2.Items.Count); } } else { throw new Exception("Not supported - too many unassigned variables"); } unassignedCount++; } } else if (property.PropertyType == typeof(IntRangeVariable)) { IntRangeVariable val = (IntRangeVariable)property.GetValue(game, null); if (val.Value == null) { // this property is unassigned if (unassignedCount == 0) { intProperty1 = property; lblGameVariable1.Visible = true; lblGameVariable1.Text = ConvertVariableNameToDisplay(property.Name); txtVariable1.Visible = true; val.Value = Program.Random.Next((int)val.MaxValue - (int)val.MinValue + 1) + (int)val.MinValue; txtVariable1.Text = val.Value.ToString(); unassignedCount++; } } } } } if (unassignedCount == 1) { lblGameVariable1.Location = new Point(lblGameVariable1.Location.X, lblGameVariable1.Location.Y + 18); txtVariable1.Location = new Point(txtVariable1.Location.X, txtVariable1.Location.Y + 18); pickVariable1.Location = new Point(pickVariable1.Location.X, pickVariable1.Location.Y + 18); } finishedLoading = true; UpdatePreviewImage(); }