public static void StartCardGame(uint player, string[] args)
        {
            var npc    = OBJECT_SELF;
            var levels = new List <int>();

            foreach (var arg in args)
            {
                if (int.TryParse(arg, out var level))
                {
                    if (level >= 1 && level <= 10)
                    {
                        levels.Add(level);
                    }
                }
            }

            if (levels.Count <= 0)
            {
                Log.Write(LogGroup.Error, $"{GetName(player)} tried to start card game with {GetName(OBJECT_SELF)} but no levels were defined.", true);
                return;
            }

            // Build a random NPC deck out of the levels assigned.
            var firstLevel = levels[0];

            levels.RemoveAt(0);
            var npcDeck = TripleTriad.BuildRandomDeck(firstLevel, levels.ToArray());

            SetLocalInt(npc, "NPC_DECK_CARD_1", (int)npcDeck.Card1);
            SetLocalInt(npc, "NPC_DECK_CARD_2", (int)npcDeck.Card2);
            SetLocalInt(npc, "NPC_DECK_CARD_3", (int)npcDeck.Card3);
            SetLocalInt(npc, "NPC_DECK_CARD_4", (int)npcDeck.Card4);
            SetLocalInt(npc, "NPC_DECK_CARD_5", (int)npcDeck.Card5);

            DelayCommand(0.1f, () =>
            {
                Dialog.StartConversation(player, npc, nameof(TripleTriadVersusDialog));
            });
        }
Esempio n. 2
0
        public static void StartCardGame(uint player, string[] args)
        {
            var npc    = OBJECT_SELF;
            var levels = new List <int>();

            foreach (var arg in args)
            {
                if (int.TryParse(arg, out var level))
                {
                    if (level >= 1 && level <= 10)
                    {
                        levels.Add(level);
                    }
                }
            }

            if (levels.Count <= 0)
            {
                SpeakString("ERROR: Deck levels were not defined! Notify an admin that this conversation is broken.");
                return;
            }

            // Build a random NPC deck out of the levels assigned.
            var firstLevel = levels[0];

            levels.RemoveAt(0);
            var npcDeck = TripleTriad.BuildRandomDeck(firstLevel, levels.ToArray());

            SetLocalInt(npc, "NPC_DECK_CARD_1", (int)npcDeck.Card1);
            SetLocalInt(npc, "NPC_DECK_CARD_2", (int)npcDeck.Card2);
            SetLocalInt(npc, "NPC_DECK_CARD_3", (int)npcDeck.Card3);
            SetLocalInt(npc, "NPC_DECK_CARD_4", (int)npcDeck.Card4);
            SetLocalInt(npc, "NPC_DECK_CARD_5", (int)npcDeck.Card5);

            DelayCommand(0.1f, () =>
            {
                Dialog.StartConversation(player, npc, nameof(TripleTriadVersusDialog));
            });
        }
        public static void SimulateTripleTriad()
        {
            var player1 = GetFirstPC();
            var player2 = GetNextPC();

            // Single player mode
            if (!GetIsObjectValid(player2))
            {
                var player = GetLastUsedBy();
                var deck1  = TripleTriad.BuildRandomDeck(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
                var deck2  = TripleTriad.BuildRandomDeck(10, 9, 8, 7);

                TripleTriad.StartGame(player, deck1, player, deck2);
            }

            // Two player mode
            else
            {
                var deck1 = TripleTriad.BuildRandomDeck(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
                var deck2 = TripleTriad.BuildRandomDeck(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);

                TripleTriad.StartGame(player1, deck1, player2, deck2);
            }
        }