Example #1
0
    void JoinTournament()
    {
        loader.IsLoading = true;

        if (!IsPlayerInWhitelist(currentData.tournament.Options.Whitelist))
        {
            OperationOnDone("You cant join to the tournament, because you arent in whitelist!", false);
        }
        else if (!currentAccountBalanceObject.IsNull() && currentAccountBalanceObject.Amount < currentData.tournament.Options.BuyIn.Amount + currentFee)
        {
            OperationOnDone("Failed\r\nInsufficient Funds available", false);
        }
        else
        {
            TournamentTransactionService.GenerateJoinToTournamentOperation(currentData)
            .Then(operaion => {
                TournamentTransactionService.JoinToTournament(operaion)
                .Then(() => {
                    gameObject.SetActive(false);
                    if (OnOperationSuccess != null)
                    {
                        OnOperationSuccess();
                    }
                    OperationOnDone("You successfully joined to tournament №" + currentData.tournament.Id.Id, true);
                })
                .Catch(exception => OperationOnDone("There was a mistake during joining of a tournament!", false));
            })
            .Catch(exception => OperationOnDone("There was a mistake during joining of a tournament!", false));
        }
    }
Example #2
0
 void Create()
 {
     if (allIsValidate)
     {
         loader.IsLoading = true;
         TournamentTransactionService.GenerateCreateTournamentOperation(NewTournament())
         .Then(operation => {
             loader.IsLoading = false;
             createNewTournamentPopupView.SetTournamentInformation(NewTournament(), isJoin);
         });
     }
 }
    public void SetUp(TournamentObject tournament)
    {
        ApiManager.Instance.Database
        .GetAccountBalances(AuthorizationManager.Instance.UserData.FullAccount.Account.Id.Id, Array.ConvertAll(AuthorizationManager.Instance.UserData.FullAccount.Balances, balance => balance.AssetType.Id))
        .Then(accountBalances => {
            var data        = new LeaveFromTournamentData();
            data.tournament = tournament;
            data.account    = AuthorizationManager.Instance.UserData.FullAccount.Account.Id;
            currentData     = data;
            AssetData asset = null;
            foreach (var balance in accountBalances)
            {
                if (balance.Asset.Equals(currentData.tournament.Options.BuyIn.Asset))
                {
                    asset = balance;
                }
            }

            TournamentTransactionService.GenerateLeaveFromTournamentOperation(currentData)
            .Then(operation => {
                var feeAsset = SpaceTypeId.CreateOne(SpaceType.Asset);

                ApiManager.Instance.Database.GetRequiredFee(operation, feeAsset.Id)
                .Then(feeResult => {
                    Repository.GetInPromise <AssetObject>(feeResult.Asset)
                    .Then(assetData => {
                        buyinText.text              = tournament.Options.BuyIn.Amount / Math.Pow(10, assetData.Precision) + assetData.Symbol;
                        feeText.text                = feeResult.Amount / Math.Pow(10, assetData.Precision) + assetData.Symbol;
                        currentFee                  = feeResult.Amount;
                        currentOperation            = operation;
                        currentAccountBalanceObject = asset;

                        ApiManager.Instance.Database.GetAccount(tournament.Creator.Id)
                        .Then(creator => {
                            gameTitleText.text            = "ROCK, PAPER, SCISSORS";
                            creatorNameText.text          = Utils.GetFormatedString(creator.Name);
                            numberOfPlayersText.text      = data.tournament.Options.NumberOfPlayers.ToString();
                            winsAmountText.text           = data.tournament.Options.NumberOfWins.ToString();
                            registrationDeadlineText.text = data.tournament.Options.RegistrationDeadline.ToString("MMMM dd, yyyy hh:mmtt (z)").ToUpper();
                            Show();
                        });
                    })
                    .Catch(exception => OperationOnDone("There was a mistake during leaving of a tournament!", false));
                })
                .Catch(exception => OperationOnDone("There was a mistake during leaving of a tournament!", false));
            })
            .Catch(exception => OperationOnDone("There was a mistake during leaving of a tournament!", false));
        });
    }
    void JoinTournament(SpaceTypeId tournament)
    {
        if (isJoinToTournament)
        {
            Action <TournamentObject> JoinToTournament = tournamentObject => {
                var joinTournamentData = new JoinToTournamentData();
                joinTournamentData.tournament = tournamentObject;
                joinTournamentData.account    = AuthorizationManager.Instance.Authorization.UserNameData.FullAccount.Account.Id;

                TournamentTransactionService.GenerateJoinToTournamentOperation(joinTournamentData)
                .Then(operation => {
                    TournamentTransactionService.JoinToTournament(operation)
                    .Then(() => JoinOperationOnDone("Your tournament was successfully created & joined!", true))
                    .Catch(exception => JoinOperationOnDone("Your tournament was successfully created, but not joined!", false));
                })
                .Catch(exception => JoinOperationOnDone("There was a mistake during joining of a tournament!", false));
            };
            Repository.GetInPromise(tournament, () => TournamentManager.Instance.LoadTournament(tournament.Id)).Then(JoinToTournament);
        }
    }
 void LeaveTournament()
 {
     loader.IsLoading = true;
     if (!currentAccountBalanceObject.IsNull() && currentAccountBalanceObject.Amount < currentData.tournament.Options.BuyIn.Amount + currentFee)
     {
         OperationOnDone("Failed\r\nInsufficient Funds available", false);
     }
     else
     {
         TournamentTransactionService.LeaveFromTournament(currentOperation)
         .Then(() => {
             gameObject.SetActive(false);
             if (OnOperationSuccess != null)
             {
                 OnOperationSuccess();
             }
             OperationOnDone("You have successfully left a tournament!", true);
         })
         .Catch(exception => OperationOnDone("There was a mistake during leaving of a tournament!", false));
     }
 }
 void CreateTournament()
 {
     loader.IsLoading = true;
     isChoosenHand    = false;
     TournamentTransactionService.GenerateCreateTournamentOperation(currentData)
     .Then(operation => {
         TournamentTransactionService.CreateTournament(operation)
         .Then(() => {
             TournamentTransactionService.OnCreateTournamentResult -= JoinTournament;
             if (isJoinToTournament)
             {
                 TournamentTransactionService.OnCreateTournamentResult += JoinTournament;
             }
             else
             {
                 CreateOperationOnDone("Your tournament was successfully created!");
             }
         })
         .Catch(exception => CreateOperationOnFailed("There was a mistake during creation of a tournament!"));
     })
     .Catch(exception => CreateOperationOnFailed("There was a mistake during creation of a tournament!"));
 }