[longomatch/redesign: 7/96] Clean up teams templates and make use of the new API



commit 1c0480a3925156902402c51c1a1dd0f1ffc57165
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Nov 21 16:20:35 2010 +0100

    Clean up teams templates and make use of the new API

 LongoMatch/DB/TeamTemplate.cs |   48 +++++++++++++++++++++++------------------
 1 files changed, 27 insertions(+), 21 deletions(-)
---
diff --git a/LongoMatch/DB/TeamTemplate.cs b/LongoMatch/DB/TeamTemplate.cs
index 37874be..ab9d9d7 100644
--- a/LongoMatch/DB/TeamTemplate.cs
+++ b/LongoMatch/DB/TeamTemplate.cs
@@ -22,6 +22,7 @@ using System.IO;
 using System.Runtime.Serialization;
 using System.Runtime.Serialization.Formatters.Binary;
 using LongoMatch.TimeNodes;
+using LongoMatch.Common;
 
 namespace LongoMatch.DB
 {
@@ -34,6 +35,17 @@ namespace LongoMatch.DB
 		public TeamTemplate() {
 			playersList = new List<Player>();
 		}
+		
+		public String TeamName{
+			get;
+			set;
+		}
+
+		public List<Player> PlayersList{
+			get {
+				return playersList;
+			}
+		}
 
 		public void Clear() {
 			playersList.Clear();
@@ -45,31 +57,10 @@ namespace LongoMatch.DB
 			}
 		}
 
-		public void CreateDefaultTemplate(int playersCount) {
-			for (int i=0; i<playersCount;i++) {
-				playersList.Add(new Player("Player "+i, new DateTime(),"", 0,0,"",i,null, false));
-			}
-		}
-
 		public void AddPlayer(Player player) {
 			playersList.Add(player);
 		}
 
-		public void SetPlayersList(List<Player> playersList) {
-			this.playersList = playersList;
-		}
-
-		public Player GetPlayer(int index) {
-			if (index >= PlayersCount)
-				throw new Exception(String.Format("The actual team template doesn't have so many players. Requesting player {0} but players count is {1}",
-				                                  index, PlayersCount));
-			return playersList[index];
-		}
-
-		public List<Player> GetPlayersList() {
-			return playersList;
-		}
-
 		public void Save(string filepath) {
 			IFormatter formatter = new BinaryFormatter();
 			Stream stream = new FileStream(filepath, FileMode.Create, FileAccess.Write, FileShare.None);
@@ -90,5 +81,20 @@ namespace LongoMatch.DB
 			defaultTemplate.CreateDefaultTemplate(playersCount);
 			return defaultTemplate;
 		}
+		
+		private void CreateDefaultTemplate(int playersCount) {
+			for (int i=0; i<playersCount;i++) {
+				playersList.Add(new Player{
+					Name = "Player " + i,
+					Birthday = new DateTime(),
+					Height = 1.80f,
+					Weight = 80,
+					Number = 0,
+					Position = "",
+					Photo = null,
+					Playing = true,
+				});
+			}
+		}
 	}
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]