SourceForge has been redesigned. Learn more.
Close

Diff of /Classes/Player.cs [569eeb] .. [c5a3d1]  Maximize  Restore

Switch to side-by-side view

--- a/Classes/Player.cs
+++ b/Classes/Player.cs
@@ -1,5 +1,6 @@
 ďťżusing System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Linq;
 using System.Net.Sockets;
 using System.Text;
@@ -13,7 +14,7 @@
         public Hand Hand;
         public Field MonsterField, StField;
         public CardStack ExtraDeck, Graveyard, Banished;
-        private uint _currdeck =0, _lifepoints;
+        private uint _lifepoints;
 
         /// <summary>
         /// Player Id
@@ -30,13 +31,14 @@
             } 
         }
 
-        public Player( uint id ) { //loads player
+        private Player( uint id ) { //loads player
             Id = id;
         }
 
         public Player( MySqlDataReader reader ) : this( reader.GetUInt32( "id" ) ) {
             uint eqdeck = reader.GetUInt32( "eqdeck" );
-            if( eqdeck != 0 ) Equipdeck( eqdeck );
+            if( eqdeck != 0 ) EquipDeck( eqdeck );
+            
             Name = reader.GetString( "name" );
         }
 
@@ -52,17 +54,7 @@
             con.Close();
         }
 
-        public void Equipdeck( uint deck ) {
-            UpdateDbLastAction();
-            if( deck == 0 ) throw new InvalidProgramException();
-            _currdeck = deck;
-            MainDeck = new Deck( _currdeck );
-
-            var con = new MySqlConnection( Com.connStr );
-            con.Open();
-            new MySqlCommand( "UPDATE `users` SET `eqdeck` = '" + deck + "' WHERE `id` =" + Id, con ).ExecuteNonQuery();
-            con.Close();
-        }
+        public void EquipDeck( uint deck ) { EquipDeck( new Deck( deck ) ); }
 
         public void InitBattle( uint startlp = 8000 ) {
             LifePoints = startlp;
@@ -74,8 +66,7 @@
             MonsterField = new Field();
             StField = new Field();
 
-            Hand = new Hand();
-            Hand.Add( MainDeck.Draw(7) );
+            Hand = new Hand( MainDeck.Draw( 7 ) );
         }
 
         public string GetIP(){
@@ -86,9 +77,14 @@
             return localIP;
         }
 
-        internal void Equipdeck( Deck deck ) {
+        public void EquipDeck( Deck deck ) {
+            MainDeck = deck;
+
+            var con = new MySqlConnection( Com.connStr );
+            con.Open();
+            new MySqlCommand( "UPDATE `users` SET `eqdeck` = '" + deck.Id + "' WHERE `id` =" + Id, con ).ExecuteNonQuery();
+            con.Close();
             UpdateDbLastAction();
-            MainDeck = deck;
         }
     }
 }