Exemplo n.º 1
0
        ResponseData EventedData(GameScript handle)
        {
            ResponseData result = new ResponseData("event");

            switch (this.TypeOutEvent)
            {
            case TypeOutEventX.ENEMY:
            {
                handle.ListEnemy.Add(outEventData as EnemyComp);
                (outEventData as EnemyComp).Initialize();
                break;
            }

            case TypeOutEventX.MAIL:
            {
                handle.player.ListMail.Add(outEventData as MailX);
                break;
            }

            case TypeOutEventX.WANTED:
            {
                handle.player.Wanted += SByte.Parse(this.outEventData.ToString());
                break;
            }

            case TypeOutEventX.FILE:
            {
                FileX file = outEventData as FileX;
                handle.player.Computer.FileList.Add(file);
                break;
            }
            }
            this.isEvented = true;
            result.Data.Add(true);
            return(result);
        }
Exemplo n.º 2
0
        public void ReadEvent(string path)
        {
            XDocument  xDoc = XDocument.Load(path);
            GameScript game = new GameScript();

            foreach (XElement ev in xDoc.Root.Elements("outs"))
            {
                EventGame Event = new EventGame(TypeInEventX.None, TypeOutEventX.None);
                foreach (XElement file in ev.Element("files").Elements("file"))
                {
                    FileX f = null;
                    switch (file.Attribute("type").Value)
                    {
                    case "TXT": f = new FileTxtX();
                        break;

                    case "SCRIPT": f = new FileScriptX();
                        break;

                    case "EXPLOIT": f = new FileExploitX();
                        break;

                    case "DATA": f = new FileDataX();
                        break;

                    case "SSHKEY": f = new FileSSHKeyX();
                        break;

                    default: f = new FileX();
                        break;
                    }
                    f.id       = file.Attribute("id").Value;
                    f.Capacity = int.Parse(file.Attribute("capacity").Value);
                    f.Name     = file.Attribute("name").Value;
                    f.AddText(file.Value);
                    Ev_File.Add(f);
                }
                foreach (XElement enem in ev.Element("enemies").Elements("enemy"))
                {
                    EnemyComp x_enemy = new EnemyComp();
                    x_enemy.id   = enem.Attribute("id").Value;
                    x_enemy.Addr = enem.Attribute("address").Value;
                    RePoint r = new RePoint();
                    x_enemy.Position  = r.Point(float.Parse(enem.Element("position").Attribute("x").Value), float.Parse(enem.Element("position").Attribute("y").Value));
                    x_enemy.isScaning = bool.Parse(enem.Element("isscan").Value);
                    x_enemy.isVisible = bool.Parse(enem.Element("isvisible").Value);
                    x_enemy.Money     = int.Parse(enem.Element("money").Value);
                    foreach (XElement sx in enem.Element("services").Elements("service"))
                    {
                        ServiceX service = new ServiceX(int.Parse(sx.Element("timestart").Value), int.Parse(sx.Element("port").Value));
                        service.id   = sx.Attribute("id").Value;
                        service.Desc = sx.Element("name").Value;
                        switch (sx.Element("type").Value)
                        {
                        case "NONE": service.Type = TypeServiceX.NONE;
                            break;

                        case "FTP": service.Type = TypeServiceX.FTP;
                            break;

                        case "FIREWALL": service.Type = TypeServiceX.FIREWALL;
                            break;

                        case "ATM": service.Type = TypeServiceX.ATM;
                            break;

                        case "PROXY": service.Type = TypeServiceX.PROXY;
                            break;

                        case "SSH": service.Type = TypeServiceX.SSH;
                            break;

                        default: service.Type = TypeServiceX.NONE;
                            break;
                        }
                        service.Pass       = sx.Element("pass").Value;
                        service.isHackPass = bool.Parse(sx.Element("ishackpass").Value);
                        foreach (XElement fx in sx.Element("files").Elements("file"))
                        {
                            FileX file = null;
                            switch (fx.Attribute("type").Value)
                            {
                            case "TXT": file = new FileTxtX();
                                break;

                            case "SCRIPT": file = new FileScriptX();
                                break;

                            case "EXPLOIT": file = new FileExploitX();
                                break;

                            case "DATA": file = new FileDataX();
                                break;

                            case "SSHKEY": file = new FileSSHKeyX();
                                break;

                            default: file = new FileX();
                                break;
                            }
                            file.id       = fx.Attribute("id").Value;
                            file.Capacity = int.Parse(fx.Attribute("capacity").Value);
                            file.Name     = fx.Attribute("name").Value;
                            file.AddText(fx.Value);
                            service.AddFile(file);
                        }
                        x_enemy.AddService(service);
                    }
                    Ev_Enemy.Add(x_enemy);
                }
                foreach (XElement m in ev.Element("mails").Elements("mail"))
                {
                    MailX mail = new MailX(m.Attribute("name").Value);
                    mail.ids = m.Attribute("id").Value;
                    mail.AddText(m.Value);
                    Ev_Mail.Add(mail);
                }
                foreach (XElement w in ev.Element("wanteds").Elements("wanted"))
                {
                    Ev_Wanted.Add(new E_Wanted(w.Attribute("id").Value, int.Parse(w.Value)));
                }
                foreach (XElement even in xDoc.Root.Element("ev").Elements("event"))
                {
                    TypeInEventX t_in    = TypeInEventX.None;
                    object       obj_inn = null;
                    switch (even.Element("in").Attribute("type").Value)
                    {
                    case "E_Scan":
                    {
                        t_in    = TypeInEventX.E_Scan;
                        obj_inn = FindEnemyId(even.Element("in").Element("enemy").Value);
                        break;
                    }

                    case "E_Crack":
                    {
                        t_in    = TypeInEventX.E_Crack;
                        obj_inn = FindEnemyId(even.Element("in").Element("enemy").Value);
                        break;
                    }

                    case "Time":
                    {
                        t_in    = TypeInEventX.Time;
                        obj_inn = int.Parse(even.Element("in").Element("time").Value);
                        break;
                    }

                    case "File":
                    {
                        t_in    = TypeInEventX.File;
                        obj_inn = FindFileId(even.Element("in").Element("file").Value);
                        break;
                    }

                    case "Wanted":
                    {
                        t_in    = TypeInEventX.Wanted;
                        obj_inn = int.Parse(even.Element("in").Element("wanted").Value);
                        break;
                    }

                    case "Connected":
                    {
                        t_in    = TypeInEventX.Connected;
                        obj_inn = FindEnemyId(even.Element("in").Element("enemy").Value);
                        break;
                    }

                    case "Service_off":
                    {
                        t_in    = TypeInEventX.Service_off;
                        obj_inn = FindServiceId(even.Element("in").Element("service").Value);
                        break;
                    }

                    default: t_in = TypeInEventX.None;
                        break;
                    }
                    object        obj_out = null;
                    TypeOutEventX t_out   = TypeOutEventX.None;
                    obj_out = FindEventOut(even.Element("out").Attribute("id").Value, out t_out);
                    X_Event.Add(game.AddEvent(t_in, t_out, obj_inn, obj_out));
                }
            }
        }
Exemplo n.º 3
0
        public override ResponseData CheckedEvent(GameScript handle)
        {
            ResponseData result = new ResponseData("event");

            if (!isEvented)
            {
                try
                {
                    switch (this.TypeInEvent)
                    {
                    case TypeInEventX.E_Crack:
                    {
                        EnemyComp e = inEventData as EnemyComp;
                        IEnumerable <EnemyComp> query = from ec in handle.ListEnemy
                                                        where ec.Addr == e.Addr
                                                        where ec.IsAllHack == true && ec.IsOffFirewall == true
                                                        select ec;
                        if (query.Count() > 0)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.E_Scan:
                    {
                        EnemyComp e = inEventData as EnemyComp;
                        IEnumerable <EnemyComp> query = from ec in handle.ListEnemy
                                                        where ec.Addr == e.Addr
                                                        where ec.isScaning == true
                                                        select ec;
                        if (query.Count() > 0)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.File:
                    {
                        FileX file = inEventData as FileX;
                        IEnumerable <FileX> query = from f in handle.player.Computer.FileList
                                                    where f.Name == file.Name
                                                    select f;
                        if (query.Count() > 0)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.Time:
                    {
                        if (isOk)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.Wanted:
                    {
                        int wanted = int.Parse(inEventData.ToString());
                        if (handle.player.Wanted >= wanted)
                        {
                            result = EventedData(handle);
                        }
                        break;
                    }

                    case TypeInEventX.Connected:
                    {
                        EnemyComp eComp = inEventData as EnemyComp;
                        if (eComp.isScaning)
                        {
                            if (handle.player.isConnected)
                            {
                                if ((handle.player.ConnectedEnemy.IsOffFirewall) && (handle.player.ConnectedEnemy.IsAllHack))
                                {
                                    if (handle.player.ConnectedEnemy.Addr == eComp.Addr)
                                    {
                                        result = EventedData(handle);
                                    }
                                }
                            }
                        }
                        break;
                    }

                    case TypeInEventX.Service_off:
                    {
                        ServiceX serv    = inEventData as ServiceX;
                        var      servOff = from ec in handle.ListEnemy
                                           where ec.Addr == serv.Parrent.Addr
                                           select ec into enC
                                           from ser in enC.Services
                                           where ser.Port == serv.Port
                                           select ser;
                        if (servOff.Count() > 0)
                        {
                            ServiceX s = servOff.ElementAt <ServiceX>(0);
                            if (s.isRun == false)
                            {
                                result = EventedData(handle);
                            }
                        }


                        break;
                    }
                    }
                }
                catch (Exception ex) { LOG.Error("Error event to: " + ex.Message); }
            }

            return(result);
        }
Exemplo n.º 4
0
 public virtual ResponseData CheckedEvent(GameScript handle)
 {
     return(new ResponseData("event"));
 }
Exemplo n.º 5
0
        public void CheckedComplete(GameScript handle)
        {
            switch (TypeQ)
            {
            case TypeQuest.Wanteding:
            {
                if (handle.player.Wanted <= LevelWanted)
                {
                    this.Complete = true;
                }
                else
                {
                    this.Complete = false;
                }
                break;
            }

            case TypeQuest.Scaning:
            {
                if (!Complete)
                {
                    foreach (EnemyComp eC in handle.ListEnemy)
                    {
                        if (eC.Addr == Computer.Addr)
                        {
                            if (eC.isScaning)
                            {
                                this.Complete = true;
                            }
                        }
                    }
                }
                break;
            }

            case TypeQuest.File:
            {
                if (!Complete)
                {
                    foreach (FileX f in handle.player.Computer.FileList)
                    {
                        if (f.Name == File.Name)
                        {
                            this.Complete = true;
                        }
                    }
                }
                break;
            }

            case TypeQuest.Money:
            {
                if (handle.player.Money >= Money)
                {
                    this.Complete = true;
                }
                else
                {
                    Complete = false;
                }
                break;
            }

            case TypeQuest.FileUpload:
            {
                if (!Complete)
                {
                    foreach (EnemyComp enC in handle.ListEnemy)
                    {
                        if (enC.Addr == Computer.Addr)
                        {
                            foreach (var servX  in enC.Services)
                            {
                                foreach (var file in servX.ListFile)
                                {
                                    if (File.Name == file.Name)
                                    {
                                        this.Complete = true;
                                        break;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                break;
            }
            }
        }