Esempio n. 1
0
        public Chars GetChars(string guid, string password, XmlData data)
        {
            using (var db = new Database())
            {
                Account a = db.Verify(guid, password, data);
                if (a != null)
                {
                    if (a.Banned)
                        return null;
                }

                Chars chrs = new Chars
                {
                    Characters = new List<Char>(),
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = a,
                };
                db.GetCharData(chrs.Account, chrs);
                db.LoadCharacters(chrs.Account, chrs);
                chrs.News = db.GetNews(Program.GameData, chrs.Account);
                chrs.OwnedSkins = Utils.GetCommaSepString(chrs.Account.OwnedSkins.ToArray());
                return chrs;
            }
        }
Esempio n. 2
0
        public void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (StreamReader rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            using (var db1 = new Database())
            {

                chrs = new Chars()
                {
                    Characters = new List<Char>() { },
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = db1.Verify(query["guid"], query["password"]),
                    Servers = new List<ServerItem>()
                    {
                        new ServerItem()
                        {
                            Name = "EUSouth",
                            Lat = 22.28,
                            Long = 114.16,
                            DNS = db.confreader.getservers(false).ToString(), //127.0.0.1, CHANGE THIS TO LET YOUR FRIENDS CONNECT
                            Usage = 0.2,
                            AdminOnly = false
                        }
                        //new ServerItem()
                        //{
                        //    Name = "Admin Realm",
                        //    Lat = 22.28,
                        //    Long = 114.16,
                        //    DNS = "127.0.0.1",
                        //    Usage = 0.2,
                        //    AdminOnly = true
                        //}
                    }
                };
                if (chrs.Account != null)
                {
                    db1.GetCharData(chrs.Account, chrs);
                    db1.LoadCharacters(chrs.Account, chrs);
                    chrs.News = db1.GetNews(chrs.Account);
                }
                else
                {
                    chrs.Account = Database.CreateGuestAccount(query["guid"]);
                    chrs.News = db1.GetNews(null);
                }

                MemoryStream ms = new MemoryStream();
                XmlSerializer serializer = new XmlSerializer(chrs.GetType(), new XmlRootAttribute(chrs.GetType().Name) { Namespace = "" });

                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding = Encoding.UTF8;
                XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
            }
        }
        protected override void HandleRequest()
        {
            string status = "<Error>Internal server error</Error>";
            using (Database db = new Database())
            {
                Account acc;
                if (CheckAccount(acc = db.Verify(Query["guid"], Query["password"], Program.GameData), db))
                {
                    if (acc.Rank < 1)
                    {
                        status = "<Error>Only donators can port prod accounts to the private server.</Error>";
                    }
                    else if (acc.IsProdAccount && acc.Rank < 2)
                    {
                        status = "<Error>You account is already transfered.</Error>";
                    }
                    else if (!acc.Banned)
                    {
                        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(String.Format("http://www.realmofthemadgodhrd.appspot.com/char/list?guid={0}&{1}={2}", Query["prodGuid"], Query["prodGuid"].StartsWith("kongregate:") || Query["prodGuid"].StartsWith("steamworks:") ? "secret" : "password", Query["prodPassword"]));
                        var resp = req.GetResponse();

                        Chars chrs = new Chars();
                        chrs.Characters = new List<Char>();

                        string s;
                        using (StreamReader rdr = new StreamReader(resp.GetResponseStream()))
                            s = rdr.ReadToEnd();

                        s = s.Replace("False", "false").Replace("True", "true");

                        try
                        {
                            XmlSerializer serializer = new XmlSerializer(chrs.GetType(),
                                new XmlRootAttribute("Chars") { Namespace = "" });
                            chrs = (Chars)serializer.Deserialize(new StringReader(s));

                            if (db.SaveChars(acc.AccountId, new [email protected]().GetChars(Query["guid"], Query["password"], Program.GameData), chrs, Program.GameData))
                                status = "<Success />";
                        }
                        catch (Exception e)
                        {
                            Program.logger.Error(e);
                        }
                    }
                    else
                        status = "<Error>Account under Maintenance</Error>";
                }
                else
                    status = "<Error>Account credentials not valid</Error>";
            }

            using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                wtr.Write(status);
        }
        protected override void HandleRequest()
        {
            using (Database db = new Database())
            {
                Account a = db.Verify(Query["guid"], Query["password"], Program.GameData);
                if (!CheckAccount(a, db)) return;
                db.LockAccount(a);
                Chars chrs = new Chars
                {
                    Characters = new List<Char>(),
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = a,
                    Servers = GetServerList()
                };
                if (chrs.Account != null)
                {
                    db.GetCharData(chrs.Account, chrs);
                    db.LoadCharacters(chrs.Account, chrs);
                    chrs.News = db.GetNews(Program.GameData, chrs.Account);
                    chrs.OwnedSkins = Utils.GetCommaSepString(chrs.Account.OwnedSkins.ToArray());
                    db.UnlockAccount(chrs.Account);
                }
                else
                {
                    chrs.Account = Database.CreateGuestAccount(Query["guid"] ?? "");
                    chrs.News = db.GetNews(Program.GameData, null);
                }
                MapPoint p = null; //GetLatLong(Context.Request.RemoteEndPoint.Address);
                if (p != null)
                {
                    chrs.Lat = p.Latitude.ToString().Replace(',', '.');
                    chrs.Long = p.Longitude.ToString().Replace(',', '.');
                }
                chrs.ClassAvailabilityList = GetClassAvailability(chrs.Account);
                chrs.TOSPopup = chrs.Account.NotAcceptedNewTos;

                chrs.ClassAvailabilityList = GetClassAvailability(chrs.Account);
                XmlSerializer serializer = new XmlSerializer(chrs.GetType(),
                    new XmlRootAttribute(chrs.GetType().Name) { Namespace = "" });

                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding = Encoding.UTF8;
                xws.Indent = true;
                xws.IndentChars = "    ";
                XmlWriter xtw = XmlWriter.Create(Context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
            }
        }
Esempio n. 5
0
 protected override void HandleRequest()
 {
     using (var db = new Database())
     {
         List<ServerItem> servers;
         if (Account == null)
             servers = GetServersForRank(0);
         else
             servers = Account.Banned ? YoureBanned() : GetServersForRank(Account.Rank);
         var chrs = new Chars
         {
             Characters = new List<Char>(),
             NextCharId = 2,
             MaxNumChars = 1,
             Account = Account,
             Servers = servers
         };
         if (chrs.Account != null)
         {
             db.GetCharData(chrs.Account, chrs);
             db.LoadCharacters(chrs.Account, chrs);
             chrs.News = db.GetNews(chrs.Account);
         }
         else
         {
             chrs.Account = Database.CreateGuestAccount(Query["guid"]);
             chrs.News = db.GetNews(null);
         }
         var serializer = new XmlSerializer(chrs.GetType(),
             new XmlRootAttribute(chrs.GetType().Name) { Namespace = "" });
         var xws = new XmlWriterSettings
         {
             OmitXmlDeclaration = true,
             Encoding = Encoding.UTF8,
             Indent = true,
             IndentChars = "    "
         };
         var xtw = XmlWriter.Create(Context.Response.OutputStream, xws);
         serializer.Serialize(xtw, chrs, chrs.Namespaces);
     }
 }
Esempio n. 6
0
        public void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (StreamReader rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            using (var db = new Database(Program.Settings.GetValue("conn")))
            {

                Chars chrs = new Chars()
                {
                    Characters = new List<Char>() { },
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = db.Verify(query["guid"], query["password"]),
                    Servers = GetServerList()
                };
                if (chrs.Account != null)
                {
                    db.GetCharData(chrs.Account, chrs);
                    db.LoadCharacters(chrs.Account, chrs);
                    chrs.News = db.GetNews(Program.GameData, chrs.Account);
                }
                else
                {
                    chrs.Account = Database.CreateGuestAccount(query["guid"]);
                    chrs.News = db.GetNews(Program.GameData, null);
                }

                MemoryStream ms = new MemoryStream();
                XmlSerializer serializer = new XmlSerializer(chrs.GetType(), new XmlRootAttribute(chrs.GetType().Name) { Namespace = "" });

                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding = Encoding.UTF8;
                XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
            }
        }
Esempio n. 7
0
        public void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;

            using (StreamReader rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            using (var db1 = new Database())
            {
                chrs = new Chars()
                {
                    Characters = new List <Char>()
                    {
                    },
                    NextCharId  = 2,
                    MaxNumChars = 1,
                    Account     = db1.Verify(query["guid"], query["password"]),
                    Servers     = new List <ServerItem>() //leave this list empty for the Oryx Sleeping message
                    {
                        new ServerItem()
                        {
                            Name      = "Local",
                            Lat       = 22.28,
                            Long      = 114.16,
                            DNS       = "127.0.0.1",//db.confreader.getservers(false).ToString(), //127.0.0.1, CHANGE THIS TO LET YOUR FRIENDS CONNECT
                            Usage     = 0.2,
                            AdminOnly = false
                        }
                        //new ServerItem()
                        //{
                        //    Name = "Admin Realm",
                        //    Lat = 22.28,
                        //    Long = 114.16,
                        //    DNS = "127.0.0.1",
                        //    Usage = 0.2,
                        //    AdminOnly = true
                        //}
                    }
                };
                Account dvh = null;
                if (chrs.Account != null)
                {
                    db1.GetCharData(chrs.Account, chrs);
                    db1.LoadCharacters(chrs.Account, chrs);
                    chrs.News = db1.GetNews(chrs.Account);
                    dvh       = chrs.Account;
                    if (db1.getRole(chrs.Account) >= (int)Database.Roles.Moderator)
                    {
                        chrs.Account.Admin = true;
                    }
                }
                else
                {
                    chrs.Account = Database.CreateGuestAccount(query["guid"]);
                    chrs.News    = db1.GetNews(null);
                }
                if (dvh != null && db1.isWhitelisted(dvh) == false)
                {
                    chrs = Whitelist.whitelisted;
                }
                if (dvh != null && db1.isBanned(dvh) == true)
                {
                    chrs = new Chars();
                }
                MemoryStream  ms         = new MemoryStream();
                XmlSerializer serializer = new XmlSerializer(chrs.GetType(), new XmlRootAttribute(chrs.GetType().Name)
                {
                    Namespace = ""
                });

                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding           = Encoding.UTF8;
                XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Reads next <see cref="PdfObject"/> from PDF stream.
        /// </summary>
        /// <param name="reader">The <see cref="PdfReader"/> to use.</param>
        /// <returns>Read PdfObject.</returns>
        public static PdfObject ReadObject(this PdfReader reader)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            reader.MoveToNonWhiteSpace();

            char firstChar = reader.Peek();

            switch (firstChar)
            {
            case '%':
                // Skip comment
                reader.SkipWhile(c => !Chars.IsEndOfLine(c));
                reader.SkipWhile(Chars.IsEndOfLine);
                // Then try read next object
                return(ReadObject(reader));

            case 't':
                reader.ReadToken(BooleanObject.TrueToken);
                return(new BooleanObject(true, true));

            case 'f':
                reader.ReadToken(BooleanObject.FalseToken);
                return(new BooleanObject(false, true));

            case 'n':
                reader.ReadToken(NullObject.NullToken);
                return(new NullObject());

            case '(':
                return(LiteralStringObject.FromReader(reader));

            case '<':
                if (reader.Peek(1) == '<')
                {
                    return(DictionaryObject.FromReader(reader));
                }
                else
                {
                    return(HexadecimalStringObject.FromReader(reader));
                }

            case '/':
                return(NameObject.FromReader(reader));

            case '[':
                return(ArrayObject.FromReader(reader));

            case '+':
            case '-':
                return(NumericObject.FromReader(reader));
            }
            if (char.IsDigit(firstChar))
            {
                int indRefLength = IsIndirectReference(reader);
                if (indRefLength >= 5)
                {
                    var indRefStr = reader.ReadString(indRefLength);
                    var objectId  = PdfObjectId.FromString(indRefStr.Substring(0, indRefLength - 2));

                    return(new IndirectReference(objectId));
                }

                return(NumericObject.FromReader(reader));
            }
            throw new NotImplementedException();
        }
Esempio n. 9
0
        protected override void HandleRequest()
        {
            string status = "<Error>Internal server error</Error>";

            using (Database db = new Database())
            {
                Account acc;
                if (CheckAccount(acc = db.Verify(Query["guid"], Query["password"], Program.GameData), db))
                {
                    if (acc.Rank < 1)
                    {
                        status = "<Error>Only donators can port prod accounts to the private server.</Error>";
                    }
                    else if (acc.IsProdAccount && acc.Rank < 2)
                    {
                        status = "<Error>You account is already transfered.</Error>";
                    }
                    else if (!acc.Banned)
                    {
                        HttpWebRequest req  = (HttpWebRequest)WebRequest.Create(String.Format("http://www.realmofthemadgodhrd.appspot.com/char/list?guid={0}&password={1}", Query["prodGuid"], Query["prodPassword"]));
                        var            resp = req.GetResponse();

                        Chars chrs = new Chars();
                        chrs.Characters = new List <Char>();

                        string s;
                        using (StreamReader rdr = new StreamReader(resp.GetResponseStream()))
                            s = rdr.ReadToEnd();

                        s = s.Replace("False", "false").Replace("True", "true");

                        try
                        {
                            XmlSerializer serializer = new XmlSerializer(chrs.GetType(),
                                                                         new XmlRootAttribute("Chars")
                            {
                                Namespace = ""
                            });
                            chrs = (Chars)serializer.Deserialize(new StringReader(s));

                            if (db.SaveChars(acc.AccountId, new [email protected]().GetChars(Query["guid"], Query["password"], Program.GameData), chrs, Program.GameData))
                            {
                                status = "<Success />";
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                    else
                    {
                        status = "<Error>Account under Maintenance</Error>";
                    }
                }
                else
                {
                    status = "<Error>Account credentials not valid</Error>";
                }
            }

            using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                wtr.Write(status);
        }
Esempio n. 10
0
        internal StandardGrammar()
        {
            this._isReadOnly = false;
            var newline = Combinator.Choice(
                Chars.Sequence("\r\n"),
                Chars.OneOf('\r', '\n', '\x85', '\u2028', '\u2029')
                .Select(EnumerableEx.Return)
                ).Select(_ => Environment.NewLine);

            var punctuation = Chars.OneOf('"', '\'', '(', ')', ',', '.', ':', ';', '[', ']', '`', '{', '}');

            Parser <Char, YacqExpression> expressionRef = null;
            var expression = new Lazy <Parser <Char, YacqExpression> >(
                () => stream => expressionRef(stream)
                );

            this.Add("yacq", "expression", g => expression.Value);

            // Comments
            {
                this.Add("comment", "eol", g => Prims.Pipe(
                             ';'.Satisfy(),
                             newline.Not().Right(Chars.Any()).Many(),
                             newline.Ignore().Or(Chars.Eof()),
                             (p, r, s) => (YacqExpression)YacqExpression.Ignore()
                             ));

                Parser <Char, YacqExpression> blockCommentRef     = null;
                Parser <Char, YacqExpression> blockCommentRestRef = null;
                var blockComment = new Lazy <Parser <Char, YacqExpression> >(
                    () => stream => blockCommentRef(stream)
                    );
                var blockCommentRest = new Lazy <Parser <Char, YacqExpression> >(
                    () => stream => blockCommentRestRef(stream)
                    );
                var blockCommentPrefix = Chars.Sequence("#|");
                var blockCommentSuffix = Chars.Sequence("|#");
                blockCommentRef = blockCommentPrefix
                                  .Right(blockCommentRest.Value.Many())
                                  .Left(blockCommentSuffix)
                                  .Select(_ => (YacqExpression)YacqExpression.Ignore());
                blockCommentRestRef = blockCommentPrefix.Not()
                                      .Right(blockCommentSuffix.Not())
                                      .Right(Chars.Any())
                                      .Select(_ => (YacqExpression)YacqExpression.Ignore())
                                      .Or(blockComment.Value);
                this.Add("comment", "block", g => blockComment.Value);

                this.Add("comment", "expression", g => Prims.Pipe(
                             Chars.Sequence("#;"),
                             g["yacq", "expression"],
                             (p, r) => (YacqExpression)YacqExpression.Ignore()
                             ));

                this.Add("yacq", "comment", g => Combinator.Choice(g["comment"]));
            }

            this.Add("yacq", "ignore", g => Combinator.Choice(
                         this.Get["yacq", "comment"].Ignore(),
                         Chars.Space().Ignore(),
                         newline.Ignore()
                         ).Many().Select(_ => (YacqExpression)YacqExpression.Ignore()));

            // Texts
            this.Add("term", "text", g => SetPosition(
                         Chars.OneOf('\'', '\"', '`')
                         .SelectMany(q => q.Satisfy()
                                     .Not()
                                     .Right('\\'.Satisfy()
                                            .Right(q.Satisfy())
                                            .Or(Chars.Any())
                                            )
                                     .Many()
                                     .Left(q.Satisfy())
                                     .Select(cs => cs.StartWith(q).EndWith(q))
                                     )
                         .Select(cs => (YacqExpression)YacqExpression.Text(new String(cs.ToArray())))
                         ));

            // Numbers
            {
                var numberPrefix = Chars.OneOf('+', '-');
                var numberSuffix = Combinator.Choice(
                    Chars.Sequence("ul"),
                    Chars.Sequence("UL"),
                    Chars.OneOf('D', 'F', 'L', 'M', 'U', 'd', 'f', 'l', 'm', 'u')
                    .Select(EnumerableEx.Return)
                    );
                var digit     = '_'.Satisfy().Many().Right(Chars.Digit());
                var hexPrefix = Chars.Sequence("0x");
                var hex       = '_'.Satisfy().Many().Right(Chars.Hex());
                var octPrefix = Chars.Sequence("0o");
                var oct       = '_'.Satisfy().Many().Right(Chars.Oct());
                var binPrefix = Chars.Sequence("0b");
                var bin       = '_'.Satisfy().Many().Right(Chars.OneOf('0', '1'));
                var fraction  = Prims.Pipe(
                    '.'.Satisfy(),
                    digit.Many(1),
                    (d, ds) => ds.StartWith(d)
                    );
                var exponent = Prims.Pipe(
                    Chars.OneOf('E', 'e'),
                    Chars.OneOf('+', '-').Maybe(),
                    digit.Many(1),
                    (e, s, ds) => ds
                    .If(_ => s.Exists(), _ => _.StartWith(s.Perform()))
                    .StartWith(e)
                    );

                this.Add("term", "number", g => Combinator.Choice(
                             SetPosition(Prims.Pipe(
                                             binPrefix,
                                             bin.Many(1),
                                             numberSuffix.Maybe(),
                                             (p, n, s) => (YacqExpression)YacqExpression.Number(
                                                 new String(p.Concat(n).If(
                                                                _ => s.Exists(),
                                                                cs => cs.Concat(s.Perform())
                                                                ).ToArray())
                                                 )
                                             )),
                             SetPosition(Prims.Pipe(
                                             octPrefix,
                                             oct.Many(1),
                                             numberSuffix.Maybe(),
                                             (p, n, s) => (YacqExpression)YacqExpression.Number(
                                                 new String(p.Concat(n).If(
                                                                _ => s.Exists(),
                                                                cs => cs.Concat(s.Perform())
                                                                ).ToArray())
                                                 )
                                             )),
                             SetPosition(Prims.Pipe(
                                             hexPrefix,
                                             hex.Many(1),
                                             numberSuffix.Maybe(),
                                             (p, n, s) => (YacqExpression)YacqExpression.Number(
                                                 new String(p.Concat(n).If(
                                                                _ => s.Exists(),
                                                                cs => cs.Concat(s.Perform())
                                                                ).ToArray())
                                                 )
                                             )),
                             SetPosition(
                                 numberPrefix.Maybe().SelectMany(p =>
                                                                 digit.Many(1).SelectMany(i =>
                                                                                          fraction.Maybe().SelectMany(f =>
                                                                                                                      exponent.Maybe().SelectMany(e =>
                                                                                                                                                  numberSuffix.Maybe().Select(s =>
                                                                                                                                                                              (YacqExpression)YacqExpression.Number(new String(EnumerableEx.Concat(
                                                                                                                                                                                                                                   i.If(_ => p.Exists(), _ => _.StartWith(p.Perform())),
                                                                                                                                                                                                                                   f.Otherwise(Enumerable.Empty <Char>),
                                                                                                                                                                                                                                   e.Otherwise(Enumerable.Empty <Char>),
                                                                                                                                                                                                                                   s.Otherwise(Enumerable.Empty <Char>)
                                                                                                                                                                                                                                   ).ToArray()))
                                                                                                                                                                              )
                                                                                                                                                  )
                                                                                                                      )
                                                                                          )
                                                                 )
                                 )
                             ));
            }

            // Lists
            this.Add("term", "list", g => SetPosition(
                         g["yacq", "expression"]
                         .Between(g["yacq", "ignore"], g["yacq", "ignore"])
                         .Many()
                         .Between('('.Satisfy(), ')'.Satisfy())
                         .Select(es => (YacqExpression)YacqExpression.List(es))
                         ));

            // Vectors
            this.Add("term", "vector", g => SetPosition(
                         g["yacq", "expression"]
                         .Between(g["yacq", "ignore"], g["yacq", "ignore"])
                         .Many()
                         .Between('['.Satisfy(), ']'.Satisfy())
                         .Select(es => (YacqExpression)YacqExpression.Vector(es))
                         ));

            // Lambda Lists
            this.Add("term", "lambdaList", g => SetPosition(
                         g["yacq", "expression"]
                         .Between(g["yacq", "ignore"], g["yacq", "ignore"])
                         .Many()
                         .Between('{'.Satisfy(), '}'.Satisfy())
                         .Select(es => (YacqExpression)YacqExpression.LambdaList(es))
                         ));

            // Quotes
            this.Add("term", "quote", g => SetPosition(
                         Prims.Pipe(
                             Chars.Sequence("#'"),
                             g["yacq", "expression"],
                             (p, e) => (YacqExpression)YacqExpression.List(YacqExpression.Identifier("quote"), e)
                             )
                         ));

            // Quasiquotes
            this.Add("term", "quasiquote", g => SetPosition(
                         Prims.Pipe(
                             Chars.Sequence("#`"),
                             g["yacq", "expression"],
                             (p, e) => (YacqExpression)YacqExpression.List(YacqExpression.Identifier("quasiquote"), e)
                             )
                         ));

            // Unquote-Splicings
            this.Add("term", "unquoteSplicing", g => SetPosition(
                         Prims.Pipe(
                             Chars.Sequence("#,@"),
                             g["yacq", "expression"],
                             (p, e) => (YacqExpression)YacqExpression.List(YacqExpression.Identifier("unquote-splicing"), e)
                             )
                         ));

            // Unquotes
            this.Add("term", "unquote", g => SetPosition(
                         Prims.Pipe(
                             Chars.Sequence("#,"),
                             g["yacq", "expression"],
                             (p, e) => (YacqExpression)YacqExpression.List(YacqExpression.Identifier("unquote"), e)
                             )
                         ));

            // Identifiers
            this.Add("term", "identifier", g => Combinator.Choice(
                         SetPosition('.'.Satisfy()
                                     .Many(1)
                                     .Select(cs => (YacqExpression)YacqExpression.Identifier(new String(cs.ToArray())))
                                     ),
                         SetPosition(':'.Satisfy()
                                     .Many(1)
                                     .Select(cs => (YacqExpression)YacqExpression.Identifier(new String(cs.ToArray())))
                                     ),
                         SetPosition(Chars.Digit()
                                     .Not()
                                     .Right(Chars.Space()
                                            .Or(punctuation)
                                            .Not()
                                            .Right(Chars.Any())
                                            .Many(1)
                                            )
                                     .Select(cs => (YacqExpression)YacqExpression.Identifier(new String(cs.ToArray())))
                                     )
                         ));

            // Terms
            this.Add("yacq", "term", g => Combinator.Choice(g["term"])
                     .Between(g["yacq", "ignore"], g["yacq", "ignore"])
                     );

            // Infix Dots
            this.Add("infix", "dot", g => Prims.Pipe(
                         g["yacq", "term"],
                         '.'.Satisfy()
                         .Right(g["yacq", "term"])
                         .Many(),
                         (h, t) => t.Aggregate(h, (l, r) =>
                                               (YacqExpression)YacqExpression.List(YacqExpression.Identifier("."), l, r)
                                               )
                         ));

            // Infix Colons
            this.Add("infix", "colon", g => Prims.Pipe(
                         g["infix", "dot"],
                         ':'.Satisfy()
                         .Right(g["infix", "dot"])
                         .Many(),
                         (h, t) => t.Aggregate(h, (l, r) =>
                                               (YacqExpression)YacqExpression.List(YacqExpression.Identifier(":"), l, r)
                                               )
                         ));

            expressionRef = this.Get["infix"].Last();

            this.Set.Default = g => g["yacq", "expression"];

            this._isReadOnly = true;
        }
Esempio n. 11
0
 public void LoadCharacters(Account acc, Chars chrs)
 {
     MySqlCommand cmd = CreateQuery();
     cmd.CommandText = "SELECT * FROM characters WHERE accId=@accId AND dead = FALSE;";
     cmd.Parameters.AddWithValue("@accId", acc.AccountId);
     using (MySqlDataReader rdr = cmd.ExecuteReader())
     {
         while (rdr.Read())
         {
             int[] stats = Utils.FromCommaSepString32(rdr.GetString("stats"));
             chrs.Characters.Add(new Char
             {
                 ObjectType = (ushort)rdr.GetInt32("charType"),
                 CharacterId = rdr.GetInt32("charId"),
                 Level = rdr.GetInt32("level"),
                 Exp = rdr.GetInt32("exp"),
                 CurrentFame = rdr.GetInt32("fame"),
                 _Equipment = rdr.GetString("items"),
                 MaxHitPoints = stats[0],
                 HitPoints = rdr.GetInt32("hp"),
                 MaxMagicPoints = stats[1],
                 MagicPoints = rdr.GetInt32("mp"),
                 Attack = stats[2],
                 Defense = stats[3],
                 Speed = stats[4],
                 Dexterity = stats[7],
                 HpRegen = stats[5],
                 MpRegen = stats[6],
                 HealthStackCount = rdr.GetInt32("hpPotions"),
                 MagicStackCount = rdr.GetInt32("mpPotions"),
                 HasBackpack = rdr.GetInt32("hasBackpack"),
                 Tex1 = rdr.GetInt32("tex1"),
                 Tex2 = rdr.GetInt32("tex2"),
                 Dead = false,
                 PCStats = rdr.GetString("fameStats"),
                 Pet = GetPet(rdr.GetInt32("petId"), acc),
                 Skin = rdr.GetInt32("skin")
             });
         }
     }
     foreach (Char i in chrs.Characters)
     {
         if (i.HasBackpack == 1)
             i._Equipment += ", " + Utils.GetCommaSepString(GetBackpack(i, acc));
     }
 }
Esempio n. 12
0
 /// <summary>
 /// Add char to text line
 /// </summary>
 /// <param name="ch">Added char</param>
 public void AddChar(Rectangle ch)
 {
     Chars        = Chars.Union(new[] { ch }).ToArray();
     BoundingRect = Union(BoundingRect, ch);
 }
Esempio n. 13
0
        public override void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            if (query.AllKeys.Length == 0)
            {
                string queryString = string.Empty;
                string currUrl = context.Request.RawUrl;
                int iqs = currUrl.IndexOf('?');
                if (iqs >= 0)
                {
                    query =
                        HttpUtility.ParseQueryString((iqs < currUrl.Length - 1)
                            ? currUrl.Substring(iqs + 1)
                            : String.Empty);
                }
            }

            using (var db = new Database(Program.Settings.GetValue("conn")))
            {
                bool isGuest = db.Verify(query["guid"], query["password"]) == null ? true : false;
                Account acc = db.Verify(query["guid"], query["password"]);

                var chrs = new Chars
                {
                    Characters = new List<Char>(),
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = db.Verify(query["guid"], query["password"]),
                    Servers = isGuest ? NoServerList() : GetServerList(acc.Admin)
                };
                if (chrs.Account != null)
                {
                    if (!chrs.Account.isBanned)
                    {
                        db.GetCharData(chrs.Account, chrs);
                        db.LoadCharacters(chrs.Account, chrs);
                        chrs.News = db.GetNews(Program.GameData, chrs.Account);
                    }
                }
                else
                {
                    chrs.Account = Database.CreateGuestAccount(query["guid"]);
                    chrs.News = db.GetNews(Program.GameData, null);
                }
                chrs.ClassAvailabilityList = GetClassAvailability(chrs.Account);

                var ms = new MemoryStream();
                var serializer = new XmlSerializer(chrs.GetType(),
                    new XmlRootAttribute(chrs.GetType().Name) {Namespace = ""});

                var xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding = Encoding.UTF8;
                XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
            }
        }
Esempio n. 14
0
File: Player.cs Progetto: gio735/RBC
 public void RemoveUsingChar()
 {
     Chars.Remove(UsingChar);
 }
Esempio n. 15
0
File: Player.cs Progetto: gio735/RBC
        public void Summon()
        {
            bool capableToSummon = MaxServant > Chars.Count;

            if (capableToSummon)
            {
                Character summoned = CharList.Randomise();
                Chars.Add(summoned);
                Console.Clear();
                Console.WriteLine($"Successfully summoned {summoned.CharType} - {summoned.Name} on slot {Chars.IndexOf(summoned) + 1}.");
                if (Program.MustSave)
                {
                    using (var context = new DataContext())
                    {
                        context.Attach <Player>(this);
                        context.SaveChanges();
                    };
                }
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Summon failed. (not enough slots)");
            }
        }
Esempio n. 16
0
 public bool IsSpaceMark()
 {
     return(Chars.Equals(Separators.Space));
 }
Esempio n. 17
0
 public bool IsWordSeparator()
 {
     return(Separators.WordSeparators.Any(x => Chars.Equals(x)));
 }
Esempio n. 18
0
 public bool IsSentenceSeparator()
 {
     return(Separators.SentenceSeparators.Any(x => Chars.Equals(x)));
 }
Esempio n. 19
0
 /// <summary>
 /// Method to recognize if our separator starts with vovel letter (needed for task 3)
 /// </summary>
 /// <returns></returns>
 public bool IsQuestionMark()
 {
     return(Chars.Contains('?'));
 }
Esempio n. 20
0
 /// <summary>
 /// Method to recognize if our word starts with vovel letter (needed for task 3)
 /// </summary>
 /// <returns></returns>
 public bool StartsWithVovel()
 {
     char[] vowels = new char[] { 'a', 'e', 'i', 'o', 'u', 'y' };
     return(vowels.Any(vowel => vowel == Chars.ToLower().First()));
 }
Esempio n. 21
0
        public bool StartWithVowel()
        {
            var vowels = new[] { 'a', 'e', 'i', 'o', 'u', 'y' };

            return(vowels.Any(vowel => vowel == Chars.ToLower().First()));
        }
Esempio n. 22
0
 public void Add(Char c)
 {
     Chars.Add(c.Letter, c);
 }
Esempio n. 23
0
        public static Pattern CSharpEscapedTextLiteral()
        {
            QuantifiedGroup chars = MaybeMany(!Chars.QuoteMark().Backslash().NewLineChar());

            return(SurroundQuoteMarks(chars + MaybeMany(Backslash().NotNewLineChar() + chars)));
        }
Esempio n. 24
0
 /// <summary>
 /// this constructor serves the mere purpose of storing an object present
 /// in the current map of a certain type, to be able to manipulate them
 /// with the moore look around feature
 /// </summary>
 /// <param name="position"> item's map placement</param>
 /// <param name="name">item's char to distinguish from others</param>
 /// <param name="info">item's info for the help text if on board</param>
 internal CurrentMapObjects(Position position, Chars name, string info)
 {
     Position = position;
     Name     = name;
     Info     = info;
 }
Esempio n. 25
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Chars obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Esempio n. 26
0
        public static void Main(string[] args)
        {
            //Resize Window in Windows
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                Console.SetWindowSize(22, 14);
            }

            //Setup the Clock Face
            Console.Clear();
            Console.CursorVisible = false;
            Face.SetFace();

            //Clock Loop
            do
            {
                //Populate ClockChar
                Clock.ClockChar.Clear();
                Clock.ClockChar.AddRange(Clock.ClockString.ToString().Select(Chars => Chars.ToString()));

                //Get the Current Time
                var Time = DateTime.Now;
                Clock.Hours   = Time.Hour;
                Clock.Minutes = Time.Minute;
                Clock.Seconds = Time.Second;
                Clock.Minute  = Clock.Minutes % 10;

                //Set time to Clock
                Minute.SetMinute();
                Hour.SetHour();
                Second.SetSecond();

                //Populate Display values
                Clock.Display.Clear();
                Clock.ClockChar.ForEach(Item => Clock.Display.Append(Item));

                //Write Dsplay to Console
                Console.SetCursorPosition(0, 0);
                Console.Write(Clock.Display);

                //Wait one Second
                System.Threading.Thread.Sleep(1000);
            } while (true);
        }
Esempio n. 27
0
        private void SetWithPerks(Chars ch, double v)
        {
            Action <double> tempAction;

            switch (ch)
            {
            case Chars.MaxHp:
                tempAction = (s) => maxHp = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetMaxHp(tempAction);
                }
                break;

            case Chars.Hp:
                tempAction = (s) => FSetHp(s);
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetHp(tempAction);
                }
                break;

            case Chars.Armor:
                tempAction = (s) => armor = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetArmor(tempAction);
                }
                break;

            case Chars.Resist:
                tempAction = (s) => resist = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetResist(tempAction);
                }
                break;

            case Chars.Regen:
                tempAction = (s) => regen = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetRegen(tempAction);
                }
                break;

            case Chars.AbilityPower:
                tempAction = (s) => abilityPower = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetAbilityPower(tempAction);
                }
                break;

            case Chars.AttackDamage:
                tempAction = (s) => attackDamage = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetAttackDamage(tempAction);
                }
                break;

            case Chars.AttackSpeed:
                tempAction = (s) => attackSpeed = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetAttackSpeed(tempAction);
                }
                break;

            case Chars.MovementSpeed:
                tempAction = (s) => movementSpeed = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetMovementSpeed(tempAction);
                }
                break;

            case Chars.AttackRange:
                tempAction = (s) => attackRange = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetAttackRange(tempAction);
                }
                break;

            case Chars.Energy:
                tempAction = (s) => energy = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetEnergy(tempAction);
                }
                break;

            case Chars.MaxEnergy:
                tempAction = (s) => maxEnergy = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetMaxEnergy(tempAction);
                }
                break;

            case Chars.EnergyRegen:
                tempAction = (s) => energyRegen = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetEnergyRegen(tempAction);
                }
                break;

            case Chars.Money:
                tempAction = (s) => money = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetMoney(tempAction);
                }
                break;

            case Chars.CDReduction:
                tempAction = (s) => cdReduction = s;
                foreach (var perk in Perks)
                {
                    tempAction = perk.SetCDReduction(tempAction);
                }
                break;

            default:
                tempAction = (s) => { };
                break;
            }
            tempAction(v);
        }
Esempio n. 28
0
 internal Trap(Position position, Chars name, string info, int maxDamage) : base(position, name, info)
 {
     MaxDamage = maxDamage;
     TrapInfo  = info;
 }
Esempio n. 29
0
        public bool SaveChars(string oldAccId, Chars oldChars, Chars chrs, XmlData data)
        {
            try
            {
                chrs.Account.AccountId = oldAccId;

                var cmd = CreateQuery();
                cmd.CommandText = "UPDATE accounts SET prodAcc=1, name=@name, namechosen=@nameChoosen, vaultCount=@vaults, maxCharSlot=@maxChars, ownedSkins=@skins, gifts=@gifts WHERE id=@oldAccId;";
                cmd.Parameters.AddWithValue("@name", chrs.Account.Name);
                cmd.Parameters.AddWithValue("@nameChoosen", chrs.Account.NameChosen ? 1 : 0);
                cmd.Parameters.AddWithValue("@vaults", chrs.Account.Vault.Chests.Count);
                cmd.Parameters.AddWithValue("@maxChars", chrs.MaxNumChars);
                cmd.Parameters.AddWithValue("@oldAccId", oldAccId);
                cmd.Parameters.AddWithValue("@gifts", chrs.Account._Gifts);
                cmd.Parameters.AddWithValue("@skins", chrs.OwnedSkins);
                cmd.ExecuteNonQuery();

                cmd = CreateQuery();
                cmd.CommandText = "DELETE FROM characters WHERE accId=@accId AND dead=0;";
                cmd.Parameters.AddWithValue("@accId", oldAccId);
                cmd.ExecuteNonQuery();

                cmd = CreateQuery();
                cmd.CommandText = "DELETE FROM vaults WHERE accId=@accId;";
                cmd.Parameters.AddWithValue("@accId", oldAccId);
                cmd.ExecuteNonQuery();

                cmd = CreateQuery();
                cmd.CommandText = "DELETE FROM classstats WHERE accId=@accId";
                cmd.Parameters.AddWithValue("@accId", oldAccId);
                cmd.ExecuteNonQuery();

                foreach (var stat in chrs.Account.Stats.ClassStates)
                {
                    cmd = CreateQuery();
                    cmd.CommandText = @"INSERT INTO classstats(accId, objType, bestLv, bestFame)
            VALUES(@accId, @objType, @bestLv, @bestFame)
            ON DUPLICATE KEY UPDATE
            bestLv = GREATEST(bestLv, @bestLv),
            bestFame = GREATEST(bestFame, @bestFame);";
                    cmd.Parameters.AddWithValue("@accId", oldAccId);
                    cmd.Parameters.AddWithValue("@objType", Utils.FromString(stat.ObjectType.ToString()));
                    cmd.Parameters.AddWithValue("@bestLv", stat.BestLevel);
                    cmd.Parameters.AddWithValue("@bestFame", stat.BestFame);
                    cmd.ExecuteNonQuery();
                }

                cmd = CreateQuery();
                cmd.CommandText = "DELETE FROM stats WHERE accId=@accId";
                cmd.Parameters.AddWithValue("@accId", oldAccId);
                cmd.ExecuteNonQuery();

                cmd = CreateQuery();
                cmd.CommandText = "INSERT INTO stats (accId, fame, totalFame, credits, totalCredits, fortuneTokens, totalFortuneTokens) VALUES(@accId, @fame, @fame, @gold, @gold, @tokens, @tokens)";
                cmd.Parameters.AddWithValue("@accId", oldAccId);
                cmd.Parameters.AddWithValue("@fame", chrs.Account.Stats.Fame);
                cmd.Parameters.AddWithValue("@totalFame", chrs.Account.Stats.TotalFame);
                cmd.Parameters.AddWithValue("@gold", chrs.Account.Credits);
                cmd.Parameters.AddWithValue("@tokens", chrs.Account.FortuneTokens);
                cmd.ExecuteNonQuery();

                cmd = CreateQuery();
                cmd.CommandText = "DELETE FROM pets WHERE accId=@accId;";
                cmd.Parameters.AddWithValue("@accId", oldAccId);
                cmd.ExecuteNonQuery();

                foreach (var @char in chrs.Characters)
                {
                    var chr = CreateCharacter(data, (ushort)@char.ObjectType, @char.CharacterId);

                    int[] stats = new[]
                    {
                        @char.MaxHitPoints,
                        @char.MaxMagicPoints,
                        @char.Attack,
                        @char.Defense,
                        @char.Speed,
                        @char.Dexterity,
                        @char.HpRegen,
                        @char.MpRegen
                    };

                    cmd = CreateQuery();
                    cmd.Parameters.AddWithValue("@accId", chrs.Account.AccountId);
                    cmd.Parameters.AddWithValue("@charId", @char.CharacterId);
                    cmd.Parameters.AddWithValue("@charType", @char.ObjectType);
                    cmd.Parameters.AddWithValue("@items", Utils.GetCommaSepString(@char.EquipSlots()));
                    cmd.Parameters.AddWithValue("@stats", Utils.GetCommaSepString(stats));
                    cmd.Parameters.AddWithValue("@fameStats", @char.PCStats);
                    cmd.Parameters.AddWithValue("@skin", @char.Skin);
                    cmd.CommandText =
                        "INSERT INTO characters (accId, charId, charType, level, exp, fame, items, hp, mp, stats, dead, pet, fameStats, skin) VALUES (@accId, @charId, @charType, 1, 0, 0, @items, 100, 100, @stats, FALSE, -1, @fameStats, @skin);";
                    cmd.ExecuteNonQuery();

                    if (@char.Pet != null)
                        CreatePet(chrs.Account, @char.Pet);

                    @char.FameStats = new FameStats();
                    @char.FameStats.Read(
                        Convert.FromBase64String(@char.PCStats.Replace('-', '+').Replace('_', '/')));

                    if (@char.Equipment.Length > 12)
                    {
                        @char.Backpack = new int[8];
                        Array.Copy(@char.Equipment, 12, @char.Backpack, 0, 8);
                        var eq = @char.Equipment;
                        Array.Resize(ref eq, 12);
                        @char.Equipment = eq;
                        @char.HasBackpack = 1;
                    }
                    chr = @char;
                    SaveCharacter(chrs.Account, chr);
                }

                foreach (var chest in chrs.Account.Vault.Chests)
                {
                    chest.ChestId = CreateChest(chrs.Account).ChestId;
                    if (chest.Items.Length < 8)
                    {
                        var inv = chest.Items;
                        Array.Resize(ref inv, 8);
                        for (int i = 0; i < inv.Length; i++)
                            if (inv[i] == 0) inv[i] = -1;
                        chest.Items = inv;
                    }
                    SaveChest(chrs.Account.AccountId, chest);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return false;
            }
            return true;
        }
Esempio n. 30
0
 public override string ToString()
 {
     return(base.ToString() + "; Chars: " + Chars.ToString());
 }
Esempio n. 31
0
 public static int LeastIndexOf(this string s, params char[] Chars)
 {
     return(Chars.Select(x => s.IndexOf(x)).OrderBy(x => x).First());
 }
Esempio n. 32
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(Chars.GetEnumerator());
 }
Esempio n. 33
0
        public void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;

            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            using (var db = new Database())
            {
                List <ServerItem> filteredServers = null;
                Account           a = db.Verify(query["guid"], query["password"]);
                if (a != null)
                {
                    if (a.Banned)
                    {
                        filteredServers = YoureBanned();
                    }
                    else
                    {
                        filteredServers = GetServersForRank(a.Rank);
                    }
                }
                else
                {
                    filteredServers = GetServersForRank(0);
                }

                var chrs = new Chars
                {
                    Characters  = new List <Char>(),
                    NextCharId  = 2,
                    MaxNumChars = 1,
                    Account     = db.Verify(query["guid"], query["password"]),
                    Servers     = filteredServers
                };
                Account dvh = null;
                if (chrs.Account != null)
                {
                    db.GetCharData(chrs.Account, chrs);
                    db.LoadCharacters(chrs.Account, chrs);
                    chrs.News = db.GetNews(chrs.Account);
                    dvh       = chrs.Account;
                }
                else
                {
                    chrs.Account = Database.CreateGuestAccount(query["guid"]);
                    chrs.News    = db.GetNews(null);
                }

                var ms         = new MemoryStream();
                var serializer = new XmlSerializer(chrs.GetType(),
                                                   new XmlRootAttribute(chrs.GetType().Name)
                {
                    Namespace = ""
                });

                var xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding           = Encoding.UTF8;
                XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
                db.Dispose();
            }
        }
Esempio n. 34
0
 // Gets the Char with the symbolName
 public static AbstractionModel GetChar(Chars symbolName)
 {
     if (!initialized)
         Initialize();
     return chars[symbolName];
 }
Esempio n. 35
0
 // check if a character is part of the valid character set
 static bool isValidChar(char c, Chars validChars)
 {
     return(validChars.Contains(c));
 }
Esempio n. 36
0
        protected override void HandleRequest()
        {
            using (var db = new Database())
            {
                List<ServerItem> filteredServers = null;
                Account a = db.Verify(Query["guid"], Query["password"]);
                if (a != null)
                {
                    if (a.Banned)
                    {
                        filteredServers = YoureBanned();
                    }
                    else
                    {
                        filteredServers = GetServersForRank(a.Rank);
                    }
                }
                else
                {
                    filteredServers = GetServersForRank(0);
                }

                Chars chrs = new Chars()
                {
                    Characters = new List<Char>() { },
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = db.Verify(Query["guid"], Query["password"]),
                    Servers = filteredServers
                };
                Account dvh = null;
                if (chrs.Account != null)
                {
                    db.GetCharData(chrs.Account, chrs);
                    db.LoadCharacters(chrs.Account, chrs);
                    chrs.News = db.GetNews(chrs.Account);
                    dvh = chrs.Account;
                }
                else
                {
                    chrs.Account = Database.CreateGuestAccount(Query["guid"]);
                    chrs.News = db.GetNews(null);
                }

                MemoryStream ms = new MemoryStream();
                XmlSerializer serializer = new XmlSerializer(chrs.GetType(), new XmlRootAttribute(chrs.GetType().Name) { Namespace = "" });

                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding = Encoding.UTF8;
                XmlWriter xtw = XmlWriter.Create(Context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
            }
        }
Esempio n. 37
0
 private void fillCharBox()
 {
     CharBox.Items.AddRange(Chars.SoundTypes());
     CharBox.Items.AddRange(_profile.SpecififcSoundTypes);
 }
Esempio n. 38
0
        public static Pattern CSharpCharacterLiteral()
        {
            QuantifiedGroup chars = MaybeMany(!Chars.Apostrophe().Backslash().NewLineChar());

            return(SurroundApostrophes(chars + MaybeMany(Backslash().NotNewLineChar() + chars)));
        }
        protected override void HandleRequest()
        {
            using (Database db = new Database())
            {
                Account a;
                if (Query["guid"].Contains("@") && !String.IsNullOrWhiteSpace(Query["password"]))
                {
                    a = db.Verify(Query["guid"], Query["password"], Program.GameData);
                    if (a == null)
                    {
                        using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                            wtr.WriteLine("<Error>Account credentials not valid</Error>");
                        Context.Response.Close();
                        return;
                    }
                }
                else
                {
                    a = db.GetAccountByName(Query["guid"], Program.GameData);
                    if (a != null)
                    {
                        if (!a.VisibleMuledump)
                        {
                            using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                                wtr.WriteLine("<Error>This player has a private muledump.</Error>");
                            Context.Response.Close();
                            return;
                        }
                    }
                    else
                    {
                        using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                            wtr.WriteLine("<Error>User not found</Error>");
                        Context.Response.Close();
                        return;
                    }
                }

                if (a.Banned)
                {
                    using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                        wtr.WriteLine("<Error>Account under maintenance</Error>");
                    Context.Response.Close();
                    return;
                }

                Chars chrs = new Chars
                {
                    Characters = new List<Char>(),
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = a
                };

                if (chrs.Account != null)
                {
                    db.GetCharData(chrs.Account, chrs);
                    db.LoadCharacters(chrs.Account, chrs);
                    chrs.News = db.GetNews(Program.GameData, chrs.Account);
                    chrs.OwnedSkins = Utils.GetCommaSepString(chrs.Account.OwnedSkins.ToArray());
                }
                else
                {
                    using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
                        wtr.WriteLine("<Error>User not found</Error>");
                    Context.Response.Close();
                    return;
                }

                XmlSerializer serializer = new XmlSerializer(chrs.GetType(),
                    new XmlRootAttribute(chrs.GetType().Name) { Namespace = "" });

                XmlWriterSettings xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding = Encoding.UTF8;
                xws.Indent = true;
                xws.IndentChars = "    ";
                XmlWriter xtw = XmlWriter.Create(Context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
            }
        }
Esempio n. 40
0
 public StackAlphabet(params char[] c) : base(c)
 {
     Chars.Add(Z);
 }
Esempio n. 41
0
 public static int getDimensions(int mgView, Floats vars, Chars types)
 {
     int ret = democmdsPINVOKE.DemoCmdsGate_getDimensions(mgView, Floats.getCPtr(vars), Chars.getCPtr(types));
     if (democmdsPINVOKE.SWIGPendingException.Pending) throw democmdsPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Esempio n. 42
0
        //public override string ToString()
        //{
        //    switch (Type)
        //    {
        //        case WordType.Numberic:
        //            return "<ins>" + Value + "</ins>";
        //        case WordType.Email:
        //            return "<ins>" + Value + "</ins>";
        //        case WordType.Url:
        //            return "<ins>" + Value + "</ins>";
        //        default:
        //            return Value;
        //    }
        //}

        //public string ToStringWithIndex()
        //{
        //    return "$" + Value + "_{" + Index +  "}$";
        //}

        public bool IsNumber()
        {
            var _digits = Chars.Where(t => t.IsDigit());

            return(_digits.Count() == Length ? true : false);
        }
Esempio n. 43
0
 public void LoadCharacters(Account acc, Chars chrs)
 {
     var cmd = CreateQuery();
     cmd.CommandText = "SELECT * FROM characters WHERE accId=@accId AND dead = FALSE;";
     cmd.Parameters.AddWithValue("@accId", acc.AccountId);
     using (var rdr = cmd.ExecuteReader())
     {
         while (rdr.Read())
         {
             int[] stats = Utils.FromCommaSepString32(rdr.GetString("stats"));
             chrs.Characters.Add(new Char()
             {
                 ObjectType = (short)rdr.GetInt32("charType"),
                 CharacterId = rdr.GetInt32("charId"),
                 Level = rdr.GetInt32("level"),
                 Exp = rdr.GetInt32("exp"),
                 CurrentFame = rdr.GetInt32("fame"),
                 _Equipment = rdr.GetString("items"),
                 MaxHitPoints = stats[0],
                 HitPoints = rdr.GetInt32("hp"),
                 MaxMagicPoints = stats[1],
                 MagicPoints = rdr.GetInt32("mp"),
                 Attack = stats[2],
                 Defense = stats[3],
                 Speed = stats[4],
                 Dexterity = stats[5],
                 HpRegen = stats[6],
                 MpRegen = stats[7],
                 Tex1 = rdr.GetInt32("tex1"),
                 Tex2 = rdr.GetInt32("tex2"),
                 Dead = false,
                 PCStats = rdr.GetString("fameStats"),
                 Pet = rdr.GetInt32("pet"),
             });
         }
     }
 }
Esempio n. 44
0
        public void GetCharData(Account acc, Chars chrs)
        {
            var cmd = CreateQuery();
            cmd.CommandText = "SELECT IFNULL(MAX(id), 0) + 1 FROM characters WHERE accId=@accId;";
            cmd.Parameters.AddWithValue("@accId", acc.AccountId);
            chrs.NextCharId = (int)(long)cmd.ExecuteScalar();

            cmd = CreateQuery();
            cmd.CommandText = "SELECT maxCharSlot FROM accounts WHERE id=@accId;";
            cmd.Parameters.AddWithValue("@accId", acc.AccountId);
            chrs.MaxNumChars = (int)cmd.ExecuteScalar();
        }
Esempio n. 45
0
        //TODO: add money, abilityPower, attackPower
        private double GetWithPerks(Chars ch)
        {
            Func <double> tempFunc;

            switch (ch)
            {
            case Chars.MaxHp:
                tempFunc = () => maxHp;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetMaxHp(tempFunc);
                }
                return(tempFunc());

            case Chars.Hp:
                tempFunc = () => hp;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetHp(tempFunc);
                }
                return(tempFunc());

            case Chars.Armor:
                tempFunc = () => armor;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetArmor(tempFunc);
                }
                return(tempFunc());

            case Chars.Resist:
                tempFunc = () => resist;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetResist(tempFunc);
                }
                return(tempFunc());

            case Chars.Regen:
                tempFunc = () => regen;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetRegen(tempFunc);
                }
                return(tempFunc());

            case Chars.Money:
                tempFunc = () => money;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetMoney(tempFunc);
                }
                return(tempFunc());

            case Chars.AbilityPower:
                tempFunc = () => abilityPower;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetAbilityPower(tempFunc);
                }
                return(tempFunc());

            case Chars.AttackDamage:
                tempFunc = () => attackDamage;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetAttackDamage(tempFunc);
                }
                return(tempFunc());

            case Chars.AttackRange:
                tempFunc = () => attackRange;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetAttackRange(tempFunc);
                }
                return(tempFunc());

            case Chars.AttackSpeed:
                tempFunc = () => attackSpeed;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetAttackSpeed(tempFunc);
                }
                return(tempFunc());

            case Chars.MovementSpeed:
                tempFunc = () => movementSpeed;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetMovementSpeed(tempFunc);
                }
                return(tempFunc());

            case Chars.Energy:
                tempFunc = () => energy;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetEnergy(tempFunc);
                }
                return(tempFunc());

            case Chars.MaxEnergy:
                tempFunc = () => maxEnergy;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetMaxEnergy(tempFunc);
                }
                return(tempFunc());

            case Chars.EnergyRegen:
                tempFunc = () => energyRegen;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetEnergyRegen(tempFunc);
                }
                return(tempFunc());

            case Chars.CDReduction:
                tempFunc = () => cdReduction;
                foreach (var perk in Perks)
                {
                    tempFunc = perk.GetCDReduction(tempFunc);
                }
                return(tempFunc());
            }
            return(0);
        }
 public void displayTank()
 {
     currentChar = Chars.tank;
 }
 public void displayTech()
 {
     currentChar = Chars.tech;
 }
 public void displayMedic()
 {
     currentChar = Chars.medic;
 }
 public void displayAssassin()
 {
     currentChar = Chars.assassin;
 }
    // Use this for initialization
    void Start()
    {
        charMenu = charMenu.GetComponent<CanvasGroup> ();
        charDescription = charDescription.GetComponent<Text> ();
        charImage = charImage.GetComponent<Image> ();

        tankIcon = tankIcon.GetComponent<Button> ();
        tankImage = tankImage.GetComponent<Image> ();
        tankImage.sprite = new TankFactory ().image;

        medicIcon = medicIcon.GetComponent<Button> ();
        medicImage = medicImage.GetComponent<Image> ();
        medicImage.sprite = new MedicFactory ().image;

        assassinIcon = assassinIcon.GetComponent<Button> ();
        assassinImage = assassinImage.GetComponent<Image> ();
        assassinImage.sprite = new AssassinFactory ().image;

        techIcon = techIcon.GetComponent<Button> ();
        techImage = techImage.GetComponent<Image> ();
        techImage.sprite = new TechFactory ().image;

        selectCharacter = selectCharacter.GetComponent<Button> ();
        beginGame = beginGame.GetComponent<Button> ();
        beginGame.enabled = false;

        teamMembers = new List<ClassFactory>();
        teamMemberIcons = new List<Image> ();

        teamMember1 = teamMember1.GetComponent<Image> ();
        teamMember2 = teamMember2.GetComponent<Image> ();
        teamMember3 = teamMember3.GetComponent<Image> ();

        teamMemberIcons.Add (teamMember1);
        teamMemberIcons.Add (teamMember2);
        teamMemberIcons.Add (teamMember3);

        talent1 = talent1.GetComponent<Button> ();
        talent2 = talent2.GetComponent<Button> ();
        talent3 = talent3.GetComponent<Button> ();
        talent4 = talent4.GetComponent<Button> ();
        talent5 = talent5.GetComponent<Button> ();
        talent6 = talent6.GetComponent<Button> ();

        talentButtons = new List<Button> ();

        talentButtons.Add (talent1);
        talentButtons.Add (talent2);
        talentButtons.Add (talent3);
        talentButtons.Add (talent4);
        talentButtons.Add (talent5);
        talentButtons.Add (talent6);

        talentDescription1 = talentDescription1.GetComponent<Text> ();
        talentDescription2 = talentDescription2.GetComponent<Text> ();
        talentDescription3 = talentDescription3.GetComponent<Text> ();
        talentDescription4 = talentDescription4.GetComponent<Text> ();
        talentDescription5 = talentDescription5.GetComponent<Text> ();
        talentDescription6 = talentDescription6.GetComponent<Text> ();

        talentDescriptionsList = new List<Text> ();

        talentDescriptionsList.Add (talentDescription1);
        talentDescriptionsList.Add (talentDescription2);
        talentDescriptionsList.Add (talentDescription3);
        talentDescriptionsList.Add (talentDescription4);
        talentDescriptionsList.Add (talentDescription5);
        talentDescriptionsList.Add (talentDescription6);

        talentImage1 = talentImage1.GetComponent<Image> ();
        talentImage2 = talentImage2.GetComponent<Image> ();
        talentImage3 = talentImage3.GetComponent<Image> ();
        talentImage4 = talentImage4.GetComponent<Image> ();
        talentImage5 = talentImage5.GetComponent<Image> ();
        talentImage6 = talentImage6.GetComponent<Image> ();

        talentImages = new List<Image>();

        talentImages.Add (talentImage1);
        talentImages.Add (talentImage2);
        talentImages.Add (talentImage3);
        talentImages.Add (talentImage4);
        talentImages.Add (talentImage5);
        talentImages.Add (talentImage6);

        currentChar = Chars.tank;

        tankDescription = "The Tank is a rough, tough melee brawler. He is capable of taking big hits as well as dishing them out.";
        medicDescription = "The Medic is";
        assassinDescription = "The Assassin is";
        techDescription = "The Tech is";
    }
Esempio n. 51
0
File: Chars.cs Progetto: rhcad/vgwpf
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Chars obj)
 {
     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
Esempio n. 52
-1
        public void HandleRequest(HttpListenerContext context)
        {
            NameValueCollection query;
            using (var rdr = new StreamReader(context.Request.InputStream))
                query = HttpUtility.ParseQueryString(rdr.ReadToEnd());

            using (var db = new Database())
            {
                List<ServerItem> filteredServers = null;
                Account a = db.Verify(query["guid"], query["password"]);
                if (a != null)
                {
                    if (a.Banned)
                    {
                        filteredServers = YoureBanned();
                    }
                    else
                    {
                        filteredServers = GetServersForRank(a.Rank);
                    }
                }
                else
                {
                    filteredServers = GetServersForRank(0);
                }

                var chrs = new Chars
                {
                    Characters = new List<Char>(),
                    NextCharId = 2,
                    MaxNumChars = 1,
                    Account = db.Verify(query["guid"], query["password"]),
                    Servers = filteredServers
                };
                Account dvh = null;
                if (chrs.Account != null)
                {
                    db.GetCharData(chrs.Account, chrs);
                    db.LoadCharacters(chrs.Account, chrs);
                    chrs.News = db.GetNews(chrs.Account);
                    dvh = chrs.Account;
                }
                else
                {
                    chrs.Account = Database.CreateGuestAccount(query["guid"]);
                    chrs.News = db.GetNews(null);
                }

                var ms = new MemoryStream();
                var serializer = new XmlSerializer(chrs.GetType(),
                    new XmlRootAttribute(chrs.GetType().Name) {Namespace = ""});

                var xws = new XmlWriterSettings();
                xws.OmitXmlDeclaration = true;
                xws.Encoding = Encoding.UTF8;
                XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws);
                serializer.Serialize(xtw, chrs, chrs.Namespaces);
                db.Dispose();
            }
        }