Esempio n. 1
0
    public static List <GamblingConfig> ParseGamblings(string text)
    {
        List <RewardEnum>      rewardTypes = ParseRewardTypes(text);
        IEnumerable <string[]> source      = TSVParser.Parse(text).Skip(1);

        return(source.Select(delegate(string[] line)
        {
            GamblingConfig gamblingConfig = new GamblingConfig
            {
                Level = line.asInt(0, line.toError <int>()),
                FailChance = line.asFloat(1, line.toError <float>())
            };
            List <WeightedObject <RewardData> > list = new List <WeightedObject <RewardData> >();
            for (int i = 2; i < line.Length; i++)
            {
                RewardEnum type = rewardTypes[i - 2];
                AmountAndWeight amountAndWeight = line.asCustom(i, AmountAndWeightParser.ParseAmountAndWeight, line.toError <AmountAndWeight>());
                WeightedObject <RewardData> item = new WeightedObject <RewardData>
                {
                    Value = new RewardData(type, amountAndWeight.Amount),
                    Weight = amountAndWeight.Weight
                };
                list.Add(item);
            }
            gamblingConfig.Rewards = list;
            return gamblingConfig;
        }).ToList());
    }
Esempio n. 2
0
 public WheelOfFortuneGame(ulong userId, long bet, GamblingConfig config, ICurrencyService cs)
 {
     _rng    = new NadekoRandom();
     _cs     = cs;
     _bet    = bet;
     _config = config;
     _userId = userId;
 }
Esempio n. 3
0
    public GamblingRunner()
    {
        Singleton <PropertyManager> .Instance.AddRootContext(this);

        SceneLoader            root = SceneLoader.Instance;
        GamblingBindingManager bind = GamblingBindingManager.Instance;

        LoadGamblingState();
        SetButtonStatesAndAnimatorsToArrays();
        MaxGamblingLevel.Value = Singleton <EconomyHelpers> .Instance.GetMaxGamblingLevel();

        CurrentGamblingLevel.Subscribe(delegate(int lvl)
        {
            m_gambConf = Singleton <EconomyHelpers> .Instance.GetGamblingConfig(lvl);
        }).AddTo(root);
        FailPaid.Subscribe(delegate(bool paid)
        {
            bind.DrJellyStealPopup.SetActive(!paid);
        }).AddTo(root);
        (from states in m_buttonStates[0].CombineLatest(m_buttonStates[1], m_buttonStates[2], m_buttonStates[3], (int one, int two, int three, int four) => new int[4]
        {
            one,
            two,
            three,
            four
        }).Skip(1)
         where states[0] > 0 || states[1] > 0 || states[2] > 0 || states[3] > 0
         select states).Subscribe(delegate
        {
            root.StartCoroutine(OpenRestCards());
        }).AddTo(root);
        (from curr in CurrentGamblingLevel
         where curr > NextJackpotLevel.Value
         select curr).Subscribe(delegate(int lvl)
        {
            NextJackpotLevel.SetValueAndForceNotify(Singleton <EconomyHelpers> .Instance.GetNextGamblingJackpotLevel(lvl));
        }).AddTo(root);
        CurrentGamblingLevel.Subscribe(delegate
        {
            root.StartCoroutine(CardSpawnAnimations());
        }).AddTo(root);
        IsJackpotLevel = (from isJP in CurrentGamblingLevel.CombineLatest(NextJackpotLevel, (int lvl, int jp) => lvl == jp)
                          select(isJP)).TakeUntilDestroy(root).ToReadOnlyReactiveProperty();
        m_initialOpening = bind.StartCoroutine(OpenInitialCards());
    }
Esempio n. 4
0
        public ReactionEvent(DiscordSocketClient client, ICurrencyService cs,
                             SocketGuild g, ITextChannel ch, EventOptions opt, GamblingConfig config,
                             Func <CurrencyEvent.Type, EventOptions, long, EmbedBuilder> embedFunc)
        {
            _client                 = client;
            _guild                  = g;
            _cs                     = cs;
            _amount                 = opt.Amount;
            PotSize                 = opt.PotSize;
            _embedFunc              = embedFunc;
            _isPotLimited           = PotSize > 0;
            _channel                = ch;
            _noRecentlyJoinedServer = false;
            _opts                   = opt;
            _config                 = config;

            _t = new Timer(OnTimerTick, null, Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(2));
            if (_opts.Hours > 0)
            {
                _timeout = new Timer(EventTimeout, null, TimeSpan.FromHours(_opts.Hours), Timeout.InfiniteTimeSpan);
            }
        }