示例#1
0
        /// <summary>
        /// Creates new options objects with values parsed from string configuration data
        /// </summary>
        /// <param name="cfg">configuration file</param>
        /// <param name="bcClientOptions"></param>
        public HoardServiceOptions(HoardServiceConfig cfg, BCClientOptions bcClientOptions)
        {
            Game = GameID.kInvalidID;
            if (!string.IsNullOrEmpty(cfg.GameID))
            {
                Game = new GameID(System.Numerics.BigInteger.Parse(cfg.GameID, NumberStyles.AllowHexSpecifier));
            }

            if (!string.IsNullOrEmpty(cfg.GameBackendUrl))
            {
                Game.Url = cfg.GameBackendUrl;
            }

            if (!string.IsNullOrEmpty(cfg.ExchangeServiceUrl))
            {
                ExchangeServiceUrl = cfg.ExchangeServiceUrl;
            }

            if (!string.IsNullOrEmpty(cfg.HoardAuthServiceUrl))
            {
                HoardAuthServiceUrl = cfg.HoardAuthServiceUrl;
            }

            if (!string.IsNullOrEmpty(cfg.HoardAuthServiceClientId))
            {
                HoardAuthServiceClientId = cfg.HoardAuthServiceClientId;
            }

            BCClientOptions = bcClientOptions;

            GameCenterContract = cfg.GameCenterContract;
        }
示例#2
0
 /// <summary>
 /// Return GameItem types for specyfied game
 /// </summary>
 /// <param name="game"></param>
 /// <returns></returns>
 public string[] GetGameItemTypes(GameID game)
 {
     if (Providers.ContainsKey(game))
     {
         IGameItemProvider p = Providers[game];
         return(p.GetItemTypes());
     }
     return(null);
 }
示例#3
0
 /// <summary>
 /// Returns amount of all items of the specified type belonging to a particular player with given type
 /// </summary>
 /// <param name="profile"></param>
 /// <param name="gameID"></param>
 /// <param name="itemType">Item type</param>
 /// <returns></returns>
 public async Task <ulong> GetPlayerItemsAmount(Profile profile, GameID gameID, string itemType)
 {
     if (Providers.ContainsKey(gameID))
     {
         IGameItemProvider c = Providers[gameID];
         return(await c.GetPlayerItemsAmount(profile, itemType).ConfigureAwait(false));
     }
     else
     {
         ErrorCallbackProvider.ReportWarning($"Game [{gameID.Name}] could not be found. Have you registered it properly?");
     }
     return(await Task.FromResult <ulong>(0));
 }
示例#4
0
        /// <summary>
        /// Register default HoardBackend connector with BC fallback.
        /// </summary>
        /// <param name="game"></param>
        public async Task RegisterHoardGame(GameID game)
        {
            if (Providers.ContainsKey(game) && (Providers[game] is HoardGameItemProvider))
            {
                return;
            }

            //assumig this is a hoard game we can use a default hoard provider that connects to Hoard game server backend
            HoardGameItemProvider provider = new HoardGameItemProvider(game);

            //for security reasons (or fallback in case server is down) we will pass a BC provider
            provider.SecureProvider = GameItemProviderFactory.CreateSecureProvider(game, BCComm);
            await RegisterGame(game, provider);
        }
示例#5
0
        /// <summary>
        /// Returns all Game Items owned by player's subaccount in particular game
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="gameID"></param>
        /// <param name="page">Page number</param>
        /// <param name="itemsPerPage">Number of items per page</param>
        /// <param name="itemType">Item type</param>
        /// <returns></returns>
        public async Task <GameItem[]> GetPlayerItems(Profile profile, GameID gameID, string itemType, ulong page, ulong itemsPerPage)
        {
            List <GameItem> items = new List <GameItem>();

            if (Providers.ContainsKey(gameID))
            {
                IGameItemProvider c = Providers[gameID];
                items.AddRange(await c.GetPlayerItems(profile, itemType, page, itemsPerPage).ConfigureAwait(false));
            }
            else
            {
                ErrorCallbackProvider.ReportWarning($"Game [{gameID.Name}] could not be found. Have you registered it properly?");
            }
            return(items.ToArray());
        }
示例#6
0
 /// <summary>
 /// Creates new instance of GameItem descriptor
 /// </summary>
 /// <param name="game"></param>
 /// <param name="symbol"></param>
 /// <param name="metadata"></param>
 public GameItem(GameID game, string symbol, IGameItemMetadata metadata)
 {
     Game     = game;
     Symbol   = symbol;
     Metadata = metadata;
 }
示例#7
0
 /// <summary>
 /// Check if game exists on the Hoard Platform.
 /// </summary>
 /// <param name="game"></param>
 public async Task <bool> GetGameExists(GameID game)
 {
     return(await BCComm.GetGameExists(game.ID));
 }