示例#1
0
        public static PackContent GenerateContent(this Pack pack)
        {
            var packContents      = new PackContent();
            var cardSelectionPool = pack.Set.Cards.ToList();
            var game = pack.Set.GetGame();

            // add the include cards to the set for this booster
            var includeCards =
                (
                    from qset in pack.Includes.Select(x => x.SetId)
                    .Distinct()
                    .Select(x => SetManager.Get().GetById(x))
                    from card in qset.Cards
                    join inc in pack.Includes on qset.Id equals inc.SetId
                    where card.Id == inc.Id
                    select new { Card = card, Include = inc }
                )
                .Select(picked =>
            {
                var card = new Card(picked.Card);

                foreach (var include in picked.Include.Properties)
                {
                    card.PropertySets[""].Properties[include.Property] = include.Value;
                }
                ;
                return(card);
            });

            cardSelectionPool.AddRange(includeCards);

            packContents.Merge(ProcessPackItems(pack, pack.Items, cardSelectionPool));
            return(packContents);
        }
示例#2
0
        public static IEnumerable <Set> Sets(this Game game)
        {
            var ret = SetManager.Get().GetByGameId(game.Id);

            return(ret);
            //return SetManager.Get().Sets.Where(x => x.GameId == game.Id);
        }
        public static string GetFullName(this Pack pack)
        {
            var set = SetManager.Get().GetById(pack.SetId);

            if (set == null)
            {
                return(null);
            }
            return(set.Name + ", " + pack.Name);
        }
示例#4
0
        public static string GetFullName(this Pack pack)
        {
            var set = SetManager.Get().GetById(pack.SetId);

            //var set = SetManager.Get().Sets.FirstOrDefault(x => x.Packs.Any(y => y.Id == pack.Id));
            if (set == null)
            {
                return(null);
            }
            return(set.Name + ", " + pack.Name);
        }
示例#5
0
        private void CardSelected(object sender, SearchCardImageEventArgs e)
        {
            if (e.Image == null)
            {
                return;
            }
            selection = e.Image;
            set_id    = e.SetId;
            var cardid = e.CardId;
            var set    = SetManager.Get().GetById(e.SetId);
            var card   = set.Cards.FirstOrDefault(x => x.Id == cardid);

            cardImageControl.Card.SetCard(card.Clone());
        }
示例#6
0
        private void cardImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (selection == null)
            {
                return;
            }
            var bim = new BitmapImage();

            bim.BeginInit();
            bim.CacheOption = BitmapCacheOption.OnLoad;
            var set = SetManager.Get().GetById(set_id);

            bim.UriSource = set.GetPictureUri(selection) ?? Game.GetCardBackUri();
            //bim.UriSource = CardModel.GetPictureUri(Game, set_id, selection);
            bim.EndInit();
            cardImage.Source = bim;
        }
示例#7
0
 public static Set GetSet(this ICard card)
 {
     try
     {
         GetSetLock.EnterUpgradeableReadLock();
         Set ret = null;
         if (!CardSetIndex.TryGetValue(card.SetId, out ret))
         {
             GetSetLock.EnterWriteLock();
             ret = SetManager.Get().GetById(card.SetId);
             CardSetIndex[card.SetId] = ret;
             GetSetLock.ExitWriteLock();
         }
         return(ret);
     }
     finally
     {
         GetSetLock.ExitUpgradeableReadLock();
     }
 }
示例#8
0
        private void CardSelected(object sender, SearchCardImageEventArgs e)
        {
            selection = e.Image;
            set_id    = e.SetId;
            var cardid = e.CardId;
            var bim    = new BitmapImage();

            bim.BeginInit();
            bim.CacheOption = BitmapCacheOption.OnLoad;

            try
            {
                var set  = SetManager.Get().GetById(e.SetId);
                var card = set.Cards.FirstOrDefault(x => x.Id == cardid);
                //var card = CardManager.Get().GetCardById(cardid);
                var uri = card.GetPicture();
                if (uri != null)
                {
                    bim.UriSource = new Uri(uri);
                }
                else
                {
                    bim.UriSource = Game.GetCardBackUri();
                }
                //bim.UriSource = e.Image != null ? new Uri(card.GetPicture()) : Game.GetCardBackUri();
                //bim.UriSource = e.Image != null ? CardModel.GetPictureUri(Game, e.SetId, e.Image) : Game.GetCardBackUri();
                bim.EndInit();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine("Error loading picture uri from game pack: " + ex.ToString());
                bim             = new BitmapImage();
                bim.CacheOption = BitmapCacheOption.OnLoad;
                bim.BeginInit();
                bim.UriSource = new Uri(@"pack://application:,,,/Octgn;component/Resources/Front.jpg");
                bim.EndInit();
            }
            cardImage.Source = bim;
        }
示例#9
0
 private void LoadDatabase()
 {
     this.UpdateStatus("Loading games...");
     foreach (var g in GameManager.Get().Games)
     {
         Log.DebugFormat("Loaded Game {0}", g.Name);
     }
     this.UpdateStatus("Loading sets...");
     foreach (var s in SetManager.Get().Sets)
     {
         Log.DebugFormat("Loaded Set {0}", s.Name);
     }
     this.UpdateStatus("Loading scripts...");
     foreach (var s in DbContext.Get().Scripts)
     {
         Log.DebugFormat("Loading Script {0}", s.Path);
     }
     this.UpdateStatus("Loading proxies...");
     foreach (var p in DbContext.Get().ProxyDefinitions)
     {
         Log.DebugFormat("Loading Proxy {0}", p.Key);
     }
     this.UpdateStatus("Loaded database.");
 }
示例#10
0
 public static Set GetSet(this ICard card)
 {
     return(SetManager.Get().GetById(card.SetId));
     //return SetManager.Get().Sets.FirstOrDefault(x => x.Id == card.SetId);
 }
示例#11
0
        private void LoadDatabase()
        {
            this.UpdateStatus("Loading games...");
            foreach (var g in GameManager.Get().Games)
            {
                Log.DebugFormat("Loaded Game {0}", g.Name);
            }
            this.UpdateStatus("Loading sets...");
            foreach (var s in SetManager.Get().Sets)
            {
                Log.DebugFormat("Loaded Set {0}", s.Name);
            }
            this.UpdateStatus("Loading scripts...");
            foreach (var s in DbContext.Get().Scripts)
            {
                Log.DebugFormat("Loading Script {0}", s.Path);
            }
            this.UpdateStatus("Loading proxies...");
            foreach (var p in DbContext.Get().ProxyDefinitions)
            {
                Log.DebugFormat("Loading Proxy {0}", p.Key);
            }
            this.UpdateStatus("Loaded database.");

            this.UpdateStatus("Migrating Images...");
            try
            {
                foreach (var g in GameManager.Get().Games)
                {
                    this.UpdateStatus(String.Format("Migrating {0} Images...", g.Name));
                    foreach (var s in g.Sets())
                    {
                        var gravePath = Config.Instance.Paths.GraveyardPath;
                        if (!Directory.Exists(gravePath))
                        {
                            Directory.CreateDirectory(gravePath);
                        }
                        var dir    = new DirectoryInfo(s.PackUri);
                        var newDir = new DirectoryInfo(s.ImagePackUri);
                        foreach (var f in dir.GetFiles("*.*"))
                        {
                            var newLocation = Path.Combine(newDir.FullName, f.Name);
                            f.MegaCopyTo(newLocation);
                            f.MoveTo(Path.Combine(gravePath, f.Name));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Warn("Migrate Files error", e);
                TopMostMessageBox.Show(
                    "There was an error migrating your image files. Restarting your computer may help",
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
            }
            this.UpdateStatus("Migrated Images");

            this.UpdateStatus("Clearing Old Proxies...");
            try
            {
                foreach (var g in GameManager.Get().Games)
                {
                    this.UpdateStatus(String.Format("Clearing {0} Proxies...", g.Name));
                    foreach (var s in g.Sets())
                    {
                        var dir = new DirectoryInfo(s.ProxyPackUri);
                        if (dir.Exists)
                        {
                            var gravePath = Config.Instance.Paths.GraveyardPath;
                            if (!Directory.Exists(gravePath))
                            {
                                Directory.CreateDirectory(gravePath);
                            }
                            foreach (var f in dir.GetFiles("*.*"))
                            {
                                f.MoveTo(Path.Combine(gravePath, f.Name));
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.Warn("Clearing Old Proxies error", e);
                TopMostMessageBox.Show(
                    "There was an error clearing your old proxies. Restarting your computer may help",
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
            }
            this.UpdateStatus("Cleared Old Proxies");

            this.UpdateStatus("Clearing Old Installers...");
            try
            {
                var rpath     = new DirectoryInfo(Config.Instance.Paths.BasePath);
                var gravePath = Config.Instance.Paths.GraveyardPath;
                if (!Directory.Exists(gravePath))
                {
                    Directory.CreateDirectory(gravePath);
                }
                foreach (var f in rpath.GetFiles("OCTGN-Setup-*.exe"))
                {
                    if (f.Name.Contains(Const.OctgnVersion.ToString()))
                    {
                        continue;
                    }
                    f.MoveTo(Path.Combine(gravePath, f.Name));
                }
            }
            catch (Exception e)
            {
                Log.Warn("Clearing Old Installers error", e);
                TopMostMessageBox.Show(
                    "There was an error clearing old installers. Restarting your computer may help",
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
            }
            this.UpdateStatus("Cleared Old Installers");
        }
示例#12
0
 public static Set Set(this Pack pack)
 {
     return(SetManager.Get().GetById(pack.SetId));
 }
示例#13
0
        public static IEnumerable <Set> Sets(this Game game)
        {
            var ret = SetManager.Get().GetByGameId(game.Id);

            return(ret);
        }