Ejemplo n.º 1
0
        static PlayerTable()
        {
            _table.Add("fc01", new Player()
            {
                Name      = "トゥリープFC会員01番",
                Name_e    = "Trepe Groupie #1",
                Rares     = new[] { CardTable.FindIdByName("Quistis") },
                RareLimit = 30,
                Levels    = new[] { 2, 5 },
            });

            _table.Add("fc02", new Player()
            {
                Name      = "トゥリープFC会員02番",
                Name_e    = "Trepe Groupie #2",
                Rares     = new[] { CardTable.FindIdByName("Quistis") },
                RareLimit = 20,
                Levels    = new[] { 1, 3, 5 },
            });

            _table.Add("fc03", new Player()
            {
                Name      = "トゥリープFC会員03番",
                Name_e    = "Trepe Groupie #3",
                Rares     = new[] { CardTable.FindIdByName("Quistis") },
                RareLimit = 10,
                Levels    = new[] { 1, 2, 4, 5 },
            });

            _table.Add("zellmama", new Player()
            {
                Name      = "ゼルママ",
                Name_e    = "Ma Dincht",
                Rares     = new[] { CardTable.FindIdByName("Zell") },
                RareLimit = 10,
                Levels    = new[] { 1, 2, 4, 5 },
            });

            _table.Add("running_boy1", new Player()
            {
                Name      = "走る少年(DISC 1)",
                Name_e    = "Running Boy (DISC 1)",
                Rares     = new[] { CardTable.FindIdByName("MiniMog") },
                RareLimit = 20,
                Levels    = new[] { 1, 2, 3 },
            });

            _table.Add("watts", new Player()
            {
                Name      = "ワッツ",
                Name_e    = "Watts",
                Rares     = new[] { CardTable.FindIdByName("Angelo") },
                RareLimit = 30,
                Levels    = new[] { 1, 4 },
            });
        }
Ejemplo n.º 2
0
        static Situation OpeningSituation(uint state, Player player, bool noRare = false)
        {
            const int DECK_MAX = 5;

            var rng  = new CardRng(state);
            var deck = new List <int>();

            if (!noRare)
            {
                foreach (var rareId in player.Rares)
                {
                    var limit = deck.Count == 0 ? player.RareLimit : player.RareLimit / 2;

                    if (rng.Next() % 100 < limit)
                    {
                        deck.Add(rareId);
                    }

                    if (deck.Count >= DECK_MAX)
                    {
                        break;
                    }
                }
            }

            var pupuId = CardTable.FindIdByName("PuPu");

            while (deck.Count < DECK_MAX)
            {
                var lv     = player.Levels[rng.Next() % player.Levels.Length];
                var row    = rng.Next() % 11;
                var cardId = (lv - 1) * 11 + (int)row;

                if (cardId == pupuId || deck.Contains(cardId))
                {
                    continue;
                }

                deck.Add(cardId);
            }

            var initiative = (rng.Next() & 1) != 0;

            return(new Situation()
            {
                Deck = deck,
                Initiative = initiative,
                FirstState = state,
                LastState = rng.State,
            });
        }
Ejemplo n.º 3
0
        static string PatternToString(Pattern pattern)
        {
            var deckNames = pattern.Deck.Select(ids =>
            {
                var names = ids.Select(id =>
                {
                    var s = CardTable.FindNameById(id);

                    if (_options.HighlightCards.Contains(id))
                    {
                        s = $"*{s}*";
                    }

                    if (_options.StrongHighlightCards.Contains(id))
                    {
                        s = $"**{s}**";
                    }

                    return(s);
                });

                var namesS = string.Join("|", names);

                return(ids.Count == 1 ? namesS : $"({namesS})");
            });

            var deckS = string.Join(", ", deckNames);

            string initiativeS;

            if (pattern.Initiative == null)
            {
                initiativeS = Translate.Get("initiative.any");
            }
            else if (pattern.Initiative == true)
            {
                initiativeS = Translate.Get("initiative.player");
            }
            else
            {
                initiativeS = Translate.Get("initiative.cpu");
            }

            return(string.Format(Translate.Get("pattern2str_fmt"), initiativeS, deckS));
        }
Ejemplo n.º 4
0
        static Pattern StringToPattern(string s, Player player, bool fuzzyRanks = false, bool silent = false)
        {
            var rare = player.Rares.Any() ? player.Rares.First() : new int?();

            var cardRegex = new Regex("[0-9a]{4}", RegexOptions.IgnoreCase);
            var ranksArr  = cardRegex.Matches(s).Cast <Match>().Select(x => x.Value).Take(5).ToList();

            if (ranksArr.Count < (rare == null ? 5 : 4))
            {
                Console.WriteLine(string.Format(Translate.Get("str2pattern.UnmatchedInput_fmt"), s));
                return(null);
            }

            var regexInitiative = new Regex("[+-]");
            var initiative      = regexInitiative.Matches(s).Cast <Match>().Select(x => x.Value).Aggregate(new bool?(), (acc, x) => x == "+");

            var customRanksOrder = "urdl".Select(c => _options.RanksOrder.IndexOf(c));
            var urdlArr          = ranksArr.Select(ranks =>
            {
                var ranksNumber = ranks
                                  .Select(c => Convert.ToInt32(c.ToString(), fromBase: 16))
                                  .Select(x => x == 0 ? 10 : x);

                return(customRanksOrder.Select(idx => ranksNumber.ElementAt(idx)).ToArray());
            });

            var idsArr     = urdlArr.Select(urdl => CardTable.ListIdsByUrdl(urdl, fuzzyRanks)).ToList();
            var retryCount = 0;

            while (true)
            {
                if (idsArr.Any(x => x.Count == 0))
                {
                    var emptyNoArr = idsArr.Select((_, idx) => idx + 1).Where(no => idsArr[no - 1].Count == 0);
                    var emptyNoS   = string.Join(", ", emptyNoArr.Select(no => string.Format("#{0}:{1}", no, ranksArr[no - 1])));
                    var errorMsg   = string.Format(Translate.Get("str2pattern.EmptyIDs_fmt"), emptyNoS);

                    retryCount++;

                    if (fuzzyRanks || retryCount > 1)
                    {
                        Console.WriteLine(errorMsg);
                        return(null);
                    }

                    if (!silent)
                    {
                        Console.WriteLine(errorMsg);
                        Console.WriteLine(Translate.Get("str2pattern.read_as_fuzzy"));
                    }

                    idsArr = urdlArr
                             .Select((urdl, idx) => CardTable.ListIdsByUrdl(urdl, fuzzy: emptyNoArr.Contains(idx + 1)))
                             .ToList();

                    continue;
                }

                break;
            }

            var arrExceptUniq = idsArr.Select(ids =>
            {
                if (!fuzzyRanks)
                {
                    return(idsArr.Count(x => x.SequenceEqual(ids)) > 1 ? ids : null);
                }
                else
                {
                    return(ids.Count == 1 && idsArr.Count(x => x.SequenceEqual(ids)) > 1 ? ids : null);
                }
            }).ToList();

            if (arrExceptUniq.Where(x => x != null).Any())
            {
                var duplicatedNoArr = arrExceptUniq.Select((_, idx) => idx + 1).Where(no => arrExceptUniq[no - 1] != null);
                var duplicatedNoS   = string.Join(", ", duplicatedNoArr.Select(no => string.Format("#{0}:{1}", no, ranksArr[no - 1])));
                var errorMsg        = string.Format(Translate.Get("str2pattern.DuplicatedIDs_fmt"), duplicatedNoS);

                Console.WriteLine(errorMsg);
                return(null);
            }

            if (idsArr.Count == 4)
            {
                idsArr.Insert(0, new List <int>()
                {
                    rare.Value
                });
            }

            return(new Pattern()
            {
                Str = s,
                Deck = idsArr,
                Initiative = initiative
            });
        }