[cf67b8]: Classes / ACard.cs Maximize Restore History

Download this file

ACard.cs    61 lines (48 with data), 2.1 kB

 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
using System.Diagnostics;
using MySql.Data.MySqlClient;
using System;
namespace YuGiOh_Ultra {
public enum CardPos { SET, NORM, DEF }
public abstract class ACard : ICard {
public CardPos Pos { get; set; }
public string Code { get; private set; }
public string Name { get; protected set; }
public virtual string Img { get { return Com.imgpath + Code + ".jpg"; } }
public virtual int ImgRot { get { return 0; } }
protected ACard( ACard c ) : this() {
Pos = c.Pos;
Code = c.Code;
Name = c.Name;
}
protected ACard() { Pos = CardPos.NORM; }
protected ACard( string code ) : this() {
if( code == null ) throw new InvalidProgramException();
this.Code = code;
}
protected ACard( string code, string name ) : this( code ) { this.Name = name; }
protected ACard( MySqlDataReader reader ) : this( reader.GetString( "code" ), reader.GetString( "name" ) ) { }
public static ACard Load( MySqlDataReader reader ) {
if( reader.GetInt16( "level" ) > 0 /*&& reader.GetString( "main" ) == "normal"*/ ) return new NormalMonster( reader );
else switch ( reader.GetString("element") ) {
case "trap":
return new Trap( reader );
case "spell":
return new Spell( reader );
}
throw new InvalidProgramException();
}
public override bool Equals( object obj ) {
if( obj == null ) return false;
if( this == obj ) return true;
var c = obj as ACard;
if( c != null ) return this.Code == c.Code;
return false;
}
public override int GetHashCode() { return Code.GetHashCode(); }
public override string ToString() { return Code; }
public virtual ACard Clone() {
Debug.WriteLine("Eseguito Clone su Card! non è stato fatto override!");
throw new InvalidProgramException();
}
}
}