예제 #1
0
파일: GameDef.cs 프로젝트: clavalle/OCTGN
        private static GameDef LoadFromXml(XElement xml, PackagePart part)
        {
            if (xml.Name != Defs.XmlnsOctgn + "game")
            {
                throw new InvalidFormatException("The root document element must be <game>.");
            }

            return(new GameDef
            {
                Id = xml.Attr <Guid>("id"),
                Name = xml.Attr <string>("name"),
                Version = xml.Attr <Version>("version"),
                OctgnVersion = xml.Attr <Version>("octgnVersion"),
                MarkerSize = xml.Attr <int>("markersize"),
                CardsRevertToOriginalOnGroupChange = xml.Attr <bool>("cardsRevertToOriginalOnGroupChange"),
                CardDefinition = CardDef.LoadFromXml(xml.Child("card"), part),
                DeckDefinition = DeckDef.LoadFromXml(xml.Child("deck")),
                SharedDeckDefinition = DeckDef.LoadFromXml(xml.Child("sharedDeck")),
                TableDefinition = GroupDef.LoadFromXml(xml.Child("table"), part, 0),
                PlayerDefinition = PlayerDef.LoadFromXml(xml.Child("player"), part),
                GlobalDefinition = SharedDef.LoadFromXml(xml.Child("shared"), part),
                GlobalVariables = GlobalVariableDef.LoadAllFromXml(xml.Child("globalvariables")),
                Variables = VariableDef.LoadAllFromXml(xml.Child("variables")),
                Scripts = ScriptDef.LoadAllFromXml(xml.Child("scripts"), part),
                Fonts = FontDef.LoadAllFromXml(xml.Child("fonts"), part),
                Icons = IconDef.LoadAllFromXml(xml.Child("iconreplacements"), part)
            });
        }
예제 #2
0
파일: CardDef.cs 프로젝트: voidbeast/OCTGN
        internal static CardDef LoadFromXml(XElement xml, PackagePart part)
        {
            var backUri = xml.Attr<string>("back");
            if (backUri != null) backUri = part.GetRelationship(backUri).TargetUri.OriginalString;

            var frontUri = xml.Attr<string>("front");
            if (frontUri != null) frontUri = part.GetRelationship(frontUri).TargetUri.OriginalString;

            var cd = new CardDef
                       {
                           back = backUri,
                           front = frontUri,
                           Width = xml.Attr<int>("width"),
                           Height = xml.Attr<int>("height"),
                           CornerRadius = xml.Attr<int>("cornerRadius"),
                           //Properties = xml.Elements(Defs.XmlnsOctgn + "property")
                           //    //.Select(PropertyDef.LoadFromXml)
                           //    .ToDictionary(x => x.Name)
                       };
            var list = xml.Elements(Defs.XmlnsOctgn + "property");
            var proplist = new Dictionary<string,PropertyDef>();
            foreach (var l in list)
            {
                var name = l.Attr<string>("name");

                string kindStr = l.Attr("textKind", "Free");
                PropertyTextKind kind;
                switch (kindStr)
                {
                    case "Free":
                        kind = PropertyTextKind.FreeText;
                        break;
                    case "Enum":
                        kind = PropertyTextKind.Enumeration;
                        break;
                    case "Tokens":
                        kind = PropertyTextKind.Tokens;
                        break;
                    default:
                        throw new InvalidFileFormatException(
                            string.Format("Unknown value '{0}' for textKind attribute (Property = {1})",
                                          kindStr, name));
                }

                var prop = new PropertyDef
                {
                    Name = name,
                    Type = l.Attr<PropertyType>("type"),
                    IgnoreText = l.Attr<bool>("ignoreText"),
                    TextKind = kind,
                    Hidden = l.Attr<bool>("hidden")
                };
                proplist.Add(name,prop);
            }
            cd.Properties = proplist;
            return cd;
        }
예제 #3
0
파일: Card.cs 프로젝트: voidbeast/OCTGN
 internal Card(Player owner, int id, ulong key, CardDef def, DataNew.Entities.Card model, bool mySecret)
     : base(owner)
 {
     _id = id;
     Type = new CardIdentity(id) {Alias = false, Key = key, Model = model, MySecret = mySecret};
     // var _definition = def;
     All.Add(id, this);
     _alternateOf = null;
     numberOfSwitchWithAlternatesNotPerformed = 0;
     _isAlternateImage = false;
 }