コード例 #1
0
        public void RollOne([Values(0.1f, 0.35f, 0.5f, 0.6f, 0.8f, 1f)] float chance)
        {
            var dependentRandom = DependentRandom.Create();
            var systemRandom    = new SystemRandom(12323542);

            var dependentRandomLongestRow = 0;
            var systemRandomLongestRow    = 0;

            var iterationCount = 1000000;

            var key = "someEventKey" + chance;

            var dependentInfo = new RollInfo();
            var systemInfo    = new RollInfo();

            for (var i = 0; i < iterationCount; i++)
            {
                dependentInfo.Update(dependentRandom.Roll(key, chance));
                systemInfo.Update(systemRandom.GetValue() < chance);
            }

            Assert.AreEqual(chance, dependentInfo.GetChance(), Delta);
            Assert.AreEqual(chance, systemInfo.GetChance(), Delta);

            Console.WriteLine(string.Format("Dependent random chance = {0}, max row = {1}", dependentInfo.GetChance(), dependentInfo.MaxRow));
            Console.WriteLine(string.Format("System random chance = {0}, max row = {1}", systemInfo.GetChance(), systemInfo.MaxRow));
        }
コード例 #2
0
        private static void ChangeRollInfoToLog(RollInfo r, bool?isChange)
        {
            if (r.IsNull())
            {
                Log.Warn("Лента билетов не определена!");
                return;
            }

            var    sb = new StringBuilder();
            string firstPart;

            if (isChange.HasValue)
            {
                firstPart = isChange.Value ? "Произошла смена ленты билетов" : "Текущая лента билетов";
            }
            else
            {
                firstPart = "Информация о ленте билетов на момент закрытия смены";
            }

            sb.AppendLine(firstPart);
            sb.AppendLine("{0} {1} {2}".F(r.Series, r.NextTicket, r.Color.Color));
            sb.AppendFormat("Состояние: {0}; Осталось билетов: {1};", ApplicationStaticHelper.IsCurrentRollDeactivated ? "Деактивирована" : "Активирована", r.TicketsLeft);
            Log.Debug(sb);
        }
コード例 #3
0
    /// <summary>
    /// Returns a RollItem representing a random item.
    /// </summary>
    /// <returns></returns>
    public static RollInfo RollItem(int gamePower)
    {
        RollInfo roll = new RollInfo(RollInitiative(gamePower));

        roll.rarity   = ChooseRarity();
        roll.prefabID = Random.Range(0, PrefabHolder.staticItemArray.Length);
        return(roll);
    }
コード例 #4
0
    /// <summary>
    /// Instantiates and returns item associated with RollInfo "info"
    /// </summary>
    /// <param name="info"></param>
    /// <param name="position"></param>
    /// <param name="rotation"></param>
    /// <param name="parent"></param>
    /// <returns></returns>
    public static GameObject InstantiateItem(RollInfo info, Vector3 position, Quaternion rotation, Transform parent)
    {
        GameObject prefab = PrefabHolder.staticItemArray[info.prefabID];
        GameObject gen    = GameObject.Instantiate(prefab, position, rotation, parent);

        gen.GetComponent <Item>().RollStats(info);

        return(gen);
    }
コード例 #5
0
ファイル: AmeisenCore.cs プロジェクト: IgorYunusov/wow-bot
        /// <summary>
        /// Read the items name that is currently beeing rolled for
        /// </summary>
        /// <param name="id">item id supplied by the roll event</param>
        /// <returns>RollInfo containing name, count and quality</returns>
        public static RollInfo ReadRollItemName(string id)
        {
            RollInfo info = new RollInfo();
            string   cmd  = $"rollInfo = \"none|0|0\"; _, abItemName, abItemCount, abItemQuality = GetLootRollItemInfo({id}); rollInfo = abItemName..\"|\"..abItemCount..\"|\"..abItemQuality;";
            string   str  = GetLocalizedText(cmd, "rollInfo");

            info.name    = str.Split('|')[0];
            info.count   = Utils.TryParseInt(str.Split('|')[1]);
            info.quality = Utils.TryParseInt(str.Split('|')[2]);

            AmeisenLogger.Instance.Log(LogLevel.DEBUG, $"[RollInfo] Name: {info.name}, Count: {info.count}, Quality: {info.quality}", "AmeisenCore");
            return(info);
        }
コード例 #6
0
    public override void RollStats(RollInfo info)
    {
        base.RollStats(info);

        info.name = info.rarity + " Heat Lance";
        name      = info.name;

        // this has been moved to item.cs
        //Rarity = info.rarity;
        //StartRolling(info);
        //PowerLevel = Mathf.RoundToInt(Roll());

        PowerConsumption = MinPowerConsumption + Mathf.Abs(Roll()) * (MaxPowerConsumption - MinPowerConsumption);

        TickRate = 1 + (int)(10 * Mathf.Abs(Roll()));

        Stats.SetDamage(DamageTypes.Heat, PowerLevel * 10 * Mathf.Abs(Roll()));
        Stats.CritChance = Mathf.Abs(Roll()) / 2;
        Stats.CritDamage = 1 + Mathf.Abs(Roll());
    }
コード例 #7
0
    public override void RollStats(RollInfo info)
    {
        base.RollStats(info);

        info.name = info.rarity + " Missile Launcher";
        name      = info.name;

        // this has been moved to item.cs
        //Rarity = info.rarity;
        //StartRolling(info);
        //PowerLevel = Mathf.RoundToInt(Roll());

        RateOfFire = FireRateMin + Mathf.Abs(Roll()) * (FireRateMax - FireRateMin);
        Ammunition = (int)(AmmoMin + Mathf.Abs(Roll()) * (AmmoMax - AmmoMin));
        ReloadTime = ReloadMin + Mathf.Abs(Roll()) * (ReloadMax - ReloadMin);
        Accuracy   = Mathf.Abs(Roll());

        Stats.SetDamage(DamageTypes.Standard, PowerLevel + (PowerLevel / 4) * Roll());
        Stats.CritChance = Mathf.Abs(Roll()) / 2;
        Stats.CritDamage = 1;
    }
コード例 #8
0
ファイル: Repeater.cs プロジェクト: colo6299/SpaceTest
    public override void RollStats(RollInfo info)
    {
        base.RollStats(info);

        info.name = info.rarity + " Repeater";
        name      = info.name;

        // this has been moved to Item.cs
        //Rarity = info.rarity;
        //StartRolling(info);
        //PowerLevel = Mathf.RoundToInt(Roll() * RarityMultiplyer());

        RateOfFire = FireRateMin + Mathf.Abs(Roll()) * (FireRateMax - FireRateMin);
        Ammunition = 0;
        ReloadTime = 0;
        Accuracy   = Mathf.Abs(Roll());

        Stats.SetDamage(DamageTypes.Standard, PowerLevel + (PowerLevel / 4) * Roll());
        Stats.CritChance = Mathf.Abs(Roll()) / 2;
        Stats.CritDamage = 1;
    }
コード例 #9
0
    private void EndRoll(RollInfo roll)
    {
        roll.ui.text = roll.currentlyWritingTextInfo.text;

        int count = roll.textQueue.Count;

        for (int i = 0; i < count; i++)
        {
            //if(roll.textQueue.Peek() != null)
            //{
            roll.ui.text += roll.textQueue.Dequeue().text;
            //}
        }


        roll.isRunning = false;

        if (roll.callback != null)
        {
            roll.callback();
        }
    }
コード例 #10
0
    public IEnumerator StartRoll(TextInfo text, RollInfo rollInfo, Action callback = null, bool start = true, bool overrideCurrent = false)
    {
        TextInfo    txt        = new TextInfo(text.text, text.rolldelay, text.startdelay);
        IEnumerator enumerator = null;

        print("Roll: Text: " + text.text + " Delay: " + text.startdelay + " Speed: " + text.rolldelay);

        if (!rollings.ContainsKey(rollInfo.ui))
        {
            rollings.Add(rollInfo.ui, rollInfo);
        }
        else
        {
            rollings[rollInfo.ui].textQueue.Enqueue(text);
        }

        if (rollings[rollInfo.ui].isRunning)
        {
            if (overrideCurrent) //if it is running and it should override stop
            {
                rollings[rollInfo.ui].shouldStop = true;
            }
        }
        else
        {
            rollings[rollInfo.ui].shouldStop = false;
            enumerator = Roll(rollings[rollInfo.ui].textQueue.Dequeue(), rollings[rollInfo.ui]);
            rollings[rollInfo.ui].currentEnumerator = enumerator;
            if (start)
            {
                StartCoroutine(enumerator);
            }
        }

        return(enumerator);
    }
コード例 #11
0
    //so the idea: when we get a new textinfo, we check the rolling dictionary to see if we have anything that rolls into that UI already (hence why UI is key). if not, we create a new one. then we add it to the queue of that list.
    //after we've added to the queue we check if that's already running and if not we run it at the top of the queue
    //at the end of the roll function (or in a top func?) we check if there are more things in the queue, and if so, we run those. each can call a callback?



    private IEnumerator Roll(TextInfo text, RollInfo roll)
    {
        bool isColored = false;

        roll.currentlyWritingTextInfo = text;
        roll.isRunning = true;

        if (text.startdelay > 0)
        {
            yield return(new WaitForSeconds(text.startdelay));
        }


        int i = 0;

        while (i < text.text.Length)
        {
            if (roll.shouldStop)
            {
                EndRoll(roll);
                yield break;
            }
            //	if(shouldStopRolling){
            //		Debug.Log("STOP");
            //		return true;
            //	}

            if (text.text[i] == '|')
            {
                string time         = "";
                int    tIdx         = i + 1;
                bool   timeRecorded = false;
                while (!timeRecorded)
                {
                    if (text.text[tIdx] == '|')
                    {
                        timeRecorded = true;
                        tIdx++;
                        break;
                    }
                    time += text.text[tIdx];
                    tIdx++;
                }
                print(time + " " + tIdx);
                float t = float.Parse(time);
                yield return(new WaitForSeconds(t));

                i = i + (tIdx - i);
            }

            if (text.text[i] == '>')
            {
                //default Escape Note: Color text.
                roll.ui.text += "<color=#6f6f6fff>" + "</color>"; //wow that hardcoding :P
                isColored     = true;
                Debug.Log("Set to isColored True");
            }
            else if (isColored)
            {
                roll.ui.text = roll.ui.text.Substring(0, roll.ui.text.Length - 8); //?? deleting the </color> stuff i think?
                if (text.text[i] == '<')
                {
                    isColored = false;
                    Debug.Log("Set to isColored False");
                    roll.ui.text += "</color>";
                }
                else
                {
                    roll.ui.text += text.text[i] + "</color>";
                }
            }
            else
            {
                roll.ui.text += text.text[i];
            }
            if (text.text[i] != ' ')
            {
                Sound.instance.PlaySacred(Sound.SFXIDS.Text, Sound.UNIQUESOURCES.Text, true);
                //Sound.instance.Play(Sound.SFXIDS.Text, true);
            }

            i++;
            yield return(new WaitForSeconds(text.rolldelay));
        }



        if (rollings[roll.ui].textQueue.Count > 0)
        {
            rollings[roll.ui].currentEnumerator = Roll(rollings[roll.ui].textQueue.Dequeue(), roll);
            StartCoroutine(rollings[roll.ui].currentEnumerator);
        }
        else
        {
            roll.isRunning = false;
            if (roll.callback != null)
            {
                roll.callback();
            }
        }
    }
コード例 #12
0
ファイル: BarcodeHelper.cs プロジェクト: Shal1928/cashier
 public static string GetBarcode(long currentNum, RollInfo roll)
 {
     return(GetBarcode(roll.Color.Id, roll.Series.ConvertToASCIICodes(), currentNum, _random.Next(1000, 9999)));
     //[ID ЦВЕТА][СЕРИЯ-НОМЕР][СЛУЧАЙНОЕ ЧИСЛО]
 }
コード例 #13
0
ファイル: Item.cs プロジェクト: colo6299/SpaceTest
 protected void StartRolling(RollInfo _Info)
 {
     RollInfo     = _Info;
     rollArray    = _Info.rollArray;
     rollIterator = -1;
 }
コード例 #14
0
ファイル: Item.cs プロジェクト: colo6299/SpaceTest
 public virtual void RollStats(RollInfo info)
 {
     Rarity = info.rarity;
     StartRolling(info);
     PowerLevel = Mathf.RoundToInt(Roll() * RarityMultiplyer());
 }
コード例 #15
0
        private void OnMainCommand()
        {
            IsShowErrorMessage = false;
            try
            {
                switch (Mode)
                {
                case RollInfoViewModelMode.OpenShift:
                    _rollInfo = BaseAPI.activateTicketRoll(FirstTicketSeries, FirstTicketNumber, RollColor.Default);
                    ApplicationStaticHelper.IsCurrentRollDeactivated = false;
                    _shift = BaseAPI.isShiftOpen() ? BaseAPI.getCurrentShift() : BaseAPI.openShift();
                    break;

                case RollInfoViewModelMode.CloseShift:
                    if (!DeactivateRoll())
                    {
                        return;
                    }
                    if (BaseAPI.isShiftOpen())
                    {
                        BaseAPI.closeShift(BaseAPI.getCurrentShift());
                        ApplicationStaticHelper.ShiftCloseDate = DateTime.Now;
                    }

                    if (BaseAPI.isShiftOpen())
                    {
                        ErrorMessage = "Закрыть смену ({0} {1}) не получилось! Режим {2}.".F(BaseAPI.getCurrentShift().CashierName, BaseAPI.getCurrentShift().OpenDate, Mode);
                        Log.Warn(ErrorMessage);
                        IsShowErrorMessage = true;
                        return;
                    }

                    _rollInfo = null;
                    _shift    = null;
                    break;

                case RollInfoViewModelMode.NeedNewRoll:
                    if (!CloseRoll())
                    {
                        return;
                    }
                    _rollInfo = BaseAPI.activateTicketRoll(FirstTicketSeries, FirstTicketNumber, RollColor.Default);
                    ApplicationStaticHelper.IsCurrentRollDeactivated = false;
                    _shift = BaseAPI.getCurrentShift();
                    break;

                case RollInfoViewModelMode.ChangeRoll:
                    if (!DeactivateRoll())
                    {
                        return;
                    }
                    _rollInfo = BaseAPI.activateTicketRoll(FirstTicketSeries, FirstTicketNumber, RollColor.Default);
                    ApplicationStaticHelper.IsCurrentRollDeactivated = false;
                    _shift = BaseAPI.getCurrentShift();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
            catch (Exception e)
            {
                Log.Debug("{0} Вызвало исключение:", Mode);
                Log.Fatal(e);
                //throw;

                ErrorMessage       = "Произошло исключение: {0}".F(e.Message);
                IsShowErrorMessage = true;
                return;
            }

            if (_rollInfo.IsNull() && Mode != RollInfoViewModelMode.CloseShift /*&& Mode != RollInfoViewModelMode.ChangeRollDeactivate*/)
            {
                ErrorMessage = String.Format("Бабина с параметрами {0} {1} не существует! Режим {2}.", FirstTicketSeries, FirstTicketNumber, Mode);
                Log.Warn(ErrorMessage);
                IsShowErrorMessage = true;
                return;
            }

            if (_shift.IsNull() && Mode != RollInfoViewModelMode.CloseShift)
            {
                ErrorMessage = String.Format("Смена не определена!");
                Log.Warn(ErrorMessage);
                IsShowErrorMessage = true;
                return;
            }

            Close();
            Dispose();
        }
コード例 #16
0
 public void Show(RollInfo currentRollInfo)
 {
     CurrentRollInfo = currentRollInfo;
     Show();
 }
コード例 #17
0
 public RollInfoEventArgs(RollInfo rollInfo, Shift shift)
 {
     RollInfo = rollInfo;
     Shift    = shift;
     IsCancel = false;
 }
コード例 #18
0
 void Awake()
 {
     attackerInfo = new RollInfo();
     defenderInfo = new RollInfo();
     specialInfo  = new RollInfo();
 }