summaryrefslogtreecommitdiff
path: root/PBNBoard.cs
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-23 16:01:49 +0200
committeremkael <emkael@tlen.pl>2016-05-23 16:02:58 +0200
commit0f96a08cbdb101d676ddb80c27ac4d97fedfd8ac (patch)
tree4fb94394b436be26b18c54c6f14d373fa9b09d3d /PBNBoard.cs
parent74ced229ca6bf25d3d8cb8cdb82bdeca34856604 (diff)
* saving double-dummy table back to PBN file
Diffstat (limited to 'PBNBoard.cs')
-rw-r--r--PBNBoard.cs49
1 files changed, 49 insertions, 0 deletions
diff --git a/PBNBoard.cs b/PBNBoard.cs
index c9ae180..3c3030f 100644
--- a/PBNBoard.cs
+++ b/PBNBoard.cs
@@ -266,5 +266,54 @@ namespace BCDD
}
}
+ public void WriteOptimumResultTable(int[,] ddTable)
+ {
+ this.Fields.Add(new PBNField("OptimumResultTable", @"Declarer;Denomination\2R;Result\2R"));
+ for (int i = 0; i < 4; i++)
+ {
+ for (int j = 0; j < 5; j++)
+ {
+ this.Fields.Add(new PBNField(String.Format("{0} {1}{2} {3}", BCalcWrapper.PLAYERS[i], BCalcWrapper.DENOMINATIONS[j], (BCalcWrapper.DENOMINATIONS[j] == 'N') ? "T" : "", ddTable[i, j])));
+ }
+ }
+ }
+
+ public void SaveDDTable(int[,] ddTable)
+ {
+ if (this.hasOptimumResultTable == null)
+ {
+ try
+ {
+ List<Match> optimumResultTable = this.ValidateOptimumResultTable(this.GetOptimumResultTable());
+ this.hasOptimumResultTable = true;
+ }
+ catch (FieldNotFoundException)
+ {
+ this.hasOptimumResultTable = false;
+ }
+ }
+ if (this.hasOptimumResultTable == false)
+ {
+ this.DeleteOptimumResultTable();
+ this.WriteOptimumResultTable(ddTable);
+ }
+ if (this.hasAbility == null)
+ {
+ try
+ {
+ MatchCollection ability = this.ValidateAbility(this.GetAbility());
+ this.hasAbility = true;
+ }
+ catch (FieldNotFoundException)
+ {
+ this.hasAbility = false;
+ }
+ }
+ if (this.hasAbility == false)
+ {
+ this.DeleteAbility();
+ this.WriteAbility(ddTable);
+ }
+ }
}
}