Example #1
0
 public override int AddItem(RollDice item)
 {
     item.TargetValue = 0;
     this.Items.Add(item);
     item.PropertyChanged += this.OnItemChanged;
     return(this.Items.Count - 1);
 }
Example #2
0
 public static string Format(this RollDice target, string format)
 {
     return(string.Format(format, target.DiceNumber
                          , target.DiceBase
                          , target.DiceConst
                          , target.Inequality
                          , target.TargetValue
                          , target.RollGroup
                          , target.RollName));
 }
Example #3
0
 public bool Copy(RollDice copy)
 {
     this.UsingSystem = copy.UsingSystem;
     this.RollGroup   = copy.RollGroup;
     this.RollName    = copy.RollName;
     this.DiceNumber  = copy.DiceNumber;
     this.DiceBase    = copy.DiceBase;
     this.DiceConst   = copy.DiceConst;
     this.Inequality  = copy.Inequality;
     this.TargetValue = copy.TargetValue;
     return(true);
 }
Example #4
0
        public static RollDice MakeNormalRollDice(this TrpgSystem system)
        {
            var result = new RollDice(system);

            switch (system)
            {
            case TrpgSystem.DiceBot:
            default:
                break;

            case TrpgSystem.Arianrhod:
            {
                result.DiceNumber = 2;
                result.DiceBase   = 6;
                result.Inequality = ">=";
                break;
            }

            case TrpgSystem.Cthulhu:
            {
                result.DiceNumber = 1;
                result.DiceBase   = 100;
                result.Inequality = "<=";
                break;
            }

            case TrpgSystem.DoubleCross:
            {
                result.DiceNumber = 1;
                result.DiceBase   = 10;
                result.Inequality = ">=";
                break;
            }

            case TrpgSystem.Insane:
            {
                result.DiceNumber = 2;
                result.DiceBase   = 6;
                result.Inequality = ">=";
                break;
            }
            }

            return(result);
        }
Example #5
0
        //入力されたスキルから各種確率を計算
        public void Calc(RollDice target)
        {
            if (DiceProbabilityTable == null)
            {
                ReadProbability();
            }

            this.TargetRoll = target;

            var DiceNumber = target.DiceNumber.InRange(0, 10);

            var NormalFailRollProbabilitiy = this.CalcFailProbability(target.DiceNumber);

            this.RollProbability        = 1.0d - NormalFailRollProbabilitiy;
            this.AddDiceRollProbability = 1.0d - this.CalcFailProbability(target.DiceNumber + 1);
            this.ReRollProbability      = 1.0d - NormalFailRollProbabilitiy * NormalFailRollProbabilitiy;
            this.CriticalProbability    = CriticalTable[DiceNumber];
            this.Average = 3.5d * target.DiceNumber + target.DiceConst;
        }
Example #6
0
        private static CoCPC ParsePC(string url, HtmlDocument html)
        {
            var result = new CoCPC
            {
                SheetUrl = url,
            };

            result.DodontoFPCData.UsingSystem = TrpgSystem.Cthulhu;

            var ArtsTitles = new Dictionary <string, string>()
            {
                { "Table_battle_arts", "戦闘" },
                { "Table_find_arts", "探索" },
                { "Table_act_arts", "行動" },
                { "Table_commu_arts", "交渉" },
                { "Table_know_arts", "知識" },
                { "Table_arms", "武具" },
                { "Table_item", "所持" }
            };

            var tables = html.DocumentNode.SelectNodes("//table");

            result.DodontoFPCData.Resources.Items.Clear();

            var cnt = 0;

            foreach (var table in tables)
            {
                switch (cnt++)
                {
                case 0:     //生まれ・能力値
                {
                    ////$Characteristics = @("STR","CON","POW","DEX","APP","SIZ","INT","EDU","HP","MP","初期SAN","アイデア","幸運","知識")
                    ////                        0     1     2     3     4     5     6     7    8    9        10         11     12     13

                    var charaTitlesRaw = table.SelectNodes("tbody/tr/th");
                    var charaValuesRaw = table.SelectNodes(@"tbody/tr/td[@class=""sumTD""]/input");
                    if (charaTitlesRaw == null || charaValuesRaw == null)
                    {
                        break;
                    }

                    var charaTitles = charaTitlesRaw.Select(i => i.InnerText).ToList();
                    var charaValues = charaValuesRaw.Select(i => i.Attributes["value"].Value).ToList <string>();
                    charaTitles.RemoveAt(0);

                    //"STR","CON","POW","DEX","APP","SIZ","INT","EDU"
                    foreach (int i in Enumerable.Range(0, 8))
                    {
                        int.TryParse(charaValues[i], out int sv);
                        result.CharacterValues.AddItem(new BindableValue <int>(sv));
                    }

                    //"HP","MP"
                    foreach (int i in Enumerable.Range(8, 2))
                    {
                        int.TryParse(charaValues[i], out int sv);
                        result.DodontoFPCData.Resources.AddItem(new BindableValue <int>(sv));        //HP,/HP
                        result.DodontoFPCData.Resources.AddItem(new BindableValue <int>(sv));        //MP,/MP
                    }
                    //"アイデア","幸運","知識" → ダイスロールに登録
                    foreach (int i in Enumerable.Range(11, 3))
                    {
                        int.TryParse(charaValues[i], out int sv);
                        var diceRoll = new RollDice(TrpgSystem.Cthulhu)
                        {
                            RollGroup   = "能力",
                            RollName    = charaTitles[i],
                            DiceNumber  = 1,
                            DiceBase    = 100,
                            DiceConst   = 0,
                            Inequality  = "<=",
                            TargetValue = sv
                        };
                        result.RollDices.AddItem(diceRoll);
                    }
                    //イニシアティブをDEXから取得
                    result.DodontoFPCData.Initiative = result.CharacterValues[3].Value;

                    break;
                }

                case 1:     //SAN
                {
                    var cv = table.SelectNodes("tr/td/input").Select(i => i.Attributes["value"].Value).ToList <string>();
                    int.TryParse(cv[0], out int cvsan);
                    result.DodontoFPCData.Resources.AddItem(new BindableValue <int>(cvsan));
                    //var currentSan = cv[0];
                    //var MaxSan     = cv[1];
                    //var FuteiSan   = cv[2];

                    break;
                }

                case 2:     //技能ポイント

                    //未使用
                    break;


                case 3:     //戦闘技能
                case 4:     //探索技能
                case 5:     //行動技能
                case 6:     //交渉技能
                case 7:     //知識技能
                {
                    var ArtsTitle = ArtsTitles[table.Id];

                    //技能名、input対応用に別関数
                    var AbilityNames = table.SelectNodes("tr/th").Select(i => getAbilityName(i)).ToList <string>();
                    var Abcnt        = AbilityNames.Count() - 1;
                    AbilityNames = AbilityNames.Where((name, index) => Enumerable.Range(8, Abcnt).Contains(index)).ToList();

                    //技能値
                    var AbilityValues = table.SelectNodes(@"tr/td[@class=""sumTD""]/input").Select(i => i.Attributes["value"].Value).ToList <string>();

                    //RollDice作成
                    Abcnt = AbilityValues.Count();

                    foreach (int i in Enumerable.Range(0, Abcnt))
                    {
                        int.TryParse(AbilityValues[i], out int sv);

                        var diceRoll = new RollDice(TrpgSystem.Cthulhu)
                        {
                            RollGroup   = ArtsTitle,
                            RollName    = AbilityNames[i],
                            DiceNumber  = 1,
                            DiceBase    = 100,
                            DiceConst   = 0,
                            Inequality  = "<=",
                            TargetValue = sv
                        };
                        result.RollDices.AddItem(diceRoll);
                    }

                    break;
                }

                case 8:     //戦闘・武器・防具

                    //未使用
                    break;


                case 9:     //所持品・所持金

                    //未使用
                    break;


                case 10:     //パーソナルデータ
                {
                    //名前のみ使用。将来的に他のデータも保持する。
                    var FieldNames  = table.SelectNodes("tbody/tr/th").Select(i => i.InnerText.Trim()).ToList <string>();
                    var FieldValues = table.SelectNodes("tbody/tr/td/input").Select(i => i.Attributes["value"].Value).ToList <string>();
                    result.Name = string.IsNullOrEmpty(FieldValues[0]) ? "名無し(パーソナルデータ-キャラクター名に名前を入力!)" : FieldValues[0];
                    break;
                }

                case 11:     //クトゥルフ神話TRPG

                    //未使用
                    break;
                }
            }

            return(result);

            string getAbilityName(HtmlNode node)
            {
                //技能名(〇〇)の")"を消す
                var preName = node.InnerText.Replace(")", "");

                //入力欄がある場合は抽出する。古いキャラシーにはなぜかvalueが設定されていないものもあるため、エラー時は入力ないものと判断。
                HtmlNode inputNode;
                var      inputName = "";

                try
                {
                    inputNode = node.SelectSingleNode("input");
                    inputName = inputNode == null ? "" : inputNode.Attributes["value"].Value.Trim();
                }
                catch
                {
                    inputName = "";
                }

                //技能名(〇〇)の場合は")"で閉じるが、〇〇未記入の場合は"("を消す。
                if (!string.IsNullOrEmpty(preName) && !string.IsNullOrEmpty(inputName))
                {
                    inputName += ")";
                }
                if (string.IsNullOrEmpty(inputName))
                {
                    preName = preName.Replace("(", "");
                }

                //もともとに入っている括弧が全角でダサいので直す
                preName = preName.Replace("(", "(").Replace(")", ")");
                return(preName + inputName);
            }
        }
Example #7
0
        private static ArPC ParsePC(string url, HtmlDocument html)
        {
            var result = new ArPC
            {
                SheetUrl = url
            };

            result.DodontoFPCData.UsingSystem = TrpgSystem.Arianrhod;


            var tables = html.DocumentNode.SelectNodes("//table");

            result.DodontoFPCData.Resources.Items.Clear();

            var cnt = 0;

            foreach (var table in tables)
            {
                var fate = "";
                switch (cnt++)
                {
                case 0:     //能力値・HP・MP
                {
                    var charaTitles = table.SelectNodes("tbody/tr/th").Select(i => i.InnerText).ToList();
                    var charaValues = table.SelectNodes(@"tbody/tr/td[@class=""sumTD""]/input").Select(i => i.Attributes["value"].Value).ToList();
                    fate = table.SelectNodes(@"tbody/tr/th/input[@id=""V_fate""]")[0].Attributes["value"].Value;         //Levelはfateをレベルに

                    //Titlesは1から、Valuesは9から9個(能力値)
                    //*[@id="SL_level"]
                    var titles = new List <string>()
                    {
                        "筋力", "器用", "敏捷", "知力", "感知", "精神", "幸運"
                    };

                    foreach (int i in Enumerable.Range(9, 7))
                    {
                        int.TryParse(charaValues[i], out int sv);

                        result.CharacterValues.AddItem(new BindableValue <int>(sv));

                        var rolldice = new RollDice(TrpgSystem.Arianrhod)
                        {
                            RollGroup   = "能力",
                            RollName    = titles[i - 9],
                            DiceNumber  = 2,
                            DiceBase    = 6,
                            DiceConst   = sv,
                            Inequality  = ">=",
                            TargetValue = 0
                        };

                        result.RollDices.AddItem(rolldice);
                    }
                    //"HP","MP"
                    foreach (int i in Enumerable.Range(16, 2))
                    {
                        int.TryParse(charaValues[i], out int sv);
                        result.DodontoFPCData.Resources.AddItem(new BindableValue <int>(sv));        //HP,/HP
                        result.DodontoFPCData.Resources.AddItem(new BindableValue <int>(sv));        //MP,/MP
                    }
                    //"Fate"
                    int.TryParse(fate, out int fateint);
                    result.DodontoFPCData.Resources.AddItem(new BindableValue <int>(fateint));

                    break;
                }

                case 1:     //ライフパス
                    //未使用
                    break;

                case 2:     //スキル
                case 3:     //一般スキル
                {
                    var SkillCosts = table.SelectNodes("tbody/tr");

                    foreach (var sCost in SkillCosts)
                    {
                        var sc = sCost.SelectNodes("td")?.Select(i => getSkillName(i)).ToList();

                        if (sc != null)
                        {
                            var nCv = new ObservableCollection <BindableValue <int> >();
                            for (var i = 0; i < 5; i++)
                            {
                                nCv.Add(new BindableValue <int>(0));
                            }

                            int.TryParse(sc[6], out int cost);
                            nCv[(int)ArResource.MP].Value = -cost;

                            //0名前 6コスト 8効果
                            var nsc = new ArCost()
                            {
                                CostGroup = "スキル使用",
                                CostName  = sc[0],
                                Items     = nCv,
                                CostUsage = $"[SL:{sc[1]}/{sc[2]}]{sc[8]}"
                            };

                            (result.DodontoFPCData as ArDodontoFPCData)?.Costs.AddItem(nsc);
                        }
                    }
                }
                break;

                case 4:     //戦闘・武器・防具
                {
                    var artsTitlesRaw = table.SelectNodes("tbody/tr/th").Select(i => i.InnerText.Replace(" ", "").Replace("\r\n", "").Replace("判定", "").Replace("力", "")).ToList <string>();
                    var artsValues    = table.SelectNodes(@"tbody/tr/td[@class=""sumTD""]/input").Select(i => i.Attributes["value"].Value).ToList <string>();
                    var diceValuesRaw = table.SelectNodes(@"tbody/tr/td/input[contains(@id,'dice')]").Select(i => i.Attributes["value"].Value).ToList <string>();

                    //命中、攻撃がそれぞれ2回、回避1回(ごり押し!)
                    var artsTitles = new List <string>()
                    {
                        "命中(右手)", "命中(左手)", "攻撃(右手)", "攻撃(左手)", "回避"
                    };

                    var diceValues = new List <string>()
                    {
                        diceValuesRaw[0], diceValuesRaw[0], diceValuesRaw[1], diceValuesRaw[1], diceValuesRaw[2]
                    };

                    //"命右","命左","攻右","攻左","回避"
                    foreach (int i in Enumerable.Range(9, 5))
                    {
                        int.TryParse(diceValues[i - 9], out int dv);
                        int.TryParse(artsValues[i], out int av);

                        var rolldice = new RollDice(TrpgSystem.Arianrhod)
                        {
                            RollGroup   = "戦闘",
                            RollName    = artsTitles[i - 9],
                            DiceNumber  = dv,
                            DiceBase    = 6,
                            DiceConst   = av,
                            Inequality  = ">=",
                            TargetValue = 0
                        };

                        result.RollDices.AddItem(rolldice);
                    }

                    //"物防","魔防","行動力","移動力"
                    {
                        var target = result.DodontoFPCData as ArDodontoFPCData;
                        target.Costs.DefPointPhysical = int.TryParse(artsValues[14], out var sv14) ? sv14 : 0;
                        target.Costs.DefPointMagical  = int.TryParse(artsValues[15], out var sv15) ? sv15 : 0;
                        target.Initiative             = int.TryParse(artsValues[16], out var sv16) ? sv16 : 0;
                        //var _                       = int.TryParse(artsValues[18], out var sv18) ? sv18 : 0;
                    }

                    break;
                }

                case 5:     //装備(価格・重量など)
                    //未使用
                    break;

                case 6:     //所持品・所持金

                    break;

                case 7:     //特殊な判定
                {
                    var SkillTitles     = table.SelectNodes("tbody/tr/th").Select(i => i.InnerText).ToList <string>();
                    var SkillValues     = table.SelectNodes(@"tbody/tr/td[@class=""sumTD""]/input").Select(i => getSkillValue(i)).ToList <string>();
                    var SkillDiceValues = table.SelectNodes(@"tbody/tr/td/input[contains(@id,'dice')]").Select(i => getSkillValue(i)).ToList <string>();

                    SkillTitles.RemoveAt(0);

                    //"罠探知","罠解除","危険感知","敵識別","魔術","呪歌","錬金術"
                    foreach (int i in Enumerable.Range(0, 8))
                    {
                        int.TryParse(SkillDiceValues[i], out int dv);
                        int.TryParse(SkillValues[i], out int sv);

                        var rolldice = new RollDice(TrpgSystem.Arianrhod)
                        {
                            RollGroup   = "特殊",
                            RollName    = SkillTitles[i],
                            DiceNumber  = dv,
                            DiceBase    = 6,
                            DiceConst   = sv,
                            Inequality  = ">=",
                            TargetValue = 0
                        };

                        result.RollDices.AddItem(rolldice);
                    }

                    var addDr = TrpgSystem.Arianrhod.MakeNormalRollDice();
                    addDr.RollGroup = "その他";

                    var addDrNames = new string[] { "アイテムドロップ", "HPポーション", "MPポーション" };

                    foreach (var ad in addDrNames)
                    {
                        addDr.RollName = ad;
                        result.RollDices.AddItem(new RollDice(addDr));
                    }

                    break;
                }

                case 8:     //レベルアップ記録
                    //未使用
                    break;

                case 9:     //成長履歴
                    //未使用
                    break;

                case 10:     //成長履歴その2
                    //未使用
                    break;

                case 11:     //パーソナルデータ
                {
                    //名前のみ使用。将来的に他のデータも保持する。
                    var FieldNames  = table.SelectNodes("tbody/tr/th").Select(i => i.InnerText.Trim()).ToList <string>();
                    var FieldValues = table.SelectNodes("tbody/tr/td/input").Select(i => i.Attributes["value"].Value).ToList <string>();
                    result.Name = string.IsNullOrEmpty(FieldValues[0]) ? "名無し(パーソナルデータ-キャラクター名に名前を入力!)" : FieldValues[0];
                    break;
                }

                case 12:     //コネクション
                    //未使用
                    break;
                }
            }

            return(result);

            string getSkillValue(HtmlNode node)
            {
                var resSV = "";

                try
                {
                    resSV = node.Attributes["value"].Value;
                }
                catch
                {
                    resSV = "0";
                }
                return(resSV);
            }

            string getSkillName(HtmlNode node)
            {
                var resSN = "";

                try
                {
                    resSN = node.SelectSingleNode("input").Attributes["Value"].Value;
                }
                catch
                {
                    resSN = "";
                }
                return(resSN);
            }
        }
Example #8
0
 public RollDice(RollDice copy)
 {
     this.Copy(copy);
 }
Example #9
0
 public static string Format(this RollDice target, bool isVissibleTargetValue)
 {
     return(target.Format(target.UsingSystem.SendingTextFormat(isVissibleTargetValue)));
 }