Esempio n. 1
0
        // Handle With NPC
        public UEchoCode HandleWithNPCEffect(Player player, NPC npc, string reason)
        {
            string rstage = Board.RoundIN;
            ushort rd = player.Uid;

            bool[] involved = new bool[Board.Garden.Count + 1];
            string[] pris = new string[Board.Garden.Count + 1];
            Fill(involved, false);
            Fill(pris, "");
            List<SKE> purse = new List<SKE>();
            foreach (string npsk in npc.Skills)
                if (nj01.ContainsKey(npsk))
                {
                    // special kind of nfuse = Code + reason + pureFuse
                    string nfuse = npc.Code + ";" + reason;
                    if (nj01[npsk].Valid(player, nfuse))
                    {
                        SKE skt = new SKE(new SkTriple()
                        {
                            Name = npsk,
                            Priorty = 0,
                            Owner = 0,
                            InType = 0,
                            Type = SKTType.NJ,
                            Consume = 0,
                            Lock = false,
                            IsOnce = false,
                        })
                        { Tg = player.Uid, Fuse = nfuse };
                        purse.Add(skt);
                        string ip = nj01[npsk].Input(player, nfuse, "");
                        if (ip != "") ip = "," + ip;
                        pris[rd] += ";" + npsk + ip;
                    }
                }
            UEchoCode r5ed = UEchoCode.END_CANCEL;
            if (pris[rd] != "")
            {
                pris[rd] = pris[rd].Substring(1);
                involved[rd] = true;
                if (reason == "R" + Board.Rounder.Uid + "NP")
                    RaiseGMessage("G1SG,0");
                SendOutU1Message(involved, pris, 0, null);
                while (r5ed != UEchoCode.END_ACTION && r5ed != UEchoCode.END_TERMIN && involved[rd])
                {
                    Base.VW.Msgs msg = WI.RecvInfRecv();
                    r5ed = HandleUMessage(msg.Msg, purse, msg.From, involved, 0);
                    if (r5ed == UEchoCode.RE_REQUEST)
                        ResendU1Message(msg.From, involved, pris, false, 0);
                    else if (r5ed == UEchoCode.END_CANCEL && Board.MonPiles.Count <= 0
                            && msg.From == player.Uid)
                        ResendU1Message(player.Uid, involved, pris, true, 0);
                    // critical, must take action.
                }
            }
            else
                r5ed = UEchoCode.NO_OPTIONS; // cannot take any action, seem as skip
            return r5ed;
        }
Esempio n. 2
0
        private UEchoCode HandleU24Message(ushort from, bool[] involved, string mai, SKE ske)
        {
            var garden = Board.Garden;
            UEchoCode u5ed = UEchoCode.END_CANCEL; int idx = mai.IndexOf(',');
            MatchedPopFromLastUV(from, "U24");
            var skName = ske != null ? ske.Name : null;
            if (ske != null && sk01.ContainsKey(skName))
            {
                Skill skill = sk01[skName];
                string args = (idx < 0) ? "" : mai.Substring(idx + 1);
                // judge whether args is complete
                string lf = (skill.IsLinked(ske.InType) ? ske.LinkFrom + ":" : "") + ske.Fuse;
                string otherPara = skill.Input(garden[from], ske.InType, lf, args);
                if (otherPara == "")
                {
                    // OK, done.
                    string enc = skill.Encrypt(args);
                    string sTop = "U5," + from + ";;" + skName;
                    string sType = ";;" + ske.InType;

                    string mMsg = sTop + (args != "" ? "," + args : "") + sType;
                    string mEnc = sTop + (enc != "" ? "," + enc : "") + sType;

                    WI.Send(mMsg, 0, from);
                    WI.Send(mEnc, ExceptStaff(from));
                    WI.Live(mEnc + sType);
                    skill.Action(garden[from], ske.InType, lf, args);
                    ++ske.Tick;
                    u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                }
                else // need further support
                {
                    string mU3 = "U3," + AcquireUVSN() + ";;" + otherPara + ";;" + mai + ";;" + ske.InType;
                    PushIntoLastUV(from, mU3);
                    WI.Send(mU3, 0, from);
                    u5ed = UEchoCode.NEXT_STEP;
                }
            }
            else if (ske != null && tx01.ContainsKey(skName))
            {
                Base.Card.Tux tux = tx01[skName];
                int jdx = mai.IndexOf(',', idx + 1);
                ushort ccode = ushort.Parse(Algo.Substring(mai, idx + 1, jdx));
                string args = mai.Substring(idx + 1);
                //if (!tux.IsEq[ske.InType])
                if (!tux.IsTuxEqiup())
                {
                    string otherPara = tux.Input(garden[from], ske.InType, ske.Fuse, args);
                    if (otherPara == "")
                    {
                        // OK, done.
                        string cargs = (args == "^") ? "" : "," + args;
                        if (tux.Type == Base.Card.Tux.TuxType.ZP)
                            RaiseGMessage("G0CZ,0," + from);
                        RaiseGMessage("G0CC," + from + ",0," + from + "," + skName +
                            cargs + ";" + ske.InType + "," + ske.Fuse);
                        ++ske.Tick;
                        u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                    }
                    else // need further support
                    {
                        string mU3 = "U3," + AcquireUVSN() + ";;" + otherPara + ";;" + mai + ";;" + ske.InType;
                        PushIntoLastUV(from, mU3);
                        WI.Send(mU3, 0, from);
                        u5ed = UEchoCode.NEXT_STEP;
                    }
                }
                else if (ske.Type == SKTType.TX)
                {
                    WI.BCast("U5," + from + ";;" + skName + "," + args + ";;" + ske.InType);
                    if (tux.IsTuxEqiup())
                    {
                        RaiseGMessage("G1UE," + from + "," + from + "," + ccode);
                        u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                    }
                }
                else
                {
                    Base.Card.TuxEqiup tue = (Base.Card.TuxEqiup)tux;
                    // args include card code now.
                    int consumeCode = ske.Consume;
                    string prev = args.IndexOf(',') < 0 ? args : args.Substring(args.IndexOf(',') + 1);
                    string lf = (tue.IsLinked(consumeCode, ske.InType) ? ske.LinkFrom + ":" : "") + ske.Fuse;
                    string otherPara = tue.ConsumeInput(garden[from], consumeCode, ske.InType, lf, prev);
                    if (otherPara == "")
                    {
                        string enc = tue.Encrypt(args);
                        string sTop = "U5," + from + ";;" + skName;
                        string sType = ";;" + ske.InType + "!" + consumeCode;

                        string mMsg = sTop + "," + args + sType;
                        string mEnc = sTop + (enc != "" ? "," + enc : "") + sType;

                        WI.Send(mMsg, 0, from);
                        WI.Send(mEnc, ExceptStaff(from));
                        WI.Live(mEnc);
                        RaiseGMessage("G0ZC," + from + "," + consumeCode +
                               "," + args + ";" + ske.InType + "," + lf);
                        u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                        ++ske.Tick;
                    }
                    else // need further support
                    {
                        string mU3 = "U3," + AcquireUVSN() + ";;" + otherPara + ";;" +
                            mai + ";;" + ske.InType + "!" + consumeCode;
                        PushIntoLastUV(from, mU3);
                        WI.Send(mU3, 0, from);
                        u5ed = UEchoCode.NEXT_STEP;
                    }
                }
            }
            else if (ske != null && cz01.ContainsKey(skName))
            {
                Operation cz = cz01[skName];
                string args = (idx < 0) ? "" : mai.Substring(idx + 1);
                // judge whether args is complete
                string otherPara = cz.Input(garden[from], ske.Fuse, args);
                if (otherPara == "")
                {
                    // OK, done.
                    //string enc = c.Encrypt(args);
                    string sTop = "U5," + from + ";;" + skName;
                    string sType = ";;" + ske.InType;
                    WI.BCast(sTop + (args != "" ? "," + args : "") + sType);
                    cz.Action(garden[from], ske.Fuse, args);
                    u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                    ++ske.Tick;
                }
                else // need further support
                {
                    string mU3 = "U3," + AcquireUVSN() + ";;" + otherPara + ";;" + mai + ";;" + ske.InType;
                    PushIntoLastUV(from, mU3);
                    WI.Send(mU3, 0, from);
                    u5ed = UEchoCode.NEXT_STEP;
                }
            }
            else if (ske != null && sf01.ContainsKey(skName))
            {
                Rune sf = sf01[skName];
                string args = (idx < 0) ? "" : mai.Substring(idx + 1);
                // judge whether args is complete
                string otherPara = sf.Input(garden[from], ske.Fuse, args);
                if (otherPara == "")
                {
                    string sTop = "U5," + from + ";;" + skName;
                    string sType = ";;" + ske.InType;
                    WI.BCast(sTop + (args != "" ? "," + args : "") + sType);
                    if (ske.Consume == 1)
                        RaiseGMessage("G0OF," + from + "," + LibTuple.RL.GetSingleIndex(sf));
                    sf.Action(garden[from], ske.Fuse, args);
                    u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                    ++ske.Tick;
                }
                else // need further support
                {
                    string mU3 = "U3," + AcquireUVSN() + ";;" + otherPara + ";;" + mai + ";;" + ske.InType;
                    PushIntoLastUV(from, mU3);
                    WI.Send(mU3, 0, from);
                    u5ed = UEchoCode.NEXT_STEP;
                }
            }
            else if (ske != null && nj01.ContainsKey(skName))
            {
                NCAction na = nj01[skName];
                string args = (idx < 0) ? "" : mai.Substring(idx + 1);
                if (ske.Type == SKTType.NJ)
                {
                    // judge whether args is complete
                    string otherPara = na.Input(garden[from], ske.Fuse, args);
                    if (otherPara == "")
                    {
                        // OK, done.
                        //string enc = c.Encrypt(args);
                        string sTop = "U5," + from + ";;" + skName;
                        string sType = ";;" + ske.InType;
                        WI.BCast(sTop + (args != "" ? "," + args : "") + sType);
                        na.Action(garden[from], ske.Fuse, args);
                        u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                        ++ske.Tick;
                    }
                    else // need further support
                    {
                        string mU3 = "U3," + AcquireUVSN() + ";;" + otherPara + ";;" + mai + ";;" + ske.InType;
                        PushIntoLastUV(from, mU3);
                        WI.Send(mU3, 0, from);
                        u5ed = UEchoCode.NEXT_STEP;
                    }
                }
                else if (ske.Type == SKTType.YJ)
                {
                    int jdx = mai.IndexOf(',', idx + 1);
                    ushort mcode = ushort.Parse(Algo.Substring(mai, idx + 1, jdx));
                    args = Algo.Substring(mai, jdx + 1, -1);
                    string otherPara = na.EscueInput(garden[from], mcode, ske.InType, ske.Fuse, args);
                    // args include card code now.
                    if (otherPara == "")
                    {
                        string sTop = "U5," + from + ";;" + skName;
                        string sType = ";;" + ske.InType;
                        WI.BCast(sTop + "," + mcode + (args == "" ? "" : ("," + args)) + sType);
                        na.EscueAction(garden[from], mcode, ske.InType, ske.Fuse, args);
                        u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                        ++ske.Tick;
                    }
                    else // need further support
                    {
                        string mU3 = "U3," + AcquireUVSN() + ";;" + otherPara + ";;" + mai + ";;" + ske.InType;
                        PushIntoLastUV(from, mU3);
                        WI.Send(mU3, 0, from);
                        u5ed = UEchoCode.NEXT_STEP;
                    }
                }
            }
            else if (ske != null && mt01.ContainsKey(skName))
            {
                Base.Card.Monster mt = mt01[skName];
                string args = mai.Substring(idx + 1);
                // args starts with monster card code now.
                int consumeCode = ske.Consume;
                string lf = (mt.IsLinked(consumeCode, ske.InType) ? ske.LinkFrom + ":" : "") + ske.Fuse;
                string otherPara = mt.ConsumeInput(garden[from], consumeCode, ske.InType, lf, args);
                if (otherPara == "")
                {
                    string sTop = "U5," + from + ";;" + skName;
                    string sType = ";;" + ske.InType + "!" + consumeCode;
                    WI.BCast(sTop + "," + args + sType);
                    RaiseGMessage("G0HH," + from + "," + consumeCode +
                           "," + args + ";" + ske.InType + "," + lf);
                    u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                    ++ske.Tick;
                }
                else // need further support
                {
                    string mU3 = "U3," + AcquireUVSN() + ";;" + otherPara + ";;" + mai + ";;" + ske.InType + "!" + consumeCode;
                    PushIntoLastUV(from, mU3);
                    WI.Send(mU3, 0, from);
                    u5ed = UEchoCode.NEXT_STEP;
                }
            }
            else if (ske != null && ev01.ContainsKey(skName))
            {
                Base.Card.Evenement ev = ev01[skName];
                string sTop = "U5," + from + ";;" + skName;
                string sType = ";;" + ske.InType;
                WI.BCast(sTop + sType);
                ev.Pers(Board.Garden[from]);
                u5ed = ske.IsTermini ? UEchoCode.END_TERMIN : UEchoCode.END_ACTION;
                ++ske.Tick;
            }
            else // invalid input, repost U1
                u5ed = UEchoCode.RE_REQUEST;
            return u5ed;
        }