JTacticalSim /JTacticalSim.DataContext/XMLDataContext.cs

Language C# Lines 1124
MD5 Hash 20f8603e956df84e27f96143444bbd41
Repository https://github.com/Queztionmark/JTacticalSim.git View Raw File
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using System.Dynamic;
using System.IO;
using System.Transactions;
using JTacticalSim.API;
using JTacticalSim.API.DTO;
using JTacticalSim.Data.DTO;
using JTacticalSim.API.Data;
using JTacticalSim.API.Component;
using JTacticalSim.Utility;

namespace JTacticalSim.DataContext
{
	/// <summary>
	/// File based data context
	/// </summary>
	public sealed class XMLDataContext : BaseDataContext
	{
		private DataFileFactory _dataFileFactory = DataFileFactory.Instance;

		private static volatile IDataContext _instance = null;
		static readonly object padlock = new object();

		public static IDataContext Instance
		{
			get
			{
				if (_instance == null)
				{
					lock (padlock)
						if (_instance == null) _instance = new XMLDataContext();
				}

				return _instance;
			}
		}
		
		// Initialize Context
		private XMLDataContext()
		{}

#region Save

		public override IResult<IGameFileCopyable> SaveData(IGameFileCopyable currentData)
		{
			var r = new DataResult<IGameFileCopyable>{Status = ResultStatus.SUCCESS, Result = currentData};

			using (var txn = new TransactionScope())
			{			
				// 1. Create a new file handler for the current game file directory
				IDataFileHandler<XDocument> dataFileHandler = null;

				try
				{
					dataFileHandler = new DataFileHandler<XDocument>(_dataFileFactory.GetDataFiles<XDocument>(currentData.GameFileDirectory, currentData.IsScenario));
				
				}
				catch (Exception ex)
				{
					r.Status = ResultStatus.EXCEPTION;
					r.ex = ex;
					r.Messages.Add("Game data not saved. DataFileHandler could not be created.");
					return r;
				}

				// 2. Backup Current Files
				if (dataFileHandler.GameDirectoryHasFiles())
				{
					try
					{
						BackupCurrentGameFiles(dataFileHandler);
					}
					catch (Exception ex)
					{
						r.Status = ResultStatus.EXCEPTION;
						r.ex = ex;
						r.Messages.Add("Game data not saved. Could not backup current game files.");
						return r;
					}
				}

				// 3. Save data
				try
				{
					SaveGameData(dataFileHandler);
				}
				catch (Exception ex)
				{
					r.Status = ResultStatus.EXCEPTION;
					r.ex = ex;
					r.Messages.Add("Game data not saved.");
					return r;
				}

				txn.Complete();
			}

			r.Messages.Add("Game data saved.");
			return r;
		}

		public override IResult<IGameFileCopyable> SaveDataAs(IGameFileCopyable currentData, IGameFileCopyable newData)
		{
			var r = new DataResult<IGameFileCopyable>{Status = ResultStatus.SUCCESS, Result = newData};

			using (var txn = new TransactionScope())
			{	
				// 1. Create a new file handler for the current and new game file directories
				IDataFileHandler<XDocument> currentDataFileHandler = null;
				IDataFileHandler<XDocument> newDataFileHandler = null;

				try
				{
					currentDataFileHandler = new DataFileHandler<XDocument>(_dataFileFactory.GetDataFiles<XDocument>(currentData.GameFileDirectory, currentData.IsScenario));
					newDataFileHandler = new DataFileHandler<XDocument>(_dataFileFactory.GetDataFiles<XDocument>(newData.GameFileDirectory, newData.IsScenario));
				}
				catch (Exception ex)
				{
					r.Status = ResultStatus.EXCEPTION;
					r.ex = ex;
					r.Messages.Add("Game data not saved. DataFileHandlers could not be created.");
					return r;
				}	

				// 2. Verify game directory. Create if it does not exists.
				if (!newDataFileHandler.GameDirectoryExists())
				{
					try
					{
						newDataFileHandler.CreateNewGameDirectory();
					}
					catch (Exception ex)
					{
						r.Status = ResultStatus.EXCEPTION;
						r.ex = ex;
						r.Messages.Add("Game data not saved. Could not create new game directory.");
						return r;
					}
				}

				// 3. Copy current files to new directory
				var result = (currentData.IsScenario) 
								? currentDataFileHandler.CopyScenarioFiles(newDataFileHandler.DataFiles.GameSaveDirectory)
								: currentDataFileHandler.CopyGameFiles(newDataFileHandler.DataFiles.GameSaveDirectory);				

				if (result.Status == ResultStatus.EXCEPTION)
				{
					r.Status = ResultStatus.EXCEPTION;
					r.ex = result.ex;
					r.Messages.Add("Game data not saved. {0}.".F(result.Message));
					return r;
				}					

				txn.Complete();
			}

			r.Messages.Add("Game data saved.");
			return r;
		}

		public override IResult<IGameFileCopyable> RemoveSavedGameData(IGameFileCopyable delData)
		{
			var r = new DataResult<IGameFileCopyable>{Status = ResultStatus.SUCCESS, Result = delData};

			using (var txn = new TransactionScope())
			{

				// 1. Create a new file handler for the game to be deleted.
				IDataFileHandler<XDocument> delDataFileHandler = null;

				try
				{
					delDataFileHandler = new DataFileHandler<XDocument>(_dataFileFactory.GetDataFiles<XDocument>(delData.GameFileDirectory, delData.IsScenario));
				}
				catch (Exception ex)
				{
					r.Status = ResultStatus.EXCEPTION;
					r.ex = ex;
					r.Messages.Add("Game data not saved. DataFileHandlers could not be created.");
					return r;
				}

				// 2. Verify game directory. Create if it does not exists.
				if (delDataFileHandler.GameRootDirectoryExists())
				{
					try
					{
						delDataFileHandler.DeleteGameDirectory();
					}
					catch (Exception ex)
					{
						r.Status = ResultStatus.EXCEPTION;
						r.ex = ex;
						r.Messages.Add("Game data not deleted. Could not delete game directory.");
						return r;
					}
				}

				// 3. Save data
				try
				{
					SaveSavedGameFile(delDataFileHandler);
				}
				catch (Exception ex)
				{
					r.Status = ResultStatus.EXCEPTION;
					r.ex = ex;
					r.Messages.Add("Game data file not saved.");
					return r;
				}

				txn.Complete();
			}

			r.Messages.Add("Game data removed.");
			return r;
		}


		private void BackupCurrentGameFiles(IDataFileHandler<XDocument> dataFileHandler)
		{
			dataFileHandler.DataFiles.ScenarioFilePaths.ForEach(path =>	
			{ 
				File.Delete("{0}.BAK".F(path));
				File.Copy(path, "{0}.BAK".F(path));	
			});	
		
			// Back up the Saved Games file
			File.Delete("{0}.BAK".F(dataFileHandler.DataFiles.SavedGameDataFilePath));
			File.Copy(dataFileHandler.DataFiles.SavedGameDataFilePath, "{0}.BAK".F(dataFileHandler.DataFiles.SavedGameDataFilePath));
		}

		private void SaveGameData(IDataFileHandler<XDocument> dataFileHandler)
		{
			SaveBoardDataFile(dataFileHandler);
			SaveUnitDataFile(dataFileHandler);
			SaveGameDataFile(dataFileHandler);
			SaveSavedGameFile(dataFileHandler);
		}

		private void SaveBoardDataFile(IDataFileHandler<XDocument> dataFileHandler)
		{
			// Clear all nodes
			var nodes = dataFileHandler.DataFiles.BoardDataFile.Descendants("Nodes").Single();
			nodes.RemoveAll();

			var attributes = dataFileHandler.DataFiles.BoardDataFile.Descendants("Attributes").Single();

			// Clear the board
			var board = dataFileHandler.DataFiles.BoardDataFile.Descendants("GameBoard").Single();
			board.RemoveAll();

			// Update attributes
			attributes.Attribute("Title").SetValue(Board.Title);
			attributes.Attribute("Width").SetValue(Board.Width);
			attributes.Attribute("Height").SetValue(Board.Height);
			attributes.Attribute("CellSize").SetValue(Board.CellSize);
			attributes.Attribute("CellMaxUnits").SetValue(Board.CellMaxUnits);

			// Create Nodes for save
			foreach (var n in NodesTable.Records)
			{
				nodes.Add(n.ToXML());
			}

			board.Add(attributes);
			board.Add(nodes);
			
			// Save back file
			board.Document.Save(dataFileHandler.DataFiles.BoardDataFilePath);
		}

		private void SaveUnitDataFile(IDataFileHandler<XDocument> dataFileHandler)
		{
			// Remove all existing units
			var units = dataFileHandler.DataFiles.UnitDataFile.Descendants("Units").Single();
			units.RemoveAll();

			// Create units for save
			foreach (var u in UnitsTable.Records)
			{
				units.Add(u.ToXML());				
			}

			units.Document.Save(dataFileHandler.DataFiles.UnitDataFilePath);
		}

		private void SaveGameDataFile(IDataFileHandler<XDocument> dataFileHandler)
		{
			// Remove all existing GameData
			var gameData = dataFileHandler.DataFiles.GameDataFile.Descendants("GameData").Single();
			gameData.RemoveAll();

			// Create Factions for save
			XElement fs = new  XElement("Factions");
			foreach (var f in FactionsTable.Records)
			{
				fs.Add(f.ToXML());
			}
			gameData.Add(fs);

			// Create Countries for save
			XElement cs = new  XElement("Countries");
			foreach (var c in CountriesTable.Records)
			{
				cs.Add(c.ToXML());
			}
			gameData.Add(cs);

			// Create Players for save
			XElement ps = new  XElement("Players");
			foreach (var p in PlayersTable.Records)
			{
				ps.Add(p.ToXML());
			}
			gameData.Add(ps);

			gameData.Add(new XComment("Conditions for winning the game for a faction. Winning is an OR proposition"));
			XElement fvcs = new XElement("FactionVictoryConditions");
			foreach (var fvc in FactionVictoryConditions)
			{
				XElement vc = new XElement("VictoryCondition");
				vc.Add(new XAttribute("Faction", fvc.Faction));
				vc.Add(new XAttribute("Condition", fvc.Condition));
				vc.Add(new XAttribute("Value", fvc.Value));

				fvcs.Add(vc);
			}
			gameData.Add(fvcs);

			gameData.Add(new XComment("Unit Assignments"));
			XElement uas = new XElement("UnitAssignments");
			foreach (var a in UnitAssignments)
			{
				XElement ua = new XElement("UnitAssignment");
				ua.Add(new XAttribute("Unit", a.Unit));
				ua.Add(new XAttribute("AssignedToUnit", a.AssignedToUnit));

				uas.Add(ua);
			}
			gameData.Add(uas);


			gameData.Add(new XComment("Unit Transports"));
			XElement uts = new XElement("UnitTransports");
			foreach (var a in UnitTransports)
			{
				XElement ua = new XElement("UnitTransport");
				ua.Add(new XAttribute("Unit", a.Unit));
				ua.Add(new XAttribute("TransportUnit", a.TransportUnit));

				uts.Add(ua);
			}
			gameData.Add(uts);
			
			gameData.Document.Save(dataFileHandler.DataFiles.GameDataFilePath);
		}

		private void SaveSavedGameFile(IDataFileHandler<XDocument> dataFileHandler)
		{
			// Remove all existing GameData
			var gameData = dataFileHandler.DataFiles.SavedGameDataFile.Descendants("SavedGames").Single();
			gameData.RemoveAll();

			foreach(var game in SavedGames.Records)
			{
				gameData.Add(game.ToXML());
			}

			gameData.Document.Save(dataFileHandler.DataFiles.SavedGameDataFilePath);
		}

#endregion

#region Load

		public override IResult<string> LoadData(string gameFileDirectory, bool IsScenario)
		{
			var r = new DataResult<string>{Status = ResultStatus.SUCCESS, Result = gameFileDirectory};

			try
			{
				IDataFileHandler<XDocument> dataFileHandler = new DataFileHandler<XDocument>(_dataFileFactory.GetDataFiles<XDocument>(gameFileDirectory, IsScenario));

				// ~~~~~~~~~~~~~~~~~~~~  Load up context
				// (Order is important for dependant objects)

				LoadComponentData(dataFileHandler.DataFiles.ComponentDataFile);
				LoadLookupData(dataFileHandler.DataFiles.LookupDataFile);
				LoadGamedata(dataFileHandler.DataFiles.GameDataFile,
								dataFileHandler.DataFiles.BoardDataFile,
								dataFileHandler.DataFiles.UnitDataFile,
								dataFileHandler.DataFiles.ComponentDataFile);

				// We need to make sure we have the last played game set correctly in the data file for saved games
				SaveSavedGameFile(dataFileHandler);
			}
			catch (Exception ex)
			{
				r.Status = ResultStatus.EXCEPTION;
				r.ex = ex;
				r.Messages.Add("Game data not loaded.");
			}

			r.Messages.Add("Game data loaded.");
			return r;
			
		}

		/// <summary>
		/// Load all static code data tables into context
		/// </summary>
		/// <param name="componentDataFile"></param>
		private void LoadComponentData(XDocument componentDataFile)
		{
			LoadBasePointValues(componentDataFile);
			LoadUnitBaseTypes(componentDataFile);
			LoadUnitGroupTypes(componentDataFile);
			LoadUnitTypes(componentDataFile);
			LoadUnitClasses(componentDataFile);
			LoadDemographicClasses(componentDataFile);
			LoadDemographicTypes(componentDataFile);
			LoadVictoryConditions(componentDataFile);

			LoadMissionData(componentDataFile);
		}

		/// <summary>
		/// Load all the lookup tables for code game code data into context
		/// </summary>
		/// <param name="lookupDataFile"></param>
		private void LoadLookupData(XDocument lookupDataFile)
		{
			LoadUnitBaseTypeUnitClasses(lookupDataFile);
			LoadUnitBaseTypeUnitGeogTypes(lookupDataFile);
			LoadUnitGeogTypeDemographicClasses(lookupDataFile);
			LoadUnitGroupTypeUnitTasks(lookupDataFile);
			LoadMissionObjectiveUnitTasks(lookupDataFile);
			LoadUnitTaskUnitClasses(lookupDataFile);
			LoadUnitGeogTypeMovementOverrides(lookupDataFile);
			LoadUnitTypeUnitGeogTypeBattleEffectives(lookupDataFile);
			LoadUnitTransportUnitTypeUnitClasses(lookupDataFile);
			LoadHybridDemographicClasses(lookupDataFile);
			LoadMovementHinderancesInDirection(lookupDataFile);
		}

		private void LoadGamedata(	XDocument gameDataFile, 
									XDocument boardDataFile, 
									XDocument unitDataFile, 
									XDocument componentDataFile)
		{
			LoadBoard(boardDataFile);
			LoadUnits(unitDataFile);
			LoadFactions(gameDataFile);
			LoadCountries(gameDataFile);
			LoadPlayers(gameDataFile);
			LoadDemographics(gameDataFile, componentDataFile);
			LoadUnitAssignments(gameDataFile);
			LoadUnitTransports(gameDataFile);
			LoadFactionVictoryConditions(gameDataFile);
		}

		private void LoadBasePointValues(XDocument staticDataFile)
		{
			var data = staticDataFile.Descendants("BasePointValues").Single();

			var basePointValues = new BasePointValuesDTO
					(
						Convert.ToInt32(data.Attribute("Movement").Value),
						Convert.ToInt32(data.Attribute("CombatRoll").Value),
						Convert.ToInt32(data.Attribute("CombatBase").Value),
						Convert.ToInt32(data.Attribute("StealthRoll").Value),
						Convert.ToInt32(data.Attribute("StealthBase").Value),
						Convert.ToInt32(data.Attribute("MedicalSupportBase").Value),
						Convert.ToInt32(data.Attribute("WeightBase").Value),
						Convert.ToInt32(data.Attribute("CostBase").Value),
						Convert.ToInt32(data.Attribute("AIBaseRoll").Value),
						Convert.ToInt32(data.Attribute("AIAggressiveness").Value),
						Convert.ToInt32(data.Attribute("AIDefensiveness").Value),
						Convert.ToInt32(data.Attribute("AIIntelligence").Value),
						Convert.ToInt32(data.Attribute("ReinforcementCalcBaseCountry").Value),
						Convert.ToInt32(data.Attribute("ReinforcementCalcBaseFaction").Value),
						Convert.ToDouble(data.Attribute("ReinforcementCalcBaseVP").Value),
						Convert.ToDouble(data.Attribute("HQBonus").Value),
						Convert.ToDouble(data.Attribute("SuppliedBonus").Value),
						Convert.ToInt32(data.Attribute("MaxSupplyDistance").Value),
						Convert.ToDouble(data.Attribute("TargetAttachedUnitBonus").Value),
						Convert.ToDouble(data.Attribute("TargetMedicalUnitBonus").Value),
						Convert.ToDouble(data.Attribute("TargetSupplyUnitBonus").Value)
					) as IBasePointValues;
	
			this._basePointValues = basePointValues;
		}

		private void LoadUnitBaseTypes(XDocument staticDataFile)
		{
			//Get base type with properties
			var unitBaseTypes = GetBaseComponentDTOs<UnitBaseTypeDTO>(staticDataFile.Descendants("UnitBaseType")).ToList();

			unitBaseTypes.ForEach(o =>
				{
					o.Item1.CanReceiveMedicalSupport = Convert.ToBoolean(o.Item2.Attribute("CanReceiveMedicalSupport").Value);
				});

			// Add to context
			this._unitBaseTypesTable.Records = unitBaseTypes.Select(p => p.Item1 as IUnitBaseTypeDTO).ToList();
		}

		private void LoadVictoryConditions(XDocument staticDataFile)
		{
			var victoryConditions = GetBaseComponentDTOs<VictoryConditionDTO>(staticDataFile.Descendants("Condition"));
			this._victoryConditionsTable.Records = victoryConditions.Select(vc => vc.Item1 as IVictoryConditionDTO).ToList();
		}

		private void LoadUnitGroupTypes(XDocument staticDataFile)
		{
			var unitGroupTypes = GetBaseComponentDTOs<UnitGroupTypeDTO>(staticDataFile.Descendants("UnitGroupType")).ToList();

			// Set type specific properties
			unitGroupTypes.ForEach(o =>
				{
					o.Item1.TextDisplay = o.Item2.Attribute("TextDisplay").Value;
					o.Item1.Level = Convert.ToInt32(o.Item2.Attribute("Level").Value);
				});

			// Add to context
			this._unitGroupTypesTable.Records = unitGroupTypes.Select(p => p.Item1 as IUnitGroupTypeDTO).ToList();
		}

		private void LoadUnitGeogTypes(XDocument staticDataFile)
		{
			var unitGeogTypes = GetBaseComponentDTOs<UnitGeogTypeDTO>(staticDataFile.Descendants("UnitGeogType")).ToList();

			// Add to context
			this._unitGeogTypesTable.Records = unitGeogTypes.Select(p => p.Item1 as IUnitGeogTypeDTO).ToList();
		}

		private void LoadUnitTypes(XDocument staticDataFile)
		{
			// Get base type with properties
			var unitTypes = GetBaseComponentDTOs<UnitTypeDTO>(staticDataFile.Descendants("UnitType")).ToList();

			// Set type specific properties
			unitTypes.ForEach(o =>
				{
					o.Item1.TextDisplay = o.Item2.Attribute("TextDisplay").Value;
					o.Item1.UnitBaseTypeID = Convert.ToInt32(o.Item2.Attribute("UnitBaseType").Value);
				});

			// Load stat modifier data
			unitTypes.ForEach(o => LoadStatModifierData(o.Item2, o.Item1));

			// Add to context
			this._unitTypesTable.Records = unitTypes.Select(p => p.Item1 as IUnitTypeDTO).ToList();
		}

		private void LoadUnitClasses(XDocument staticDataFile)
		{
			// Get base type with properties
			var unitClasses = GetBaseComponentDTOs<UnitClassDTO>(staticDataFile.Descendants("UnitClass")).ToList();

			// Set type specific properties
			unitClasses.ForEach(o =>
				{
					o.Item1.TextDisplay = o.Item2.Attribute("TextDisplay").Value;
				});

			// Load stat modifier data
			unitClasses.ForEach(o => LoadStatModifierData(o.Item2, o.Item1));

			// Add to context
			this._unitClassesTable.Records = unitClasses.Select(p => p.Item1 as IUnitClassDTO).ToList();
		}


		private void LoadMissionData(XDocument staticDataFile)
		{
			// UnitTasks
			var unitTasks = GetBaseComponentDTOs<UnitTaskDTO>(staticDataFile.Descendants("UnitTask")).ToList();
			this._unitTasksTable.Records = unitTasks.Select(p => p.Item1 as IUnitTaskDTO).ToList();

			//MissionObjectives
			var missionObjectives = GetBaseComponentDTOs<MissionObjectiveDTO>(staticDataFile.Descendants("MissionObjective")).ToList();

			missionObjectives.ForEach(o =>
				{
					o.Item1.Priority = Convert.ToInt32(o.Item2.Attribute("Priority").Value);
					o.Item1.TurnOrder = Convert.ToInt32(o.Item2.Attribute("TurnOrder").Value);
				});

			this._missionObjectivesTable.Records = missionObjectives.Select(mo => mo.Item1 as IMissionObjectiveDTO).ToList();
		}

		private void LoadDemographicClasses(XDocument staticDataFile)
		{
			// Get base type with properties
			var demographicClasses = GetBaseComponentDTOs<DemographicClassDTO>(staticDataFile.Descendants("DemographicClass")).ToList();

			// Set type specific properties
			demographicClasses.ForEach(o =>
				{
					o.Item1.TextDisplay = o.Item2.Attribute("TextDisplay").Value;
					o.Item1.DemographicType = Convert.ToInt32(o.Item2.Attribute("DemographicType").Value);
				});

			// Load stat modifier data
			demographicClasses.ForEach(o => LoadStatModifierData(o.Item2, o.Item1));


			// Add to context
			this._demographicClassesTable.Records = demographicClasses.Select(p => p.Item1 as IDemographicClassDTO).ToList();
		}

		private void LoadDemographicTypes(XDocument staticDataFile)
		{
			// Get base type with properties
			var demographicTypes = GetBaseComponentDTOs<DemographicTypeDTO>(staticDataFile.Descendants("DemographicType")).ToList();

			demographicTypes.ForEach(dt =>
				{
					dt.Item1.DisplayOrder = Convert.ToInt32(dt.Item2.Attribute("DisplayOrder").Value);
				});

			// Add to context
			this._demographicTypesTable.Records = demographicTypes.Select(p => p.Item1 as IDemographicTypeDTO).ToList();
		}

		private void LoadDemographics(XDocument gameDataFile, XDocument componentDataFile)
		{
			var defaultDemographicsList = GetBaseComponentDTOs<DemographicDTO>(componentDataFile.Descendants("Demographic")).ToList();
			var gameDemographicsList = GetBaseComponentDTOs<DemographicDTO>(gameDataFile.Descendants("Demographic")).ToList();

			var demographicsList = defaultDemographicsList.Concat(gameDemographicsList).ToList();

			// Set type specific properties
			demographicsList.ForEach(o =>
				{
					o.Item1.DemographicClass = Convert.ToInt32(o.Item2.Attribute("DemographicClass").Value);
					o.Item1.Value = o.Item2.Attribute("Value").Value;
				});

			// Add to context
			this._demographicsTable.Records = demographicsList.Select(p => p.Item1 as IDemographicDTO).ToList();
		}


		private void LoadFactions(XDocument gameDataFile)
		{
			// Get base type with properties
			var factionList = GetBaseComponentDTOs<FactionDTO>(gameDataFile.Descendants("Faction")).ToList();

			// Add to context
			this._factionsTable.Records = factionList.Select(p => p.Item1 as IFactionDTO).ToList();
		}

		private void LoadCountries(XDocument gameDataFile)
		{
			// Get base type with properties
			var countryList = GetBaseComponentDTOs<CountryDTO>(gameDataFile.Descendants("Country")).ToList();

			// Set type specific properties
			countryList.ForEach(o =>
				{
					o.Item1.Faction = Convert.ToInt32(o.Item2.Attribute("Faction").Value);
				});


			// Add to context
			this._countriesTable.Records = countryList.Select(p => p.Item1 as ICountryDTO).ToList();
		}

		private void LoadPlayers(XDocument gameDataFile)
		{
			// Get base type with properties
			var playerList = GetBaseComponentDTOs<PlayerDTO>(gameDataFile.Descendants("Player")).ToList();

			// Set type specific properties
			playerList.ForEach(o =>
				{
					var units = o.Item2.Descendants("Unit").ToList();
					units.ForEach(u => o.Item1.UnplacedReinforcements.Add(Convert.ToInt32(u.Attribute("ID").Value)));
					o.Item1.Country = Convert.ToInt32(o.Item2.Attribute("Country").Value);
					o.Item1.ReinforcementPoints = Convert.ToInt32(o.Item2.Attribute("ReinforcementPoints").Value);
					o.Item1.IsCurrentPlayer = (o.Item2.Attribute("IsCurrentPlayer") != null) && Convert.ToBoolean(o.Item2.Attribute(("IsCurrentPlayer")).Value);
					o.Item1.IsAIPlayer = (o.Item2.Attribute("IsAIPlayer") != null) && Convert.ToBoolean(o.Item2.Attribute(("IsAIPlayer")).Value);
				});




			// Add to context
			this._playersTable.Records = playerList.Select(p => p.Item1 as IPlayerDTO).ToList();
		}

		private void LoadBoard(XDocument boardDataFile)
		{
			// Board Data
			var dimension = boardDataFile.Descendants("Attributes").SingleOrDefault();
			
			var board = new BoardDTO
					{
						Title = dimension.Attribute("Title").Value,
						Height = Convert.ToInt32(dimension.Attribute("Height").Value),
						Width = Convert.ToInt32(dimension.Attribute("Width").Value),
						CellSize = Convert.ToInt32(dimension.Attribute("CellSize").Value),
						CellMaxUnits = Convert.ToInt32(dimension.Attribute("CellSize").Value),
					} as IBoardDTO;			

			var nodeList = boardDataFile.Descendants("Node");
			var nodesToSave = new List<INodeDTO>();
			var tilesToSave = new List<ITileDTO>();

			foreach (var e in nodeList)
			{
				var c = new CoordinateDTO
					{
						X = Convert.ToInt32(e.Descendants("Coordinate").SingleOrDefault().Attribute("X").Value),
						Y = Convert.ToInt32(e.Descendants("Coordinate").SingleOrDefault().Attribute("Y").Value),
						Z = Convert.ToInt32(e.Descendants("Coordinate").SingleOrDefault().Attribute("Z").Value)
					} as ICoordinateDTO;
				

				var dgs = e.Descendants("Demographics").Descendants("Demographic")
									.Select(d => 
										new DemographicDTO
											{
												ID = Convert.ToInt32(d.Attribute("ID").Value), 
												Orientation = (d.Attribute("Orientation") != null) ? d.Attribute("Orientation").Value : ""
											} as IDemographicDTO );								
						

				var v = Convert.ToInt32(e.Descendants("Tile").SingleOrDefault().Attribute("VictoryPoints").Value);

				var t = new TileDTO
							{
								UID = Guid.NewGuid(),
								VictoryPoints = v,
								Location = c,
								Demographics = dgs
							} as ITileDTO;

				tilesToSave.Add(t);

				
				var n = new NodeDTO
							{
								Name = "Node - {0}".F(c.ToString()),
								UID = Guid.NewGuid(),
								Location = c,
								Country = Convert.ToInt32(e.Descendants("Country").SingleOrDefault().Attribute("ID").Value),
								DefaultTile = t
							} as INodeDTO;


				nodesToSave.Add(n);

			}
				
			// Add to context
			this._tilesTable.Records = tilesToSave;
			this._nodesTable.Records = nodesToSave;
			this._board = board;
		}

		private void LoadUnits(XDocument unitDataFile)
		{
			var unitUnitList = unitDataFile.Descendants("Unit");
			var unitsToSave = new List<IUnitDTO>();

			foreach (var e in unitUnitList)
			{

				// No Location indicates unplaced unit
				var	c = (e.Descendants("Coordinate").SingleOrDefault() == null) ? null : new CoordinateDTO
																							{
																								X = Convert.ToInt32(e.Descendants("Coordinate").SingleOrDefault().Attribute("X").Value),
																								Y = Convert.ToInt32(e.Descendants("Coordinate").SingleOrDefault().Attribute("Y").Value),
																								Z = Convert.ToInt32(e.Descendants("Coordinate").SingleOrDefault().Attribute("Z").Value)
																							};
				
				

				var m = new UnitDTO
							{
								ID = Convert.ToInt32(e.Attribute("ID").Value),
								UID = Guid.NewGuid(),
								Name = e.Attribute("Name").Value,
								SubNodeLocation = Convert.ToInt32(e.Descendants("SubNodeLocation").SingleOrDefault().Attribute("Value").Value),
								Location = c,
								Description = e.Attribute("Description").Value,
								Country = Convert.ToInt32(e.Descendants("Country").SingleOrDefault().Attribute("ID").Value),
								StackOrder = Convert.ToInt32(e.Attribute("StackOrder").Value),
								UnitClass = Convert.ToInt32(e.Descendants("UnitInfo").SingleOrDefault().Attribute("UnitClass").Value),
								UnitType = Convert.ToInt32(e.Descendants("UnitInfo").SingleOrDefault().Attribute("UnitType").Value),
								UnitGroupType = Convert.ToInt32(e.Descendants("UnitInfo").SingleOrDefault().Attribute("UnitGroupType").Value)
								
							};

				// Movement stats if this is a saved game
				// Data saved mid-turn
				if (e.Descendants("MovementStats").SingleOrDefault() != null)
				{
					m.CurrentHasPerformedAction =
						Convert.ToBoolean(e.Descendants("MovementStats").SingleOrDefault().Attribute("CurrentHasPerformedAction").Value);
					m.CurrentMovementPoints =
						Convert.ToInt32(e.Descendants("MovementStats").SingleOrDefault().Attribute("CurrentMovementPoints").Value);
					m.CurrentRemoteFirePoints =
						Convert.ToInt32(e.Descendants("MovementStats").SingleOrDefault().Attribute("CurrentRemoteFirePoints").Value);
				}
					

				var tu = new List<int>();
				unitsToSave.Add(m);
			}	


			this._unitsTable.Records = unitsToSave;
		}


		private void LoadUnitAssignments(XDocument gameDataFile)
		{
			var lookupTmp = gameDataFile.Descendants("UnitAssignment");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.Unit = Convert.ToInt32(e.Attribute("Unit").Value);
				d.AssignedToUnit = Convert.ToInt32(e.Attribute("AssignedToUnit").Value);

				lookupListTmp.Add(d);
			}

			this._unitAssignments = lookupListTmp;
		}

		private void LoadUnitTransports(XDocument gameDataFile)
		{
			var lookupTmp = gameDataFile.Descendants("UnitTransport");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.Unit = Convert.ToInt32(e.Attribute("Unit").Value);
				d.TransportUnit = Convert.ToInt32(e.Attribute("TransportUnit").Value);

				lookupListTmp.Add(d);
			}

			this._unitTransports = lookupListTmp;
		}

		private void LoadUnitBaseTypeUnitClasses(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("UnitBaseTypeUnitClass");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.UnitBaseType = Convert.ToInt32(e.Attribute("UnitBaseType").Value);
				d.UnitClass = Convert.ToInt32(e.Attribute("UnitClass").Value);

				lookupListTmp.Add(d);
			}

			this._unitBaseTypeUnitClassesLookup = lookupListTmp;
		}

		private void LoadUnitBaseTypeUnitGeogTypes(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("UnitBaseTypeUnitGeogType");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.UnitBaseType = Convert.ToInt32(e.Attribute("UnitBaseType").Value);
				d.UnitGeogType = Convert.ToInt32(e.Attribute("UnitGeogType").Value);

				lookupListTmp.Add(d);
			}

			this._unitBaseTypeUnitGeogTypesLookup = lookupListTmp;
		}

		private void LoadHybridDemographicClasses(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("HybridDemographicClass");
			var lookupListTmp = new List<int>();

			foreach (var e in lookupTmp)
			{
				lookupListTmp.Add(Convert.ToInt32(e.Attribute("DemographicClass").Value));
			}

			this._hybridDemographicClasses = lookupListTmp;
		}

		private void LoadMovementHinderancesInDirection(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("MovementHinderance");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.DemographicClass = Convert.ToInt32(e.Attribute("DemographicClass").Value);
				d.UnitGeogType = Convert.ToInt32(e.Attribute("UnitGeogType").Value);
				d.Direction = (Direction)Convert.ToInt32(e.Attribute("Direction").Value);

				lookupListTmp.Add(d);
			}

			this._movementHinderanceInDirection = lookupListTmp;
		}

		private void LoadUnitGeogTypeDemographicClasses(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("UnitGeogTypeDemographicClass");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.UnitGeogType = Convert.ToInt32(e.Attribute("UnitGeogType").Value);
				d.DemographicClass = Convert.ToInt32(e.Attribute("DemographicClass").Value);

				lookupListTmp.Add(d);
			}

			this._unitGeogTypeDemographicClassesLookup = lookupListTmp;
		}

		private void LoadUnitGroupTypeUnitTasks(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("UnitGroupTypeUnitTask");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.UnitGroupType = Convert.ToInt32(e.Attribute("UnitGroupType").Value);
				d.UnitTask = Convert.ToInt32(e.Attribute("UnitTask").Value);

				lookupListTmp.Add(d);
			}

			this._unitGroupTypeUnitTaskLookup = lookupListTmp;
		}

		private void LoadMissionObjectiveUnitTasks(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("MissionObjectiveUnitTask");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.MissionObjective = Convert.ToInt32(e.Attribute("MissionObjective").Value);
				d.UnitTask = Convert.ToInt32(e.Attribute("UnitTask").Value);
				d.StepOrder = Convert.ToInt32(e.Attribute("StepOrder").Value);

				lookupListTmp.Add(d);
			}

			this._missionObjectiveUnitTasks = lookupListTmp;
		}

		private void LoadUnitTaskUnitClasses(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("UnitTaskUnitClass");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.UnitClass = Convert.ToInt32(e.Attribute("UnitClass").Value);
				d.UnitTask = Convert.ToInt32(e.Attribute("UnitTask").Value);

				lookupListTmp.Add(d);
			}

			this._unitTaskUnitClassesLookup = lookupListTmp;
		}

		private void LoadUnitGeogTypeMovementOverrides(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("UnitGeogTypeMovementOverrides").First().Descendants("Override");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.UnitGeogType = Convert.ToInt32(e.Attribute("UnitGeogType").Value);
				d.Geography = Convert.ToInt32(e.Attribute("DemographicClassA").Value);
				d.Infrastructure = Convert.ToInt32(e.Attribute("DemographicClassB").Value);

				lookupListTmp.Add(d);
			}

			this._unitGeogTypeMovementOverrides = lookupListTmp;
		}

		private void LoadUnitTypeUnitGeogTypeBattleEffectives(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("UnitTypeUnitGeogTypeBattleEffective").First().Descendants("BattleEffective");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.UnitType = Convert.ToInt32(e.Attribute("UnitType").Value);
				d.UnitGeogType = Convert.ToInt32(e.Attribute("UnitGeogType").Value);

				lookupListTmp.Add(d);
			}

			this._unitBattleEffectiveLookup = lookupListTmp;
		}

		private void LoadUnitTransportUnitTypeUnitClasses(XDocument lookupDataFile)
		{
			var lookupTmp = lookupDataFile.Descendants("UnitTransportUnitTypeUnitClasses").First().Descendants("TransportEffective");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.TransportUnitType = Convert.ToInt32(e.Attribute("TransportUnitType").Value);
				d.CarriedUnitType = Convert.ToInt32(e.Attribute("CarriedUnitType").Value);
				d.CarriedUnitClass = Convert.ToInt32(e.Attribute("CarriedUnitClass").Value);

				lookupListTmp.Add(d);
			}

			this._unitTransportUnitTypeUnitClasses = lookupListTmp;
		}		

		private void LoadFactionVictoryConditions(XDocument gameDataFile)
		{
			var lookupTmp = gameDataFile.Descendants("VictoryCondition");
			var lookupListTmp = new List<dynamic>();

			foreach (var e in lookupTmp)
			{
				dynamic d = new ExpandoObject();
				d.Faction = Convert.ToInt32(e.Attribute("Faction").Value);
				d.Condition = Convert.ToInt32(e.Attribute("Condition").Value);
				d.Value = Convert.ToInt32(e.Attribute("Value").Value);

				lookupListTmp.Add(d);
			}

			this._factionVictoryConditions = lookupListTmp;
		}

#endregion

#region Helper Methods

		/// <summary>
		/// Returns a list of IBaseGameComponentDTO and matching source elements with the properties set from the data source
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="elements"></param>
		/// <returns></returns>
		private IEnumerable<Tuple<T, XElement>> GetBaseComponentDTOs<T>(IEnumerable<XElement> elements)
			where T : class, IBaseGameComponentDTO, new() 
		{
			var retVal = elements
						.Select(c => new {element = c, pair = new Tuple<T, XElement>(GetBaseComponentDTO<T>(c), c)})
						.Select(p => p.pair);

			return retVal;
		}

		/// <summary>
		/// Returns an IBaseGameComponentDTO with the properties set from the data source
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="e"></param>
		/// <returns></returns>
		private T GetBaseComponentDTO<T>(XElement e) 
			where T : class, IBaseGameComponentDTO, new()
		{
			var retVal = new T
						{
							UID = Guid.NewGuid(),
							Name = e.Attribute("Name").Value, 
							Description = e.Attribute("Description").Value,
							ID = Convert.ToInt32(e.Attribute("ID").Value)
						} ;

			return retVal;
		}

		
		private void LoadStatModifierData(XElement e, IStatModifier dto)
		{
			dto.AttackModifier = (e.Attribute("AttackModifier") != null) ? Convert.ToDouble(e.Attribute("AttackModifier").Value) : 0;
			dto.AttackDistanceModifier = (e.Attribute("AttackDistanceModifier") != null) ? Convert.ToDouble(e.Attribute("AttackDistanceModifier").Value) : 0;
			dto.DefenceModifier = (e.Attribute("DefenceModifier") != null) ? Convert.ToDouble(e.Attribute("DefenceModifier").Value) : 0;
			dto.MovementModifier = (e.Attribute("MovementModifier") != null) ? Convert.ToDouble(e.Attribute("MovementModifier").Value) : 0;
			dto.UnitWeightModifier = (e.Attribute("UnitWeightModifier") != null) ? Convert.ToDouble(e.Attribute("UnitWeightModifier").Value) : 0;
			dto.AllowableWeightModifier = (e.Attribute("AllowableWeightModifier") != null) ? Convert.ToDouble(e.Attribute("AllowableWeightModifier").Value) : 0;
			dto.UnitCostModifier = (e.Attribute("UnitCostModifier") != null) ? Convert.ToDouble(e.Attribute("UnitCostModifier").Value) : 0;
			dto.StealthModifier = (e.Attribute("StealthModifier") != null) ? Convert.ToDouble(e.Attribute("StealthModifier").Value) : 0;
		}

#endregion	
		

	}



}
Back to Top